diff --git a/debian-live-config/README.md b/debian-live-config/README.md index 1e699cc6..595bab83 100644 --- a/debian-live-config/README.md +++ b/debian-live-config/README.md @@ -10,4 +10,5 @@ See https://live-team.pages.debian.net/live-manual/html/live-manual/index.en.htm * `docker run --rm -v /home/user/district-of-columbia-230111.osm.pbf:/data/region.osm.pbf lrnselfreliance/osm-map-dumper > debian-live-config/config/includes.chroot/opt/wrolpi-blobs/map-db-gis.dump` 2. Run the build. * `sudo ./build.sh` + * Or, build specific branch: `sudo ./build.sh -b master` 3. The ISO is now in the `debian-live-config` directory. diff --git a/debian-live-config/build.sh b/debian-live-config/build.sh index 44f0dad9..7119227e 100755 --- a/debian-live-config/build.sh +++ b/debian-live-config/build.sh @@ -6,6 +6,25 @@ BUILD_DIR=/var/tmp/wrolpi-build-debian VERSION=$(cat "${SCRIPT_DIR}/../wrolpi/version.txt") +Help() { + echo "Build WROLPi Debian Live ISO image." + echo + echo "Syntax: build.sh [-h] [-b BRANCH]" + echo "options:" + echo "h Print this help." + echo "b Build from this git BRANCH (default: 'release')." + echo +} + +BRANCH="release" +while getopts ":hb:" option; do + case $option in + h) Help; exit ;; + b) BRANCH="${OPTARG}" ;; + *) echo "Error: Invalid option"; exit 1 ;; + esac +done + # Re-execute this script if it wasn't called with sudo. if [ $EUID != 0 ]; then sudo "$0" "$@" @@ -78,6 +97,9 @@ lb config \ rsync -a "${SCRIPT_DIR}/config" "${BUILD_DIR}/" +# Write branch config for hook script. +echo "${BRANCH}" > "${BUILD_DIR}/config/includes.chroot/opt/wrolpi-branch" + time nice -n 18 lb build 2>&1 | tee "${SCRIPT_DIR}/build.log" grep "9999-wrolpi.hook.chroot completed" "${SCRIPT_DIR}/build.log" >/dev/null 2>&1 || (echo "build hook failed!" && exit 1) diff --git a/debian-live-config/config/hooks/normal/9999-wrolpi.hook.chroot b/debian-live-config/config/hooks/normal/9999-wrolpi.hook.chroot index 10fe9a2e..d1a007f9 100644 --- a/debian-live-config/config/hooks/normal/9999-wrolpi.hook.chroot +++ b/debian-live-config/config/hooks/normal/9999-wrolpi.hook.chroot @@ -18,7 +18,10 @@ EOF git --version -git clone -b master https://github.com/lrnselfreliance/wrolpi.git /opt/wrolpi +WROLPI_BRANCH="release" +[ -f /opt/wrolpi-branch ] && WROLPI_BRANCH=$(cat /opt/wrolpi-branch) +git clone -b "${WROLPI_BRANCH}" https://github.com/lrnselfreliance/wrolpi.git /opt/wrolpi +rm -f /opt/wrolpi-branch # Install webapp. cd /opt/wrolpi/app diff --git a/pi-gen/README.md b/pi-gen/README.md index b0a09bb9..b7b9407a 100644 --- a/pi-gen/README.md +++ b/pi-gen/README.md @@ -19,12 +19,12 @@ See https://github.com/RPI-Distro/pi-gen 2. Run the build (or, with a specific git branch) - * Build master branch + * Build release branch (default) sudo ./build.sh * Build specific branch - sudo ./build.sh -b release-candidate + sudo ./build.sh -b master 3. The images are now in the `pi-gen` directory. diff --git a/pi-gen/build.sh b/pi-gen/build.sh index 1841213c..3af762d4 100755 --- a/pi-gen/build.sh +++ b/pi-gen/build.sh @@ -6,6 +6,25 @@ BUILD_DIR=/var/tmp/wrolpi-build-pi-gen VERSION=$(cat "${SCRIPT_DIR}/../wrolpi/version.txt") +Help() { + echo "Build WROLPi Raspberry Pi OS image." + echo + echo "Syntax: build.sh [-h] [-b BRANCH]" + echo "options:" + echo "h Print this help." + echo "b Build from this git BRANCH (default: 'release')." + echo +} + +BRANCH="release" +while getopts ":hb:" option; do + case $option in + h) Help; exit ;; + b) BRANCH="${OPTARG}" ;; + *) echo "Error: Invalid option"; exit 1 ;; + esac +done + # Re-execute this script if it wasn't called with sudo. if [ $EUID != 0 ]; then sudo "$0" "$@" @@ -81,6 +100,7 @@ mv /var/tmp/pi-gen-bookworm-arm64 /var/tmp/wrolpi-build-pi-gen # Copy the configuration and build files into the pi-gen directory. cp "${SCRIPT_DIR}/config.txt" "${BUILD_DIR}/config.txt" +echo "WROLPI_BRANCH=${BRANCH}" >> "${BUILD_DIR}/config.txt" rsync -a "${SCRIPT_DIR}"/stage2/* "${BUILD_DIR}/stage2/" # We only need to build the Lite and Desktop images. diff --git a/pi-gen/stage2/04-wrolpi/03-run-chroot.sh b/pi-gen/stage2/04-wrolpi/03-run-chroot.sh index 2c2bf52f..a0248fbc 100755 --- a/pi-gen/stage2/04-wrolpi/03-run-chroot.sh +++ b/pi-gen/stage2/04-wrolpi/03-run-chroot.sh @@ -35,8 +35,8 @@ chmod +x /usr/local/bin/deno rm /tmp/deno.zip deno --version -# Put the latest WROLPi master in /opt/wrolpi. -git clone -b master https://github.com/lrnselfreliance/wrolpi.git /opt/wrolpi +# Put the latest WROLPi in /opt/wrolpi. +git clone -b "${WROLPI_BRANCH:-release}" https://github.com/lrnselfreliance/wrolpi.git /opt/wrolpi git config --global --add safe.directory /opt/wrolpi # Install Python requirements. Try multiple times because pypi may stop responding.