blob: 200974d35c322601be32769fdda34e64a3c7fe01 [file] [log] [blame]
#!/bin/sh
help=$'Generate SquashFS image Script
Generates a SquashFS image from the PNOR image
usage: generate-squashfs [OPTION]
Options:
-f, --file <file> Specify destination file. Defaults to
`pwd`/pnor.xz.squashfs if unspecified.
-h, --help Display this help text and exit.
'
outfile=`pwd`"/pnor.xz.squashfs"
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-f|--file)
outfile="$2"
shift 2
;;
-h|--help)
echo "$help"
exit
;;
*)
echo "Unknown option $1. Display available options with -h or --help"
exit
;;
esac
done
scratch_dir=`mktemp -d` || exit 1
partitions=($(pflash --info | grep ID | awk '{print $2}'))
for partition in "${partitions[@]}"; do
echo "Reading ${partition}..."
pflash_cmd="pflash --partition=${partition} --read=${scratch_dir}/${partition}"
${pflash_cmd} || exit 1
done
echo "Creating SquashFS image..."
cd "${scratch_dir}"
squashfs_cmd="mksquashfs ${partitions[*]} ${outfile}"
${squashfs_cmd} || exit 1
echo "SquashFS Image at ${outfile}"
rm -r "${scratch_dir}"