forked from davycnn/arpl-i18n
-
Notifications
You must be signed in to change notification settings - Fork 0
/
img-gen.sh
executable file
·68 lines (53 loc) · 1.79 KB
/
img-gen.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
#!/usr/bin/env bash
set -e
. scripts/func.sh
# Convert po2mo
convertpo2mo "files/initrd/opt/rr/lang"
IMAGE_FILE="rr.img"
gzip -dc "files/grub.img.gz" >"${IMAGE_FILE}"
fdisk -l "${IMAGE_FILE}"
LOOPX=$(sudo losetup -f)
sudo losetup -P "${LOOPX}" "${IMAGE_FILE}"
echo "Mounting image file"
sudo rm -rf "/tmp/files/p1"
sudo rm -rf "/tmp/files/p3"
sudo mkdir -p "/tmp/files/p1"
sudo mkdir -p "/tmp/files/p3"
sudo mount ${LOOPX}p1 "/tmp/files/p1"
sudo mount ${LOOPX}p3 "/tmp/files/p3"
echo "Get Buildroot"
[ ! -f "br/bzImage-rr" -o ! -f "br/initrd-rr" ] && getBuildroot "2023.02.x" "br"
[ ! -f "br/bzImage-rr" -o ! -f "br/initrd-rr" ] && return 1
read -p "Press enter to continue"
echo "Repack initrd"
sudo cp -f "br/bzImage-rr" "/tmp/files/p3/bzImage-rr"
repackInitrd "br/initrd-rr" "files/initrd" "/tmp/files/p3/initrd-rr"
echo "Copying files"
sudo cp -Rf "files/p1/"* "/tmp/files/p1"
sudo cp -Rf "files/p3/"* "/tmp/files/p3"
# Get extractor, LKM, addons and Modules
getLKMs "/tmp/files/p3/lkms" true
getAddons "/tmp/files/p3/addons" true
getModules "/tmp/files/p3/modules" true
getExtractor "/tmp/files/p3/extractor"
sync
# update.zip
sha256sum update-list.yml update-check.sh >sha256sum
zip -9j update.zip update-list.yml update-check.sh
while read F; do
if [ -d "/tmp/${F}" ]; then
FTGZ="$(basename "/tmp/${F}").tgz"
tar -czf "${FTGZ}" -C "/tmp/${F}" .
sha256sum "${FTGZ}" >>sha256sum
zip -9j update.zip "${FTGZ}"
sudo rm -f "${FTGZ}"
else
(cd $(dirname "/tmp/${F}") && sha256sum $(basename "/tmp/${F}")) >>sha256sum
zip -9j update.zip "/tmp/${F}"
fi
done < <(yq '.replace | explode(.) | to_entries | map([.key])[] | .[]' update-list.yml)
zip -9j update.zip sha256sum
echo "Unmount image file"
sudo umount "/tmp/files/p1"
sudo umount "/tmp/files/p3"
sudo losetup --detach ${LOOPX}