Merge pull request #2664 from HiassofT/le9-sha256sum

create sha256 checksum files of tars and images
This commit is contained in:
MilhouseVH 2018-04-24 23:38:46 +01:00 committed by GitHub
commit d3607bae0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 9 deletions

View File

@ -319,6 +319,11 @@ if [ "$1" = "release" -o "$1" = "mkimage" -o "$1" = "amlpkg" -o "$1" = "noobs" ]
# create release tarball
tar cf $TARGET_IMG/$IMAGE_NAME.tar -C target $IMAGE_NAME
# create sha256 checksum of tarball
( cd $TARGET_IMG
sha256sum ${IMAGE_NAME}.tar > ${IMAGE_NAME}.tar.sha256
)
# create image files if requested
if [[ ( "$1" = "amlpkg" || "$1" = "noobs" || "$1" = "mkimage" ) && -n "$BOOTLOADER" ]]; then
# projects can set KERNEL_NAME (kernel.img)
@ -423,6 +428,11 @@ if [ "$1" = "release" -o "$1" = "mkimage" -o "$1" = "amlpkg" -o "$1" = "noobs" ]
zip -q $TARGET_IMG/$IMAGE_NAME.zip *
# create sha256 checksum of zip
( cd $TARGET_IMG
sha256sum ${IMAGE_NAME}.zip > ${IMAGE_NAME}.zip.sha256
)
popd > /dev/null
popd > /dev/null
@ -531,6 +541,11 @@ if [ "$1" = "release" -o "$1" = "mkimage" -o "$1" = "amlpkg" -o "$1" = "noobs" ]
# create release tarball
tar cf $TARGET_IMG/${IMAGE_NAME}-$1.tar -C $TARGET ${IMAGE_NAME}-$1
# create sha256 checksum of tarball
( cd $TARGET_IMG
sha256sum ${IMAGE_NAME}-$1.tar > ${IMAGE_NAME}-$1.tar.sha256
)
fi
if [ -d $RELEASE_DIR ]; then

View File

@ -43,7 +43,8 @@
DISK_START_PADDING=$(( ($SYSTEM_PART_START + 2048 - 1) / 2048 ))
DISK_GPT_PADDING=1
DISK_SIZE=$(( $DISK_START_PADDING + $SYSTEM_SIZE + $STORAGE_SIZE + $DISK_GPT_PADDING ))
DISK="$TARGET_IMG/$IMAGE_NAME.img"
DISK_BASENAME="$TARGET_IMG/$IMAGE_NAME"
DISK="${DISK_BASENAME}.img"
# functions
cleanup() {
@ -305,7 +306,7 @@ fi # bootloader
if [ "$PROJECT" = "Generic" ]; then
echo "image: creating open virtual appliance..."
# duplicate $DISK so anything we do to it directly doesn't effect original
dd if="$DISK" of="${DISK/img/tmp}" bs=1M >"$SAVE_ERROR" 2>&1 || show_error
dd if="$DISK" of="${DISK_BASENAME}.tmp" bs=1M >"$SAVE_ERROR" 2>&1 || show_error
# change syslinux default to 'run'
echo "image: modifying fs on part1 for open virtual appliance..."
sed -i "/DEFAULT/ s/installer/run/" "$LE_TMP"/syslinux.cfg
@ -318,20 +319,24 @@ fi # bootloader
sync
# merge modified part1 back to tmp disk image
echo "image: merging part1 back to open virtual appliance..."
dd if="$LE_TMP/part1.fat" of="${DISK/img/tmp}" bs=512 seek="$SYSTEM_PART_START" conv=fsync,notrunc >"$SAVE_ERROR" 2>&1 || show_error
dd if="$LE_TMP/part1.fat" of="${DISK_BASENAME}.tmp" bs=512 seek="$SYSTEM_PART_START" conv=fsync,notrunc >"$SAVE_ERROR" 2>&1 || show_error
# create vmdk from tmp $DISK
qemu-img convert -O vmdk -o subformat=streamOptimized "${DISK/img/tmp}" "${DISK/img/vmdk}"
qemu-img convert -O vmdk -o subformat=streamOptimized "${DISK_BASENAME}.tmp" "${DISK_BASENAME}.vmdk"
# generate ovf from template
sed -e "s,@DISTRO@,$DISTRO,g" -e "s,@DISK@,$(basename ${DISK/.img}),g" \
sed -e "s,@DISTRO@,$DISTRO,g" -e "s,@DISK@,${IMAGE_NAME},g" \
-e "s,@DISK_SIZE@,$(($DISK_SIZE*1024*1024)),g" \
$PROJECT_DIR/$PROJECT/config/ovf.template > ${DISK/img/ovf}
$PROJECT_DIR/$PROJECT/config/ovf.template > ${DISK_BASENAME}.ovf
# combine ovf and vmdk into official ova
tar -C $TARGET_IMG -cf ${DISK/img/ova} $(basename ${DISK/img/ovf}) $(basename ${DISK/img/vmdk})
tar -C $TARGET_IMG -cf ${DISK_BASENAME}.ova ${IMAGE_NAME}.ovf ${IMAGE_NAME}.vmdk
# create sha256 checksum of ova image
( cd $TARGET_IMG
sha256sum ${IMAGE_NAME}.ova > ${IMAGE_NAME}.ova.sha256
)
echo "image: cleaning up..."
# remove tmp $DISK, vmdk and ovf
rm ${DISK/img/tmp} ${DISK/img/vmdk} ${DISK/img/ovf}
rm ${DISK_BASENAME}.tmp ${DISK_BASENAME}.vmdk ${DISK_BASENAME}.ovf
# set owner
[ -n "$SUDO_USER" ] && chown $SUDO_USER: ${DISK/img/ova}
[ -n "$SUDO_USER" ] && chown $SUDO_USER: ${DISK_BASENAME}.ova
fi
# gzip
@ -342,6 +347,10 @@ fi # bootloader
if [ -n "$SUDO_USER" ] ; then
chown $SUDO_USER: $DISK.gz
fi
# create sha256 checksum of image
( cd $TARGET_IMG
sha256sum $(basename $DISK).gz > $(basename $DISK).gz.sha256
)
# cleanup
cleanup