From 612c1a73f1cb2184639163d0e37e303b70f5f7bc Mon Sep 17 00:00:00 2001 From: Teguh Sobirin Date: Sat, 16 Apr 2016 21:02:48 +0700 Subject: [PATCH 1/4] Add missing /dev/pts Missing /dev/pts causing "Can not write log, openpty() failed (/dev/pts not mounted?)" --- scripts/common | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/common b/scripts/common index 8c0e914..814f37f 100644 --- a/scripts/common +++ b/scripts/common @@ -51,6 +51,10 @@ on_chroot() { 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 From aca321fd700deaa0ef36b03ead65661bd654f61c Mon Sep 17 00:00:00 2001 From: Serge Schneider Date: Wed, 4 May 2016 15:51:41 +0100 Subject: [PATCH 2/4] Various fixes --- .gitignore | 3 +++ build.sh | 30 +++++++++++++++++++++--------- scripts/common | 24 ++++++++++++++++++++++-- 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 9f52a0f..ec91fd6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ deploy/* work/* config +SKIP +.pc +*-pc diff --git a/build.sh b/build.sh index e3f7a6e..11988a2 100755 --- a/build.sh +++ b/build.sh @@ -77,10 +77,14 @@ EOF run_stage(){ log "Begin ${STAGE_DIR}" + STAGE=$(basename ${STAGE_DIR}) pushd ${STAGE_DIR} > /dev/null unmount ${WORK_DIR}/${STAGE} STAGE_WORK_DIR=${WORK_DIR}/${STAGE} ROOTFS_DIR=${STAGE_WORK_DIR}/rootfs + if [ -f ${STAGE_DIR}/EXPORT_IMAGE ]; then + EXPORT_DIRS="${EXPORT_DIRS} ${STAGE_DIR}" + fi if [ ! -f SKIP ]; then if [ "${CLEAN}" = "1" ]; then if [ -d ${ROOTFS_DIR} ]; then @@ -93,7 +97,8 @@ run_stage(){ log "End ${STAGE_DIR}/prerun.sh" fi for SUB_STAGE_DIR in ${STAGE_DIR}/*; do - if [ -d ${SUB_STAGE_DIR} ]; then + if [ -d ${SUB_STAGE_DIR} ] && + [ ! -f ${SUB_STAGE_DIR}/SKIP ]; then run_sub_stage fi done @@ -125,6 +130,7 @@ export IMG_DATE=${IMG_DATE:-"$(date -u +%Y-%m-%d)"} export BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" export SCRIPT_DIR="${BASE_DIR}/scripts" export WORK_DIR="${BASE_DIR}/work/${IMG_DATE}-${IMG_NAME}" +export DEPLOY_DIR="${BASE_DIR}/deploy" export LOG_FILE="${WORK_DIR}/build.log" export CLEAN @@ -132,11 +138,15 @@ export IMG_NAME export APT_PROXY export STAGE -export PREV_STAGE export STAGE_DIR +export STAGE_WORK_DIR +export PREV_STAGE export PREV_STAGE_DIR export ROOTFS_DIR export PREV_ROOTFS_DIR +export IMG_SUFFIX +export EXPORT_DIR +export EXPORT_ROOTFS_DIR export QUILT_PATCHES export QUILT_NO_DIFF_INDEX=1 @@ -144,18 +154,20 @@ export QUILT_NO_DIFF_TIMESTAMPS=1 export QUILT_REFRESH_ARGS="-p ab" source ${SCRIPT_DIR}/common -export -f log -export -f bootstrap -export -f unmount -export -f on_chroot -export -f copy_previous -export -f update_issue mkdir -p ${WORK_DIR} log "Begin ${BASE_DIR}" for STAGE_DIR in ${BASE_DIR}/stage*; do - STAGE=$(basename ${STAGE_DIR}) + run_stage +done + +STAGE_DIR=${BASE_DIR}/export-image + +CLEAN=1 +for EXPORT_DIR in ${EXPORT_DIRS}; do + IMG_SUFFIX=$(cat ${EXPORT_DIR}/EXPORT_IMAGE) + EXPORT_ROOTFS_DIR=${WORK_DIR}/$(basename ${EXPORT_DIR})/rootfs run_stage done diff --git a/scripts/common b/scripts/common index 814f37f..e2969ad 100644 --- a/scripts/common +++ b/scripts/common @@ -1,6 +1,7 @@ log (){ date +"[%T] $@" | tee -a ${LOG_FILE} } +export -f log bootstrap(){ ARCH=$(dpkg --print-architecture) @@ -18,6 +19,7 @@ bootstrap(){ --no-check-gpg \ $1 $2 $3 } +export -f bootstrap copy_previous(){ if [ ! -d ${PREV_ROOTFS_DIR} ]; then @@ -27,6 +29,7 @@ copy_previous(){ mkdir -p ${ROOTFS_DIR} rsync -aHAX ${PREV_ROOTFS_DIR}/ ${ROOTFS_DIR}/ } +export -f copy_previous unmount(){ if [ -z "$1" ]; then @@ -38,10 +41,24 @@ unmount(){ while mount | grep -q $DIR; do LOCS=`mount | grep $DIR | cut -f 3 -d ' ' | sort -r` for loc in $LOCS; do - sudo umount $loc + umount $loc done done } +export -f unmount + +unmount_image(){ + sync + sleep 1 + unmount $(dirname ${1}) + LOOP_DEV=$(losetup -j ${1} | cut -f1 -d':') + if [ -n "${LOOP_DEV}" ]; then + sleep 1 + kpartx -ds ${LOOP_DEV} + losetup -d ${LOOP_DEV} + fi +} +export -f unmount_image on_chroot() { if ! mount | grep -q `realpath ${ROOTFS_DIR}/proc`; then @@ -62,7 +79,10 @@ on_chroot() { chroot ${ROOTFS_DIR}/ "$@" } +export -f on_chroot update_issue() { - echo -e "Raspberry Pi reference ${DATE}\nGenerated using Pi-gen, https://github.com/RPi-Distro/Pi-gen, ${1}" > ${ROOTFS_DIR}/etc/rpi-issue + GIT_HASH=$(git rev-parse HEAD) + echo -e "Raspberry Pi reference ${DATE}\nGenerated using pi-gen, https://github.com/RPi-Distro/pi-gen, ${GIT_HASH}, ${1}" > ${ROOTFS_DIR}/etc/rpi-issue } +export -f update_issue From b61c63db8f86a9a75ffd42bdb869030d94612059 Mon Sep 17 00:00:00 2001 From: Serge Schneider Date: Thu, 5 May 2016 14:55:53 +0100 Subject: [PATCH 3/4] common: Fix issue date --- scripts/common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/common b/scripts/common index e2969ad..a9d722d 100644 --- a/scripts/common +++ b/scripts/common @@ -83,6 +83,6 @@ export -f on_chroot update_issue() { GIT_HASH=$(git rev-parse HEAD) - echo -e "Raspberry Pi reference ${DATE}\nGenerated using pi-gen, https://github.com/RPi-Distro/pi-gen, ${GIT_HASH}, ${1}" > ${ROOTFS_DIR}/etc/rpi-issue + echo -e "Raspberry Pi reference ${IMG_DATE}\nGenerated using pi-gen, https://github.com/RPi-Distro/pi-gen, ${GIT_HASH}, ${1}" > ${ROOTFS_DIR}/etc/rpi-issue } export -f update_issue From de878cc21718bade5d7dbd19d8cdfebc0176c155 Mon Sep 17 00:00:00 2001 From: Serge Schneider Date: Thu, 5 May 2016 16:55:35 +0100 Subject: [PATCH 4/4] build.sh: fix patches --- build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 11988a2..9a889f2 100755 --- a/build.sh +++ b/build.sh @@ -43,11 +43,12 @@ EOF fi QUILT_PATCHES=${SUB_STAGE_DIR}/${i}-patches mkdir -p ${i}-pc - ln -sf .pc ${i}-pc + ln -sf ${i}-pc .pc if [ -e ${SUB_STAGE_DIR}/${i}-patches/EDIT ]; then echo "Dropping into bash to edit patches..." bash fi + quilt upgrade RC=0 quilt push -a || RC=$? case "$RC" in