diff --git a/build-docker.sh b/build-docker.sh index 5d31f86..ee83518 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -7,42 +7,42 @@ BUILD_OPTS="$*" DOCKER="docker" if ! ${DOCKER} ps >/dev/null 2>&1; then - DOCKER="sudo docker" + DOCKER="sudo docker" fi if ! ${DOCKER} ps >/dev/null; then - echo "error connecting to docker:" - ${DOCKER} ps - exit 1 + echo "error connecting to docker:" + ${DOCKER} ps + exit 1 fi CONFIG_FILE="" if [ -f "${DIR}/config" ]; then - CONFIG_FILE="${DIR}/config" + CONFIG_FILE="${DIR}/config" fi while getopts "c:" flag do - case "${flag}" in - c) - CONFIG_FILE="${OPTARG}" - ;; - *) - ;; - esac + case "${flag}" in + c) + CONFIG_FILE="${OPTARG}" + ;; + *) + ;; + esac done # Ensure that the configuration file is an absolute path if test -x /usr/bin/realpath; then - CONFIG_FILE=$(realpath -s "$CONFIG_FILE" || realpath "$CONFIG_FILE") + CONFIG_FILE=$(realpath -s "$CONFIG_FILE" || realpath "$CONFIG_FILE") fi # Ensure that the confguration file is present if test -z "${CONFIG_FILE}"; then - echo "Configuration file need to be present in '${DIR}/config' or path passed as parameter" - exit 1 + echo "Configuration file need to be present in '${DIR}/config' or path passed as parameter" + exit 1 else - # shellcheck disable=SC1090 - source ${CONFIG_FILE} + # shellcheck disable=SC1090 + source ${CONFIG_FILE} fi CONTAINER_NAME=${CONTAINER_NAME:-pigen_work} @@ -50,8 +50,8 @@ CONTINUE=${CONTINUE:-0} PRESERVE_CONTAINER=${PRESERVE_CONTAINER:-0} if [ -z "${IMG_NAME}" ]; then - echo "IMG_NAME not set in 'config'" 1>&2 - echo 1>&2 + echo "IMG_NAME not set in 'config'" 1>&2 + echo 1>&2 exit 1 fi @@ -61,14 +61,14 @@ GIT_HASH=${GIT_HASH:-"$(git rev-parse HEAD)"} CONTAINER_EXISTS=$(${DOCKER} ps -a --filter name="${CONTAINER_NAME}" -q) CONTAINER_RUNNING=$(${DOCKER} ps --filter name="${CONTAINER_NAME}" -q) if [ "${CONTAINER_RUNNING}" != "" ]; then - echo "The build is already running in container ${CONTAINER_NAME}. Aborting." - exit 1 + echo "The build is already running in container ${CONTAINER_NAME}. Aborting." + exit 1 fi if [ "${CONTAINER_EXISTS}" != "" ] && [ "${CONTINUE}" != "1" ]; then - echo "Container ${CONTAINER_NAME} already exists and you did not specify CONTINUE=1. Aborting." - echo "You can delete the existing container like this:" - echo " ${DOCKER} rm -v ${CONTAINER_NAME}" - exit 1 + echo "Container ${CONTAINER_NAME} already exists and you did not specify CONTINUE=1. Aborting." + echo "You can delete the existing container like this:" + echo " ${DOCKER} rm -v ${CONTAINER_NAME}" + exit 1 fi # Modify original build-options to allow config file to be mounted in the docker container @@ -86,32 +86,32 @@ esac ${DOCKER} build --build-arg BASE_IMAGE=${BASE_IMAGE} -t pi-gen "${DIR}" if [ "${CONTAINER_EXISTS}" != "" ]; then - trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}_cont' SIGINT SIGTERM - time ${DOCKER} run --rm --privileged \ - --cap-add=ALL \ - -v /dev:/dev \ - -v /lib/modules:/lib/modules \ - --volume "${CONFIG_FILE}":/config:ro \ - -e "GIT_HASH=${GIT_HASH}" \ - --volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \ - pi-gen \ - bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static && - cd /pi-gen; ./build.sh ${BUILD_OPTS} && - rsync -av work/*/build.log deploy/" & - wait "$!" + trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}_cont' SIGINT SIGTERM + time ${DOCKER} run --rm --privileged \ + --cap-add=ALL \ + -v /dev:/dev \ + -v /lib/modules:/lib/modules \ + --volume "${CONFIG_FILE}":/config:ro \ + -e "GIT_HASH=${GIT_HASH}" \ + --volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \ + pi-gen \ + bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static && + cd /pi-gen; ./build.sh ${BUILD_OPTS} && + rsync -av work/*/build.log deploy/" & + wait "$!" else - trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}' SIGINT SIGTERM - time ${DOCKER} run --name "${CONTAINER_NAME}" --privileged \ - --cap-add=ALL \ - -v /dev:/dev \ - -v /lib/modules:/lib/modules \ - --volume "${CONFIG_FILE}":/config:ro \ - -e "GIT_HASH=${GIT_HASH}" \ - pi-gen \ - bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static && - cd /pi-gen; ./build.sh ${BUILD_OPTS} && - rsync -av work/*/build.log deploy/" & - wait "$!" + trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}' SIGINT SIGTERM + time ${DOCKER} run --name "${CONTAINER_NAME}" --privileged \ + --cap-add=ALL \ + -v /dev:/dev \ + -v /lib/modules:/lib/modules \ + --volume "${CONFIG_FILE}":/config:ro \ + -e "GIT_HASH=${GIT_HASH}" \ + pi-gen \ + bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static && + cd /pi-gen; ./build.sh ${BUILD_OPTS} && + rsync -av work/*/build.log deploy/" & + wait "$!" fi echo "copying results from deploy/" @@ -120,7 +120,7 @@ ls -lah deploy # cleanup if [ "${PRESERVE_CONTAINER}" != "1" ]; then - ${DOCKER} rm -v "${CONTAINER_NAME}" + ${DOCKER} rm -v "${CONTAINER_NAME}" fi echo "Done! Your image(s) should be in deploy/" diff --git a/build.sh b/build.sh index ff008be..490c154 100755 --- a/build.sh +++ b/build.sh @@ -3,183 +3,183 @@ # shellcheck disable=SC2119 run_sub_stage() { - log "Begin ${SUB_STAGE_DIR}" - pushd "${SUB_STAGE_DIR}" > /dev/null - for i in {00..99}; do - if [ -f "${i}-debconf" ]; then - log "Begin ${SUB_STAGE_DIR}/${i}-debconf" - on_chroot << EOF + log "Begin ${SUB_STAGE_DIR}" + pushd "${SUB_STAGE_DIR}" > /dev/null + for i in {00..99}; do + if [ -f "${i}-debconf" ]; then + log "Begin ${SUB_STAGE_DIR}/${i}-debconf" + on_chroot << EOF debconf-set-selections < /dev/null - if [ "${CLEAN}" = "1" ]; then - rm -rf .pc - rm -rf ./*-pc - fi - QUILT_PATCHES="${SUB_STAGE_DIR}/${i}-patches" - SUB_STAGE_QUILT_PATCH_DIR="$(basename "$SUB_STAGE_DIR")-pc" - mkdir -p "$SUB_STAGE_QUILT_PATCH_DIR" - ln -snf "$SUB_STAGE_QUILT_PATCH_DIR" .pc - quilt upgrade - if [ -e "${SUB_STAGE_DIR}/${i}-patches/EDIT" ]; then - echo "Dropping into bash to edit patches..." - bash - fi - RC=0 - quilt push -a || RC=$? - case "$RC" in - 0|2) - ;; - *) - false - ;; - esac - popd > /dev/null - log "End ${SUB_STAGE_DIR}/${i}-patches" - fi - if [ -x ${i}-run.sh ]; then - log "Begin ${SUB_STAGE_DIR}/${i}-run.sh" - ./${i}-run.sh - log "End ${SUB_STAGE_DIR}/${i}-run.sh" - fi - if [ -f ${i}-run-chroot.sh ]; then - log "Begin ${SUB_STAGE_DIR}/${i}-run-chroot.sh" - on_chroot < ${i}-run-chroot.sh - log "End ${SUB_STAGE_DIR}/${i}-run-chroot.sh" - fi - done - popd > /dev/null - log "End ${SUB_STAGE_DIR}" + fi + fi + log "End ${SUB_STAGE_DIR}/${i}-packages" + fi + if [ -d "${i}-patches" ]; then + log "Begin ${SUB_STAGE_DIR}/${i}-patches" + pushd "${STAGE_WORK_DIR}" > /dev/null + if [ "${CLEAN}" = "1" ]; then + rm -rf .pc + rm -rf ./*-pc + fi + QUILT_PATCHES="${SUB_STAGE_DIR}/${i}-patches" + SUB_STAGE_QUILT_PATCH_DIR="$(basename "$SUB_STAGE_DIR")-pc" + mkdir -p "$SUB_STAGE_QUILT_PATCH_DIR" + ln -snf "$SUB_STAGE_QUILT_PATCH_DIR" .pc + quilt upgrade + if [ -e "${SUB_STAGE_DIR}/${i}-patches/EDIT" ]; then + echo "Dropping into bash to edit patches..." + bash + fi + RC=0 + quilt push -a || RC=$? + case "$RC" in + 0|2) + ;; + *) + false + ;; + esac + popd > /dev/null + log "End ${SUB_STAGE_DIR}/${i}-patches" + fi + if [ -x ${i}-run.sh ]; then + log "Begin ${SUB_STAGE_DIR}/${i}-run.sh" + ./${i}-run.sh + log "End ${SUB_STAGE_DIR}/${i}-run.sh" + fi + if [ -f ${i}-run-chroot.sh ]; then + log "Begin ${SUB_STAGE_DIR}/${i}-run-chroot.sh" + on_chroot < ${i}-run-chroot.sh + log "End ${SUB_STAGE_DIR}/${i}-run-chroot.sh" + fi + done + popd > /dev/null + log "End ${SUB_STAGE_DIR}" } run_stage(){ - log "Begin ${STAGE_DIR}" - STAGE="$(basename "${STAGE_DIR}")" - - pushd "${STAGE_DIR}" > /dev/null - - STAGE_WORK_DIR="${WORK_DIR}/${STAGE}" - ROOTFS_DIR="${STAGE_WORK_DIR}"/rootfs - - if [ "${USE_QCOW2}" = "1" ]; then - if [ ! -f SKIP ]; then - load_qimage - fi - else - # make sure we are not umounting during export-image stage - if [ "${USE_QCOW2}" = "0" ] && [ "${NO_PRERUN_QCOW2}" = "0" ]; then - unmount "${WORK_DIR}/${STAGE}" - fi - fi - - if [ ! -f SKIP_IMAGES ]; then - if [ -f "${STAGE_DIR}/EXPORT_IMAGE" ]; then - EXPORT_DIRS="${EXPORT_DIRS} ${STAGE_DIR}" - fi - fi - if [ ! -f SKIP ]; then - if [ "${CLEAN}" = "1" ] && [ "${USE_QCOW2}" = "0" ] ; then - if [ -d "${ROOTFS_DIR}" ]; then - rm -rf "${ROOTFS_DIR}" - fi - fi - if [ -x prerun.sh ]; then - log "Begin ${STAGE_DIR}/prerun.sh" - ./prerun.sh - log "End ${STAGE_DIR}/prerun.sh" - fi - for SUB_STAGE_DIR in "${STAGE_DIR}"/*; do - if [ -d "${SUB_STAGE_DIR}" ] && [ ! -f "${SUB_STAGE_DIR}/SKIP" ]; then - run_sub_stage - fi - done - fi - - if [ "${USE_QCOW2}" = "1" ]; then - unload_qimage - else - # make sure we are not umounting during export-image stage - if [ "${USE_QCOW2}" = "0" ] && [ "${NO_PRERUN_QCOW2}" = "0" ]; then - unmount "${WORK_DIR}/${STAGE}" - fi - fi - - PREV_STAGE="${STAGE}" - PREV_STAGE_DIR="${STAGE_DIR}" - PREV_ROOTFS_DIR="${ROOTFS_DIR}" - popd > /dev/null - log "End ${STAGE_DIR}" + log "Begin ${STAGE_DIR}" + STAGE="$(basename "${STAGE_DIR}")" + + pushd "${STAGE_DIR}" > /dev/null + + STAGE_WORK_DIR="${WORK_DIR}/${STAGE}" + ROOTFS_DIR="${STAGE_WORK_DIR}"/rootfs + + if [ "${USE_QCOW2}" = "1" ]; then + if [ ! -f SKIP ]; then + load_qimage + fi + else + # make sure we are not umounting during export-image stage + if [ "${USE_QCOW2}" = "0" ] && [ "${NO_PRERUN_QCOW2}" = "0" ]; then + unmount "${WORK_DIR}/${STAGE}" + fi + fi + + if [ ! -f SKIP_IMAGES ]; then + if [ -f "${STAGE_DIR}/EXPORT_IMAGE" ]; then + EXPORT_DIRS="${EXPORT_DIRS} ${STAGE_DIR}" + fi + fi + if [ ! -f SKIP ]; then + if [ "${CLEAN}" = "1" ] && [ "${USE_QCOW2}" = "0" ] ; then + if [ -d "${ROOTFS_DIR}" ]; then + rm -rf "${ROOTFS_DIR}" + fi + fi + if [ -x prerun.sh ]; then + log "Begin ${STAGE_DIR}/prerun.sh" + ./prerun.sh + log "End ${STAGE_DIR}/prerun.sh" + fi + for SUB_STAGE_DIR in "${STAGE_DIR}"/*; do + if [ -d "${SUB_STAGE_DIR}" ] && [ ! -f "${SUB_STAGE_DIR}/SKIP" ]; then + run_sub_stage + fi + done + fi + + if [ "${USE_QCOW2}" = "1" ]; then + unload_qimage + else + # make sure we are not umounting during export-image stage + if [ "${USE_QCOW2}" = "0" ] && [ "${NO_PRERUN_QCOW2}" = "0" ]; then + unmount "${WORK_DIR}/${STAGE}" + fi + fi + + PREV_STAGE="${STAGE}" + PREV_STAGE_DIR="${STAGE_DIR}" + PREV_ROOTFS_DIR="${ROOTFS_DIR}" + popd > /dev/null + log "End ${STAGE_DIR}" } if [ "$(id -u)" != "0" ]; then - echo "Please run as root" 1>&2 - exit 1 + echo "Please run as root" 1>&2 + exit 1 fi BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" export BASE_DIR if [ -f config ]; then - # shellcheck disable=SC1091 - source config + # shellcheck disable=SC1091 + source config fi while getopts "c:" flag do - case "$flag" in - c) - EXTRA_CONFIG="$OPTARG" - # shellcheck disable=SC1090 - source "$EXTRA_CONFIG" - ;; - *) - ;; - esac + case "$flag" in + c) + EXTRA_CONFIG="$OPTARG" + # shellcheck disable=SC1090 + source "$EXTRA_CONFIG" + ;; + *) + ;; + esac done term() { - if [ "${USE_QCOW2}" = "1" ]; then - log "Unloading image" - unload_qimage - fi + if [ "${USE_QCOW2}" = "1" ]; then + log "Unloading image" + unload_qimage + fi } trap term EXIT INT TERM @@ -188,8 +188,8 @@ export PI_GEN=${PI_GEN:-pi-gen} export PI_GEN_REPO=${PI_GEN_REPO:-https://github.com/RPi-Distro/pi-gen} if [ -z "${IMG_NAME}" ]; then - echo "IMG_NAME not set" 1>&2 - exit 1 + echo "IMG_NAME not set" 1>&2 + exit 1 fi export USE_QEMU="${USE_QEMU:-0}" @@ -257,9 +257,9 @@ export USE_QCOW2="${USE_QCOW2:-1}" export BASE_QCOW2_SIZE=${BASE_QCOW2_SIZE:-12G} source "${SCRIPT_DIR}/qcow2_handling" if [ "${USE_QCOW2}" = "1" ]; then - NO_PRERUN_QCOW2=1 + NO_PRERUN_QCOW2=1 else - NO_PRERUN_QCOW2=0 + NO_PRERUN_QCOW2=0 fi export NO_PRERUN_QCOW2="${NO_PRERUN_QCOW2:-1}" @@ -268,23 +268,23 @@ dependencies_check "${BASE_DIR}/depends" #check username is valid if [[ ! "$FIRST_USER_NAME" =~ ^[a-z][-a-z0-9_]*$ ]]; then - echo "Invalid FIRST_USER_NAME: $FIRST_USER_NAME" - exit 1 + echo "Invalid FIRST_USER_NAME: $FIRST_USER_NAME" + exit 1 fi if [[ -n "${APT_PROXY}" ]] && ! curl --silent "${APT_PROXY}" >/dev/null ; then - echo "Could not reach APT_PROXY server: ${APT_PROXY}" - exit 1 + echo "Could not reach APT_PROXY server: ${APT_PROXY}" + exit 1 fi if [[ -n "${WPA_PASSWORD}" && ${#WPA_PASSWORD} -lt 8 || ${#WPA_PASSWORD} -gt 63 ]] ; then - echo "WPA_PASSWORD" must be between 8 and 63 characters - exit 1 + echo "WPA_PASSWORD" must be between 8 and 63 characters + exit 1 fi if [[ "${PUBKEY_ONLY_SSH}" = "1" && -z "${PUBKEY_SSH_FIRST_USER}" ]]; then - echo "Must set 'PUBKEY_SSH_FIRST_USER' to a valid SSH public key if using PUBKEY_ONLY_SSH" - exit 1 + echo "Must set 'PUBKEY_SSH_FIRST_USER' to a valid SSH public key if using PUBKEY_ONLY_SSH" + exit 1 fi mkdir -p "${WORK_DIR}" @@ -293,108 +293,108 @@ log "Begin ${BASE_DIR}" STAGE_LIST=${STAGE_LIST:-${BASE_DIR}/stage*} for STAGE_DIR in $STAGE_LIST; do - STAGE_DIR=$(realpath "${STAGE_DIR}") - run_stage + STAGE_DIR=$(realpath "${STAGE_DIR}") + run_stage done CLEAN=1 for EXPORT_DIR in ${EXPORT_DIRS}; do - STAGE_DIR=${BASE_DIR}/export-image - # shellcheck source=/dev/null - source "${EXPORT_DIR}/EXPORT_IMAGE" - EXPORT_ROOTFS_DIR=${WORK_DIR}/$(basename "${EXPORT_DIR}")/rootfs - if [ "${USE_QCOW2}" = "1" ]; then - USE_QCOW2=0 - EXPORT_NAME="${IMG_FILENAME}${IMG_SUFFIX}" - echo "------------------------------------------------------------------------" - echo "Running export stage for ${EXPORT_NAME}" - rm -f "${WORK_DIR}/export-image/${EXPORT_NAME}.img" || true - rm -f "${WORK_DIR}/export-image/${EXPORT_NAME}.qcow2" || true - rm -f "${WORK_DIR}/${EXPORT_NAME}.img" || true - rm -f "${WORK_DIR}/${EXPORT_NAME}.qcow2" || true - EXPORT_STAGE=$(basename "${EXPORT_DIR}") - for s in $STAGE_LIST; do - TMP_LIST=${TMP_LIST:+$TMP_LIST }$(basename "${s}") - done - FIRST_STAGE=${TMP_LIST%% *} - FIRST_IMAGE="image-${FIRST_STAGE}.qcow2" - - pushd "${WORK_DIR}" > /dev/null - echo "Creating new base "${EXPORT_NAME}.qcow2" from ${FIRST_IMAGE}" - cp "./${FIRST_IMAGE}" "${EXPORT_NAME}.qcow2" - - ARR=($TMP_LIST) - # rebase stage images to new export base - for CURR_STAGE in "${ARR[@]}"; do - if [ "${CURR_STAGE}" = "${FIRST_STAGE}" ]; then - PREV_IMG="${EXPORT_NAME}" - continue - fi - echo "Rebasing image-${CURR_STAGE}.qcow2 onto ${PREV_IMG}.qcow2" - qemu-img rebase -f qcow2 -u -b ${PREV_IMG}.qcow2 image-${CURR_STAGE}.qcow2 - if [ "${CURR_STAGE}" = "${EXPORT_STAGE}" ]; then - break - fi - PREV_IMG="image-${CURR_STAGE}" - done - - # commit current export stage into base export image - echo "Committing image-${EXPORT_STAGE}.qcow2 to ${EXPORT_NAME}.qcow2" - qemu-img commit -f qcow2 -p -b "${EXPORT_NAME}.qcow2" image-${EXPORT_STAGE}.qcow2 - - # rebase stage images back to original first stage for easy re-run - for CURR_STAGE in "${ARR[@]}"; do - if [ "${CURR_STAGE}" = "${FIRST_STAGE}" ]; then - PREV_IMG="image-${CURR_STAGE}" - continue - fi - echo "Rebasing back image-${CURR_STAGE}.qcow2 onto ${PREV_IMG}.qcow2" - qemu-img rebase -f qcow2 -u -b ${PREV_IMG}.qcow2 image-${CURR_STAGE}.qcow2 - if [ "${CURR_STAGE}" = "${EXPORT_STAGE}" ]; then - break - fi - PREV_IMG="image-${CURR_STAGE}" - done - popd > /dev/null - - mkdir -p "${WORK_DIR}/export-image/rootfs" - mv "${WORK_DIR}/${EXPORT_NAME}.qcow2" "${WORK_DIR}/export-image/" - echo "Mounting image ${WORK_DIR}/export-image/${EXPORT_NAME}.qcow2 to rootfs ${WORK_DIR}/export-image/rootfs" - mount_qimage "${WORK_DIR}/export-image/${EXPORT_NAME}.qcow2" "${WORK_DIR}/export-image/rootfs" - - CLEAN=0 - run_stage - CLEAN=1 - USE_QCOW2=1 - - else - run_stage - fi - if [ "${USE_QEMU}" != "1" ]; then - if [ -e "${EXPORT_DIR}/EXPORT_NOOBS" ]; then - # shellcheck source=/dev/null - source "${EXPORT_DIR}/EXPORT_NOOBS" - STAGE_DIR="${BASE_DIR}/export-noobs" - if [ "${USE_QCOW2}" = "1" ]; then - USE_QCOW2=0 - run_stage - USE_QCOW2=1 - else - run_stage - fi - fi - fi + STAGE_DIR=${BASE_DIR}/export-image + # shellcheck source=/dev/null + source "${EXPORT_DIR}/EXPORT_IMAGE" + EXPORT_ROOTFS_DIR=${WORK_DIR}/$(basename "${EXPORT_DIR}")/rootfs + if [ "${USE_QCOW2}" = "1" ]; then + USE_QCOW2=0 + EXPORT_NAME="${IMG_FILENAME}${IMG_SUFFIX}" + echo "------------------------------------------------------------------------" + echo "Running export stage for ${EXPORT_NAME}" + rm -f "${WORK_DIR}/export-image/${EXPORT_NAME}.img" || true + rm -f "${WORK_DIR}/export-image/${EXPORT_NAME}.qcow2" || true + rm -f "${WORK_DIR}/${EXPORT_NAME}.img" || true + rm -f "${WORK_DIR}/${EXPORT_NAME}.qcow2" || true + EXPORT_STAGE=$(basename "${EXPORT_DIR}") + for s in $STAGE_LIST; do + TMP_LIST=${TMP_LIST:+$TMP_LIST }$(basename "${s}") + done + FIRST_STAGE=${TMP_LIST%% *} + FIRST_IMAGE="image-${FIRST_STAGE}.qcow2" + + pushd "${WORK_DIR}" > /dev/null + echo "Creating new base "${EXPORT_NAME}.qcow2" from ${FIRST_IMAGE}" + cp "./${FIRST_IMAGE}" "${EXPORT_NAME}.qcow2" + + ARR=($TMP_LIST) + # rebase stage images to new export base + for CURR_STAGE in "${ARR[@]}"; do + if [ "${CURR_STAGE}" = "${FIRST_STAGE}" ]; then + PREV_IMG="${EXPORT_NAME}" + continue + fi + echo "Rebasing image-${CURR_STAGE}.qcow2 onto ${PREV_IMG}.qcow2" + qemu-img rebase -f qcow2 -u -b ${PREV_IMG}.qcow2 image-${CURR_STAGE}.qcow2 + if [ "${CURR_STAGE}" = "${EXPORT_STAGE}" ]; then + break + fi + PREV_IMG="image-${CURR_STAGE}" + done + + # commit current export stage into base export image + echo "Committing image-${EXPORT_STAGE}.qcow2 to ${EXPORT_NAME}.qcow2" + qemu-img commit -f qcow2 -p -b "${EXPORT_NAME}.qcow2" image-${EXPORT_STAGE}.qcow2 + + # rebase stage images back to original first stage for easy re-run + for CURR_STAGE in "${ARR[@]}"; do + if [ "${CURR_STAGE}" = "${FIRST_STAGE}" ]; then + PREV_IMG="image-${CURR_STAGE}" + continue + fi + echo "Rebasing back image-${CURR_STAGE}.qcow2 onto ${PREV_IMG}.qcow2" + qemu-img rebase -f qcow2 -u -b ${PREV_IMG}.qcow2 image-${CURR_STAGE}.qcow2 + if [ "${CURR_STAGE}" = "${EXPORT_STAGE}" ]; then + break + fi + PREV_IMG="image-${CURR_STAGE}" + done + popd > /dev/null + + mkdir -p "${WORK_DIR}/export-image/rootfs" + mv "${WORK_DIR}/${EXPORT_NAME}.qcow2" "${WORK_DIR}/export-image/" + echo "Mounting image ${WORK_DIR}/export-image/${EXPORT_NAME}.qcow2 to rootfs ${WORK_DIR}/export-image/rootfs" + mount_qimage "${WORK_DIR}/export-image/${EXPORT_NAME}.qcow2" "${WORK_DIR}/export-image/rootfs" + + CLEAN=0 + run_stage + CLEAN=1 + USE_QCOW2=1 + + else + run_stage + fi + if [ "${USE_QEMU}" != "1" ]; then + if [ -e "${EXPORT_DIR}/EXPORT_NOOBS" ]; then + # shellcheck source=/dev/null + source "${EXPORT_DIR}/EXPORT_NOOBS" + STAGE_DIR="${BASE_DIR}/export-noobs" + if [ "${USE_QCOW2}" = "1" ]; then + USE_QCOW2=0 + run_stage + USE_QCOW2=1 + else + run_stage + fi + fi + fi done if [ -x postrun.sh ]; then - log "Begin postrun.sh" - cd "${BASE_DIR}" - ./postrun.sh - log "End postrun.sh" + log "Begin postrun.sh" + cd "${BASE_DIR}" + ./postrun.sh + log "End postrun.sh" fi if [ "${USE_QCOW2}" = "1" ]; then - unload_qimage + unload_qimage fi log "End ${BASE_DIR}" diff --git a/export-image/00-allow-rerun/00-run.sh b/export-image/00-allow-rerun/00-run.sh index dd67f4c..82308d8 100755 --- a/export-image/00-allow-rerun/00-run.sh +++ b/export-image/00-allow-rerun/00-run.sh @@ -1,9 +1,9 @@ #!/bin/bash -e if [ ! -x "${ROOTFS_DIR}/usr/bin/qemu-arm-static" ]; then - cp /usr/bin/qemu-arm-static "${ROOTFS_DIR}/usr/bin/" + cp /usr/bin/qemu-arm-static "${ROOTFS_DIR}/usr/bin/" fi if [ -e "${ROOTFS_DIR}/etc/ld.so.preload" ]; then - mv "${ROOTFS_DIR}/etc/ld.so.preload" "${ROOTFS_DIR}/etc/ld.so.preload.disabled" + mv "${ROOTFS_DIR}/etc/ld.so.preload" "${ROOTFS_DIR}/etc/ld.so.preload.disabled" fi diff --git a/export-image/03-set-partuuid/00-run.sh b/export-image/03-set-partuuid/00-run.sh index 16e1b15..66f3f06 100755 --- a/export-image/03-set-partuuid/00-run.sh +++ b/export-image/03-set-partuuid/00-run.sh @@ -2,17 +2,17 @@ if [ "${NO_PRERUN_QCOW2}" = "0" ]; then - IMG_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img" + IMG_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img" - IMGID="$(dd if="${IMG_FILE}" skip=440 bs=1 count=4 2>/dev/null | xxd -e | cut -f 2 -d' ')" + IMGID="$(dd if="${IMG_FILE}" skip=440 bs=1 count=4 2>/dev/null | xxd -e | cut -f 2 -d' ')" - BOOT_PARTUUID="${IMGID}-01" - ROOT_PARTUUID="${IMGID}-02" + BOOT_PARTUUID="${IMGID}-01" + ROOT_PARTUUID="${IMGID}-02" - sed -i "s/BOOTDEV/PARTUUID=${BOOT_PARTUUID}/" "${ROOTFS_DIR}/etc/fstab" - sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${ROOTFS_DIR}/etc/fstab" + sed -i "s/BOOTDEV/PARTUUID=${BOOT_PARTUUID}/" "${ROOTFS_DIR}/etc/fstab" + sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${ROOTFS_DIR}/etc/fstab" - sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${ROOTFS_DIR}/boot/cmdline.txt" + sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${ROOTFS_DIR}/boot/cmdline.txt" fi diff --git a/export-image/04-finalise/01-run.sh b/export-image/04-finalise/01-run.sh index d7ace58..b7bf583 100755 --- a/export-image/04-finalise/01-run.sh +++ b/export-image/04-finalise/01-run.sh @@ -5,23 +5,23 @@ INFO_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.info" on_chroot << EOF if [ -x /etc/init.d/fake-hwclock ]; then - /etc/init.d/fake-hwclock stop + /etc/init.d/fake-hwclock stop fi if hash hardlink 2>/dev/null; then - hardlink -t /usr/share/doc + hardlink -t /usr/share/doc fi EOF if [ -d "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.config" ]; then - chmod 700 "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.config" + chmod 700 "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.config" fi rm -f "${ROOTFS_DIR}/usr/bin/qemu-arm-static" if [ "${USE_QEMU}" != "1" ]; then - if [ -e "${ROOTFS_DIR}/etc/ld.so.preload.disabled" ]; then - mv "${ROOTFS_DIR}/etc/ld.so.preload.disabled" "${ROOTFS_DIR}/etc/ld.so.preload" - fi + if [ -e "${ROOTFS_DIR}/etc/ld.so.preload.disabled" ]; then + mv "${ROOTFS_DIR}/etc/ld.so.preload.disabled" "${ROOTFS_DIR}/etc/ld.so.preload" + fi fi rm -f "${ROOTFS_DIR}/etc/network/interfaces.dpkg-old" @@ -59,21 +59,21 @@ cp "$ROOTFS_DIR/etc/rpi-issue" "$INFO_FILE" { - if [ -f "$ROOTFS_DIR/usr/share/doc/raspberrypi-kernel/changelog.Debian.gz" ]; then - firmware=$(zgrep "firmware as of" \ - "$ROOTFS_DIR/usr/share/doc/raspberrypi-kernel/changelog.Debian.gz" | \ - head -n1 | sed -n 's|.* \([^ ]*\)$|\1|p') - printf "\nFirmware: https://github.com/raspberrypi/firmware/tree/%s\n" "$firmware" + if [ -f "$ROOTFS_DIR/usr/share/doc/raspberrypi-kernel/changelog.Debian.gz" ]; then + firmware=$(zgrep "firmware as of" \ + "$ROOTFS_DIR/usr/share/doc/raspberrypi-kernel/changelog.Debian.gz" | \ + head -n1 | sed -n 's|.* \([^ ]*\)$|\1|p') + printf "\nFirmware: https://github.com/raspberrypi/firmware/tree/%s\n" "$firmware" - kernel="$(curl -s -L "https://github.com/raspberrypi/firmware/raw/$firmware/extra/git_hash")" - printf "Kernel: https://github.com/raspberrypi/linux/tree/%s\n" "$kernel" + kernel="$(curl -s -L "https://github.com/raspberrypi/firmware/raw/$firmware/extra/git_hash")" + printf "Kernel: https://github.com/raspberrypi/linux/tree/%s\n" "$kernel" - uname="$(curl -s -L "https://github.com/raspberrypi/firmware/raw/$firmware/extra/uname_string7")" - printf "Uname string: %s\n" "$uname" - fi + uname="$(curl -s -L "https://github.com/raspberrypi/firmware/raw/$firmware/extra/uname_string7")" + printf "Uname string: %s\n" "$uname" + fi - printf "\nPackages:\n" - dpkg -l --root "$ROOTFS_DIR" + printf "\nPackages:\n" + dpkg -l --root "$ROOTFS_DIR" } >> "$INFO_FILE" mkdir -p "${DEPLOY_DIR}" @@ -84,22 +84,22 @@ rm -f "${DEPLOY_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img" mv "$INFO_FILE" "$DEPLOY_DIR/" if [ "${USE_QCOW2}" = "0" ] && [ "${NO_PRERUN_QCOW2}" = "0" ]; then - ROOT_DEV="$(mount | grep "${ROOTFS_DIR} " | cut -f1 -d' ')" + ROOT_DEV="$(mount | grep "${ROOTFS_DIR} " | cut -f1 -d' ')" - unmount "${ROOTFS_DIR}" - zerofree "${ROOT_DEV}" + unmount "${ROOTFS_DIR}" + zerofree "${ROOT_DEV}" - unmount_image "${IMG_FILE}" + unmount_image "${IMG_FILE}" else - unload_qimage - make_bootable_image "${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.qcow2" "$IMG_FILE" + unload_qimage + make_bootable_image "${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.qcow2" "$IMG_FILE" fi if [ "${DEPLOY_ZIP}" == "1" ]; then - pushd "${STAGE_WORK_DIR}" > /dev/null - zip "${DEPLOY_DIR}/${ZIP_FILENAME}${IMG_SUFFIX}.zip" \ - "$(basename "${IMG_FILE}")" - popd > /dev/null + pushd "${STAGE_WORK_DIR}" > /dev/null + zip "${DEPLOY_DIR}/${ZIP_FILENAME}${IMG_SUFFIX}.zip" \ + "$(basename "${IMG_FILE}")" + popd > /dev/null else - mv "$IMG_FILE" "$DEPLOY_DIR/" + mv "$IMG_FILE" "$DEPLOY_DIR/" fi diff --git a/export-image/prerun.sh b/export-image/prerun.sh index fad7f80..e30ab3f 100755 --- a/export-image/prerun.sh +++ b/export-image/prerun.sh @@ -1,87 +1,87 @@ #!/bin/bash -e if [ "${NO_PRERUN_QCOW2}" = "0" ]; then - IMG_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img" - - unmount_image "${IMG_FILE}" - - rm -f "${IMG_FILE}" - - rm -rf "${ROOTFS_DIR}" - mkdir -p "${ROOTFS_DIR}" - - BOOT_SIZE="$((256 * 1024 * 1024))" - ROOT_SIZE=$(du --apparent-size -s "${EXPORT_ROOTFS_DIR}" --exclude var/cache/apt/archives --exclude boot --block-size=1 | cut -f 1) - - # All partition sizes and starts will be aligned to this size - ALIGN="$((4 * 1024 * 1024))" - # Add this much space to the calculated file size. This allows for - # some overhead (since actual space usage is usually rounded up to the - # filesystem block size) and gives some free space on the resulting - # image. - ROOT_MARGIN="$(echo "($ROOT_SIZE * 0.2 + 200 * 1024 * 1024) / 1" | bc)" - - BOOT_PART_START=$((ALIGN)) - BOOT_PART_SIZE=$(((BOOT_SIZE + ALIGN - 1) / ALIGN * ALIGN)) - ROOT_PART_START=$((BOOT_PART_START + BOOT_PART_SIZE)) - ROOT_PART_SIZE=$(((ROOT_SIZE + ROOT_MARGIN + ALIGN - 1) / ALIGN * ALIGN)) - IMG_SIZE=$((BOOT_PART_START + BOOT_PART_SIZE + ROOT_PART_SIZE)) - - truncate -s "${IMG_SIZE}" "${IMG_FILE}" - - parted --script "${IMG_FILE}" mklabel msdos - parted --script "${IMG_FILE}" unit B mkpart primary fat32 "${BOOT_PART_START}" "$((BOOT_PART_START + BOOT_PART_SIZE - 1))" - parted --script "${IMG_FILE}" unit B mkpart primary ext4 "${ROOT_PART_START}" "$((ROOT_PART_START + ROOT_PART_SIZE - 1))" - - PARTED_OUT=$(parted -sm "${IMG_FILE}" unit b print) - BOOT_OFFSET=$(echo "$PARTED_OUT" | grep -e '^1:' | cut -d':' -f 2 | tr -d B) - 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) - - echo "Mounting BOOT_DEV..." - cnt=0 - until BOOT_DEV=$(losetup --show -f -o "${BOOT_OFFSET}" --sizelimit "${BOOT_LENGTH}" "${IMG_FILE}"); do - if [ $cnt -lt 5 ]; then - cnt=$((cnt + 1)) - echo "Error in losetup for BOOT_DEV. Retrying..." - sleep 5 - else - echo "ERROR: losetup for BOOT_DEV failed; exiting" - exit 1 - fi - done - - echo "Mounting ROOT_DEV..." - cnt=0 - until ROOT_DEV=$(losetup --show -f -o "${ROOT_OFFSET}" --sizelimit "${ROOT_LENGTH}" "${IMG_FILE}"); do - if [ $cnt -lt 5 ]; then - cnt=$((cnt + 1)) - echo "Error in losetup for ROOT_DEV. Retrying..." - sleep 5 - else - echo "ERROR: losetup for ROOT_DEV failed; exiting" - exit 1 - fi - done - - echo "/boot: offset $BOOT_OFFSET, length $BOOT_LENGTH" - echo "/: offset $ROOT_OFFSET, length $ROOT_LENGTH" - - ROOT_FEATURES="^huge_file" - for FEATURE in metadata_csum 64bit; do - if grep -q "$FEATURE" /etc/mke2fs.conf; then - ROOT_FEATURES="^$FEATURE,$ROOT_FEATURES" - fi - done - mkdosfs -n boot -F 32 -v "$BOOT_DEV" > /dev/null - mkfs.ext4 -L rootfs -O "$ROOT_FEATURES" "$ROOT_DEV" > /dev/null - - mount -v "$ROOT_DEV" "${ROOTFS_DIR}" -t ext4 - mkdir -p "${ROOTFS_DIR}/boot" - mount -v "$BOOT_DEV" "${ROOTFS_DIR}/boot" -t vfat - - rsync -aHAXx --exclude /var/cache/apt/archives --exclude /boot "${EXPORT_ROOTFS_DIR}/" "${ROOTFS_DIR}/" - rsync -rtx "${EXPORT_ROOTFS_DIR}/boot/" "${ROOTFS_DIR}/boot/" + IMG_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img" + + unmount_image "${IMG_FILE}" + + rm -f "${IMG_FILE}" + + rm -rf "${ROOTFS_DIR}" + mkdir -p "${ROOTFS_DIR}" + + BOOT_SIZE="$((256 * 1024 * 1024))" + ROOT_SIZE=$(du --apparent-size -s "${EXPORT_ROOTFS_DIR}" --exclude var/cache/apt/archives --exclude boot --block-size=1 | cut -f 1) + + # All partition sizes and starts will be aligned to this size + ALIGN="$((4 * 1024 * 1024))" + # Add this much space to the calculated file size. This allows for + # some overhead (since actual space usage is usually rounded up to the + # filesystem block size) and gives some free space on the resulting + # image. + ROOT_MARGIN="$(echo "($ROOT_SIZE * 0.2 + 200 * 1024 * 1024) / 1" | bc)" + + BOOT_PART_START=$((ALIGN)) + BOOT_PART_SIZE=$(((BOOT_SIZE + ALIGN - 1) / ALIGN * ALIGN)) + ROOT_PART_START=$((BOOT_PART_START + BOOT_PART_SIZE)) + ROOT_PART_SIZE=$(((ROOT_SIZE + ROOT_MARGIN + ALIGN - 1) / ALIGN * ALIGN)) + IMG_SIZE=$((BOOT_PART_START + BOOT_PART_SIZE + ROOT_PART_SIZE)) + + truncate -s "${IMG_SIZE}" "${IMG_FILE}" + + parted --script "${IMG_FILE}" mklabel msdos + parted --script "${IMG_FILE}" unit B mkpart primary fat32 "${BOOT_PART_START}" "$((BOOT_PART_START + BOOT_PART_SIZE - 1))" + parted --script "${IMG_FILE}" unit B mkpart primary ext4 "${ROOT_PART_START}" "$((ROOT_PART_START + ROOT_PART_SIZE - 1))" + + PARTED_OUT=$(parted -sm "${IMG_FILE}" unit b print) + BOOT_OFFSET=$(echo "$PARTED_OUT" | grep -e '^1:' | cut -d':' -f 2 | tr -d B) + 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) + + echo "Mounting BOOT_DEV..." + cnt=0 + until BOOT_DEV=$(losetup --show -f -o "${BOOT_OFFSET}" --sizelimit "${BOOT_LENGTH}" "${IMG_FILE}"); do + if [ $cnt -lt 5 ]; then + cnt=$((cnt + 1)) + echo "Error in losetup for BOOT_DEV. Retrying..." + sleep 5 + else + echo "ERROR: losetup for BOOT_DEV failed; exiting" + exit 1 + fi + done + + echo "Mounting ROOT_DEV..." + cnt=0 + until ROOT_DEV=$(losetup --show -f -o "${ROOT_OFFSET}" --sizelimit "${ROOT_LENGTH}" "${IMG_FILE}"); do + if [ $cnt -lt 5 ]; then + cnt=$((cnt + 1)) + echo "Error in losetup for ROOT_DEV. Retrying..." + sleep 5 + else + echo "ERROR: losetup for ROOT_DEV failed; exiting" + exit 1 + fi + done + + echo "/boot: offset $BOOT_OFFSET, length $BOOT_LENGTH" + echo "/: offset $ROOT_OFFSET, length $ROOT_LENGTH" + + ROOT_FEATURES="^huge_file" + for FEATURE in metadata_csum 64bit; do + if grep -q "$FEATURE" /etc/mke2fs.conf; then + ROOT_FEATURES="^$FEATURE,$ROOT_FEATURES" + fi + done + mkdosfs -n boot -F 32 -v "$BOOT_DEV" > /dev/null + mkfs.ext4 -L rootfs -O "$ROOT_FEATURES" "$ROOT_DEV" > /dev/null + + mount -v "$ROOT_DEV" "${ROOTFS_DIR}" -t ext4 + mkdir -p "${ROOTFS_DIR}/boot" + mount -v "$BOOT_DEV" "${ROOTFS_DIR}/boot" -t vfat + + rsync -aHAXx --exclude /var/cache/apt/archives --exclude /boot "${EXPORT_ROOTFS_DIR}/" "${ROOTFS_DIR}/" + rsync -rtx "${EXPORT_ROOTFS_DIR}/boot/" "${ROOTFS_DIR}/boot/" fi diff --git a/export-noobs/00-release/00-run.sh b/export-noobs/00-release/00-run.sh index 8524730..d2191bf 100755 --- a/export-noobs/00-release/00-run.sh +++ b/export-noobs/00-release/00-run.sh @@ -2,13 +2,13 @@ NOOBS_DIR="${STAGE_WORK_DIR}/${IMG_DATE}-${IMG_NAME}${IMG_SUFFIX}" -install -v -m 744 files/partition_setup.sh "${NOOBS_DIR}/" -install -v files/partitions.json "${NOOBS_DIR}/" -install -v files/os.json "${NOOBS_DIR}/" -install -v files/OS.png "${NOOBS_DIR}/" -install -v files/release_notes.txt "${NOOBS_DIR}/" +install -v -m 744 files/partition_setup.sh "${NOOBS_DIR}/" +install -v files/partitions.json "${NOOBS_DIR}/" +install -v files/os.json "${NOOBS_DIR}/" +install -v files/OS.png "${NOOBS_DIR}/" +install -v files/release_notes.txt "${NOOBS_DIR}/" -tar -v -c -C files/marketing -f "${NOOBS_DIR}/marketing.tar" . +tar -v -c -C files/marketing -f "${NOOBS_DIR}/marketing.tar" . BOOT_SHASUM="$(sha256sum "${NOOBS_DIR}/boot.tar.xz" | cut -f1 -d' ')" ROOT_SHASUM="$(sha256sum "${NOOBS_DIR}/root.tar.xz" | cut -f1 -d' ')" @@ -42,7 +42,7 @@ sed "${NOOBS_DIR}/os.json" -i -e "s|KERNEL|$(cat "${STAGE_WORK_DIR}/kernel_versi sed "${NOOBS_DIR}/release_notes.txt" -i -e "s|UNRELEASED|${IMG_DATE}|" if [ "${USE_QCOW2}" = "1" ]; then - mv "${NOOBS_DIR}" "${DEPLOY_DIR}/" + mv "${NOOBS_DIR}" "${DEPLOY_DIR}/" else - cp -a "${NOOBS_DIR}" "${DEPLOY_DIR}/" + cp -a "${NOOBS_DIR}" "${DEPLOY_DIR}/" fi diff --git a/export-noobs/prerun.sh b/export-noobs/prerun.sh index bb9450a..86927d7 100755 --- a/export-noobs/prerun.sh +++ b/export-noobs/prerun.sh @@ -4,9 +4,9 @@ NOOBS_DIR="${STAGE_WORK_DIR}/${IMG_DATE}-${IMG_NAME}${IMG_SUFFIX}" mkdir -p "${STAGE_WORK_DIR}" if [ "${DEPLOY_ZIP}" == "1" ]; then - IMG_FILE="${WORK_DIR}/export-image/${IMG_FILENAME}${IMG_SUFFIX}.img" + IMG_FILE="${WORK_DIR}/export-image/${IMG_FILENAME}${IMG_SUFFIX}.img" else - IMG_FILE="${DEPLOY_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img" + IMG_FILE="${DEPLOY_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img" fi unmount_image "${IMG_FILE}" @@ -23,27 +23,27 @@ ROOT_LENGTH=$(echo "$PARTED_OUT" | grep -e '^2:' | cut -d':' -f 4 | tr -d B) echo "Mounting BOOT_DEV..." cnt=0 until BOOT_DEV=$(losetup --show -f -o "${BOOT_OFFSET}" --sizelimit "${BOOT_LENGTH}" "${IMG_FILE}"); do - if [ $cnt -lt 5 ]; then - cnt=$((cnt + 1)) - echo "Error in losetup for BOOT_DEV. Retrying..." - sleep 5 - else - echo "ERROR: losetup for BOOT_DEV failed; exiting" - exit 1 - fi + if [ $cnt -lt 5 ]; then + cnt=$((cnt + 1)) + echo "Error in losetup for BOOT_DEV. Retrying..." + sleep 5 + else + echo "ERROR: losetup for BOOT_DEV failed; exiting" + exit 1 + fi done echo "Mounting ROOT_DEV..." cnt=0 until ROOT_DEV=$(losetup --show -f -o "${ROOT_OFFSET}" --sizelimit "${ROOT_LENGTH}" "${IMG_FILE}"); do - if [ $cnt -lt 5 ]; then - cnt=$((cnt + 1)) - echo "Error in losetup for ROOT_DEV. Retrying..." - sleep 5 - else - echo "ERROR: losetup for ROOT_DEV failed; exiting" - exit 1 - fi + if [ $cnt -lt 5 ]; then + cnt=$((cnt + 1)) + echo "Error in losetup for ROOT_DEV. Retrying..." + sleep 5 + else + echo "ERROR: losetup for ROOT_DEV failed; exiting" + exit 1 + fi done echo "/boot: offset $BOOT_OFFSET, length $BOOT_LENGTH" @@ -65,7 +65,7 @@ umount "${STAGE_WORK_DIR}/rootfs/boot" bsdtar --numeric-owner --format gnutar -C "${STAGE_WORK_DIR}/rootfs" --one-file-system -cpf - . | xz -T0 > "${NOOBS_DIR}/root.tar.xz" if [ "${USE_QCOW2}" = "1" ]; then - rm "$ROOTFS_DIR/etc/systemd/system/multi-user.target.wants/apply_noobs_os_config.service" + rm "$ROOTFS_DIR/etc/systemd/system/multi-user.target.wants/apply_noobs_os_config.service" fi unmount_image "${IMG_FILE}" diff --git a/imagetool.sh b/imagetool.sh index adc1ab7..0284c88 100755 --- a/imagetool.sh +++ b/imagetool.sh @@ -1,15 +1,15 @@ #!/bin/bash if [ "$(id -u)" != "0" ]; then - echo "Please run as root" 1>&2 - exit 1 + echo "Please run as root" 1>&2 + exit 1 fi progname=$(basename $0) function usage() { - cat << HEREDOC + cat << HEREDOC Usage: Mount Image : $progname [--mount] [--image-name ] [--mount-point ] @@ -36,77 +36,77 @@ IMAGE="" MOUNTPOINT="" nbd_cleanup() { - DEVS="$(lsblk | grep nbd | grep disk | cut -d" " -f1)" - if [ ! -z "${DEVS}" ]; then - for d in $DEVS; do - if [ ! -z "${d}" ]; then - QDEV="$(ps xa | grep $d | grep -v grep)" - if [ -z "${QDEV}" ]; then - kpartx -d /dev/$d && echo "Unconnected device map removed: /dev/$d" - fi - fi - done - fi + DEVS="$(lsblk | grep nbd | grep disk | cut -d" " -f1)" + if [ ! -z "${DEVS}" ]; then + for d in $DEVS; do + if [ ! -z "${d}" ]; then + QDEV="$(ps xa | grep $d | grep -v grep)" + if [ -z "${QDEV}" ]; then + kpartx -d /dev/$d && echo "Unconnected device map removed: /dev/$d" + fi + fi + done + fi } # As long as there is at least one more argument, keep looping while [[ $# -gt 0 ]]; do - key="$1" - case "$key" in - -h|--help) - usage - exit - ;; - -c|--cleanup) - nbd_cleanup - ;; - -m|--mount) - MOUNT=1 - ;; - -u|--umount) - UMOUNT=1 - ;; - -i|--image-name) - shift - IMAGE="$1" - ;; - -p|--mount-point) - shift - MOUNTPOINT="$1" - ;; - *) - echo "Unknown option '$key'" - usage - exit - ;; - esac - # Shift after checking all the cases to get the next option - shift + key="$1" + case "$key" in + -h|--help) + usage + exit + ;; + -c|--cleanup) + nbd_cleanup + ;; + -m|--mount) + MOUNT=1 + ;; + -u|--umount) + UMOUNT=1 + ;; + -i|--image-name) + shift + IMAGE="$1" + ;; + -p|--mount-point) + shift + MOUNTPOINT="$1" + ;; + *) + echo "Unknown option '$key'" + usage + exit + ;; + esac + # Shift after checking all the cases to get the next option + shift done if [ "${MOUNT}" = "1" ] && [ "${UMOUNT}" = "1" ]; then - usage - echo "Concurrent mount options not possible." - exit + usage + echo "Concurrent mount options not possible." + exit fi if [ "${MOUNT}" = "1" ] && ([ -z "${IMAGE}" ] || [ -z "${MOUNTPOINT}" ]); then - usage - echo "Can not mount image. Image path and/or mount point missing." - exit + usage + echo "Can not mount image. Image path and/or mount point missing." + exit fi if [ "${UMOUNT}" = "1" ] && [ -z "${MOUNTPOINT}" ]; then - usage - echo "Can not umount. Mount point parameter missing." - exit + usage + echo "Can not umount. Mount point parameter missing." + exit fi export NBD_DEV="${NBD_DEV:-/dev/nbd1}" source scripts/qcow2_handling if [ "${MOUNT}" = "1" ]; then - mount_qimage "${MOUNTPOINT}" "${IMAGE}" + mount_qimage "${MOUNTPOINT}" "${IMAGE}" elif [ "${UMOUNT}" = "1" ]; then - umount_qimage "${MOUNTPOINT}" + umount_qimage "${MOUNTPOINT}" fi diff --git a/scripts/common b/scripts/common index e2048d9..e7383de 100644 --- a/scripts/common +++ b/scripts/common @@ -1,100 +1,100 @@ log (){ - date +"[%T] $*" | tee -a "${LOG_FILE}" + date +"[%T] $*" | tee -a "${LOG_FILE}" } export -f log bootstrap(){ - local BOOTSTRAP_CMD=debootstrap - local BOOTSTRAP_ARGS=() + local BOOTSTRAP_CMD=debootstrap + local BOOTSTRAP_ARGS=() - export http_proxy=${APT_PROXY} + export http_proxy=${APT_PROXY} - if [ "$(dpkg --print-architecture)" != "armhf" ] && [ "$(dpkg --print-architecture)" != "aarch64" ]; then - BOOTSTRAP_CMD=qemu-debootstrap - fi + if [ "$(dpkg --print-architecture)" != "armhf" ] && [ "$(dpkg --print-architecture)" != "aarch64" ]; then + BOOTSTRAP_CMD=qemu-debootstrap + fi - BOOTSTRAP_ARGS+=(--arch armhf) - BOOTSTRAP_ARGS+=(--components "main,contrib,non-free") - BOOTSTRAP_ARGS+=(--keyring "${STAGE_DIR}/files/raspberrypi.gpg") - BOOTSTRAP_ARGS+=("$@") - printf -v BOOTSTRAP_STR '%q ' "${BOOTSTRAP_ARGS[@]}" + BOOTSTRAP_ARGS+=(--arch armhf) + BOOTSTRAP_ARGS+=(--components "main,contrib,non-free") + BOOTSTRAP_ARGS+=(--keyring "${STAGE_DIR}/files/raspberrypi.gpg") + BOOTSTRAP_ARGS+=("$@") + printf -v BOOTSTRAP_STR '%q ' "${BOOTSTRAP_ARGS[@]}" - setarch linux32 capsh --drop=cap_setfcap -- -c "'${BOOTSTRAP_CMD}' $BOOTSTRAP_STR" || true + setarch linux32 capsh --drop=cap_setfcap -- -c "'${BOOTSTRAP_CMD}' $BOOTSTRAP_STR" || true - if [ -d "$2/debootstrap" ]; then - rmdir "$2/debootstrap" - fi + if [ -d "$2/debootstrap" ]; then + rmdir "$2/debootstrap" + fi } export -f bootstrap copy_previous(){ - if [ ! -d "${PREV_ROOTFS_DIR}" ]; then - echo "Previous stage rootfs not found" - false - fi - mkdir -p "${ROOTFS_DIR}" - rsync -aHAXx --exclude var/cache/apt/archives "${PREV_ROOTFS_DIR}/" "${ROOTFS_DIR}/" + if [ ! -d "${PREV_ROOTFS_DIR}" ]; then + echo "Previous stage rootfs not found" + false + fi + mkdir -p "${ROOTFS_DIR}" + rsync -aHAXx --exclude var/cache/apt/archives "${PREV_ROOTFS_DIR}/" "${ROOTFS_DIR}/" } export -f copy_previous unmount(){ - if [ -z "$1" ]; then - DIR=$PWD - else - DIR=$1 - fi + if [ -z "$1" ]; then + DIR=$PWD + else + DIR=$1 + fi - while mount | grep -q "$DIR"; do - local LOCS - LOCS=$(mount | grep "$DIR" | cut -f 3 -d ' ' | sort -r) - for loc in $LOCS; do - umount "$loc" - done - done + while mount | grep -q "$DIR"; do + local LOCS + LOCS=$(mount | grep "$DIR" | cut -f 3 -d ' ' | sort -r) + for loc in $LOCS; do + umount "$loc" + done + done } export -f unmount unmount_image(){ - sync - sleep 1 - local LOOP_DEVICES - LOOP_DEVICES=$(losetup --list | grep "$(basename "${1}")" | cut -f1 -d' ') - for LOOP_DEV in ${LOOP_DEVICES}; do - if [ -n "${LOOP_DEV}" ]; then - local MOUNTED_DIR - MOUNTED_DIR=$(mount | grep "$(basename "${LOOP_DEV}")" | head -n 1 | cut -f 3 -d ' ') - if [ -n "${MOUNTED_DIR}" ] && [ "${MOUNTED_DIR}" != "/" ]; then - unmount "$(dirname "${MOUNTED_DIR}")" - fi - sleep 1 - losetup -d "${LOOP_DEV}" - fi - done + sync + sleep 1 + local LOOP_DEVICES + LOOP_DEVICES=$(losetup --list | grep "$(basename "${1}")" | cut -f1 -d' ') + for LOOP_DEV in ${LOOP_DEVICES}; do + if [ -n "${LOOP_DEV}" ]; then + local MOUNTED_DIR + MOUNTED_DIR=$(mount | grep "$(basename "${LOOP_DEV}")" | head -n 1 | cut -f 3 -d ' ') + if [ -n "${MOUNTED_DIR}" ] && [ "${MOUNTED_DIR}" != "/" ]; then + unmount "$(dirname "${MOUNTED_DIR}")" + fi + sleep 1 + losetup -d "${LOOP_DEV}" + fi + done } export -f unmount_image on_chroot() { - if ! mount | grep -q "$(realpath "${ROOTFS_DIR}"/proc)"; then - mount -t proc proc "${ROOTFS_DIR}/proc" - fi + if ! mount | grep -q "$(realpath "${ROOTFS_DIR}"/proc)"; then + mount -t proc proc "${ROOTFS_DIR}/proc" + fi - if ! mount | grep -q "$(realpath "${ROOTFS_DIR}"/dev)"; then - mount --bind /dev "${ROOTFS_DIR}/dev" - fi - - if ! mount | grep -q "$(realpath "${ROOTFS_DIR}"/dev/pts)"; then - mount --bind /dev/pts "${ROOTFS_DIR}/dev/pts" - fi + if ! mount | grep -q "$(realpath "${ROOTFS_DIR}"/dev)"; then + mount --bind /dev "${ROOTFS_DIR}/dev" + fi + + if ! mount | grep -q "$(realpath "${ROOTFS_DIR}"/dev/pts)"; then + mount --bind /dev/pts "${ROOTFS_DIR}/dev/pts" + fi - if ! mount | grep -q "$(realpath "${ROOTFS_DIR}"/sys)"; then - mount --bind /sys "${ROOTFS_DIR}/sys" - fi + if ! mount | grep -q "$(realpath "${ROOTFS_DIR}"/sys)"; then + mount --bind /sys "${ROOTFS_DIR}/sys" + fi - setarch linux32 capsh --drop=cap_setfcap "--chroot=${ROOTFS_DIR}/" -- -e "$@" + setarch linux32 capsh --drop=cap_setfcap "--chroot=${ROOTFS_DIR}/" -- -e "$@" } export -f on_chroot update_issue() { - echo -e "Raspberry Pi reference ${IMG_DATE}\nGenerated using ${PI_GEN}, ${PI_GEN_REPO}, ${GIT_HASH}, ${1}" > "${ROOTFS_DIR}/etc/rpi-issue" + echo -e "Raspberry Pi reference ${IMG_DATE}\nGenerated using ${PI_GEN}, ${PI_GEN_REPO}, ${GIT_HASH}, ${1}" > "${ROOTFS_DIR}/etc/rpi-issue" } export -f update_issue diff --git a/scripts/dependencies_check b/scripts/dependencies_check index 375512b..840651e 100644 --- a/scripts/dependencies_check +++ b/scripts/dependencies_check @@ -1,38 +1,38 @@ # dependencies_check -# $@ Dependency files to check +# $@ Dependency files to check # # Each dependency is in the form of a tool to test for, optionally followed by # a : and the name of a package if the package on a Debian-ish system is not # named for the tool (i.e., qemu-user-static). dependencies_check() { - local depfile deps missing + local depfile deps missing - for depfile in "$@"; do - if [[ -e "$depfile" ]]; then - deps="$(sed -f "${SCRIPT_DIR}/remove-comments.sed" < "${BASE_DIR}/depends")" + for depfile in "$@"; do + if [[ -e "$depfile" ]]; then + deps="$(sed -f "${SCRIPT_DIR}/remove-comments.sed" < "${BASE_DIR}/depends")" - fi - for dep in $deps; do - if ! hash "${dep%:*}" 2>/dev/null; then - missing="${missing:+$missing }${dep#*:}" - fi - done - done + fi + for dep in $deps; do + if ! hash "${dep%:*}" 2>/dev/null; then + missing="${missing:+$missing }${dep#*:}" + fi + done + done - if [[ "$missing" ]]; then - echo "Required dependencies not installed" - echo - echo "This can be resolved on Debian/Raspbian systems by installing:" - echo "$missing" - false - fi + if [[ "$missing" ]]; then + echo "Required dependencies not installed" + echo + echo "This can be resolved on Debian/Raspbian systems by installing:" + echo "$missing" + false + fi - if ! grep -q "/proc/sys/fs/binfmt_misc" /proc/mounts; then - echo "Module binfmt_misc not loaded in host" - echo "Please run:" - echo " sudo modprobe binfmt_misc" - exit 1 - fi + if ! grep -q "/proc/sys/fs/binfmt_misc" /proc/mounts; then + echo "Module binfmt_misc not loaded in host" + echo "Please run:" + echo " sudo modprobe binfmt_misc" + exit 1 + fi } diff --git a/scripts/qcow2_handling b/scripts/qcow2_handling index f722937..4c41188 100644 --- a/scripts/qcow2_handling +++ b/scripts/qcow2_handling @@ -16,241 +16,241 @@ export MAP_ROOT_DEV # find and initialize free block device nodes init_nbd() { - modprobe nbd max_part=16 - if [ -z "${NBD_DEV}" ]; then - for x in /sys/class/block/nbd* ; do - S=`cat $x/size` - if [ "$S" == "0" ] ; then - NBD_DEV=/dev/$(basename $x) - MAP_BOOT_DEV=/dev/mapper/$(basename $x)p1 - MAP_ROOT_DEV=/dev/mapper/$(basename $x)p2 - break - fi - done - fi + modprobe nbd max_part=16 + if [ -z "${NBD_DEV}" ]; then + for x in /sys/class/block/nbd* ; do + S=`cat $x/size` + if [ "$S" == "0" ] ; then + NBD_DEV=/dev/$(basename $x) + MAP_BOOT_DEV=/dev/mapper/$(basename $x)p1 + MAP_ROOT_DEV=/dev/mapper/$(basename $x)p2 + break + fi + done + fi } export -f init_nbd # connect image to block device connect_blkdev() { - init_nbd - qemu-nbd --discard=unmap -c $NBD_DEV "$1" - sync - kpartx -a $NBD_DEV - sync - CURRENT_IMAGE="$1" + init_nbd + qemu-nbd --discard=unmap -c $NBD_DEV "$1" + sync + kpartx -a $NBD_DEV + sync + CURRENT_IMAGE="$1" } export -f connect_blkdev # disconnect image from block device disconnect_blkdev() { - kpartx -d $NBD_DEV - qemu-nbd -d $NBD_DEV - NBD_DEV= - MAP_BOOT_DEV= - MAP_ROOT_DEV= - CURRENT_IMAGE= + kpartx -d $NBD_DEV + qemu-nbd -d $NBD_DEV + NBD_DEV= + MAP_BOOT_DEV= + MAP_ROOT_DEV= + CURRENT_IMAGE= } export -f disconnect_blkdev # mount qcow2 image: mount_image mount_qimage() { - connect_blkdev "$1" - mount -v -t ext4 $MAP_ROOT_DEV "$2" - mkdir -p "${ROOTFS_DIR}/boot" - mount -v -t vfat $MAP_BOOT_DEV "$2/boot" - CURRENT_MOUNTPOINT="$2" + connect_blkdev "$1" + mount -v -t ext4 $MAP_ROOT_DEV "$2" + mkdir -p "${ROOTFS_DIR}/boot" + mount -v -t vfat $MAP_BOOT_DEV "$2/boot" + CURRENT_MOUNTPOINT="$2" } export -f mount_qimage # umount qcow2 image: umount_image umount_qimage() { - sync - #umount "$1/boot" - while mount | grep -q "$1"; do - local LOCS - LOCS=$(mount | grep "$1" | cut -f 3 -d ' ' | sort -r) - for loc in $LOCS; do - echo "$loc" - while mountpoint -q "$loc" && ! umount "$loc"; do - sleep 0.1 - done - done - done - CURRENT_MOUNTPOINT= - disconnect_blkdev + sync + #umount "$1/boot" + while mount | grep -q "$1"; do + local LOCS + LOCS=$(mount | grep "$1" | cut -f 3 -d ' ' | sort -r) + for loc in $LOCS; do + echo "$loc" + while mountpoint -q "$loc" && ! umount "$loc"; do + sleep 0.1 + done + done + done + CURRENT_MOUNTPOINT= + disconnect_blkdev } export -f umount_qimage # create base image / backing image / mount image load_qimage() { - if [ -z "${CURRENT_MOUNTPOINT}" ]; then - if [ ! -d "${ROOTFS_DIR}" ]; then - mkdir -p "${ROOTFS_DIR}"; - fi - - if [ "${CLEAN}" = "1" ] && [ -f "${WORK_DIR}/image-${STAGE}.qcow2" ]; then - rm -f "${WORK_DIR}/image-${STAGE}.qcow2"; - fi - - if [ ! -f "${WORK_DIR}/image-${STAGE}.qcow2" ]; then - pushd ${WORK_DIR} > /dev/null - init_nbd - if [ -z "${PREV_STAGE}" ]; then - echo "Creating base image: image-${STAGE}.qcow2" - # -o preallocation=falloc - qemu-img create -f qcow2 image-${STAGE}.qcow2 $BASE_QCOW2_SIZE - sync - qemu-nbd --discard=unmap -c $NBD_DEV image-${STAGE}.qcow2 - sync - sfdisk $NBD_DEV << EOF + if [ -z "${CURRENT_MOUNTPOINT}" ]; then + if [ ! -d "${ROOTFS_DIR}" ]; then + mkdir -p "${ROOTFS_DIR}"; + fi + + if [ "${CLEAN}" = "1" ] && [ -f "${WORK_DIR}/image-${STAGE}.qcow2" ]; then + rm -f "${WORK_DIR}/image-${STAGE}.qcow2"; + fi + + if [ ! -f "${WORK_DIR}/image-${STAGE}.qcow2" ]; then + pushd ${WORK_DIR} > /dev/null + init_nbd + if [ -z "${PREV_STAGE}" ]; then + echo "Creating base image: image-${STAGE}.qcow2" + # -o preallocation=falloc + qemu-img create -f qcow2 image-${STAGE}.qcow2 $BASE_QCOW2_SIZE + sync + qemu-nbd --discard=unmap -c $NBD_DEV image-${STAGE}.qcow2 + sync + sfdisk $NBD_DEV << EOF 4MiB,250MiB,c,* 254MiB,,83; EOF - sync - kpartx -a $NBD_DEV - mkdosfs -n boot -F 32 -v $MAP_BOOT_DEV - mkfs.ext4 -L rootfs -O "^huge_file,^metadata_csum,^64bit" $MAP_ROOT_DEV - sync - else - if [ ! -f "${WORK_DIR}/image-${PREV_STAGE}.qcow2" ]; then - exit 1; - fi - echo "Creating backing image: image-${STAGE}.qcow2 <- ${WORK_DIR}/image-${PREV_STAGE}.qcow2" - qemu-img create -f qcow2 \ - -o backing_file=${WORK_DIR}/image-${PREV_STAGE}.qcow2 \ - ${WORK_DIR}/image-${STAGE}.qcow2 - sync - qemu-nbd --discard=unmap -c $NBD_DEV image-${STAGE}.qcow2 - sync - kpartx -a $NBD_DEV - fi - - mount -v -t ext4 $MAP_ROOT_DEV "${ROOTFS_DIR}" - mkdir -p "${ROOTFS_DIR}/boot" - mount -v -t vfat $MAP_BOOT_DEV "${ROOTFS_DIR}/boot" - CURRENT_IMAGE=${WORK_DIR}/image-${STAGE}.qcow2 - CURRENT_MOUNTPOINT=${ROOTFS_DIR} - popd > /dev/null - else - mount_qimage "${WORK_DIR}/image-${STAGE}.qcow2" "${ROOTFS_DIR}" - fi - echo "Current image in use: ${CURRENT_IMAGE} (MP: ${CURRENT_MOUNTPOINT})" - fi + sync + kpartx -a $NBD_DEV + mkdosfs -n boot -F 32 -v $MAP_BOOT_DEV + mkfs.ext4 -L rootfs -O "^huge_file,^metadata_csum,^64bit" $MAP_ROOT_DEV + sync + else + if [ ! -f "${WORK_DIR}/image-${PREV_STAGE}.qcow2" ]; then + exit 1; + fi + echo "Creating backing image: image-${STAGE}.qcow2 <- ${WORK_DIR}/image-${PREV_STAGE}.qcow2" + qemu-img create -f qcow2 \ + -o backing_file=${WORK_DIR}/image-${PREV_STAGE}.qcow2 \ + ${WORK_DIR}/image-${STAGE}.qcow2 + sync + qemu-nbd --discard=unmap -c $NBD_DEV image-${STAGE}.qcow2 + sync + kpartx -a $NBD_DEV + fi + + mount -v -t ext4 $MAP_ROOT_DEV "${ROOTFS_DIR}" + mkdir -p "${ROOTFS_DIR}/boot" + mount -v -t vfat $MAP_BOOT_DEV "${ROOTFS_DIR}/boot" + CURRENT_IMAGE=${WORK_DIR}/image-${STAGE}.qcow2 + CURRENT_MOUNTPOINT=${ROOTFS_DIR} + popd > /dev/null + else + mount_qimage "${WORK_DIR}/image-${STAGE}.qcow2" "${ROOTFS_DIR}" + fi + echo "Current image in use: ${CURRENT_IMAGE} (MP: ${CURRENT_MOUNTPOINT})" + fi } export -f load_qimage # umount current image and refresh mount point env var unload_qimage() { - if [ ! -z "${CURRENT_MOUNTPOINT}" ]; then - fstrim -v "${CURRENT_MOUNTPOINT}" || true - umount_qimage "${CURRENT_MOUNTPOINT}" - fi + if [ ! -z "${CURRENT_MOUNTPOINT}" ]; then + fstrim -v "${CURRENT_MOUNTPOINT}" || true + umount_qimage "${CURRENT_MOUNTPOINT}" + fi } export -f unload_qimage # based on: https://github.com/SirLagz/RaspberryPi-ImgAutoSizer # helper function for make_bootable_image, do not call directly function resize_qcow2() { - if [ -z "$CALL_FROM_MBI" ]; then - echo "resize_qcow2: cannot be called directly, use make_bootable_image instead" - return 1 - fi - - # ROOT_MARGIN=$((800*1024*1024)) - ROOT_MARGIN=$((1*1024*1024)) - PARTED_OUT=`parted -s -m "$NBD_DEV" unit B print` - PART_NO=`echo "$PARTED_OUT" | grep ext4 | awk -F: ' { print $1 } '` - PART_START=`echo "$PARTED_OUT" | grep ext4 | awk -F: ' { print substr($2,1,length($2)-1) } '` - - e2fsck -y -f $MAP_ROOT_DEV || true - - DATA_SIZE=`resize2fs -P $MAP_ROOT_DEV | awk -F': ' ' { print $2 } '` - BLOCK_SIZE=$(dumpe2fs -h $MAP_ROOT_DEV | grep 'Block size' | awk -F': ' ' { print $2 }') - BLOCK_SIZE=${BLOCK_SIZE// /} - - let DATA_SIZE=$DATA_SIZE+$ROOT_MARGIN/$BLOCK_SIZE - resize2fs -p $MAP_ROOT_DEV $DATA_SIZE - sleep 1 - - let PART_NEW_SIZE=$DATA_SIZE*$BLOCK_SIZE - let PART_NEW_END=$PART_START+$PART_NEW_SIZE - ACT1=`parted -s "$NBD_DEV" rm 2` - ACT2=`parted -s "$NBD_DEV" unit B mkpart primary $PART_START $PART_NEW_END` - NEW_IMG_SIZE=`parted -s -m "$NBD_DEV" unit B print free | tail -1 | awk -F: ' { print substr($2,1,length($2)-1) } '` + if [ -z "$CALL_FROM_MBI" ]; then + echo "resize_qcow2: cannot be called directly, use make_bootable_image instead" + return 1 + fi + + # ROOT_MARGIN=$((800*1024*1024)) + ROOT_MARGIN=$((1*1024*1024)) + PARTED_OUT=`parted -s -m "$NBD_DEV" unit B print` + PART_NO=`echo "$PARTED_OUT" | grep ext4 | awk -F: ' { print $1 } '` + PART_START=`echo "$PARTED_OUT" | grep ext4 | awk -F: ' { print substr($2,1,length($2)-1) } '` + + e2fsck -y -f $MAP_ROOT_DEV || true + + DATA_SIZE=`resize2fs -P $MAP_ROOT_DEV | awk -F': ' ' { print $2 } '` + BLOCK_SIZE=$(dumpe2fs -h $MAP_ROOT_DEV | grep 'Block size' | awk -F': ' ' { print $2 }') + BLOCK_SIZE=${BLOCK_SIZE// /} + + let DATA_SIZE=$DATA_SIZE+$ROOT_MARGIN/$BLOCK_SIZE + resize2fs -p $MAP_ROOT_DEV $DATA_SIZE + sleep 1 + + let PART_NEW_SIZE=$DATA_SIZE*$BLOCK_SIZE + let PART_NEW_END=$PART_START+$PART_NEW_SIZE + ACT1=`parted -s "$NBD_DEV" rm 2` + ACT2=`parted -s "$NBD_DEV" unit B mkpart primary $PART_START $PART_NEW_END` + NEW_IMG_SIZE=`parted -s -m "$NBD_DEV" unit B print free | tail -1 | awk -F: ' { print substr($2,1,length($2)-1) } '` } export -f resize_qcow2 # create raw img from qcow2: make_bootable_image function make_bootable_image() { - EXPORT_QCOW2="$1" - EXPORT_IMAGE="$2" - - echo "Connect block device to source qcow2" - connect_blkdev "${EXPORT_QCOW2}" - - echo "Resize fs and partition" - CALL_FROM_MBI=1 - resize_qcow2 - sync - CALL_FROM_MBI= - - echo "Disconnect block device" - disconnect_blkdev - - if [ -z "$NEW_IMG_SIZE" ]; then - echo "NEW_IMG_SIZE could not be calculated, cannot process image. Exit." - exit 1 - fi - - echo "Shrinking qcow2 image" - qemu-img resize --shrink "${EXPORT_QCOW2}" $NEW_IMG_SIZE - sync - - echo "Convert qcow2 to raw image" - qemu-img convert -f qcow2 -O raw "${EXPORT_QCOW2}" "${EXPORT_IMAGE}" - sync - - echo "Get PARTUUIDs from image" - IMGID="$(blkid -o value -s PTUUID "${EXPORT_IMAGE}")" - - BOOT_PARTUUID="${IMGID}-01" - echo "Boot: $BOOT_PARTUUID" - ROOT_PARTUUID="${IMGID}-02" - echo "Root: $ROOT_PARTUUID" - - echo "Mount image" - MOUNTROOT=${WORK_DIR}/tmpimage - mkdir -p $MOUNTROOT - - MOUNTPT=$MOUNTROOT - PARTITION=2 - mount "${EXPORT_IMAGE}" "$MOUNTPT" -o loop,offset=$[ `/sbin/sfdisk -d "${EXPORT_IMAGE}" | grep "start=" | head -n $PARTITION | tail -n1 | sed 's/.*start=[ ]*//' | sed 's/,.*//'` * 512 ],sizelimit=$[ `/sbin/sfdisk -d "${EXPORT_IMAGE}" | grep "start=" | head -n $PARTITION | tail -n1 | sed 's/.*size=[ ]*//' | sed 's/,.*//'` * 512 ] || exit 1 - - MOUNTPT=$MOUNTROOT/boot - PARTITION=1 - mount "${EXPORT_IMAGE}" "$MOUNTPT" -o loop,offset=$[ `/sbin/sfdisk -d "${EXPORT_IMAGE}" | grep "start=" | head -n $PARTITION | tail -n1 | sed 's/.*start=[ ]*//' | sed 's/,.*//'` * 512 ],sizelimit=$[ `/sbin/sfdisk -d "${EXPORT_IMAGE}" | grep "start=" | head -n $PARTITION | tail -n1 | sed 's/.*size=[ ]*//' | sed 's/,.*//'` * 512 ] || exit 1 - - if [ ! -d "${MOUNTROOT}/root" ]; then - echo "Image damaged or not mounted. Exit." - exit 1 - fi - - echo "Setup PARTUUIDs" - if [ ! -z "$BOOT_PARTUUID" ] && [ ! -z "$ROOT_PARTUUID" ]; then - echo "Set UUIDs to make it bootable" - sed -i "s/BOOTDEV/PARTUUID=${BOOT_PARTUUID}/" "${MOUNTROOT}/etc/fstab" - sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${MOUNTROOT}/etc/fstab" - sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${MOUNTROOT}/boot/cmdline.txt" - fi - - echo "Umount image" - sync - umount "${MOUNTROOT}/boot" || exit 1 - umount "${MOUNTROOT}" || exit 1 - - echo "Remove qcow2 export image" - rm -f "${EXPORT_QCOW2}" + EXPORT_QCOW2="$1" + EXPORT_IMAGE="$2" + + echo "Connect block device to source qcow2" + connect_blkdev "${EXPORT_QCOW2}" + + echo "Resize fs and partition" + CALL_FROM_MBI=1 + resize_qcow2 + sync + CALL_FROM_MBI= + + echo "Disconnect block device" + disconnect_blkdev + + if [ -z "$NEW_IMG_SIZE" ]; then + echo "NEW_IMG_SIZE could not be calculated, cannot process image. Exit." + exit 1 + fi + + echo "Shrinking qcow2 image" + qemu-img resize --shrink "${EXPORT_QCOW2}" $NEW_IMG_SIZE + sync + + echo "Convert qcow2 to raw image" + qemu-img convert -f qcow2 -O raw "${EXPORT_QCOW2}" "${EXPORT_IMAGE}" + sync + + echo "Get PARTUUIDs from image" + IMGID="$(blkid -o value -s PTUUID "${EXPORT_IMAGE}")" + + BOOT_PARTUUID="${IMGID}-01" + echo "Boot: $BOOT_PARTUUID" + ROOT_PARTUUID="${IMGID}-02" + echo "Root: $ROOT_PARTUUID" + + echo "Mount image" + MOUNTROOT=${WORK_DIR}/tmpimage + mkdir -p $MOUNTROOT + + MOUNTPT=$MOUNTROOT + PARTITION=2 + mount "${EXPORT_IMAGE}" "$MOUNTPT" -o loop,offset=$[ `/sbin/sfdisk -d "${EXPORT_IMAGE}" | grep "start=" | head -n $PARTITION | tail -n1 | sed 's/.*start=[ ]*//' | sed 's/,.*//'` * 512 ],sizelimit=$[ `/sbin/sfdisk -d "${EXPORT_IMAGE}" | grep "start=" | head -n $PARTITION | tail -n1 | sed 's/.*size=[ ]*//' | sed 's/,.*//'` * 512 ] || exit 1 + + MOUNTPT=$MOUNTROOT/boot + PARTITION=1 + mount "${EXPORT_IMAGE}" "$MOUNTPT" -o loop,offset=$[ `/sbin/sfdisk -d "${EXPORT_IMAGE}" | grep "start=" | head -n $PARTITION | tail -n1 | sed 's/.*start=[ ]*//' | sed 's/,.*//'` * 512 ],sizelimit=$[ `/sbin/sfdisk -d "${EXPORT_IMAGE}" | grep "start=" | head -n $PARTITION | tail -n1 | sed 's/.*size=[ ]*//' | sed 's/,.*//'` * 512 ] || exit 1 + + if [ ! -d "${MOUNTROOT}/root" ]; then + echo "Image damaged or not mounted. Exit." + exit 1 + fi + + echo "Setup PARTUUIDs" + if [ ! -z "$BOOT_PARTUUID" ] && [ ! -z "$ROOT_PARTUUID" ]; then + echo "Set UUIDs to make it bootable" + sed -i "s/BOOTDEV/PARTUUID=${BOOT_PARTUUID}/" "${MOUNTROOT}/etc/fstab" + sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${MOUNTROOT}/etc/fstab" + sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${MOUNTROOT}/boot/cmdline.txt" + fi + + echo "Umount image" + sync + umount "${MOUNTROOT}/boot" || exit 1 + umount "${MOUNTROOT}" || exit 1 + + echo "Remove qcow2 export image" + rm -f "${EXPORT_QCOW2}" } export -f make_bootable_image diff --git a/stage0/00-configure-apt/00-run.sh b/stage0/00-configure-apt/00-run.sh index d10a49f..4e06d81 100755 --- a/stage0/00-configure-apt/00-run.sh +++ b/stage0/00-configure-apt/00-run.sh @@ -6,10 +6,10 @@ sed -i "s/RELEASE/${RELEASE}/g" "${ROOTFS_DIR}/etc/apt/sources.list" sed -i "s/RELEASE/${RELEASE}/g" "${ROOTFS_DIR}/etc/apt/sources.list.d/raspi.list" if [ -n "$APT_PROXY" ]; then - install -m 644 files/51cache "${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache" - sed "${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache" -i -e "s|APT_PROXY|${APT_PROXY}|" + install -m 644 files/51cache "${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache" + sed "${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache" -i -e "s|APT_PROXY|${APT_PROXY}|" else - rm -f "${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache" + rm -f "${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache" fi on_chroot apt-key add - < files/raspberrypi.gpg.key diff --git a/stage0/01-locale/00-debconf b/stage0/01-locale/00-debconf index b0ad3e4..1fc5a59 100644 --- a/stage0/01-locale/00-debconf +++ b/stage0/01-locale/00-debconf @@ -1,6 +1,6 @@ # Locales to be generated: # Choices: All locales, aa_DJ ISO-8859-1, aa_DJ.UTF-8 UTF-8, aa_ER UTF-8, aa_ER@saaho UTF-8, aa_ET UTF-8, af_ZA ISO-8859-1, af_ZA.UTF-8 UTF-8, ak_GH UTF-8, am_ET UTF-8, an_ES ISO-8859-15, an_ES.UTF-8 UTF-8, anp_IN UTF-8, ar_AE ISO-8859-6, ar_AE.UTF-8 UTF-8, ar_BH ISO-8859-6, ar_BH.UTF-8 UTF-8, ar_DZ ISO-8859-6, ar_DZ.UTF-8 UTF-8, ar_EG ISO-8859-6, ar_EG.UTF-8 UTF-8, ar_IN UTF-8, ar_IQ ISO-8859-6, ar_IQ.UTF-8 UTF-8, ar_JO ISO-8859-6, ar_JO.UTF-8 UTF-8, ar_KW ISO-8859-6, ar_KW.UTF-8 UTF-8, ar_LB ISO-8859-6, ar_LB.UTF-8 UTF-8, ar_LY ISO-8859-6, ar_LY.UTF-8 UTF-8, ar_MA ISO-8859-6, ar_MA.UTF-8 UTF-8, ar_OM ISO-8859-6, ar_OM.UTF-8 UTF-8, ar_QA ISO-8859-6, ar_QA.UTF-8 UTF-8, ar_SA ISO-8859-6, ar_SA.UTF-8 UTF-8, ar_SD ISO-8859-6, ar_SD.UTF-8 UTF-8, ar_SS UTF-8, ar_SY ISO-8859-6, ar_SY.UTF-8 UTF-8, ar_TN ISO-8859-6, ar_TN.UTF-8 UTF-8, ar_YE ISO-8859-6, ar_YE.UTF-8 UTF-8, as_IN UTF-8, ast_ES ISO-8859-15, ast_ES.UTF-8 UTF-8, ayc_PE UTF-8, az_AZ UTF-8, be_BY CP1251, be_BY.UTF-8 UTF-8, be_BY@latin UTF-8, bem_ZM UTF-8, ber_DZ UTF-8, ber_MA UTF-8, bg_BG CP1251, bg_BG.UTF-8 UTF-8, bho_IN UTF-8, bn_BD UTF-8, bn_IN UTF-8, bo_CN UTF-8, bo_IN UTF-8, br_FR ISO-8859-1, br_FR.UTF-8 UTF-8, br_FR@euro ISO-8859-15, brx_IN UTF-8, bs_BA ISO-8859-2, bs_BA.UTF-8 UTF-8, byn_ER UTF-8, ca_AD ISO-8859-15, ca_AD.UTF-8 UTF-8, ca_ES ISO-8859-1, ca_ES.UTF-8 UTF-8, ca_ES.UTF-8@valencia UTF-8, ca_ES@euro ISO-8859-15, ca_ES@valencia ISO-8859-15, ca_FR ISO-8859-15, ca_FR.UTF-8 UTF-8, ca_IT ISO-8859-15, ca_IT.UTF-8 UTF-8, cmn_TW UTF-8, crh_UA UTF-8, cs_CZ ISO-8859-2, cs_CZ.UTF-8 UTF-8, csb_PL UTF-8, cv_RU UTF-8, cy_GB ISO-8859-14, cy_GB.UTF-8 UTF-8, da_DK ISO-8859-1, da_DK.UTF-8 UTF-8, de_AT ISO-8859-1, de_AT.UTF-8 UTF-8, de_AT@euro ISO-8859-15, de_BE ISO-8859-1, de_BE.UTF-8 UTF-8, de_BE@euro ISO-8859-15, de_CH ISO-8859-1, de_CH.UTF-8 UTF-8, de_DE ISO-8859-1, de_DE.UTF-8 UTF-8, de_DE@euro ISO-8859-15, de_LI.UTF-8 UTF-8, de_LU ISO-8859-1, de_LU.UTF-8 UTF-8, de_LU@euro ISO-8859-15, doi_IN UTF-8, dv_MV UTF-8, dz_BT UTF-8, el_CY ISO-8859-7, el_CY.UTF-8 UTF-8, el_GR ISO-8859-7, el_GR.UTF-8 UTF-8, en_AG UTF-8, en_AU ISO-8859-1, en_AU.UTF-8 UTF-8, en_BW ISO-8859-1, en_BW.UTF-8 UTF-8, en_CA ISO-8859-1, en_CA.UTF-8 UTF-8, en_DK ISO-8859-1, en_DK.ISO-8859-15 ISO-8859-15, en_DK.UTF-8 UTF-8, en_GB ISO-8859-1, en_GB.ISO-8859-15 ISO-8859-15, en_GB.UTF-8 UTF-8, en_HK ISO-8859-1, en_HK.UTF-8 UTF-8, en_IE ISO-8859-1, en_IE.UTF-8 UTF-8, en_IE@euro ISO-8859-15, en_IN UTF-8, en_NG UTF-8, en_NZ ISO-8859-1, en_NZ.UTF-8 UTF-8, en_PH ISO-8859-1, en_PH.UTF-8 UTF-8, en_SG ISO-8859-1, en_SG.UTF-8 UTF-8, en_US ISO-8859-1, en_US.ISO-8859-15 ISO-8859-15, en_US.UTF-8 UTF-8, en_ZA ISO-8859-1, en_ZA.UTF-8 UTF-8, en_ZM UTF-8, en_ZW ISO-8859-1, en_ZW.UTF-8 UTF-8, eo ISO-8859-3, eo.UTF-8 UTF-8, es_AR ISO-8859-1, es_AR.UTF-8 UTF-8, es_BO ISO-8859-1, es_BO.UTF-8 UTF-8, es_CL ISO-8859-1, es_CL.UTF-8 UTF-8, es_CO ISO-8859-1, es_CO.UTF-8 UTF-8, es_CR ISO-8859-1, es_CR.UTF-8 UTF-8, es_CU UTF-8, es_DO ISO-8859-1, es_DO.UTF-8 UTF-8, es_EC ISO-8859-1, es_EC.UTF-8 UTF-8, es_ES ISO-8859-1, es_ES.UTF-8 UTF-8, es_ES@euro ISO-8859-15, es_GT ISO-8859-1, es_GT.UTF-8 UTF-8, es_HN ISO-8859-1, es_HN.UTF-8 UTF-8, es_MX ISO-8859-1, es_MX.UTF-8 UTF-8, es_NI ISO-8859-1, es_NI.UTF-8 UTF-8, es_PA ISO-8859-1, es_PA.UTF-8 UTF-8, es_PE ISO-8859-1, es_PE.UTF-8 UTF-8, es_PR ISO-8859-1, es_PR.UTF-8 UTF-8, es_PY ISO-8859-1, es_PY.UTF-8 UTF-8, es_SV ISO-8859-1, es_SV.UTF-8 UTF-8, es_US ISO-8859-1, es_US.UTF-8 UTF-8, es_UY ISO-8859-1, es_UY.UTF-8 UTF-8, es_VE ISO-8859-1, es_VE.UTF-8 UTF-8, et_EE ISO-8859-1, et_EE.ISO-8859-15 ISO-8859-15, et_EE.UTF-8 UTF-8, eu_ES ISO-8859-1, eu_ES.UTF-8 UTF-8, eu_ES@euro ISO-8859-15, eu_FR ISO-8859-1, eu_FR.UTF-8 UTF-8, eu_FR@euro ISO-8859-15, fa_IR UTF-8, ff_SN UTF-8, fi_FI ISO-8859-1, fi_FI.UTF-8 UTF-8, fi_FI@euro ISO-8859-15, fil_PH UTF-8, fo_FO ISO-8859-1, fo_FO.UTF-8 UTF-8, fr_BE ISO-8859-1, fr_BE.UTF-8 UTF-8, fr_BE@euro ISO-8859-15, fr_CA ISO-8859-1, fr_CA.UTF-8 UTF-8, fr_CH ISO-8859-1, fr_CH.UTF-8 UTF-8, fr_FR ISO-8859-1, fr_FR.UTF-8 UTF-8, fr_FR@euro ISO-8859-15, fr_LU ISO-8859-1, fr_LU.UTF-8 UTF-8, fr_LU@euro ISO-8859-15, fur_IT UTF-8, fy_DE UTF-8, fy_NL UTF-8, ga_IE ISO-8859-1, ga_IE.UTF-8 UTF-8, ga_IE@euro ISO-8859-15, gd_GB ISO-8859-15, gd_GB.UTF-8 UTF-8, gez_ER UTF-8, gez_ER@abegede UTF-8, gez_ET UTF-8, gez_ET@abegede UTF-8, gl_ES ISO-8859-1, gl_ES.UTF-8 UTF-8, gl_ES@euro ISO-8859-15, gu_IN UTF-8, gv_GB ISO-8859-1, gv_GB.UTF-8 UTF-8, ha_NG UTF-8, hak_TW UTF-8, he_IL ISO-8859-8, he_IL.UTF-8 UTF-8, hi_IN UTF-8, hne_IN UTF-8, hr_HR ISO-8859-2, hr_HR.UTF-8 UTF-8, hsb_DE ISO-8859-2, hsb_DE.UTF-8 UTF-8, ht_HT UTF-8, hu_HU ISO-8859-2, hu_HU.UTF-8 UTF-8, hy_AM UTF-8, hy_AM.ARMSCII-8 ARMSCII-8, ia_FR UTF-8, id_ID ISO-8859-1, id_ID.UTF-8 UTF-8, ig_NG UTF-8, ik_CA UTF-8, is_IS ISO-8859-1, is_IS.UTF-8 UTF-8, it_CH ISO-8859-1, it_CH.UTF-8 UTF-8, it_IT ISO-8859-1, it_IT.UTF-8 UTF-8, it_IT@euro ISO-8859-15, iu_CA UTF-8, iw_IL ISO-8859-8, iw_IL.UTF-8 UTF-8, ja_JP.EUC-JP EUC-JP, ja_JP.UTF-8 UTF-8, ka_GE GEORGIAN-PS, ka_GE.UTF-8 UTF-8, kk_KZ PT154, kk_KZ RK1048, kk_KZ.UTF-8 UTF-8, kl_GL ISO-8859-1, kl_GL.UTF-8 UTF-8, km_KH UTF-8, kn_IN UTF-8, ko_KR.EUC-KR EUC-KR, ko_KR.UTF-8 UTF-8, kok_IN UTF-8, ks_IN UTF-8, ks_IN@devanagari UTF-8, ku_TR ISO-8859-9, ku_TR.UTF-8 UTF-8, kw_GB ISO-8859-1, kw_GB.UTF-8 UTF-8, ky_KG UTF-8, lb_LU UTF-8, lg_UG ISO-8859-10, lg_UG.UTF-8 UTF-8, li_BE UTF-8, li_NL UTF-8, lij_IT UTF-8, lo_LA UTF-8, lt_LT ISO-8859-13, lt_LT.UTF-8 UTF-8, lv_LV ISO-8859-13, lv_LV.UTF-8 UTF-8, lzh_TW UTF-8, mag_IN UTF-8, mai_IN UTF-8, mg_MG ISO-8859-15, mg_MG.UTF-8 UTF-8, mhr_RU UTF-8, mi_NZ ISO-8859-13, mi_NZ.UTF-8 UTF-8, mk_MK ISO-8859-5, mk_MK.UTF-8 UTF-8, ml_IN UTF-8, mn_MN UTF-8, mni_IN UTF-8, mr_IN UTF-8, ms_MY ISO-8859-1, ms_MY.UTF-8 UTF-8, mt_MT ISO-8859-3, mt_MT.UTF-8 UTF-8, my_MM UTF-8, nan_TW UTF-8, nan_TW@latin UTF-8, nb_NO ISO-8859-1, nb_NO.UTF-8 UTF-8, nds_DE UTF-8, nds_NL UTF-8, ne_NP UTF-8, nhn_MX UTF-8, niu_NU UTF-8, niu_NZ UTF-8, nl_AW UTF-8, nl_BE ISO-8859-1, nl_BE.UTF-8 UTF-8, nl_BE@euro ISO-8859-15, nl_NL ISO-8859-1, nl_NL.UTF-8 UTF-8, nl_NL@euro ISO-8859-15, nn_NO ISO-8859-1, nn_NO.UTF-8 UTF-8, nr_ZA UTF-8, nso_ZA UTF-8, oc_FR ISO-8859-1, oc_FR.UTF-8 UTF-8, om_ET UTF-8, om_KE ISO-8859-1, om_KE.UTF-8 UTF-8, or_IN UTF-8, os_RU UTF-8, pa_IN UTF-8, pa_PK UTF-8, pap_AN UTF-8, pap_AW UTF-8, pap_CW UTF-8, pl_PL ISO-8859-2, pl_PL.UTF-8 UTF-8, ps_AF UTF-8, pt_BR ISO-8859-1, pt_BR.UTF-8 UTF-8, pt_PT ISO-8859-1, pt_PT.UTF-8 UTF-8, pt_PT@euro ISO-8859-15, quz_PE UTF-8, ro_RO ISO-8859-2, ro_RO.UTF-8 UTF-8, ru_RU ISO-8859-5, ru_RU.CP1251 CP1251, ru_RU.KOI8-R KOI8-R, ru_RU.UTF-8 UTF-8, ru_UA KOI8-U, ru_UA.UTF-8 UTF-8, rw_RW UTF-8, sa_IN UTF-8, sat_IN UTF-8, sc_IT UTF-8, sd_IN UTF-8, sd_IN@devanagari UTF-8, se_NO UTF-8, shs_CA UTF-8, si_LK UTF-8, sid_ET UTF-8, sk_SK ISO-8859-2, sk_SK.UTF-8 UTF-8, sl_SI ISO-8859-2, sl_SI.UTF-8 UTF-8, so_DJ ISO-8859-1, so_DJ.UTF-8 UTF-8, so_ET UTF-8, so_KE ISO-8859-1, so_KE.UTF-8 UTF-8, so_SO ISO-8859-1, so_SO.UTF-8 UTF-8, sq_AL ISO-8859-1, sq_AL.UTF-8 UTF-8, sq_MK UTF-8, sr_ME UTF-8, sr_RS UTF-8, sr_RS@latin UTF-8, ss_ZA UTF-8, st_ZA ISO-8859-1, st_ZA.UTF-8 UTF-8, sv_FI ISO-8859-1, sv_FI.UTF-8 UTF-8, sv_FI@euro ISO-8859-15, sv_SE ISO-8859-1, sv_SE.ISO-8859-15 ISO-8859-15, sv_SE.UTF-8 UTF-8, sw_KE UTF-8, sw_TZ UTF-8, szl_PL UTF-8, ta_IN UTF-8, ta_LK UTF-8, te_IN UTF-8, tg_TJ KOI8-T, tg_TJ.UTF-8 UTF-8, th_TH TIS-620, th_TH.UTF-8 UTF-8, the_NP UTF-8, ti_ER UTF-8, ti_ET UTF-8, tig_ER UTF-8, tk_TM UTF-8, tl_PH ISO-8859-1, tl_PH.UTF-8 UTF-8, tn_ZA UTF-8, tr_CY ISO-8859-9, tr_CY.UTF-8 UTF-8, tr_TR ISO-8859-9, tr_TR.UTF-8 UTF-8, ts_ZA UTF-8, tt_RU UTF-8, tt_RU@iqtelif UTF-8, ug_CN UTF-8, uk_UA KOI8-U, uk_UA.UTF-8 UTF-8, unm_US UTF-8, ur_IN UTF-8, ur_PK UTF-8, uz_UZ ISO-8859-1, uz_UZ.UTF-8 UTF-8, uz_UZ@cyrillic UTF-8, ve_ZA UTF-8, vi_VN UTF-8, wa_BE ISO-8859-1, wa_BE.UTF-8 UTF-8, wa_BE@euro ISO-8859-15, wae_CH UTF-8, wal_ET UTF-8, wo_SN UTF-8, xh_ZA ISO-8859-1, xh_ZA.UTF-8 UTF-8, yi_US CP1255, yi_US.UTF-8 UTF-8, yo_NG UTF-8, yue_HK UTF-8, zh_CN GB2312, zh_CN.GB18030 GB18030, zh_CN.GBK GBK, zh_CN.UTF-8 UTF-8, zh_HK BIG5-HKSCS, zh_HK.UTF-8 UTF-8, zh_SG GB2312, zh_SG.GBK GBK, zh_SG.UTF-8 UTF-8, zh_TW BIG5, zh_TW.EUC-TW EUC-TW, zh_TW.UTF-8 UTF-8, zu_ZA ISO-8859-1, zu_ZA.UTF-8 UTF-8 -locales locales/locales_to_be_generated multiselect ${LOCALE_DEFAULT} UTF-8 +locales locales/locales_to_be_generated multiselect ${LOCALE_DEFAULT} UTF-8 # Default locale for the system environment: # Choices: None, C.UTF-8, en_GB.UTF-8 -locales locales/default_environment_locale select ${LOCALE_DEFAULT} +locales locales/default_environment_locale select ${LOCALE_DEFAULT} diff --git a/stage0/prerun.sh b/stage0/prerun.sh index d4dd0a1..44d40cc 100755 --- a/stage0/prerun.sh +++ b/stage0/prerun.sh @@ -1,5 +1,5 @@ #!/bin/bash -e if [ ! -d "${ROOTFS_DIR}" ] || [ "${USE_QCOW2}" = "1" ]; then - bootstrap ${RELEASE} "${ROOTFS_DIR}" http://raspbian.raspberrypi.org/raspbian/ + bootstrap ${RELEASE} "${ROOTFS_DIR}" http://raspbian.raspberrypi.org/raspbian/ fi diff --git a/stage1/01-sys-tweaks/00-run.sh b/stage1/01-sys-tweaks/00-run.sh index 9c380ec..83d4747 100755 --- a/stage1/01-sys-tweaks/00-run.sh +++ b/stage1/01-sys-tweaks/00-run.sh @@ -6,7 +6,7 @@ install -v -m 644 files/fstab "${ROOTFS_DIR}/etc/fstab" on_chroot << EOF if ! id -u ${FIRST_USER_NAME} >/dev/null 2>&1; then - adduser --disabled-password --gecos "" ${FIRST_USER_NAME} + adduser --disabled-password --gecos "" ${FIRST_USER_NAME} fi echo "${FIRST_USER_NAME}:${FIRST_USER_PASS}" | chpasswd echo "root:root" | chpasswd diff --git a/stage1/02-net-tweaks/00-run.sh b/stage1/02-net-tweaks/00-run.sh index 4943cab..f48e5c1 100755 --- a/stage1/02-net-tweaks/00-run.sh +++ b/stage1/02-net-tweaks/00-run.sh @@ -1,6 +1,6 @@ #!/bin/bash -e echo "${TARGET_HOSTNAME}" > "${ROOTFS_DIR}/etc/hostname" -echo "127.0.1.1 ${TARGET_HOSTNAME}" >> "${ROOTFS_DIR}/etc/hosts" +echo "127.0.1.1 ${TARGET_HOSTNAME}" >> "${ROOTFS_DIR}/etc/hosts" ln -sf /dev/null "${ROOTFS_DIR}/etc/systemd/network/99-default.link" diff --git a/stage1/prerun.sh b/stage1/prerun.sh index 9acd13c..64323b4 100755 --- a/stage1/prerun.sh +++ b/stage1/prerun.sh @@ -1,5 +1,5 @@ #!/bin/bash -e if [ ! -d "${ROOTFS_DIR}" ]; then - copy_previous + copy_previous fi diff --git a/stage2/01-sys-tweaks/00-debconf b/stage2/01-sys-tweaks/00-debconf index c13e3b1..b98a536 100644 --- a/stage2/01-sys-tweaks/00-debconf +++ b/stage2/01-sys-tweaks/00-debconf @@ -1,26 +1,26 @@ # Encoding to use on the console: # Choices: ARMSCII-8, CP1251, CP1255, CP1256, GEORGIAN-ACADEMY, GEORGIAN-PS, IBM1133, ISIRI-3342, ISO-8859-1, ISO-8859-10, ISO-8859-11, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, KOI8-R, KOI8-U, TIS-620, UTF-8, VISCII -console-setup console-setup/charmap47 select UTF-8 +console-setup console-setup/charmap47 select UTF-8 # Character set to support: # Choices: . Arabic, # Armenian, # Cyrillic - KOI8-R and KOI8-U, # Cyrillic - non-Slavic languages, # Cyrillic - Slavic languages (also Bosnian and Serbian Latin), . Ethiopic, # Georgian, # Greek, # Hebrew, # Lao, # Latin1 and Latin5 - western Europe and Turkic languages, # Latin2 - central Europe and Romanian, # Latin3 and Latin8 - Chichewa; Esperanto; Irish; Maltese and Welsh, # Latin7 - Lithuanian; Latvian; Maori and Marshallese, . Latin - Vietnamese, # Thai, . Combined - Latin; Slavic Cyrillic; Hebrew; basic Arabic, . Combined - Latin; Slavic Cyrillic; Greek, . Combined - Latin; Slavic and non-Slavic Cyrillic, Guess optimal character set -console-setup console-setup/codeset47 select Guess optimal character set +console-setup console-setup/codeset47 select Guess optimal character set # Font for the console: # Choices: Fixed, Goha, GohaClassic, Terminus, TerminusBold, TerminusBoldVGA, VGA, Do not change the boot/kernel font, Let the system select a suitable font -console-setup console-setup/fontface47 select Do not change the boot/kernel font +console-setup console-setup/fontface47 select Do not change the boot/kernel font # Key to function as AltGr: # Choices: The default for the keyboard layout, No AltGr key, Right Alt (AltGr), Right Control, Right Logo key, Menu key, Left Alt, Left Logo key, Keypad Enter key, Both Logo keys, Both Alt keys -keyboard-configuration keyboard-configuration/altgr select The default for the keyboard layout +keyboard-configuration keyboard-configuration/altgr select The default for the keyboard layout # Keyboard model: # Choices: A4Tech KB-21, A4Tech KBS-8, A4Tech Wireless Desktop RFKB-23, Acer AirKey V, Acer C300, Acer Ferrari 4000, Acer Laptop, Advance Scorpius KI, Amiga, Apple, Apple Aluminium Keyboard (ANSI), Apple Aluminium Keyboard (ISO), Apple Aluminium Keyboard (JIS), Apple Laptop, Asus Laptop, Atari TT, Azona RF2300 wireless Internet Keyboard, BTC 5090, BTC 5113RF Multimedia, BTC 5126T, BTC 6301URF, BTC 9000, BTC 9000A, BTC 9001AH, BTC 9019U, BTC 9116U Mini Wireless Internet and Gaming, BenQ X-Touch, BenQ X-Touch 730, BenQ X-Touch 800, Brother Internet Keyboard, Cherry B.UNLIMITED, Cherry Blue Line CyBo@rd, Cherry Blue Line CyBo@rd (alternate option), Cherry CyBo@rd USB-Hub, Cherry CyMotion Expert, Cherry CyMotion Master Linux, Cherry CyMotion Master XPress, Chicony Internet Keyboard, Chicony KB-9885, Chicony KU-0108, Chicony KU-0420, Classmate PC, Compaq Easy Access Keyboard, Compaq Internet Keyboard (13 keys), Compaq Internet Keyboard (18 keys), Compaq Internet Keyboard (7 keys), Compaq iPaq Keyboard, Creative Desktop Wireless 7000, DTK2000, Dell, Dell 101-key PC, Dell Laptop/notebook Inspiron 6xxx/8xxx, Dell Laptop/notebook Precision M series, Dell Latitude series laptop, Dell Precision M65, Dell SK-8125, Dell SK-8135, Dell USB Multimedia Keyboard, Dexxa Wireless Desktop Keyboard, Diamond 9801 / 9802 series, Ennyah DKB-1008, Everex STEPnote, FL90, Fujitsu-Siemens Computers AMILO laptop, Generic 101-key PC, Generic 102-key (Intl) PC, Generic 104-key PC, Generic 105-key (Intl) PC, Genius Comfy KB-12e, Genius Comfy KB-16M / Genius MM Keyboard KWD-910, Genius Comfy KB-21e-Scroll, Genius KB-19e NB, Genius KKB-2050HS, Gyration, HTC Dream, Happy Hacking Keyboard, Happy Hacking Keyboard for Mac, Hewlett-Packard Internet Keyboard, Hewlett-Packard Mini 110 Notebook, Hewlett-Packard Omnibook 500 FA, Hewlett-Packard Omnibook 5xx, Hewlett-Packard Omnibook 6000/6100, Hewlett-Packard Omnibook XE3 GC, Hewlett-Packard Omnibook XE3 GF, Hewlett-Packard Omnibook XT1000, Hewlett-Packard Pavilion ZT11xx, Hewlett-Packard Pavilion dv5, Hewlett-Packard SK-250x Multimedia Keyboard, Hewlett-Packard nx9020, Honeywell Euroboard, Htc Dream phone, IBM Rapid Access, IBM Rapid Access II, IBM Space Saver, IBM ThinkPad 560Z/600/600E/A22E, IBM ThinkPad R60/T60/R61/T61, IBM ThinkPad Z60m/Z60t/Z61m/Z61t, Keytronic FlexPro, Kinesis, Laptop/notebook Compaq (eg. Armada) Laptop Keyboard, Laptop/notebook Compaq (eg. Presario) Internet Keyboard, Laptop/notebook eMachines m68xx, Logitech Access Keyboard, Logitech Cordless Desktop, Logitech Cordless Desktop (alternate option), Logitech Cordless Desktop EX110, Logitech Cordless Desktop LX-300, Logitech Cordless Desktop Navigator, Logitech Cordless Desktop Optical, Logitech Cordless Desktop Pro (alternate option 2), Logitech Cordless Desktop iTouch, Logitech Cordless Freedom/Desktop Navigator, Logitech G15 extra keys via G15daemon, Logitech Generic Keyboard, Logitech Internet 350 Keyboard, Logitech Internet Keyboard, Logitech Internet Navigator Keyboard, Logitech Media Elite Keyboard, Logitech Ultra-X Cordless Media Desktop Keyboard, Logitech Ultra-X Keyboard, Logitech diNovo Edge Keyboard, Logitech diNovo Keyboard, Logitech iTouch, Logitech iTouch Cordless Keyboard (model Y-RB6), Logitech iTouch Internet Navigator Keyboard SE, Logitech iTouch Internet Navigator Keyboard SE (USB), MacBook/MacBook Pro, MacBook/MacBook Pro (Intl), Macintosh, Macintosh Old, Memorex MX1998, Memorex MX2500 EZ-Access Keyboard, Memorex MX2750, Microsoft Comfort Curve Keyboard 2000, Microsoft Internet Keyboard, Microsoft Internet Keyboard Pro\, Swedish, Microsoft Natural, Microsoft Natural Keyboard Elite, Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro, Microsoft Natural Keyboard Pro OEM, Microsoft Natural Keyboard Pro USB / Microsoft Internet Keyboard Pro, Microsoft Natural Wireless Ergonomic Keyboard 4000, Microsoft Natural Wireless Ergonomic Keyboard 7000, Microsoft Office Keyboard, Microsoft Wireless Multimedia Keyboard 1.0A, Northgate OmniKey 101, OLPC, Ortek MCK-800 MM/Internet keyboard, PC-98xx Series, Propeller Voyager (KTEZ-1000), QTronix Scorpius 98N+, SILVERCREST Multimedia Wireless Keyboard, SK-1300, SK-2500, SK-6200, SK-7100, SVEN Ergonomic 2500, SVEN Slim 303, Samsung SDM 4500P, Samsung SDM 4510P, Sanwa Supply SKB-KG3, Sun Type 4, Sun Type 5, Sun Type 6 (Japanese layout), Sun Type 6 USB (Japanese layout), Sun Type 6 USB (Unix layout), Sun Type 6/7 USB, Sun Type 6/7 USB (European layout), Sun Type 7 USB, Sun Type 7 USB (European layout), Sun Type 7 USB (Japanese layout) / Japanese 106-key, Sun Type 7 USB (Unix layout), Super Power Multimedia Keyboard, Symplon PaceBook (tablet PC), Targa Visionary 811, Toshiba Satellite S3000, Trust Direct Access Keyboard, Trust Slimline, Trust Wireless Keyboard Classic, TypeMatrix EZ-Reach 2020, TypeMatrix EZ-Reach 2030 PS2, TypeMatrix EZ-Reach 2030 USB, TypeMatrix EZ-Reach 2030 USB (102/105:EU mode), TypeMatrix EZ-Reach 2030 USB (106:JP mode), Unitek KB-1925, ViewSonic KU-306 Internet Keyboard, Winbook Model XP5, Yahoo! Internet Keyboard -keyboard-configuration keyboard-configuration/model select Generic 105-key (Intl) PC +keyboard-configuration keyboard-configuration/model select Generic 105-key (Intl) PC # Keymap to use: # Choices: American English, Albanian, Arabic, Asturian, Bangladesh, Belarusian, Bengali, Belgian, Bosnian, Brazilian, British English, Bulgarian, Bulgarian (phonetic layout), Burmese, Canadian French, Canadian Multilingual, Catalan, Chinese, Croatian, Czech, Danish, Dutch, Dvorak, Dzongkha, Esperanto, Estonian, Ethiopian, Finnish, French, Georgian, German, Greek, Gujarati, Gurmukhi, Hebrew, Hindi, Hungarian, Icelandic, Irish, Italian, Japanese, Kannada, Kazakh, Khmer, Kirghiz, Korean, Kurdish (F layout), Kurdish (Q layout), Lao, Latin American, Latvian, Lithuanian, Macedonian, Malayalam, Nepali, Northern Sami, Norwegian, Persian, Philippines, Polish, Portuguese, Punjabi, Romanian, Russian, Serbian (Cyrillic), Sindhi, Sinhala, Slovak, Slovenian, Spanish, Swedish, Swiss French, Swiss German, Tajik, Tamil, Telugu, Thai, Tibetan, Turkish (F layout), Turkish (Q layout), Ukrainian, Uyghur, Vietnamese -keyboard-configuration keyboard-configuration/xkb-keymap select ${KEYBOARD_KEYMAP} +keyboard-configuration keyboard-configuration/xkb-keymap select ${KEYBOARD_KEYMAP} # Compose key: # Choices: No compose key, Right Alt (AltGr), Right Control, Right Logo key, Menu key, Left Logo key, Caps Lock -keyboard-configuration keyboard-configuration/compose select No compose key +keyboard-configuration keyboard-configuration/compose select No compose key # Use Control+Alt+Backspace to terminate the X server? -keyboard-configuration keyboard-configuration/ctrl_alt_bksp boolean true +keyboard-configuration keyboard-configuration/ctrl_alt_bksp boolean true # Keyboard layout: # Choices: English (UK), English (UK) - English (UK\, Colemak), English (UK) - English (UK\, Dvorak with UK punctuation), English (UK) - English (UK\, Dvorak), English (UK) - English (UK\, Macintosh international), English (UK) - English (UK\, Macintosh), English (UK) - English (UK\, extended WinKeys), English (UK) - English (UK\, international with dead keys), Other -keyboard-configuration keyboard-configuration/variant select ${KEYBOARD_LAYOUT} +keyboard-configuration keyboard-configuration/variant select ${KEYBOARD_LAYOUT} diff --git a/stage2/01-sys-tweaks/00-patches/05-path.diff b/stage2/01-sys-tweaks/00-patches/05-path.diff index 25b80a1..e6ba04d 100644 --- a/stage2/01-sys-tweaks/00-patches/05-path.diff +++ b/stage2/01-sys-tweaks/00-patches/05-path.diff @@ -2,12 +2,12 @@ Index: jessie-stage2/rootfs/etc/login.defs =================================================================== --- jessie-stage2.orig/rootfs/etc/login.defs +++ jessie-stage2/rootfs/etc/login.defs -@@ -100,7 +100,7 @@ HUSHLOGIN_FILE .hushlogin +@@ -100,7 +100,7 @@ HUSHLOGIN_FILE .hushlogin # # (they are minimal, add the rest in the shell startup files) - ENV_SUPATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin --ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games -+ENV_PATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games + ENV_SUPATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +-ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games ++ENV_PATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games # # Terminal permissions diff --git a/stage2/01-sys-tweaks/01-run.sh b/stage2/01-sys-tweaks/01-run.sh index c1836f9..03ba9e8 100755 --- a/stage2/01-sys-tweaks/01-run.sh +++ b/stage2/01-sys-tweaks/01-run.sh @@ -1,25 +1,25 @@ #!/bin/bash -e -install -m 755 files/resize2fs_once "${ROOTFS_DIR}/etc/init.d/" +install -m 755 files/resize2fs_once "${ROOTFS_DIR}/etc/init.d/" -install -d "${ROOTFS_DIR}/etc/systemd/system/rc-local.service.d" -install -m 644 files/ttyoutput.conf "${ROOTFS_DIR}/etc/systemd/system/rc-local.service.d/" +install -d "${ROOTFS_DIR}/etc/systemd/system/rc-local.service.d" +install -m 644 files/ttyoutput.conf "${ROOTFS_DIR}/etc/systemd/system/rc-local.service.d/" -install -m 644 files/50raspi "${ROOTFS_DIR}/etc/apt/apt.conf.d/" +install -m 644 files/50raspi "${ROOTFS_DIR}/etc/apt/apt.conf.d/" -install -m 644 files/console-setup "${ROOTFS_DIR}/etc/default/" +install -m 644 files/console-setup "${ROOTFS_DIR}/etc/default/" -install -m 755 files/rc.local "${ROOTFS_DIR}/etc/" +install -m 755 files/rc.local "${ROOTFS_DIR}/etc/" if [ -n "${PUBKEY_SSH_FIRST_USER}" ]; then - install -v -m 0700 -o 1000 -g 1000 -d "${ROOTFS_DIR}"/home/"${FIRST_USER_NAME}"/.ssh - echo "${PUBKEY_SSH_FIRST_USER}" >"${ROOTFS_DIR}"/home/"${FIRST_USER_NAME}"/.ssh/authorized_keys - chown 1000:1000 "${ROOTFS_DIR}"/home/"${FIRST_USER_NAME}"/.ssh/authorized_keys - chmod 0600 "${ROOTFS_DIR}"/home/"${FIRST_USER_NAME}"/.ssh/authorized_keys + install -v -m 0700 -o 1000 -g 1000 -d "${ROOTFS_DIR}"/home/"${FIRST_USER_NAME}"/.ssh + echo "${PUBKEY_SSH_FIRST_USER}" >"${ROOTFS_DIR}"/home/"${FIRST_USER_NAME}"/.ssh/authorized_keys + chown 1000:1000 "${ROOTFS_DIR}"/home/"${FIRST_USER_NAME}"/.ssh/authorized_keys + chmod 0600 "${ROOTFS_DIR}"/home/"${FIRST_USER_NAME}"/.ssh/authorized_keys fi if [ "${PUBKEY_ONLY_SSH}" = "1" ]; then - sed -i -Ee 's/^#?[[:blank:]]*PubkeyAuthentication[[:blank:]]*no[[:blank:]]*$/PubkeyAuthentication yes/ + sed -i -Ee 's/^#?[[:blank:]]*PubkeyAuthentication[[:blank:]]*no[[:blank:]]*$/PubkeyAuthentication yes/ s/^#?[[:blank:]]*PasswordAuthentication[[:blank:]]*yes[[:blank:]]*$/PasswordAuthentication no/' "${ROOTFS_DIR}"/etc/ssh/sshd_config fi @@ -28,29 +28,29 @@ systemctl disable hwclock.sh systemctl disable nfs-common systemctl disable rpcbind if [ "${ENABLE_SSH}" == "1" ]; then - systemctl enable ssh + systemctl enable ssh else - systemctl disable ssh + systemctl disable ssh fi systemctl enable regenerate_ssh_host_keys EOF if [ "${USE_QEMU}" = "1" ]; then - echo "enter QEMU mode" - install -m 644 files/90-qemu.rules "${ROOTFS_DIR}/etc/udev/rules.d/" - on_chroot << EOF + echo "enter QEMU mode" + install -m 644 files/90-qemu.rules "${ROOTFS_DIR}/etc/udev/rules.d/" + on_chroot << EOF systemctl disable resize2fs_once EOF - echo "leaving QEMU mode" + echo "leaving QEMU mode" else - on_chroot << EOF + on_chroot << EOF systemctl enable resize2fs_once EOF fi on_chroot <> "${ROOTFS_DIR}/etc/wpa_supplicant/wpa_supplicant.conf" + echo "country=${WPA_COUNTRY}" >> "${ROOTFS_DIR}/etc/wpa_supplicant/wpa_supplicant.conf" fi if [ -v WPA_ESSID ] && [ -v WPA_PASSWORD ]; then @@ -19,8 +19,8 @@ elif [ -v WPA_ESSID ]; then cat >> "${ROOTFS_DIR}/etc/wpa_supplicant/wpa_supplicant.conf" << EOL network={ - ssid="${WPA_ESSID}" - key_mgmt=NONE + ssid="${WPA_ESSID}" + key_mgmt=NONE } EOL fi diff --git a/stage2/04-install-sks-hello/01-run.sh b/stage2/04-install-sks-hello/01-run.sh index 594387f..a4b50fc 100755 --- a/stage2/04-install-sks-hello/01-run.sh +++ b/stage2/04-install-sks-hello/01-run.sh @@ -12,11 +12,11 @@ install -m 777 files/run-sks-hello.sh "${ROOTFS_DIR}/home/sks/hello/" install -m 644 files/sks-hello.service "${ROOTFS_DIR}/etc/systemd/system/" on_chroot << EOF -sudo chmod +x /home/sks/hello/run-sks-hello.sh + sudo chmod +x /home/sks/hello/run-sks-hello.sh -cd /home/sks/hello -sudo python3 -m pip install -r requirements.txt + cd /home/sks/hello + sudo python3 -m pip install -r requirements.txt -sudo systemctl daemon-reload -sudo systemctl enable sks-hello.service + sudo systemctl daemon-reload + sudo systemctl enable sks-hello.service EOF diff --git a/stage2/EXPORT_IMAGE b/stage2/EXPORT_IMAGE index aa8f936..720b2f7 100644 --- a/stage2/EXPORT_IMAGE +++ b/stage2/EXPORT_IMAGE @@ -1,4 +1,4 @@ IMG_SUFFIX="-lite" if [ "${USE_QEMU}" = "1" ]; then - export IMG_SUFFIX="${IMG_SUFFIX}-qemu" + export IMG_SUFFIX="${IMG_SUFFIX}-qemu" fi diff --git a/stage2/prerun.sh b/stage2/prerun.sh index 9acd13c..64323b4 100755 --- a/stage2/prerun.sh +++ b/stage2/prerun.sh @@ -1,5 +1,5 @@ #!/bin/bash -e if [ ! -d "${ROOTFS_DIR}" ]; then - copy_previous + copy_previous fi diff --git a/stage3/00-install-packages/00-debconf b/stage3/00-install-packages/00-debconf index 7dbd12e..5266723 100644 --- a/stage3/00-install-packages/00-debconf +++ b/stage3/00-install-packages/00-debconf @@ -1,2 +1,2 @@ # Adobe Flash Player. Copyright 1996-2015. Adobe Systems Incorporated. All Rights Reserved. -rpi-chromium-mods rpi-chromium-mods/adobe note +rpi-chromium-mods rpi-chromium-mods/adobe note diff --git a/stage3/prerun.sh b/stage3/prerun.sh index 9acd13c..64323b4 100755 --- a/stage3/prerun.sh +++ b/stage3/prerun.sh @@ -1,5 +1,5 @@ #!/bin/bash -e if [ ! -d "${ROOTFS_DIR}" ]; then - copy_previous + copy_previous fi diff --git a/stage4/01-console-autologin/00-run.sh b/stage4/01-console-autologin/00-run.sh index 665dcdb..cfb22bd 100755 --- a/stage4/01-console-autologin/00-run.sh +++ b/stage4/01-console-autologin/00-run.sh @@ -1,5 +1,5 @@ #!/bin/bash -e on_chroot << EOF - SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_boot_behaviour B4 + SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_boot_behaviour B4 EOF diff --git a/stage4/03-bookshelf/00-run.sh b/stage4/03-bookshelf/00-run.sh index 5bd9885..1b9da6a 100755 --- a/stage4/03-bookshelf/00-run.sh +++ b/stage4/03-bookshelf/00-run.sh @@ -5,8 +5,8 @@ GUIDE_URL="$(curl -s "$BOOKSHELF_URL" | awk -F '[<>]' "/Raspberry Pi Begi OUTPUT="$(basename "$GUIDE_URL" | cut -f1 -d'?')" if [ ! -f "files/$OUTPUT" ]; then - rm files/*.pdf -f - curl -s "$GUIDE_URL" -o "files/$OUTPUT" + rm files/*.pdf -f + curl -s "$GUIDE_URL" -o "files/$OUTPUT" fi file "files/$OUTPUT" | grep -q "PDF document" diff --git a/stage4/04-enable-xcompmgr/00-run.sh b/stage4/04-enable-xcompmgr/00-run.sh index ad6298d..f0ed74a 100755 --- a/stage4/04-enable-xcompmgr/00-run.sh +++ b/stage4/04-enable-xcompmgr/00-run.sh @@ -1,5 +1,5 @@ #!/bin/bash -e on_chroot << EOF - raspi-config nonint do_xcompmgr 0 + raspi-config nonint do_xcompmgr 0 EOF diff --git a/stage4/EXPORT_IMAGE b/stage4/EXPORT_IMAGE index 79ec11a..16aad24 100644 --- a/stage4/EXPORT_IMAGE +++ b/stage4/EXPORT_IMAGE @@ -1,4 +1,4 @@ IMG_SUFFIX="" if [ "${USE_QEMU}" = "1" ]; then - export IMG_SUFFIX="${IMG_SUFFIX}-qemu" + export IMG_SUFFIX="${IMG_SUFFIX}-qemu" fi diff --git a/stage4/prerun.sh b/stage4/prerun.sh index 9acd13c..64323b4 100755 --- a/stage4/prerun.sh +++ b/stage4/prerun.sh @@ -1,5 +1,5 @@ #!/bin/bash -e if [ ! -d "${ROOTFS_DIR}" ]; then - copy_previous + copy_previous fi diff --git a/stage5/EXPORT_IMAGE b/stage5/EXPORT_IMAGE index a81a844..f5d782e 100644 --- a/stage5/EXPORT_IMAGE +++ b/stage5/EXPORT_IMAGE @@ -1,4 +1,4 @@ IMG_SUFFIX="-full" if [ "${USE_QEMU}" = "1" ]; then - export IMG_SUFFIX="${IMG_SUFFIX}-qemu" + export IMG_SUFFIX="${IMG_SUFFIX}-qemu" fi diff --git a/stage5/prerun.sh b/stage5/prerun.sh index 9acd13c..64323b4 100755 --- a/stage5/prerun.sh +++ b/stage5/prerun.sh @@ -1,5 +1,5 @@ #!/bin/bash -e if [ ! -d "${ROOTFS_DIR}" ]; then - copy_previous + copy_previous fi