Merge branch 'master' into arm64

This commit is contained in:
Serge Schneider 2022-11-08 12:07:33 +00:00
commit bd2cf0e0e4
4 changed files with 27 additions and 8 deletions

View File

@ -27,10 +27,10 @@ Getting started is as simple as cloning this repository on your build machine. Y
can do so with: can do so with:
```bash ```bash
git clone --depth 1 https://github.com/RPI-Distro/pi-gen.git git clone https://github.com/RPI-Distro/pi-gen.git
``` ```
Using `--depth 1` with `git clone` will create a shallow clone, only containing `--depth 1` can be added afer `git clone` to create a shallow clone, only containing
the latest revision of the repository. Do not do this on your development machine. 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. Also, be careful to clone the repository to a base path **NOT** containing spaces.
@ -80,8 +80,11 @@ The following environment variables are supported:
* `RELEASE` (Default: bullseye) * `RELEASE` (Default: bullseye)
The release version to build images against. Valid values are jessie, stretch, The release version to build images against. Valid values are any supported
buster, bullseye, and testing. Debian release. However, since different releases will have different sets of
packages available, you'll need to either modify your stages accordingly, or
checkout the appropriate branch. For example, if you'd like to build a
`buster` image, you should do so from the `buster` branch.
* `APT_PROXY` (Default: unset) * `APT_PROXY` (Default: unset)
@ -212,6 +215,13 @@ The following environment variables are supported:
public key authentication. Note that if SSH is not enabled this will take public key authentication. Note that if SSH is not enabled this will take
effect when SSH becomes enabled. effect when SSH becomes enabled.
* `SETFCAP` (Default: unset)
* Setting to `1` will prevent pi-gen from dropping the "capabilities"
feature. Generating the root filesystem with capabilities enabled and running
it from a filesystem that does not support capabilities (like NFS) can cause
issues. Only enable this if you understand what it is.
* `STAGE_LIST` (Default: `stage*`) * `STAGE_LIST` (Default: `stage*`)
If set, then instead of working through the numeric stages in order, this list will be followed. For example setting to `"stage0 stage1 mystage stage2"` will run the contents of `mystage` before stage2. Note that quotes are needed around the list. An absolute or relative path can be given for stages outside the pi-gen directory. If set, then instead of working through the numeric stages in order, this list will be followed. For example setting to `"stage0 stage1 mystage stage2"` will run the contents of `mystage` before stage2. Note that quotes are needed around the list. An absolute or relative path can be given for stages outside the pi-gen directory.
@ -489,7 +499,7 @@ A 64 bit image can be generated from the `arm64` branch in this repository. Just
replace the command from [this section](#getting-started-with-building-your-images) replace the command from [this section](#getting-started-with-building-your-images)
by the one below, and follow the rest of the documentation: by the one below, and follow the rest of the documentation:
```bash ```bash
git clone --depth 1 --branch arm64 https://github.com/RPI-Distro/pi-gen.git git clone --branch arm64 https://github.com/RPI-Distro/pi-gen.git
``` ```
If you want to generate a 64 bits image from a Raspberry Pi running a 32 bits If you want to generate a 64 bits image from a Raspberry Pi running a 32 bits

View File

@ -226,7 +226,7 @@ export TARGET_HOSTNAME=${TARGET_HOSTNAME:-raspberrypi}
export FIRST_USER_NAME=${FIRST_USER_NAME:-pi} export FIRST_USER_NAME=${FIRST_USER_NAME:-pi}
export FIRST_USER_PASS export FIRST_USER_PASS
export DISABLE_FIRST_BOOT_USER_RENAME=${DISABLE_FIRST_BOOT_USER_RENAME:-0} export DISABLE_FIRST_BOOT_USER_RENAME=${DISABLE_FIRST_BOOT_USER_RENAME:-0}
export RELEASE=${RELEASE:-bullseye} export RELEASE=${RELEASE:-bullseye} # Don't forget to update stage0/prerun.sh
export WPA_ESSID export WPA_ESSID
export WPA_PASSWORD export WPA_PASSWORD
export WPA_COUNTRY export WPA_COUNTRY
@ -283,6 +283,10 @@ fi
export NO_PRERUN_QCOW2="${NO_PRERUN_QCOW2:-1}" export NO_PRERUN_QCOW2="${NO_PRERUN_QCOW2:-1}"
if [ "$SETFCAP" != "1" ]; then
export CAPSH_ARG="--drop=cap_setfcap"
fi
dependencies_check "${BASE_DIR}/depends" dependencies_check "${BASE_DIR}/depends"
#check username is valid #check username is valid

View File

@ -18,7 +18,7 @@ bootstrap(){
BOOTSTRAP_ARGS+=("$@") BOOTSTRAP_ARGS+=("$@")
printf -v BOOTSTRAP_STR '%q ' "${BOOTSTRAP_ARGS[@]}" printf -v BOOTSTRAP_STR '%q ' "${BOOTSTRAP_ARGS[@]}"
capsh --drop=cap_setfcap -- -c "'${BOOTSTRAP_CMD}' $BOOTSTRAP_STR" || true capsh $CAPSH_ARG -- -c "'${BOOTSTRAP_CMD}' $BOOTSTRAP_STR" || true
if [ -d "$2/debootstrap" ] && ! rmdir "$2/debootstrap"; then if [ -d "$2/debootstrap" ] && ! rmdir "$2/debootstrap"; then
cp "$2/debootstrap/debootstrap.log" "${STAGE_WORK_DIR}" cp "$2/debootstrap/debootstrap.log" "${STAGE_WORK_DIR}"
@ -91,7 +91,7 @@ on_chroot() {
mount --bind /sys "${ROOTFS_DIR}/sys" mount --bind /sys "${ROOTFS_DIR}/sys"
fi fi
capsh --drop=cap_setfcap "--chroot=${ROOTFS_DIR}/" -- -e "$@" capsh $CAPSH_ARG "--chroot=${ROOTFS_DIR}/" -- -e "$@"
} }
export -f on_chroot export -f on_chroot

View File

@ -1,5 +1,10 @@
#!/bin/bash -e #!/bin/bash -e
if [ "$RELEASE" != "bullseye" ]; then
echo "WARNING: RELEASE does not match the intended option for this branch."
echo " Please check the relevant README.md section."
fi
if [ ! -d "${ROOTFS_DIR}" ] || [ "${USE_QCOW2}" = "1" ]; then if [ ! -d "${ROOTFS_DIR}" ] || [ "${USE_QCOW2}" = "1" ]; then
bootstrap ${RELEASE} "${ROOTFS_DIR}" http://deb.debian.org/debian/ bootstrap ${RELEASE} "${ROOTFS_DIR}" http://deb.debian.org/debian/
fi fi