From 9cc6bc7aa1edcbadca85c135ecf5261b9644b1b5 2017-01-28 10:49:26 From: Denis Mosolov Date: 2017-01-28 10:49:26 Subject: [PATCH] Add IMAGE_NAME --- diff --git a/README.md b/README.md index 916d1a1..89a8965 100644 --- a/README.md +++ b/README.md @@ -337,7 +337,10 @@ Sets key size in bits. The argument has to be a multiple of 8. #### Build settings: ##### `BASEDIR`=$(pwd)/images/${RELEASE} -Path to a directory where the script stores all temporary files during generating the image. +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 f459f23..9855789 100755 --- a/rpi23-gen-image.sh +++ b/rpi23-gen-image.sh @@ -68,6 +68,9 @@ UBOOT_URL=${UBOOT_URL:=git://git.denx.de/u-boot.git} # Build directories 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" @@ -517,42 +520,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 <