-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmk-swu.sh
executable file
·56 lines (44 loc) · 1.31 KB
/
mk-swu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# process args
#input=0
#output=0
#config=0
#partition=0
while getopts i:o:c:p: opt; do
case $opt in
i) input=$OPTARG;;
o) output=$OPTARG;;
c) config=$OPTARG;;
p) partition=$OPTARG;;
\?)
exit 1
;;
:)
exit 1
;;
esac
done
# make sure args are provided
if [ -z ${input+x} ] || [ -z ${output+x} ] || [ -z ${config+x} ] || [ -z ${partition+x} ]; then
echo "usage: $0 -i <input> -o <output> -c <config> -p <partition>" >&2
exit 1
fi
# create a temporary directory
tempdirectory=`mktemp -d`
# setup the paths to all of the upgrade image components
swdescription="sw-description"
bankimage="bank.img"
# extract the partition to the temporary file
echo "extracting partition $partition from $input into $tempdirectory/$bankimage"
`./extract-partition.py --input $input --config $config --output "$tempdirectory/$bankimage" --partition $partition`
# change into the temporary directory
cd $tempdirectory
# setup the list of inputs into the output file
FILES="$bankimage"
echo "creating $output using $FILES"
# start creating the update file
for i in $FILES; do echo $i; done | cpio -ov -H crc > $output
# remove the temporary directory
rm -r $tempdirectory
# done
echo "finished creating upgrade file $output"