From 0b4874f75ae0a7907b334358403c87fd5750fe54 Mon Sep 17 00:00:00 2001 From: simonliedl Date: Wed, 19 Jan 2022 16:16:51 +0100 Subject: [PATCH 1/4] Fix docker build with debian bullseye image - Fix missing sfdisk which is not included anymore in bullseye container - Fix problem with binfmt_misc not being mounted inside docker although present on host --- Dockerfile | 2 +- build-docker.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e7fc561..479e708 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN apt-get -y update && \ git vim parted \ quilt coreutils qemu-user-static debootstrap zerofree zip dosfstools \ libarchive-tools libcap2-bin rsync grep udev xz-utils curl xxd file kmod bc\ - binfmt-support ca-certificates qemu-utils kpartx \ + binfmt-support ca-certificates qemu-utils kpartx fdisk \ && rm -rf /var/lib/apt/lists/* COPY . /pi-gen/ diff --git a/build-docker.sh b/build-docker.sh index 85200e4..2dc55c1 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -98,6 +98,8 @@ if [ "${CONTAINER_EXISTS}" != "" ]; then --volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \ pi-gen \ bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static && + # binfmt_misc is sometimes not mounted with debian bullseye image + (mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc || true) && cd /pi-gen; ./build.sh ${BUILD_OPTS} && rsync -av work/*/build.log deploy/" & wait "$!" @@ -112,6 +114,8 @@ else -e "GIT_HASH=${GIT_HASH}" \ pi-gen \ bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static && + # binfmt_misc is sometimes not mounted with debian bullseye image + (mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc || true) && cd /pi-gen; ./build.sh ${BUILD_OPTS} && rsync -av work/*/build.log deploy/" & wait "$!" From c393ef105eae82448d31194c28f54b71e1f83da7 Mon Sep 17 00:00:00 2001 From: Serge Schneider Date: Wed, 2 Feb 2022 14:01:30 +0000 Subject: [PATCH 2/4] Strip trailing spaces --- README.md | 12 ++++++------ build-docker.sh | 2 +- build.sh | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 08b2c13..e1676bb 100644 --- a/README.md +++ b/README.md @@ -328,7 +328,7 @@ maintenance and allows for more easy customization. - **Stage 5** - The Raspbian Full image. More development tools, an email client, learning tools like Scratch, specialized packages - like sonic-pi, office productivity, etc. + like sonic-pi, office productivity, etc. ### Stage specification @@ -380,8 +380,8 @@ Example: ```bash root@build-machine:~/$ lsblk | grep nbd -nbd1 43:32 0 10G 0 disk -├─nbd1p1 43:33 0 10G 0 part +nbd1 43:32 0 10G 0 disk +├─nbd1p1 43:33 0 10G 0 part └─nbd1p1 253:0 0 10G 0 part root@build-machine:~/$ ps xa | grep qemu-nbd @@ -405,7 +405,7 @@ It can happen, that your build stops in case of an error. Normally `./build.sh` A typical message indicating that there are some orphaned device mapper entries is this: ``` -Failed to set NBD socket +Failed to set NBD socket Disconnect client, due to: Unexpected end-of-file before all bytes were read ``` @@ -428,10 +428,10 @@ If that happens go through the following steps: or sudo ./imagetool.sh --cleanup ``` - + Note: The `imagetool.sh` command will cleanup any /dev/nbdX that is not connected to a running `qemu-nbd` daemon. Be careful if you use network block devices for other tasks utilizing NBDs on your build machine as well. -Now you should be able to start a new build without running into troubles again. Most of the time, especially when using Docker build, you will only need no. 3 to get everything up and running again. +Now you should be able to start a new build without running into troubles again. Most of the time, especially when using Docker build, you will only need no. 3 to get everything up and running again. # Troubleshooting diff --git a/build-docker.sh b/build-docker.sh index 2dc55c1..a7f18f1 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -48,7 +48,7 @@ fi CONTAINER_NAME=${CONTAINER_NAME:-pigen_work} CONTINUE=${CONTINUE:-0} PRESERVE_CONTAINER=${PRESERVE_CONTAINER:-0} -PIGEN_DOCKER_OPTS=${PIGEN_DOCKER_OPTS:-""} +PIGEN_DOCKER_OPTS=${PIGEN_DOCKER_OPTS:-""} if [ -z "${IMG_NAME}" ]; then echo "IMG_NAME not set in 'config'" 1>&2 diff --git a/build.sh b/build.sh index bcfdeb6..6f6a0d2 100755 --- a/build.sh +++ b/build.sh @@ -133,7 +133,7 @@ run_stage(){ done fi - if [ "${USE_QCOW2}" = "1" ]; then + if [ "${USE_QCOW2}" = "1" ]; then unload_qimage else # make sure we are not umounting during export-image stage @@ -369,7 +369,7 @@ for EXPORT_DIR in ${EXPORT_DIRS}; do else run_stage - fi + fi if [ "${USE_QEMU}" != "1" ]; then if [ -e "${EXPORT_DIR}/EXPORT_NOOBS" ]; then # shellcheck source=/dev/null From 8862e4d9ff15b44daa8563872fc928a3317e33dc Mon Sep 17 00:00:00 2001 From: Romain Bazile Date: Wed, 2 Feb 2022 14:10:24 +0100 Subject: [PATCH 3/4] Add check and warning for a space presence in the base path --- README.md | 18 ++++++++++++++++++ build.sh | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/README.md b/README.md index e1676bb..893a5cc 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,24 @@ qemu-utils kpartx The file `depends` contains a list of tools needed. The format of this package is `[:]`. +## Getting started with building your images + +Getting started is as simple as cloning this repository on your build machine. You +can do so with: + +```bash +git clone -–depth 1 https://github.com/RPI-Distro/pi-gen.git +``` + +Using `--depth 1` with `git clone` will create a shallow clone, only containing +the latest revision of the repository. Do not do this on your development machine. + +Also, be careful to clone the repository to a base path **NOT** containing spaces. +This configuration is not supported by debootstrap and will lead to `pi-gen` not +running. + +After cloning the repository, you can move to the next step and start configuring +your build. ## Config diff --git a/build.sh b/build.sh index 6f6a0d2..f743e2a 100755 --- a/build.sh +++ b/build.sh @@ -155,6 +155,14 @@ if [ "$(id -u)" != "0" ]; then fi BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +if [[ $BASE_DIR = *" "* ]]; then + echo "There is a space in the base path of pi-gen" + echo "This is not a valid setup supported by debootstrap." + echo "Please remove the spaces, or move pi-gen directory to a base path without spaces" 1>&2 + exit 1 +fi + export BASE_DIR if [ -f config ]; then From 724820051c400f9554d7fa311e7fc378bf598282 Mon Sep 17 00:00:00 2001 From: bwisn Date: Tue, 1 Feb 2022 14:42:00 +0100 Subject: [PATCH 4/4] Add gpg dependency --- Dockerfile | 2 +- README.md | 2 +- depends | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 479e708..69fd86c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN apt-get -y update && \ git vim parted \ quilt coreutils qemu-user-static debootstrap zerofree zip dosfstools \ libarchive-tools libcap2-bin rsync grep udev xz-utils curl xxd file kmod bc\ - binfmt-support ca-certificates qemu-utils kpartx fdisk \ + binfmt-support ca-certificates qemu-utils kpartx fdisk gpg \ && rm -rf /var/lib/apt/lists/* COPY . /pi-gen/ diff --git a/README.md b/README.md index 893a5cc..cda0255 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ To install the required dependencies for `pi-gen` you should run: ```bash apt-get install coreutils quilt parted qemu-user-static debootstrap zerofree zip \ dosfstools libarchive-tools libcap2-bin grep rsync xz-utils file git curl bc \ -qemu-utils kpartx +qemu-utils kpartx gpg ``` The file `depends` contains a list of tools needed. The format of this diff --git a/depends b/depends index eeb2490..654531a 100644 --- a/depends +++ b/depends @@ -19,3 +19,4 @@ lsmod:kmod bc qemu-nbd:qemu-utils kpartx +gpg