2011-12-28 17:56:54 +01:00
|
|
|
#!/bin/bash
|
|
|
|
# Compress the freaking MMC image using xz
|
|
|
|
#
|
|
|
|
# Available env vars:
|
|
|
|
# IMAGE_PATH = path to generated image
|
|
|
|
# IMAGE_CHECKSUM_PATH = path to generated md5 for image
|
|
|
|
#
|
|
|
|
|
|
|
|
/usr/sbin/env-update && source /etc/profile
|
|
|
|
|
|
|
|
COMPRESSED_IMAGE_PATH="${IMAGE_PATH}.xz"
|
2011-12-30 12:27:03 +01:00
|
|
|
COMPRESSED_IMAGE_CHECKSUM_PATH="${COMPRESSED_IMAGE_PATH}.md5"
|
2011-12-28 17:56:54 +01:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Spawning xz --compress --force for:"
|
|
|
|
echo "IMAGE_PATH = ${IMAGE_PATH}"
|
|
|
|
echo "COMPRESSED_IMAGE_PATH = ${COMPRESSED_IMAGE_PATH}"
|
2011-12-30 12:27:03 +01:00
|
|
|
echo "COMPRESSED_IMAGE_CHECKSUM_PATH = ${COMPRESSED_IMAGE_CHECKSUM_PATH}"
|
2011-12-28 17:56:54 +01:00
|
|
|
echo
|
|
|
|
|
|
|
|
xz --compress --force "${IMAGE_PATH}" || exit 1
|
|
|
|
[[ ! -f "${COMPRESSED_IMAGE_PATH}" ]] && { echo "${COMPRESSED_IMAGE_PATH} not found"; exit 1; }
|
|
|
|
|
2011-12-29 23:00:27 +01:00
|
|
|
chmod 644 "${COMPRESSED_IMAGE_PATH}" || exit 1
|
|
|
|
|
2011-12-28 17:56:54 +01:00
|
|
|
cd "$(dirname "${COMPRESSED_IMAGE_PATH}")" || exit 1
|
|
|
|
img_name=$(basename "${COMPRESSED_IMAGE_PATH}")
|
2011-12-30 12:27:03 +01:00
|
|
|
md5sum "${img_name}" > "${COMPRESSED_IMAGE_CHECKSUM_PATH}" || exit 1
|
|
|
|
|
|
|
|
echo "All done"
|
|
|
|
|
2011-12-28 17:56:54 +01:00
|
|
|
exit ${?}
|
|
|
|
|