forked from scorp2kk/u-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pack_resource.sh
executable file
·65 lines (60 loc) · 1.6 KB
/
pack_resource.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
#!/bin/sh
OLD_IMAGE=$1
IMAGE=resource.img
TOOL=../rkbin/tools/resource_tool
RESOURCES=./tools/images/
usage()
{
echo "Usage:"
echo " ./pack_resource <input resource.img>"
}
prepare()
{
echo
if [ "$OLD_IMAGE" = '--help' -o "$OLD_IMAGE" = '-h' -o "$OLD_IMAGE" = '--h' ]; then
usage
exit 0
elif [ ! -f "$TOOL" ];then
echo "Can't find '../rkbin/' Responsity, please download it before pack image!"
echo "How to obtain? 3 ways:"
echo " 1. Login your Rockchip gerrit account: \"Projects\" -> \"List\" -> search \"rk/rkbin\" Responsity"
echo " 2. Github Responsity: https://github.com/rockchip-linux/rkbin"
echo " 3. Download full release SDK Responsity"
exit 1
elif [ ! -d "$RESOURCES" ];then
echo "Can't find resources: $RESOURCES"
exit 1
elif [ -z "$OLD_IMAGE" ];then
echo "Missing: <input image>"
usage
exit 1
elif [ ! -f "$OLD_IMAGE" ];then
echo "Can't find file: $OLD_IMAGE"
usage
exit 1
fi
}
append_resource()
{
local TMP_DIR=.resource_tmp
rm -r $TMP_DIR 2>/dev/null
mkdir $TMP_DIR
echo "Pack $RESOURCES & $OLD_IMAGE to $IMAGE ..."
if [ -f "$OLD_IMAGE" ];then
echo "Unpacking old image($OLD_IMAGE):"
$TOOL --unpack --verbose --image=$OLD_IMAGE $TMP_DIR 2>&1|grep entry|sed "s/^.*://"|xargs echo
fi
if [ -d "$RESOURCES" ];then
cp -r $RESOURCES/* $TMP_DIR
else
cp -r $RESOURCES $TMP_DIR
fi
$TOOL --pack --root=$TMP_DIR --image=$IMAGE `find $TMP_DIR -type f|sort`
echo "Packed resources:"
$TOOL --unpack --verbose --image=$IMAGE $TMP_DIR 2>&1|grep entry|sed "s/^.*://"|xargs echo
rm -r $TMP_DIR 2>/dev/null
echo
echo "resource.img is packed ready"
}
prepare
append_resource