devtool clones the wrong repository for recipe development - embedded-linux

I am using krogoth and recently I have been observing that everytime I do the following:
Add a recipe
devtool add buttonflux https://github.com/shantanoo-desai/buttonflux/archive/v1.0.tar.gz
I get the a previous recipe which I worked up.
here is the recipe-tool generated recipe of the above repository:
# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully functional.
# (Feel free to remove these comments when editing.)
#
# WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is
# your responsibility to verify that the values are complete and correct.
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=7e8b8d2e60aca564edd8578b5f1f4951"
HOMEPAGE = "https://github.com/shantanoo-desai/bnoflux"
SUMMARY = "Extract IMU Values from BNO055 and store them in InfluxDB via UDP"
SRC_URI = "https://github.com/shantanoo-desai/buttonflux/archive/v${PV}.tar.gz"
SRC_URI[md5sum] = "1c897adf29ed058315d23d3a79f9c532"
SRC_URI[sha256sum] = "1c5611a579ee169a611fc5b401eb1aa6ad8cb4c168722df0dba7d61bb8fd2d2b"
S = "${WORKDIR}/bnoflux-${PV}"
inherit setuptools
# WARNING: the following rdepends are from setuptools install_requires. These
# upstream names may not correspond exactly to bitbake package names.
RDEPENDS_${PN} += "python-influxdb"
# WARNING: the following rdepends are determined through basic analysis of the
# python sources, and might not be 100% accurate.
RDEPENDS_${PN} += "python-argparse python-core python-logging"
# WARNING: We were unable to map the following python package/module
# dependencies to the bitbake packages which include them:
# influxdb.client
# smbus
It is worth noting the the HOMEPAGE is false and so are the SRC_URI hashes. (I want to use buttonflux and not bnoflux which was my previously worked upon recipe)
I tried reseting the recipes but this problem is still persistent.
my workspace clones also the wrong repository:
workspace/
├── appends
│   └── buttonflux_1.0.bbappend
├── attic
├── conf
│   └── layer.conf
├── README
├── recipes
│   └── buttonflux
│   └── buttonflux_1.0.bb
└── sources
└── buttonflux
├── bin
│   ├── bnoflux
│   └── calibrate
├── bnoflux
│   ├── BNO055.py
│   ├── bnoflux.py
│   ├── calibrate.py
│   └── __init__.py
├── LICENSE
├── MANIFEST.in
├── README.md
└── setup.py
even though the source is called buttonflux the code within it belongs to bnoflux repository.
I do not understand why this is happening.

Related

My app failed to import another local package without pushing changes to remote repo

Envs
GO111MODULE=on
golang:1.15.2-alpine
What I want to do
I implemented some features in a local project and I want to confirm the behavior before pushing
changes to the remote repo.
But my project can't access the new package.
Error text
When docker-compose run 'go build' I got his error.
Both 'github.com/Asuha-a/URLShortener/api/pb/url' and 'github.com/Asuha-a/URLShortener/api/utility' don't exist in the remote repo because it's not pushed yet.
main.go:10:2: module github.com/Asuha-a/URLShortener/api#latest found (v0.0.0-20201114002535-3dac2ebd322a), but does not contain package github.com/Asuha-a/URLShortener/api/pb/url
main.go:12:2: module github.com/Asuha-a/URLShortener/api#latest found (v0.0.0-20201114002535-3dac2ebd322a), but does not contain package github.com/Asuha-a/URLShortener/api/utility
Project architecture
I deleted some of the files look like not related to this issue.
$ tree
.
├── api
│   ├── Dockerfile
│   ├── go.mod
│   ├── go.sum
│   ├── main.go
│   ├── pb
│   │   ├── url // new package
│   │      ├── url_grpc.pb.go
│   │      ├── url.pb.go
│   │      └── url.proto
│   ├── services
│   │   ├── url
│   │   │   ├── db
│   │   │   │   ├── settings.go
│   │   │   │   └── url.go
│   │   │   ├── Dockerfile
│   │   │   ├── go.mod
│   │   │   ├── go.sum
│   │   │   └── main.go // failed building
│   └── utility // new package
│   ├── jwt.go
│   └── url.go
├── docker-compose.yml
What I tried
I found this issue.
Importing local changes of a package without pushing code in Go
That says I can access local packages by adding 'replace MODULE_URL => /PATH/TO/MODULE/DIR'.
I edited the 'api/services/url/go.mod' like this.
module github.com/Asuha-a/URLShortener/api/services/url
go 1.15
replace github.com/Asuha-a/URLShortener/api => ../../.
require (
github.com/jackc/pgx/v4 v4.9.2 // indirect
github.com/satori/go.uuid v1.2.0
golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9 // indirect
golang.org/x/text v0.3.4 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/grpc v1.33.2
gorm.io/datatypes v1.0.0
gorm.io/driver/postgres v1.0.5
gorm.io/gorm v1.20.6
)
But I got this error:
main.go:10:2: module github.com/Asuha-a/URLShortener/api#latest found (v0.0.0-20201114002535-3dac2ebd322a, replaced by ../../.), but does not contain package github.com/Asuha-a/URLShortener/api/pb/url
main.go:12:2: module github.com/Asuha-a/URLShortener/api#latest found (v0.0.0-20201114002535-3dac2ebd322a, replaced by ../../.), but does not contain package github.com/Asuha-a/URLShortener/api/utility
Then I tried the full path '/home/asuha/go/src/github.com/Asuha-a/URLShortener/api'.
But I got this error:
main.go:10:2: github.com/Asuha-a/URLShortener/api#v0.0.0-00010101000000-000000000000: replacement directory /home/asuha/go/src/github.com/Asuha-a/URLShortener/api does not exist
main.go:12:2: github.com/Asuha-a/URLShortener/api#v0.0.0-00010101000000-000000000000: replacement directory /home/asuha/go/src/github.com/Asuha-a/URLShortener/api does not exist
I want to know
How to fix this error?
Some basics first:
A module is a set of packages versioned together.
A module has a name declared in the go.mod, e.g. github.com/anyone/someproject
A package is imported by its import path (the import path basically is package identity).
A package belonging to a module must have an import path beginning with the module name. In the example above any package belonging to the module github.com/anyone/someproject must have an import path like e.g. github.com/anyone/someproject/whatever/hierarchy/pkgname
You never need to replace packages from the same module. replace is for replacing other modules.
You declared the module
module github.com/Asuha-a/URLShortener/api/services/url
That makes the name of your module "github.com/Asuha-a/URLShortener/api/services/url" and only packages with import path like module "github.com/Asuha-a/URLShortener/api/services/url/I/really/like/deeply/nested/stuff" would belong to that package.
Clearly you utility package (btw. don't do such packages, this is fundamental code smell!) doesn't belong to your module: You probably try to import it as "github.com/Asuha-a/URLShortener/api/utiliyt" but this is not part of the module "github.com/Asuha-a/URLShortener/api/services/url".
The fact that the folder utility is "below" the go.mod file in the filesystem doesn't overrule the fact that your module declares on its first line: "All my packages have import paths starting with github.com/Asuha-a/URLShortener/api/services/url! Anything else does not belong to me!"
You probably should name your module at least module github.com/Asuha-a/URLShortener/api (if not module github.com/Asuha-a/URLShortener).
I urge you to (re-)read "How to Write Go Code" and stick to it.
Takeaway:
Modules are really just a set of packages with the same import path prefix (the module name) versioned together.

Kubernetes client code generator: Can the code exist only locally and not on a repository for the core-generator to work?

I am trying to generate client code using k8s.io/code-generator.
These are the instructions that I am following: https://itnext.io/how-to-generate-client-codes-for-kubernetes-custom-resource-definitions-crd-b4b9907769ba
My question is, does my go module need to be present on a repository or can I simply run the generate-groups.sh script on a go module that is ONLY present on my local system and not on any repository?
I have already tried running it and from what I understand, there needs to be a repository having ALL the contents of my local go module. Is my understanding correct?
You CAN run kubernetes/code-generator's generate-groups.sh on a go module that is only present on your local system. Neither code-generator nor your module needs to be in your GOPATH.
Verification
Cloned kubernetes/code-generator into a new directory.
$HOME/somedir
├── code-generator
Created a project called myrepo and mocked it with content to resemble sample-controller. Did this in the same directory to keep it simple.
somedir
├── code-generator
└── myorg.com
└── myrepo # mock of sample-controller
├── go.mod
├── go.sum
└── pkg
└── apis
└── myorg
├── register.go
└── v1alpha1
├── doc.go
├── register.go
└── types.go
My go.mod looked like
module myorg.com/myrepo
go 1.14
require k8s.io/apimachinery v0.17.4
Ran generate-group.sh. The -h flag specifies which header file to use. The -o flag specifies the output base which is necessary here because we're not in GOPATH.
$HOME/somedir/code-generator/generate-groups.sh all myorg.com/myrepo/pkg/client myorg.com/myrepo/pkg/apis "myorg:v1alpha1" \
-h $HOME/somedir/code-generator/hack/boilerplate.go.txt \
-o $HOME/somedir
Confirmed code generated in correct locations
myrepo
├── go.mod
├── go.sum
└── pkg
├── apis
│   └── myorg
│   ├── register.go
│   └── v1alpha1
│   ├── doc.go
│   ├── register.go
│   ├── types.go
│   └── zz_generated.deepcopy.go
└── client
├── clientset
│   └── versioned
│   ├── clientset.go
│   ├── doc.go
│   ├── fake
│   ├── scheme
│   └── typed
├── informers
│   └── externalversions
│   ├── factory.go
│   ├── generic.go
│   ├── internalinterfaces
│   └── myorg
└── listers
└── myorg
└── v1alpha1
Sources
Go modules support https://github.com/kubernetes/code-generator/issues/57
Documentation or support for Go modules https://github.com/kubernetes/sample-controller/issues/47

Yocto: how to add out-of-tree Device driver?

First of all I should say I am a complete newbie to the Yocto world.
I have a working environment that produces my uboot+kernel+rootfs.
I need to add a (complex) driver I have as a subdirectory.
This driver can be compiled natively in the standard way:
here=$(pwd)
make -C /lib/modules/$(uname -r)/build M=$here/bcmdhd modules CONFIG_BCMDHD_PCIE=y CONFIG_BCMDHD=m CONFIG_BCM4359=y
I have seen Integrate out-of-tree driver in kernel and rebuild yocto project image and I have read Yocto Kernel Development Manual.
I tried to follow directions:
Created a directory in .../recipes-kernel beside linux dir.
Copied the source directory in it.
Created a .bb file.
The resulting source tree is:
recipes-kernel/
├── kernel-modules
│   ├── kernel-module-bcmdhd
│   │   └── bcmdhd
│   │   ├── include
│   │   │   ├── include files
│   │   ├── Kconfig
│   │   ├── Makefile
│   │   └── other source files
│   └── kernel-module-bcmdhd_0.1.bb
└── linux
├── linux-imx-4.1.15
│   └── imx
│   └── defconfig
└── linux-imx_4.1.15.bbappend
My BCM89359-mod_0.1.bb contains:
SUMMARY = "Integration of Cypress BCMDHD external Linux kernel module"
LICENSE = "Proprietary"
inherit module
SRC_URI = "file://bcmdhd"
S = "${WORKDIR}"
Unfortunately this doesn't seem to be enough as running bitbake results in no compilation attempted.
I am quite plainly missing something, but I'm unable to understand what.
Any help welcome.
You should have the following source tree:
recipes-kernel/
├── kernel-modules
│   ├── kernel-module-bcm89359_0.1.bb
│ └── kernel-module-bcm89359
│ └ bcmdhd
│ ├ Kconfig
└── linux
├── ...
(For the record)
You can add your module to MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "kernel-module-bcm89359" to local.conf or machine configuration. Also, you can add KERNEL_MODULE_AUTOLOAD = "bcm89359" to load your module automatically.

Yocto device tree overlay

I am working on a Beaglebone Black, using Yocto.
Using this implementation of a PWM driver as a guide, I am unable to add my PWMs to the device tree.
The best solution would be to create a device tree overlay as Mr. Saad Ahmad is doing, but I don't understand how to do this using Yocto.
I am not using capemgr, but I am using meta-bbb. I also have custom layer meta-tfe which currently holds the pwm-driver and some examples. This layer also defines a new bitbake image recipe:
include recipes-core/images/core-image-base.bb
IMAGE_INSTALL += "\
helloworld \
hellokernel \
bbb-pwm \
"
KERNEL_MODULE_AUTOLOAD += "\
hellokernel \
bbb-pwm \
"
export IMAGE_BASENAME = "tfe-image-base"
Following is the .bb file of the pwm-driver:
DESCRIPTION = "PWM kernel module"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=d41d8cd98f00b204e9800998ecf8427e"
PR = "r0"
inherit module
SRC_URI = "file://bbb-pwm.c \
file://Makefile \
file://COPYING \
"
S = "${WORKDIR}"
Does anyone know how to do this?
Edit:
A colleague hinted that I could use a .bbappend file, appending to the kernel build-rules in meta-bbb. Hence this is what I did, and now my recipes-kernel directory now looks like this:
.
├── bbb-pwm
│   ├── bbb-pwm.bb
│   └── files
│   ├── bbb-pwm.c
│   ├── COPYING
│   └── Makefile
├── hellokernel
│   └── {...}
└── linux
   ├── linux-stable_4.1
│ └── {...}
   ├── linux-stable_4.1.bbappend
   ├── linux-stable_4.4
│ └── {...}
   ├── linux-stable_4.4.bbappend
   ├── linux-stable_4.5
   │   └── dts
   │   ├── bbb-pwm.dts
   │   └── sc_pwm_P8_13-00A0.dtsi
   └── linux-stable_4.5.bbappend
The directories linux-stable_4.*/ all have the same structure, to reflect the mirrored structure in meta-bbb.
My .bbappend files look like this:
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}/dts:"
KERNEL_DEVICETREE_beaglebone += " \
bbb-pwm.dtb \
"
However, when bitbaking, an error occurs saying there are no build rules for bbb-pwm.dtb:
| make[3]: *** No rule to make target 'arch/arm/boot/dts/bbb-pwm.dtb'. Stop.
| arch/arm/Makefile:333: recipe for target 'bbb-pwm.dtb' failed
Edit: Here is sc_pwm_P8_13-00A0.dtsi
When you want to use a custom device tree and edit the KERNEL_DEVICETREE variable, the device tree sources (*.dts files and *.dtsi files) are searched in arch/arm/boot/dts (according to your architecture).
In your example your files are placed in a separate folder and not fetched by the bbappend file. The correct layer structure would be following:
└── linux
├── linux-stable_4.5
│ └── git
│ └── arch
│ └── arm
│ └── boot
│ └── dts
│ ├── bbb-pwm.dts
│ └── sc_pwm_P8_13-00A0.dtsi
└── linux-stable_4.5.bbappend
To make bitbake sensible for those new files they have to be added via the SRC_URI variable in the bbappend file:
SRC_URI += "file://git/arch/arm/boot/dts/bbb-pwm.dts"
SRC_URI += "file://git/arch/arm/boot/dts/sc_pwm_P8_13-00A0.dtsi"

In what order is a Chef cookbook executed

I'm trying to get a grasp on chef and for the life of me I cannot find how cook books are run
If I have the file structure
chef-repo
├── cookbooks
│   └── test
│   ├── attributes
│   │   ├── default.rb
│   │   └── test.rb
│   ├── files...
│   ├── metadata.rb
│   ├── recipes
│   │   ├── default.rb
│   │   └── test.rb
│   └── templates...
├── roles
│   └── starter.rb
└── Vagrantfile
How are the attributes loaded and in what order? eg it loads all the attributes (default.rb and test.rb) with default.rb always loaded first
How are the recipes run? eg only default.rb is run and everything , or all are run in alphabetical order.
I've found http://docs.opscode.com/essentials_nodes_chef_run.html but it doesn't explain cookbook execution only node level execution. Any resources or links to chef docs would be appreciated
Cheers
Recipes are run in the order they occur in the runlist. Only recipes that occur in the run list will be executed (plus any recipes that are included in place using include_recipe. Note that each recipe will only run once, even if it occurs multiple times in the runlist.
Attribute files from cookbooks are loaded in this order:
Attributes of dependencies (i.e. cookbooks declared with depends in metadata.rb
attributes/default.rb
all other attributes files in alphabetical order.
Note that all attribute files in a cookbook are loaded, regardless of their name. Only attributes of cookbooks which either explicitly occur in the resolved runlist (i.e. recipes loaded by roles or explicit inclusion into the runlist) or which are dependencies of their cookbooks will be loaded.

Resources