From 2eab713d9cccafad51f79327b3a1dd7591b10096 Mon Sep 17 00:00:00 2001 From: Cliff Brake Date: Tue, 20 Nov 2018 13:59:12 -0500 Subject: [PATCH 1/6] fix up feed server tooling and document --- docs/README.md | 4 +++- docs/packages.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ envsetup.sh | 28 +++++++++++++++++++++++----- 3 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 docs/packages.md diff --git a/docs/README.md b/docs/README.md index b794bc465..664043ad8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -14,8 +14,10 @@ included for some of them below. ## Using Yoe -- [Working with git submodules](git-submodules.md) - [Docker Integration](docker.md) +- [Packages](packages.md) - information on installing packages from your build directory + in a development scenario. +- [Working with git submodules](git-submodules.md) ## Image Configuration diff --git a/docs/packages.md b/docs/packages.md new file mode 100644 index 000000000..bf6ba2bd0 --- /dev/null +++ b/docs/packages.md @@ -0,0 +1,45 @@ +# Packages + +[up](README.md) + +During an image build, OpenEmbedded builds all software into packages, which are then +combined into a rootfs. One benefit of this is you can install packages later into a +running system, much like you would a desktop distribution like Debian, Ubuntu, Arch, +etc. OE supports the RPM, DEB, and IPK package formats, and the format can be set using the +[PACKAGE_CLASSES](https://www.yoctoproject.org/docs/2.6/mega-manual/mega-manual.html#var-PACKAGE_CLASSES) +variable. + +## Installing packages from a local build + +You can install packages directly from your local OE build onto a target system with the +following procedure: + +- packaging information must be included in the target image: + - `IMAGE_FEATURES += "packages-management"` +- a ssh server must be enabled in the target image: + - `IMAGE_FEATURES += "ssh-server-dropbear"` +- target system just be on the same network as your build computer. +- run `yoe_setup_feed_server `. This configures the target to fetch packages + from your build computer. Alternatively you can set the MACHINE_IP environment variable. +- run `yoe_feed_server`. This starts a web server that serves packages. +- on target system, run: + - `opkg update` + - `opkg list` (list packages available) + - `opkg install python3` (install python3) + +If the package is not built yet, simply bitbake it and rerun `yoe_feed_server` +(required to rebuild the package index). You can then `opkg install` the package +on the target system. + +This technique is very useful for testing new packages, or for installing packages that +are only needed for development that you don't want to include in production images +(strace, gdb, testing tools, etc). Dependencies are automatically handled by the package +manager. + +For larger development teams or field deployments, you might want to set up a feed server +to serve packages to any connected device. + +See also: + +- https://www.yoctoproject.org/docs/2.6/mega-manual/mega-manual.html#package-feeds-dev-environment +- https://www.yoctoproject.org/docs/2.6/ref-manual/ref-manual.html#var-FEED_DEPLOYDIR_BASE_URI diff --git a/envsetup.sh b/envsetup.sh index e187cc54e..e01ef362b 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -290,17 +290,36 @@ yoe_feed_server() { cd $SAVEDPWD } +yoe_host_ip() { + hostname -i | cut -d' ' -f 1 +} + yoe_setup_feed_server() { + if [ -n "$1" ]; then + MIP=$1 + else + if [ -z "$MACHINE_IP" ]; then + echo + echo "Error: Machine IP address not given" + echo "Usage: yoe_setup_feed_server " + echo " or set the MACHINE_IP env variable" + echo + return 1 + fi + MIP=$MACHINE_IP + fi # set TARGET_IP in local.sh # set HOST_IP in local.sh if different - if [ -n "${HOST_IP}" ]; then + if [ -z "${HOST_IP}" ]; then HOST_IP=$(hostname -i | cut -d' ' -f 1) fi - ssh root@$MACHINE_IP ls /etc/opkg/base-feeds.conf >/dev/null 2>&1 + ssh root@$MIP ls /etc/opkg/base-feeds.conf >/dev/null 2>&1 if [ $? -ne 0 ]; then - echo "opkg is not installed, can't setup feeds on machine $MACHINE_IP" + echo "opkg is not installed, can't setup feeds on machine $MIP" else - ssh root@$MACHINE_IP "sed -i -e 's|http://.*\/|http://$HOST_IP:8000/|' /etc/opkg/base-feeds.conf" + SERVER=http://$HOST_IP:8000 + echo "pointing feeds to $SERVER" + ssh root@$MIP "sed -i -e 's|http://.*\/|${SERVER}/|' /etc/opkg/base-feeds.conf" fi } @@ -395,7 +414,6 @@ yoe_clean_sstate() { if [ -z "$DOCKER_REPO" ]; then echo "Setting DOCKER_REPO to yoedistro/yoe-build:stretch" - echo "set DOCKER_REPO to 'none' to disable docker" export DOCKER_REPO=yoedistro/yoe-build:stretch fi From 2373ab1991ee295d86ddceb773524bea1d94fcd8 Mon Sep 17 00:00:00 2001 From: Cliff Brake Date: Tue, 20 Nov 2018 14:03:33 -0500 Subject: [PATCH 2/6] point to packages documentation --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index 9bfe8b6b5..2d16734cc 100644 --- a/README.md +++ b/README.md @@ -124,12 +124,7 @@ as parallel build options. Sometimes you want to install packages you build on the target system without building and re-installing the entire rootfs. This can be done -using a feed server. - -- Workstation: `yoe_feed_server` (this starts a feed server on port 4000) -- Target: modify /etc/opkg to http://[your workstation IP]:4000 -- Target: `opkg update` -- Target: `opkg install [package]` +using a [feed server](docs/packages.md). This advantage of a feed server versus scp'ing opkg files to the target and installing manually is that dependencies will automatically get installed. From c2fa96dff87361b3531fe39be08713bc870af1e0 Mon Sep 17 00:00:00 2001 From: Cliff Brake Date: Tue, 20 Nov 2018 14:06:49 -0500 Subject: [PATCH 3/6] fix formatting --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d16734cc..99ed8f78e 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ Additional machines can be added by including appropriate BSP layers. This is where all the magic happens. In general, this build system must be run in a bash shell. To set up the environment, source the following file: -`. ./\-envsetup.sh` +`. ./-envsetup.sh` Or, you can export a MACHINE environment variable, and then source envsetup.sh. From b2c31cad3c1d1a97ee2f7d79cb2ab2b41b7f2bda Mon Sep 17 00:00:00 2001 From: Cliff Brake Date: Tue, 20 Nov 2018 15:05:58 -0500 Subject: [PATCH 4/6] return if package-index fails --- envsetup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/envsetup.sh b/envsetup.sh index e01ef362b..ab77baf37 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -284,7 +284,7 @@ _EOF yoe_feed_server() { SAVEDPWD=$PWD cd $OE_BASE - bitbake package-index + bitbake package-index || return 1 cd build/tmp/deploy/ipk python3 -m http.server 8000 cd $SAVEDPWD From becae39b95b2aa005b0b524a31aec8b0e149b4df Mon Sep 17 00:00:00 2001 From: Cliff Brake Date: Tue, 20 Nov 2018 15:06:10 -0500 Subject: [PATCH 5/6] point to latest docs instead of 2.6 --- docs/packages.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/packages.md b/docs/packages.md index bf6ba2bd0..7cdea159a 100644 --- a/docs/packages.md +++ b/docs/packages.md @@ -6,7 +6,7 @@ During an image build, OpenEmbedded builds all software into packages, which are combined into a rootfs. One benefit of this is you can install packages later into a running system, much like you would a desktop distribution like Debian, Ubuntu, Arch, etc. OE supports the RPM, DEB, and IPK package formats, and the format can be set using the -[PACKAGE_CLASSES](https://www.yoctoproject.org/docs/2.6/mega-manual/mega-manual.html#var-PACKAGE_CLASSES) +[PACKAGE_CLASSES](https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#var-PACKAGE_CLASSES) variable. ## Installing packages from a local build @@ -41,5 +41,5 @@ to serve packages to any connected device. See also: -- https://www.yoctoproject.org/docs/2.6/mega-manual/mega-manual.html#package-feeds-dev-environment -- https://www.yoctoproject.org/docs/2.6/ref-manual/ref-manual.html#var-FEED_DEPLOYDIR_BASE_URI +- https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#package-feeds-dev-environment +- https://www.yoctoproject.org/docs/latest/ref-manual/ref-manual.html#var-FEED_DEPLOYDIR_BASE_URI From de87b6e12df78e8d38ae7fbbfc777882265f4aa5 Mon Sep 17 00:00:00 2001 From: Cliff Brake Date: Tue, 20 Nov 2018 15:25:33 -0500 Subject: [PATCH 6/6] expand building/installing package --- docs/packages.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/packages.md b/docs/packages.md index 7cdea159a..428e5b404 100644 --- a/docs/packages.md +++ b/docs/packages.md @@ -27,9 +27,13 @@ following procedure: - `opkg list` (list packages available) - `opkg install python3` (install python3) -If the package is not built yet, simply bitbake it and rerun `yoe_feed_server` -(required to rebuild the package index). You can then `opkg install` the package -on the target system. +If the package is not built yet, simply: + +- `bitbake ` +- `bitbake package-index` (required to rebuild the package index) +- on target: + - `opkg update` + - `opkg install ` This technique is very useful for testing new packages, or for installing packages that are only needed for development that you don't want to include in production images