-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-image
executable file
·79 lines (62 loc) · 1.83 KB
/
build-image
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
#!/bin/bash
## System Checks
function check_deps(){
if [ ! -x "$1" ]; then
echo "ERROR: Missing dependency ${1}" 1>&2
exit 1
fi
}
check_deps /usr/bin/git
check_deps /usr/bin/gh
if [ "$(uname -m)" != "aarch64" ]; then
check_deps /usr/bin/qemu-arm-static
fi
check_deps /usr/bin/xz
apt install -y python3-git lsof
## Options
function usage() { echo "Usage: $0 -v VERSION" 1>&2; exit 1; }
while getopts "v:" opt; do
case $opt in
v) VER="$OPTARG" ;;
*) usage ;;
esac
done
shift $((OPTIND-1))
if [ -z "${VER}" ]; then
usage
fi
## Error out immediately on any problem
set -e
## Clone the CustomPiOS Builder
git clone --depth 1 https://github.com/guysoft/CustomPiOS
## Generate the image build system
pushd CustomPiOS
# Install the patches for CustomPiOS
patch -p1 < ../aarch64_fixes.patch
patch -p1 < ../wpa_supp_fix1.patch
patch -p1 < ../mod_net_quirks.patch
if [ -d asl3 ]; then
echo "ERROR: Image structure asl3 already exists" 1>&2
exit 1
fi
export USER=root
./src/make_custom_pi_os -v raspios_lite_arm64 -g ./asl3
cp -r ../modules/* asl3/src/modules/
perl -pe "s/\@\@VER\@\@/${VER}/g" ../config > asl3/src/config
## Spin the image
pushd asl3/src
echo "export ASL3_REPO_LVL=\"${REPOLVL}\"" >> config
sudo ./build_dist
popd
echo "Compressing image... this takes a long time...."
IMGFILE=$(ls asl3/src/workspace/*.img)
xz -T 0 -c ${IMGFILE} > ../allstar3-arm64-${VER}.img.xz
popd
ls -l *.xz
## Copy to repo
echo "${SSH_REPO_AWS_PI_IMAGE_KEY}" > id_ed25519
chmod 600 id_ed25519
SSH_VARS="-i id_ed25519 -o StrictHostKeyChecking=accept-new"
scp ${SSH_VARS} allstar3-arm64-${VER}.img.xz [email protected]:/var/www/html/images/pi
sha256sum allstar3-arm64-${VER}.img.xz > allstar3-arm64-${VER}.img.xz.sha256
scp ${SSH_VARS} allstar3-arm64-${VER}.img.xz.sha256 [email protected]:/var/www/html/images/pi