Gunnar Mills | e822190 | 2017-02-03 15:59:06 -0600 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | help=$'Generate SquashFS image Script |
| 4 | |
| 5 | Generates a SquashFS image from the PNOR image |
| 6 | |
| 7 | usage: generate-squashfs [OPTION] |
| 8 | |
| 9 | Options: |
Gunnar Mills | 37751f9 | 2017-02-07 21:05:01 -0600 | [diff] [blame^] | 10 | -f, --file <file> Specify destination file. Defaults to |
| 11 | `pwd`/pnor.xz.squashfs if unspecified. |
Gunnar Mills | e822190 | 2017-02-03 15:59:06 -0600 | [diff] [blame] | 12 | -h, --help Display this help text and exit. |
| 13 | ' |
| 14 | |
Gunnar Mills | 18f7cdb | 2017-02-07 16:44:19 -0600 | [diff] [blame] | 15 | declare -a partitions=( |
| 16 | "HBB" |
| 17 | "HBEL" |
| 18 | "GUARD" |
| 19 | "HBD" |
| 20 | "DJVPD" |
| 21 | "MVPD" |
| 22 | "CVPD" |
| 23 | "HBI" |
| 24 | "SBE" |
| 25 | "HCODE" |
| 26 | "HBRT" |
| 27 | "PAYLOAD" |
| 28 | "TEST" |
| 29 | "TESTRO" |
| 30 | "HBBL" |
| 31 | "GLOBAL" |
| 32 | "RINGOVD" |
| 33 | "SBKT" |
| 34 | "OCC" |
| 35 | ) |
| 36 | |
Gunnar Mills | 37751f9 | 2017-02-07 21:05:01 -0600 | [diff] [blame^] | 37 | outfile=`pwd`"/pnor.xz.squashfs" |
| 38 | |
Gunnar Mills | e822190 | 2017-02-03 15:59:06 -0600 | [diff] [blame] | 39 | while [[ $# -gt 0 ]]; do |
| 40 | key="$1" |
| 41 | case $key in |
Gunnar Mills | 37751f9 | 2017-02-07 21:05:01 -0600 | [diff] [blame^] | 42 | -f|--file) |
| 43 | outfile="$2" |
| 44 | shift 2 |
| 45 | ;; |
Gunnar Mills | e822190 | 2017-02-03 15:59:06 -0600 | [diff] [blame] | 46 | -h|--help) |
| 47 | echo "$help" |
| 48 | exit |
| 49 | ;; |
| 50 | *) |
| 51 | echo "Unknown option $1. Display available options with -h or --help" |
| 52 | exit |
| 53 | ;; |
| 54 | esac |
| 55 | done |
Gunnar Mills | 18f7cdb | 2017-02-07 16:44:19 -0600 | [diff] [blame] | 56 | |
Gunnar Mills | 37751f9 | 2017-02-07 21:05:01 -0600 | [diff] [blame^] | 57 | scratch_dir=`mktemp -d` || exit 1 |
| 58 | |
Gunnar Mills | 18f7cdb | 2017-02-07 16:44:19 -0600 | [diff] [blame] | 59 | for partition in "${partitions[@]}"; do |
| 60 | echo "Reading ${partition}..." |
Gunnar Mills | 37751f9 | 2017-02-07 21:05:01 -0600 | [diff] [blame^] | 61 | pflash_cmd="pflash --partition=${partition} --read=${scratch_dir}/${partition}" |
Gunnar Mills | 18f7cdb | 2017-02-07 16:44:19 -0600 | [diff] [blame] | 62 | ${pflash_cmd} || exit 1 |
| 63 | done |
Gunnar Mills | 37751f9 | 2017-02-07 21:05:01 -0600 | [diff] [blame^] | 64 | |
| 65 | echo "Creating SquashFS image..." |
| 66 | |
| 67 | cd "${scratch_dir}" |
| 68 | squashfs_cmd="mksquashfs ${partitions[*]} ${outfile}" |
| 69 | ${squashfs_cmd} || exit 1 |
| 70 | |
| 71 | echo "SquashFS Image at ${outfile}" |
| 72 | rm -r "${scratch_dir}" |