diff --git a/.gitignore b/.gitignore index 96a23b6..8233806 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ postrun.sh .pc *-pc apt-cacher-ng/ +.customvars diff --git a/build-docker.sh b/build-docker.sh index 79b68d4..2141451 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -5,6 +5,10 @@ BUILD_OPTS="$*" DOCKER="docker" +# Ensure that any config variables we passed in are written to an env_file +# so invocations in subsquent shells preserve these values +printenv | grep 'FWVERSION=\|SERIAL=\|ROOTUSER\|ROOTUSERPASS' > "$DIR/.customvars" + if ! ${DOCKER} ps >/dev/null 2>&1; then DOCKER="sudo docker" fi @@ -79,6 +83,7 @@ if [ "${CONTAINER_EXISTS}" != "" ]; then time ${DOCKER} run --rm --privileged \ --volume "${CONFIG_FILE}":/config:ro \ -e "GIT_HASH=${GIT_HASH}" \ + --env-file=${DIR}/.customvars \ --volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \ pi-gen \ bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static && @@ -90,6 +95,7 @@ else time ${DOCKER} run --name "${CONTAINER_NAME}" --privileged \ --volume "${CONFIG_FILE}":/config:ro \ -e "GIT_HASH=${GIT_HASH}" \ + --env-file=${DIR}/.customvars \ pi-gen \ bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static && cd /pi-gen; ./build.sh ${BUILD_OPTS} && diff --git a/config b/config old mode 100644 new mode 100755 index b79c3c8..1525ac0 --- a/config +++ b/config @@ -1,6 +1,6 @@ -# Override these values by setting FWVERSION, SERIAL, ROOTUSER -# and ROOTUSERPASS before invoking build(-docker).sh like so: -# FWVERSION=3 SERIAL=0001 ./build-docker.sh +# Override these values by optionally setting FWVERSION, SERIAL, +# ROOTUSER and ROOTUSERPASS before invoking build(-docker).sh like so: +# FWVERSION="XX.YY.ZZZ" SERIAL="XXXXXXXXXXXX" ./build-docker.sh export IMG_NAME="moab-fw-${FWVERSION:=dev}" echo "IMG_NAME is $IMG_NAME" @@ -12,7 +12,7 @@ TIMEZONE=$(cat /etc/timezone) export TIMEZONE_DEFAULT=$TIMEZONE echo "TIMEZONE_DEFAULT is $TIMEZONE_DEFAULT" -export LOCALE_DEFAULT=$(cat /etc/default/locale) +export LOCALE_DEFAULT=${LANG:="en_US.UTF-8"} echo "LOCALE_DEFAULT is $LOCALE_DEFAULT" export FIRST_USER_NAME=${ROOTUSER:="pi"} diff --git a/export-image/prerun.sh b/export-image/prerun.sh index 01f1e74..a984c99 100755 --- a/export-image/prerun.sh +++ b/export-image/prerun.sh @@ -39,10 +39,6 @@ BOOT_LENGTH=$(echo "$PARTED_OUT" | grep -e '^1:' | cut -d':' -f 4 | tr -d B) ROOT_OFFSET=$(echo "$PARTED_OUT" | grep -e '^2:' | cut -d':' -f 2 | tr -d B) ROOT_LENGTH=$(echo "$PARTED_OUT" | grep -e '^2:' | cut -d':' -f 4 | tr -d B) -# Ensures that freshly created loop devices are available to mount -# https://github.com/RPi-Distro/pi-gen/issues/320#issuecomment-518484064 -sleep 5 - BOOT_DEV=$(losetup --show -f -o "${BOOT_OFFSET}" --sizelimit "${BOOT_LENGTH}" "${IMG_FILE}") ROOT_DEV=$(losetup --show -f -o "${ROOT_OFFSET}" --sizelimit "${ROOT_LENGTH}" "${IMG_FILE}") echo "/boot: offset $BOOT_OFFSET, length $BOOT_LENGTH" @@ -57,6 +53,10 @@ done mkdosfs -n boot -F 32 -v "$BOOT_DEV" > /dev/null mkfs.ext4 -L rootfs -O "$ROOT_FEATURES" "$ROOT_DEV" > /dev/null +# Ensures that freshly created loop devices are available to mount +# https://github.com/RPi-Distro/pi-gen/issues/320#issuecomment-518484064 +sleep 5 + mount -v "$ROOT_DEV" "${ROOTFS_DIR}" -t ext4 mkdir -p "${ROOTFS_DIR}/boot" mount -v "$BOOT_DEV" "${ROOTFS_DIR}/boot" -t vfat diff --git a/stage2/04-custom-tweaks/00-packages b/stage2/04-custom-tweaks/00-packages new file mode 100644 index 0000000..cfe86da --- /dev/null +++ b/stage2/04-custom-tweaks/00-packages @@ -0,0 +1 @@ +python3-pip \ No newline at end of file diff --git a/stage2/04-custom-tweaks/01-run.sh b/stage2/04-custom-tweaks/01-run.sh index 1a5614c..b6aef34 100755 --- a/stage2/04-custom-tweaks/01-run.sh +++ b/stage2/04-custom-tweaks/01-run.sh @@ -7,4 +7,13 @@ echo "Installing docker..." on_chroot << EOF curl -sSL get.docker.com | sh usermod -aG docker ${FIRST_USER_NAME} -EOF \ No newline at end of file +EOF + +# Install docker-compose +echo "Installing docker-compose" +on_chroot << EOF +pip3 install docker-compose + +# Ensure it's in PATH +ln -sfn /home/${FIRST_USER_NAME}/.local/bin/docker-compose /usr/bin/docker-compose +EOF