-
Notifications
You must be signed in to change notification settings - Fork 1
/
no-gdisk-arm64
99 lines (75 loc) · 3.14 KB
/
no-gdisk-arm64
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
#!/bin/bash
#ROS7=`curl https://download.mikrotik.com/routeros/NEWESTa7.stable | awk '{print $1}'`
#ROS7testing=`curl https://download.mikrotik.com/routeros/NEWESTa7.testing | awk '{print $1}'`
#ROS7longterm=`curl https://download.mikrotik.com/routeros/NEWESTa7.long-term | awk '{print $1}'`
#ROS7dev=`curl https://download.mikrotik.com/routeros/NEWESTa7.development | awk '{print $1}'`
#for ROSVER in $ROS7 $ROS7testing ;
#do
ROSVER=$1
wget -nv --no-check-certificate https://download.mikrotik.com/routeros/$ROSVER/chr-$ROSVER-arm64.img.zip -O /tmp/chr-$ROSVER.img.zip
unzip -p /tmp/chr-$ROSVER.img.zip > /tmp/chr-$ROSVER.img
rm -rf chr-$ROSVER.qcow2
qemu-img convert -f raw -O qcow2 /tmp/chr-$ROSVER.img chr-$ROSVER.qcow2
rm -rf /tmp/chr-$ROSVER.im*
modprobe nbd
qemu-nbd -c /dev/nbd0 chr-$ROSVER.qcow2
sleep 5
lsblk
rm -rf /tmp/tmp*
mkdir /tmp/tmpmount/
mkdir diskfiles
mkdir /tmp/tmpefipart/
mount /dev/nbd0p1 /tmp/tmpmount/
rsync -a /tmp/tmpmount/ /tmp/tmpefipart/
mkdir diskfiles/part1
rsync -a /tmp/tmpmount/ ./diskfiles/part1/
umount /dev/nbd0p1
mkfs -t fat /dev/nbd0p1
mount /dev/nbd0p1 /tmp/tmpmount/
rsync -a /tmp/tmpefipart/ /tmp/tmpmount/
umount /dev/nbd0p1
mount /dev/nbd0p2 /tmp/tmpmount/
mkdir diskfiles/part2
rsync -a /tmp/tmpmount/ ./diskfiles/part2/
umount /dev/nbd0p2
echo "/tmp..."
ls /tmp
echo "/diskfiles..."
ls diskfiles
rm -rf /tmp/tmp*
echo "unmount orginal image"
qemu-nbd -d /dev/nbd0
sleep 2
echo "created file chr.qcow2, now back to raw but uncompressed..."
qemu-img convert -f qcow2 -O raw chr-$ROSVER.qcow2 chr-$ROSVER.uefi-fat.raw
echo "created file chr.vmdk too"
qemu-img convert -O vmdk chr-$ROSVER.uefi-fat.raw chr-$ROSVER.uefi-fat.vmdk
echo "created file ZIP with raw files (for debuging)"
# docs say dmg is not a valid OUTPUT...
#qemu-img convert -O dmg chr-$ROSVER.uefi-fat.raw chr-$ROSVER.uefi-fat.dmg
# tried using hfsplus instead... also not as easy
zip -r partition-debug-$ROSVER.zip diskfiles
echo "*** created chr-$ROSVER.uefi-fat for RAW and VMDK"
sleep 1
echo "downloading extra-packages"
wget -nv --no-check-certificate https://download.mikrotik.com/routeros/$ROSVER/all_packages-arm64-$ROSVER.zip -O /tmp/all_packages-arm64-$ROSVER.zip
mkdir /tmp/all_packages-arm64-$ROSVER
unzip /tmp/all_packages-arm64-$ROSVER.zip -d /tmp/all_packages-arm64-$ROSVER
echo "create disk image with extra-packages for mounting"
mkdir /tmp/tmpmntpkg
qemu-img create -f raw chr-extra-packages-$ROSVER-arm64.img 16M
parted chr-extra-packages-$ROSVER-arm64.img mklabel msdos
parted chr-extra-packages-$ROSVER-arm64.img mkpart primary fat32 1MiB 100%
mkfs.fat -F32 chr-extra-packages-$ROSVER-arm64.img
mount -o loop chr-extra-packages-$ROSVER-arm64.img /tmp/tmpmntpkg
cp /tmp/all_packages-arm64-$ROSVER/* /tmp/tmpmntpkg
chmod a-w /tmp/tmpmntpkg/*
umount /tmp/tmpmntpkg
echo "created file chr.vmdk for extra packages too"
qemu-img convert -O vmdk chr-extra-packages-$ROSVER-arm64.img chr-extra-packages-$ROSVER-arm64.vmdk
echo "build CDROM image"
#genisoimage -l -J -R -o chr-extra-packages-$ROSVER.iso /tmp/all_packages-arm64-$ROSVER
mkisofs -R -J -l -iso-level 4 -o chr-extra-packages-$ROSVER-arm64.iso /tmp/all_packages-arm64-$ROSVER/
echo "*** done "
sleep 1
#done