1010#  * we are not offering as many choices to users and are designing around automation.
1111#  Later we can make this work for more devices and platforms with nearly the same technique.
1212#  Reasonable build targets include: https://archlinuxarm.org/platforms/armv8
13- #  For example, the Odroid-N2  is the same software-wise as our Router!
13+ #  For example, the Odroid-C2  is the same software-wise as our Router!
1414
1515#  Fail on error
1616set  -exo pipefail
@@ -46,31 +46,32 @@ sudo bash -c "echo starport > ./.tmp/result-rootfs/etc/hostname"
4646#  ===================================================================================
4747
4848
49- #  Unmount anything on the loop device
50- sudo umount /dev/loop0p2 ||  true 
51- sudo umount /dev/loop0p1 ||  true 
49+ #  Unmount anything on the loop device (uncomment if building on metal and "working in a loop") 
50+ #   sudo umount /dev/loop0p2 || true
51+ #   sudo umount /dev/loop0p1 || true
5252
53- #  Detach from the loop device
54- sudo losetup -d /dev/loop0 ||  true 
53+ #  Detach from the loop device (uncomment if building on metal and "working in a loop") 
54+ #   sudo losetup -d /dev/loop0 || true
5555
56- #  Create a folder for images
57- rm -rf images ||  true 
58- mkdir -p  images
56+ #  Create a folder for images (uncomment if building on metal and "working in a loop") 
57+ #   rm -rf images || true
58+ mkdir images
5959
6060#  Make the image file
6161fallocate -l 4G " images/starport.img" 
6262
63+ 
6364#  loop-mount the image file so it becomes a disk
64- sudo losetup --find --show images/starport.img
65+ export  LOOP= $( sudo losetup --find --show images/starport.img) 
6566
6667#  partition the loop-mounted disk
67- sudo parted --script /dev/loop0  mklabel msdos
68- sudo parted --script /dev/loop0  mkpart primary fat32 0% 200M
69- sudo parted --script /dev/loop0  mkpart primary ext4 200M 100%
68+ sudo parted --script $LOOP  mklabel msdos
69+ sudo parted --script $LOOP  mkpart primary fat32 0% 200M
70+ sudo parted --script $LOOP  mkpart primary ext4 200M 100%
7071
7172#  format the newly partitioned loop-mounted disk
72- sudo mkfs.vfat -F32 /dev/loop0p1 
73- sudo mkfs.ext4 -F /dev/loop0p2 
73+ sudo mkfs.vfat -F32 $( echo  $LOOP ) p1 
74+ sudo mkfs.ext4 -F $( echo  $LOOP ) p2 
7475
7576#  Use the toolbox to copy the rootfs into the filesystem we formatted above.
7677#  * mount the disk's /boot and / partitions
@@ -79,12 +80,12 @@ sudo mkfs.ext4 -F /dev/loop0p2
7980#  soon will not use toolbox
8081
8182sudo mkdir -p mnt/boot mnt/rootfs
82- sudo mount /dev/loop0p1  mnt/boot
83- sudo mount /dev/loop0p2  mnt/rootfs
83+ sudo mount $( echo  $LOOP ) p1  mnt/boot
84+ sudo mount $( echo  $LOOP ) p2  mnt/rootfs
8485sudo rsync -a ./.tmp/result-rootfs/boot/*  mnt/boot
8586sudo rsync -a ./.tmp/result-rootfs/*  mnt/rootfs --exclude boot
8687sudo mkdir mnt/rootfs/boot
87- sudo umount mnt/boot mnt/rootfs  ||   true 
88+ sudo umount mnt/boot mnt/rootfs
8889
89- #  Drop the loop mount
90- sudo losetup -d /dev/loop0
90+ #  Drop the loop mount (uncomment if building outside of Github Actions) 
91+ #   sudo losetup -d /dev/loop0
0 commit comments