-
-
Notifications
You must be signed in to change notification settings - Fork 9
342 lines (319 loc) · 16.6 KB
/
build.yml
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
name: Patch GSI to Samsung Super Image
on:
workflow_dispatch:
inputs:
TAR_SUPER:
description: 'Super Image, but in TAR'
required: false
LZ4_SUPER:
description: 'Super Image, but in lz4'
required: false
SUPER_LOCATE:
description: 'Super Image Link, make sure its in super.img form, NOT IN SUPER.IMG.LZ4'
required: false
NAME_ID:
description: 'What you want to call the finished product'
required: true
default: 'extract'
COMPRESSION_CHOICE:
description: 'Contain the image? (other types of compression coming soon)'
required: true
default: 'yes-tar'
type: choice
options:
- 'tar'
- 'xz'
- '7z'
GSI_IMG_LOCATION_XT:
description: 'Enter GSI Link (Extracted, img only, NO SPACES!)'
required: false
GSI_IMG_LOCATION_CMP:
description: 'Enter GSI Link (Compressed into .xz)'
required: false
NAME_REL:
description: 'Enter Name for Github Release'
required: true
jobs:
Building-GSI:
if: github.event.repository.owner.id == github.event.sender.id
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Display Session Parameters, for Logging Purposes
run: |
echo "::group::User ENV Var"
echo "Super Location: ${{ github.event.inputs.SUPER_LOCATE }}"
echo "Name ID: ${{ github.event.inputs.NAME_ID }}"
echo "Compression Choice: ${{ github.event.inputs.COMPRESSION_CHOICE }}"
echo "GSI IMG Location in Extracted Form: ${{ github.event.inputs.GSI_IMG_LOCATION_XT }}"
echo "GSI IMG Location in Compressed form: ${{ github.event.inputs.GSI_IMG_LOCATION_CMP }}"
echo "Name REL: ${{ github.event.inputs.NAME_REL }}"
echo "Super LZ4: ${{ github.event.inputs.LZ4_SUPER }}"
- name: Check Out
uses: actions/checkout@v3
- name: Cleanup Bloated Action Environment
uses: rokibhasansagar/slimhub_actions@main
- name: Display Size Block
run: |
lsblk
- name: Prepare the Environment
run: |
sudo apt update
sudo apt upgrade -y
sudo apt install p7zip* wget android-tools* lz4 zstd libprotobuf-dev brotli android-sdk-libsparse-utils
# IDK TF AM I DOING
pwd >> dir.txt
LOCATION_POINT=$(pwd)
echo $LOCATION_POINT
- name: Grab Utils
run: |
mkdir bin
cd bin
wget https://github.com/SUFandom/super-patch/raw/main/packages/amd64/lpadd
wget https://github.com/SUFandom/super-patch/raw/main/packages/amd64/lpdump
wget https://github.com/SUFandom/super-patch/raw/main/packages/amd64/lpmake
wget https://github.com/SUFandom/super-patch/raw/main/packages/amd64/lpunpack
chmod +x *
sudo cp * /usr/bin/
cd ..
mkdir universal
cd universal
wget https://github.com/SUFandom/super-patch/raw/main/fake-props/product.img
wget https://github.com/SUFandom/super-patch/raw/main/fake-props/system_ext.img
cd ..
- name: Grabbing Images
run: |
LOC_CMP="${{ github.event.inputs.GSI_IMG_LOCATION_CMP }}"
LOC_XT="${{ github.event.inputs.GSI_IMG_LOCATION_XT }}"
if [[ -n "$LOC_CMP" ]] && [[ -n "$LOC_XT" ]]; then
echo "Only One variable are allowed"
exit 1
fi
if [[ -n "$LOC_CMP" ]]; then
mkdir cmp_img
cd cmp_img
wget -q ${{ github.event.inputs.GSI_IMG_LOCATION_CMP }}
7za x *.xz
cp *.img system.img
cd ..
elif [[ -n "$LOC_XT" ]]; then
mkdir cmp_img
cd cmp_img
wget -q ${{ github.event.inputs.GSI_IMG_LOCATION_XT }}
cp *.img system.img
cd ..
else
echo "Error, Empty INPUT"
exit 1
fi
- name: Grabbing Super Image - TAR
if: |
github.event.inputs.TAR_SUPER != null
&& github.event.inputs.SUPER_LOCATE == null
&& github.event.inputs.LZ4_SUPER == null
run: |
echo "Preparing"
mkdir image_build
export DIR="$(pwd)/image_build"
export ODM="$DIR/odm.img"
export SYSTEM="$DIR/system.img"
export SYSTEM_EXT="$DIR/system_ext.img"
export VENDOR="$DIR/vendor.img"
export SUPER="$DIR/super.img"
wget ${{ github.event.inputs.TAR_SUPER }}
tar -xf *.tar
mv super.img $DIR/
- name: Grabbing Super Image - LZ4
if: |
github.event.inputs.TAR_SUPER == null
&& github.event.inputs.SUPER_LOCATE == null
&& github.event.inputs.LZ4_SUPER != null
run: |
echo "Preparing"
mkdir image_build
export DIR="$(pwd)/image_build"
export ODM="$DIR/odm.img"
export SYSTEM="$DIR/system.img"
export SYSTEM_EXT="$DIR/system_ext.img"
export VENDOR="$DIR/vendor.img"
export SUPER="$DIR/super.img"
wget ${{ github.event.inputs.LZ4_SUPER }}
lz4 super.img.lz4
mv super.img $DIR/
- name: Grabbing Super Image
if:
github.event.inputs.TAR_SUPER == null
&& github.event.inputs.SUPER_LOCATE != null
&& github.event.inputs.LZ4_SUPER == null
run: |
echo "Preparing"
mkdir image_build
export DIR="$(pwd)/image_build"
export ODM="$DIR/odm.img"
export SYSTEM="$DIR/system.img"
export SYSTEM_EXT="$DIR/system_ext.img"
export VENDOR="$DIR/vendor.img"
export SUPER="$DIR/super.img"
wget ${{ github.event.inputs.SUPER_LOCATE }}
mv super.img $(pwd)/image_build/
- name: Indexing Files
run: |
# Tryna make sure lol
export DIR="$(pwd)/image_build"
export ODM="$DIR/odm.img"
export SYSTEM="$DIR/system.img"
export SYSTEM_EXT="$DIR/system_ext.img"
export VENDOR="$DIR/vendor.img"
export SUPER="$DIR/super.img"
# Add some temps
export TMP_ENVIRO="$(pwd)/tmp"
mkdir tmp
if [ -e "$DIR/super.img" ]; then
simg2img $DIR/super.img $DIR/super_raw.img
if [ -e "$DIR/super_raw.img" ]; then
if [ "$(ls -nl "$DIR/super_raw.img" | awk '{print $5}')" -lt 100000 ]; then
rm -rf super_raw.img
lpdump $DIR/super.img > $TMP_ENVIRO/super_map.txt
printf "$(<$TMP_ENVIRO/super_map.txt)" | grep -e "Size:" | awk '{print $2}' > $TMP_ENVIRO/super_size.txt
printf "$(<$TMP_ENVIRO/super_map.txt)" | grep -e "Maximum size:" | awk '{print $3}' | sed '2!d' > $TMP_ENVIRO/super_main.txt
lpunpack $DIR/super.img $DIR/
else
rm -rf $DIR/super.img
lpdump $DIR/super_raw.img > $TMP_ENVIRO/super_map.txt
printf "$(<$TMP_ENVIRO/super_map.txt)" | grep -e "Size:" | awk '{print $2}' > $TMP_ENVIRO/super_size.txt
printf "$(<$TMP_ENVIRO/super_map.txt)" | grep -e "Maximum size:" | awk '{print $3}' | sed '2!d' > $TMP_ENVIRO/super_main.txt
lpunpack $DIR/super_raw.img $DIR/
fi
else
echo "Super.img is corrupted"
exit 1
fi
fi
- name: Editing the Super.img
run: |
# Tryna make sure lol
export DIR="$(pwd)/image_build"
export ODM="$DIR/odm.img"
export SYSTEM="$DIR/system.img"
export SYSTEM_EXT="$DIR/system_ext.img"
export VENDOR="$DIR/vendor.img"
export SUPER="$DIR/super.img"
# Add some temps
export TMP_ENVIRO="$(pwd)/tmp"
rm -rf $SYSTEM
mv cmp_img/system.img $SYSTEM
if [ "$(ls -nl "$gsi_input" | awk '{print $5}')" -lt 100000 ]; then
echo "Invalid size for a GSI"
exit 1
fi
cp universal/* $DIR/
- name: Building the whole Super.img
run: |
# Tryna make sure lol
export DIR="$(pwd)/image_build"
export ODM="$DIR/odm.img"
export SYSTEM="$DIR/system.img"
export SYSTEM_EXT="$DIR/system_ext.img"
export VENDOR="$DIR/vendor.img"
export SUPER="$DIR/super.img"
# Add some temps
export TMP_ENVIRO="$(pwd)/tmp"
rm -rf $SUPER
if [ "$(find $DIR/system.img -type f ! -size 0 -printf '%S\n' | sed 's/.\.[0-9]*//')" == 1 ]; then
echo "PRC"
else
simg2img $DIR/system.img $DIR/system.raw.img
fi
if [ -e "$DIR/odm.img" ]; then
if [ -e "$DIR/product.img" ]; then
if [ "$(ls -nl $DIR/product.img | awk '{print $5}')" -gt 6000 ]; then
cp -rf universal/product.img $DIR/product.img
fi
else
cp -rf universal/product.img $DIR/product.img
fi
lpmake --metadata-size 65536 --super-name super --metadata-slots 2 --device super:$(<$TMP_ENVIRO/super_size.txt) --group main:$(<$TMP_ENVIRO/super_main.txt) --partition system:readonly:$(ls -nl $DIR/system.img | awk '{print $5}'):main --image system=$DIR/system.img --partition vendor:readonly:$(ls -nl $DIR/vendor.img | awk '{print $5}'):main --image vendor=$DIR/vendor.img --partition product:readonly:$(ls -nl $DIR/product.img | awk '{print $5}'):main --image product=$DIR/product.img --partition odm:readonly:$(ls -nl $DIR/odm.img | awk '{print $5}'):main --image odm=$DIR/odm.img --sparse --output $DIR/super.img
else
if [ -e "$DIR/product.img" ]; then
if [ "$(ls -nl $DIR/product.img | awk '{print $5}')" -gt 6000 ]; then
cp -rf universal/product.img $DIR/product.img
fi
else
cp -rf universal/product.img $DIR/product.img
fi
if [ ! -e "$DIR/system_ext.img" ]; then
cp -rf universal/system_ext.img $DIR/product.img
else
cp -rf universal/system_ext.img $DIR/product.img
fi
lpmake --metadata-size 65536 --super-name super --metadata-slots 2 --device super:$(<$TMP_ENVIRO/super_size.txt) --group main:$(<$TMP_ENVIRO/super_main.txt) --partition system:readonly:$(ls -nl $DIR/system.img | awk '{print $5}'):main --image system=$DIR/system.img --partition vendor:readonly:$(ls -nl $DIR/vendor.img | awk '{print $5}'):main --image vendor=$DIR/vendor.img --partition product:readonly:$(ls -nl $DIR/product.img | awk '{print $5}'):main --image product=$DIR/product.img --partition system_ext:readonly:$(ls -nl $DIR/system_ext.img | awk '{print $5}'):main --image system_ext=$DIR/system_ext.img --sparse --output $DIR/super.img
fi
- name: Packing the image
run: |
# Tryna make sure lol
export DIR="$(pwd)/image_build"
export ODM="$DIR/odm.img"
export SYSTEM="$DIR/system.img"
export SYSTEM_EXT="$DIR/system_ext.img"
export VENDOR="$DIR/vendor.img"
export SUPER="$DIR/super.img"
# Add some temps
export TMP_ENVIRO="$(pwd)/tmp"
export SELECT_SLIDER="${{ github.event.inputs.COMPRESSION_CHOICE }}"
export NAME_CHOICE="${{ github.event.inputs.NAME_ID }}"
case "$SELECT_SLIDER" in
"tar")
tar -cvf "$(pwd)/$NAME_CHOICE.tar" image_build/super.img
;;
"xz")
tar --xz -Jcvf "$(pwd)/$NAME_CHOICE.tar.xz" image_build/super.img
;;
"7z")
7za a -mx=9 "$(pwd)/$NAME_CHOICE.7z" image_build/super.img
;;
# "uncompressed")
# echo "Bruh, ok"
# ;;
esac
- name: Upload to Github Artifacts, tar
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.inputs.NAME_REL }}
path: |
"${{ github.event.inputs.NAME_ID }}.tar"
compression-level: 9
- name: Upload to Github Artifacts, tar.xz
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.inputs.NAME_REL }}
path: |
"${{ github.event.inputs.NAME_ID }}.tar.xz"
compression-level: 9
- name: Upload to Github Artifacts, 7z
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.inputs.NAME_REL }}
path: |
"${{ github.event.inputs.NAME_ID }}.7z"
compression-level: 9
- name: Upload to Github Releases
continue-on-error: true
uses: softprops/action-gh-release@v2
with:
files: |
*.tar
*.tar.xz
*.7z
name: ${{ github.event.inputs.NAME_REL }} - ${{ github.run_id }}
tag_name: ${{ github.run_id }}
body: |
Super Image File used: ${{ github.event.inputs.SUPER_LOCATE }}
GSI Downloaded:
Compressed: ${{ github.event.inputs.GSI_IMG_LOCATION_CMP }}
Uncompressed: ${{ github.event.inputs.GSI_IMG_LOCATION_XT }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}