-
Notifications
You must be signed in to change notification settings - Fork 2
/
prepare-fake-ota-stable.sh
executable file
·115 lines (95 loc) · 3.97 KB
/
prepare-fake-ota-stable.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
HERE=$(pwd)
source "${HERE}/deviceinfo"
# Fetches android9 rootfs and generic system image to prepare flashable image from CI-built device tarball
URL='https://system-image.ubports.com'
ROOTFS_URL=${ROOTFS_URL:-'https://ci.ubports.com/job/xenial-hybris-android9-rootfs-arm64/lastSuccessfulBuild/artifact/ubuntu-touch-android9-arm64.tar.gz'}
STABLE_ROOTFS_URL='https://system-image.ubports.com/pool/ubports-0cd6d21caa26d8603c3484c1765f12cad81edab452aa5cce1a6cc3b99a09c17f.tar.xz'
OTA_CHANNEL='16.04/arm64/android9/devel'
case "$deviceinfo_bootimg_os_version" in
9)
DEVICE_GENERIC_URL='https://ci.ubports.com/job/UBportsCommunityPortsJenkinsCI/job/ubports%252Fporting%252Fcommunity-ports%252Fjenkins-ci%252Fgeneric_arm64/job/main/lastSuccessfulBuild/artifact/halium_halium_arm64.tar.xz'
;;
10)
DEVICE_GENERIC_URL='https://ci.ubports.com/job/UBportsCommunityPortsJenkinsCI/job/ubports%252Fporting%252Fcommunity-ports%252Fjenkins-ci%252Fgeneric_arm64/job/halium-10.0/lastSuccessfulBuild/artifact/halium_halium_arm64.tar.xz'
;;
11)
DEVICE_GENERIC_URL='https://ci.ubports.com/job/UBportsCommunityPortsJenkinsCI/job/ubports%252Fporting%252Fcommunity-ports%252Fjenkins-ci%252Fgeneric_arm64/job/halium-11.0/lastSuccessfulBuild/artifact/halium_halium_arm64.tar.xz'
;;
*)
echo "Unsupported Android version $deviceinfo_bootimg_os_version!"
exit 1
;;
esac
DEVICE_TARBALL="$1"
OUTPUT="$2"
mkdir -p "$OUTPUT" || true
download_file_and_asc() {
wget "$1" -P "$2"
wget "$1.asc" -P "$2"
}
# Downloads master and signing keyrings
download_file_and_asc "${URL}/gpg/image-signing.tar.xz" "$OUTPUT"
download_file_and_asc "${URL}/gpg/image-master.tar.xz" "$OUTPUT"
# Start to generate ubuntu_command file
echo '# Generated by ubports rootfs-builder-debos' > "$OUTPUT/ubuntu_command"
cat << EOF >> "$OUTPUT/ubuntu_command"
format system
load_keyring image-master.tar.xz image-master.tar.xz.asc
load_keyring image-signing.tar.xz image-signing.tar.xz.asc
mount system
EOF
# Download and prepare rootfs
#file=$(basename "$ROOTFS_URL")
#wget "$ROOTFS_URL" -P "$OUTPUT"
#mkdir -p "$OUTPUT/rootfs/system"
#cd "$OUTPUT/rootfs"
#sudo tar xpzf "../$file" --numeric-owner -C system
mkdir -p "$OUTPUT/rootfs/system"
wget "$STABLE_ROOTFS_URL" -O "$OUTPUT/rootfs"/stable_rootfs.tar.xz
cd "$OUTPUT/rootfs"
sudo tar -xf stable_rootfs.tar.xz
# Enable SSH and USB tethering for debugging in devel-flashable builds
echo "start on startup" > system/etc/init/ssh.override
echo "exec /usr/sbin/sshd -D -o PasswordAuthentication=yes -o PermitEmptyPasswords=yes" >> system/etc/init/ssh.override
echo "start on startup" > system/etc/init/usb-tethering.conf
echo "exec /bin/bash /usr/bin/usb-tethering" >> system/etc/init/usb-tethering.conf
sudo XZ_OPT=-1 tar cJf "../rootfs.tar.xz" system
cd -
sudo rm -rf "./$OUTPUT/rootfs"
file="rootfs.tar.xz"
touch "$OUTPUT/$file.asc"
echo "update $file $file.asc" >> "$OUTPUT/ubuntu_command"
# Device-generic tarball (Halium GSI)
file=$(basename "$DEVICE_GENERIC_URL")
wget "$DEVICE_GENERIC_URL" -P "$OUTPUT"
touch "$OUTPUT/$file.asc"
echo "update $file $file.asc" >> "$OUTPUT/ubuntu_command"
# Device tarball
file=$(basename "$DEVICE_TARBALL")
cp "$DEVICE_TARBALL" "$OUTPUT"
touch "$OUTPUT/$file.asc"
echo "update $file $file.asc" >> "$OUTPUT/ubuntu_command"
# Version tarball
mkdir "$OUTPUT/version"
cd "$OUTPUT/version"
mkdir -p system/etc/system-image
cat << EOF >> system/etc/system-image/channel.ini
[service]
base: system-image.ubports.com
http_port: 80
https_port: 443
channel: $OTA_CHANNEL
device: $deviceinfo_codename
EOF
mkdir -p system/etc/system-image/config.d
ln -s ../client.ini system/etc/system-image/config.d/00_default.ini
ln -s ../channel.ini system/etc/system-image/config.d/01_channel.ini
tar cvJf "../version.tar.xz" system
cd -
rm -r "$OUTPUT/version"
file="version.tar.xz"
touch "$OUTPUT/$file.asc"
echo "update $file $file.asc" >> "$OUTPUT/ubuntu_command"
# End ubuntu_command
echo 'unmount system' >> "$OUTPUT/ubuntu_command"