pack.sh 1.34 KB
Newer Older
fuyanbin's avatar
fuyanbin committed
1
#!/bin/bash
牛文敏's avatar
牛文敏 committed
2
set -e
fuyanbin's avatar
fuyanbin committed
3
img="$1"
牛文敏's avatar
牛文敏 committed
4
5
zippath="$2"

fuyanbin's avatar
fuyanbin committed
6
7
8
9
10
11
12
13
14
15
16
17
build_dir=$(mktemp -d ./tmp.XXXXX)
systemfile="$build_dir/system.PARTITION"
systemfile_ext4="$build_dir/system.PARTITION.ext4"

aml_image_v2_packer -d "$img" "./$build_dir"
if file "$systemfile" | grep "Android sparse image"
then
    simg2img "$systemfile" "$systemfile_ext4"
    loopdev=$(sudo losetup -P -f --show "$systemfile_ext4")
else
    loopdev=$(sudo losetup -P -f --show "$systemfile")
fi
fuyanbin's avatar
fuyanbin committed
18

fuyanbin's avatar
fuyanbin committed
19
20
21
mkdir "$build_dir/system"
sudo mount "$loopdev" "$build_dir/system"

fuyanbin's avatar
fuyanbin committed
22
sudo touch "$build_dir/system/.androidrom"
牛文敏's avatar
牛文敏 committed
23

fuyanbin's avatar
fuyanbin committed
24
25
26
27
if [[ -n "$zippath" ]]
then
    sudo wget "$zippath" -O "$build_dir/system/bin/hugep-all.zip"
fi
fuyanbin's avatar
fuyanbin committed
28

fuyanbin's avatar
fuyanbin committed
29
30
31
32
33
34
sudo find ./services/ -type f -name "*.rc" -exec install -t "$build_dir"/system/etc/init/ {} \;
sudo find ./services/ -type f ! -name  "*.rc" -exec install -m 0777 -t "$build_dir"/system/bin/ {} \;
for file in $(find ./services/ -type f ! -name "*.rc")
do
    sudo chcon u:object_r:drmserver_exec:s0 "$build_dir/system/bin/$(basename "$file")"
done
fuyanbin's avatar
fuyanbin committed
35

fuyanbin's avatar
fuyanbin committed
36
rm -f "$build_dir/system/hugep-all.zip"
37

fuyanbin's avatar
fuyanbin committed
38
39
sudo umount "$loopdev"
sudo losetup -d "$loopdev"
40
rm -rf "$build_dir/system"
fuyanbin's avatar
fuyanbin committed
41
42
43
44
45
46
47
48
49
sync

if [[ -f "$systemfile_ext4" ]]
then
    rm -f "$systemfile"
    img2simg "$systemfile_ext4" "$systemfile"
    rm -f "$systemfile_ext4"
fi
aml_image_v2_packer -r "./$build_dir/image.cfg" "$build_dir" "$(basename "$img")"
fuyanbin's avatar
fuyanbin committed
50
sudo rm -rf "./$build_dir/"