forked from xndcn/pebble-firmware-utils
-
Notifications
You must be signed in to change notification settings - Fork 12
/
packResources.sh
executable file
·80 lines (72 loc) · 1.94 KB
/
packResources.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
print_help() {
echo "This script converts list of files to PBPack."
echo "It uses pbpack_meta_data.py script from Pebble framework,"
echo "so you should have framework installed."
echo "Resource files should be already prepared, or extracted from ready pbpack."
echo
echo "Usage:"
echo "packResources.sh [-f] [-a] [-w pathToFramework] [-o system_resources.pbpack] [-t timestamp] res_file [...]"
echo "use -f to force output file overwriting."
echo "use -a to use application resource format. Default is system resource format."
}
#framework="/opt/pebble/Pebble"
framework="$HOME/.pebble-sdk/SDKs/current/sdk-core/pebble"
outfile="system_resources.pbpack"
timestamp=$(date +%s)
overwrite=0
sys=1
while getopts "h?fw:o:t:a" opt; do
case "$opt" in
h|\?)
print_help
exit 0
;;
f)
overwrite=1
;;
w)
framework=$OPTARG
;;
o)
outfile=$OPTARG
;;
t)
timestamp=$OPTARG
;;
a)
sys=0
;;
esac
done
shift $((OPTIND-1))
[ "$1" == "--" ] && shift
if [ $# -lt 1 ]; then
echo "Please provide at least one file to put in bundle!"
echo
print_help
exit 1
fi
if [ -e "$outfile" ]; then
if [ $overwrite -eq 1 ]; then
echo "Warning: overwriting output file $outfile"
else
echo "Will not overwrite existing output file $outfile"
echo "Use -f to force."
exit 1
fi
fi
fwfile=$framework/common/tools/pbpack_meta_data.py
[ -e "$fwfile" ] || fwfile=$framework/Pebble/tools/pbpack_meta_data.py
if ! [ -e "$fwfile" ]; then
echo "Framework repacking script not found in $framework - failed"
exit 1
fi
fwrun="python2 $fwfile"
[ $sys -eq 1 ] && fwrun="$fwrun --system"
$fwrun manifest "$outfile".manifest "$timestamp" "$@" || exit 1
$fwrun table "$outfile".table "$@" || exit 1
$fwrun content "$outfile".content "$@" || exit 1
cat "$outfile".manifest "$outfile".table "$outfile".content > "$outfile"
rm "$outfile".manifest "$outfile".table "$outfile".content > /dev/null
echo "Bundle with $# resources saved to $outfile"