From efc5a8fb5f7adacba422e47bc4ebe3276be57f69 2017-01-28 20:08:04 From: drtyhlpr Date: 2017-01-28 20:08:04 Subject: [PATCH] Merge pull request #72 from denismosolov/image-name Add BASEDIR and IMAGE_NAME --- diff --git a/README.md b/README.md index ac4cbde..f25b11f 100644 --- a/README.md +++ b/README.md @@ -336,6 +336,15 @@ Set cipher specification string. `aes-xts*` ciphers are strongly recommended. ##### `CRYPTFS_XTSKEYSIZE`=512 Sets key size in bits. The argument has to be a multiple of 8. +--- + +#### Build settings: +##### `BASEDIR`=$(pwd)/images/${RELEASE} +Set a path to a working directory used by the script to generate an image. + +##### `IMAGE_NAME`=${BASEDIR}/${DATE}-rpi${RPI_MODEL}-${RELEASE} +Set a filename for the output file(s). Note: the script will create $IMAGE_NAME.img if `ENABLE_SPLITFS`=false or $IMAGE_NAME-frmw.img and $IMAGE_NAME-root.img if `ENABLE_SPLITFS`=true. + ## Understanding the script The functions of this script that are required for the different stages of the bootstrapping are split up into single files located inside the `bootstrap.d` directory. During the bootstrapping every script in this directory gets executed in lexicographical order: diff --git a/rpi23-gen-image.sh b/rpi23-gen-image.sh index 655e50a..f816a20 100755 --- a/rpi23-gen-image.sh +++ b/rpi23-gen-image.sh @@ -66,8 +66,11 @@ FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git} UBOOT_URL=${UBOOT_URL:=git://git.denx.de/u-boot.git} # Build directories -BASEDIR="$(pwd)/images/${RELEASE}" +BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}} BUILDDIR="${BASEDIR}/build" +# Prepare date string for default image file name +DATE="$(date +%Y-%m-%d)" +IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-rpi${RPI_MODEL}-${RELEASE}} # Chroot directories R="${BUILDDIR}/chroot" @@ -524,42 +527,39 @@ ROOT_SECTORS=$(expr $(expr ${CHROOT_SIZE} + ${CHROOT_SIZE} \/ 100 \* 25) \* 1024 # Calculate required image size in 512 Byte sectors IMAGE_SECTORS=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS}) -# Prepare date string for image file name -DATE="$(date +%Y-%m-%d)" - # Prepare image file if [ "$ENABLE_SPLITFS" = true ] ; then - dd if=/dev/zero of="$BASEDIR/${DATE}-rpi${RPI_MODEL}-${RELEASE}-frmw.img" bs=512 count=${TABLE_SECTORS} - dd if=/dev/zero of="$BASEDIR/${DATE}-rpi${RPI_MODEL}-${RELEASE}-frmw.img" bs=512 count=0 seek=${FRMW_SECTORS} - dd if=/dev/zero of="$BASEDIR/${DATE}-rpi${RPI_MODEL}-${RELEASE}-root.img" bs=512 count=${TABLE_SECTORS} - dd if=/dev/zero of="$BASEDIR/${DATE}-rpi${RPI_MODEL}-${RELEASE}-root.img" bs=512 count=0 seek=${ROOT_SECTORS} + dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=${TABLE_SECTORS} + dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek=${FRMW_SECTORS} + dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=${TABLE_SECTORS} + dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek=${ROOT_SECTORS} # Write firmware/boot partition tables - sfdisk -q -L -uS -f "$BASEDIR/${DATE}-rpi${RPI_MODEL}-${RELEASE}-frmw.img" 2> /dev/null < /dev/null < /dev/null < /dev/null < /dev/null < /dev/null <