-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild_sysutils_Rock5_Chroot_debian.yml
More file actions
143 lines (131 loc) · 5.5 KB
/
build_sysutils_Rock5_Chroot_debian.yml
File metadata and controls
143 lines (131 loc) · 5.5 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: build_sysutils_radxa_arm64_debian
on:
workflow_dispatch:
push:
branches:
- "main"
- "dev-release"
- "release"
- "openhd-3.0"
jobs:
build:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- image_type: rock5b
release: bullseye
- image_type: rock5b
release: bookworm
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 512
swap-size-mb: 1024
remove-dotnet: "true"
remove-android: "true"
remove-haskell: "true"
overprovision-lvm: "true"
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Building OpenHD-SysUtils in CHROOT
run: |
git clone https://github.com/OpenHD/OpenHD-ChrootCompiler /opt/OpenHD-ChrootCompiler
mkdir -p /opt/OpenHD-ChrootCompiler/additionalFiles
cp -a "$GITHUB_WORKSPACE/." /opt/OpenHD-ChrootCompiler/additionalFiles/
printf '%s\n' "$CLOUDSMITH_API_KEY" > /opt/OpenHD-ChrootCompiler/additionalFiles/cloudsmith_api_key.txt
echo "standard" > /opt/OpenHD-ChrootCompiler/additionalFiles/custom.txt
echo "arm64" > /opt/OpenHD-ChrootCompiler/additionalFiles/arch.txt
echo "debian" > /opt/OpenHD-ChrootCompiler/additionalFiles/distro.txt
echo "${{ matrix.release }}" > /opt/OpenHD-ChrootCompiler/additionalFiles/flavor.txt
echo "${{ github.ref_name }}" > /opt/OpenHD-ChrootCompiler/additionalFiles/repo.txt
cat << 'EOF' > /opt/OpenHD-ChrootCompiler/additionalFiles/build_chroot.sh
#!/bin/bash
set -euo pipefail
chmod 1777 /tmp || true
apt-get update --fix-missing
apt-get install -y cmake g++ python3
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
cd build
cpack -G DEB
cp *.deb /out/
EOF
chmod +x /opt/OpenHD-ChrootCompiler/additionalFiles/build_chroot.sh
cd /opt/OpenHD-ChrootCompiler/
sudo apt update
sudo bash install_dep.sh
python3 - <<'PY'
from pathlib import Path
packages_stage = Path("/opt/OpenHD-ChrootCompiler/stages/02-Packages/00-run-chroot.sh")
packages_text = packages_stage.read_text()
packages_old = 'if [[ "${OS}" == "radxa-debian-rock5a" ]] || [[ "${OS}" == "radxa-debian-rock5b" ]]; then'
packages_new = 'if [[ "${DISTRO}" == "bullseye" ]] && { [[ "${OS}" == "radxa-debian-rock5a" ]] || [[ "${OS}" == "radxa-debian-rock5b" ]]; }; then'
if packages_new not in packages_text:
if packages_old not in packages_text:
raise SystemExit("Could not find Rock5 package-preflight block in ChrootCompiler")
packages_stage.write_text(packages_text.replace(packages_old, packages_new, 1))
build_sh = Path("/opt/OpenHD-ChrootCompiler/build.sh")
text = build_sh.read_text()
original = text
image_needle = "mv OpenHD-ImageBuilder/images .\n"
image_patch = (
image_needle
+ "for board in rock5a rock5b radxa-cm5 radxa-zero3w; do\n"
+ " if [ ! -f \"images/${board}\" ] && [ -f \"images/${board}_base\" ]; then\n"
+ " cp \"images/${board}_base\" \"images/${board}\"\n"
+ " fi\n"
+ "done\n"
)
if "images/${board}_base" not in text:
if image_needle not in text:
raise SystemExit("Could not find ImageBuilder image import in build.sh")
text = text.replace(image_needle, image_patch, 1)
if "export BASE_IMAGE_SHA512" not in text:
text = text.replace(
"export BASE_IMAGE_SHA256\n",
"export BASE_IMAGE_SHA256\nexport BASE_IMAGE_SHA512\n",
1,
)
needle = "mv OpenHD-ImageBuilder/stages/01-Baseimage stages/\n"
patch = (
needle
+ "sed -i 's/WANTEDSIZE=\"6800000000\"/WANTEDSIZE=\"15000000000\"/' stages/01-Baseimage/01-run.sh\n"
)
if "WANTEDSIZE=\"15000000000\"" not in text:
if needle not in text:
raise SystemExit("Could not find ImageBuilder stage import in build.sh")
text = text.replace(needle, patch, 1)
if text != original:
build_sh.write_text(text)
PY
sudo bash build.sh "${{ matrix.image_type }}" "$API_KEY" debian "${{ matrix.release }}"
- name: Collect artifacts
run: |
cp -r /opt/OpenHD-ChrootCompiler/out/* .
- name: Upload to Github
uses: "actions/upload-artifact@v4"
with:
name: "OpenHD-SysUtils-${{ matrix.release }}-arm64"
path: |
*.deb
- name: Push
if: github.ref_name == 'release' || github.ref_name == 'dev-release' || github.ref_name == 'main'
uses: cloudsmith-io/action@master
with:
api-key: ${{ secrets.CLOUDSMITH_API_KEY }}
command: "push"
format: "deb"
owner: "openhd"
repo: dev-release
distro: "debian"
release: "${{ matrix.release }}"
republish: "true"
file: "*.deb"