diff --git a/.github/workflows/mikrotik_patch.yml b/.github/workflows/mikrotik_patch.yml index 99b57ba..b6dd16f 100644 --- a/.github/workflows/mikrotik_patch.yml +++ b/.github/workflows/mikrotik_patch.yml @@ -149,7 +149,7 @@ jobs: cd ./new_iso sudo zip ../all_packages-x86-$LATEST_VERSION.zip *.npk cd .. - sudo rm -rf ./new_iso + #sudo rm -rf ./new_iso - name: Create chr-${{ env.LATEST_VERSION }}.img run: | @@ -185,8 +185,7 @@ jobs: sudo chmod +x extlinux sudo ./extlinux --install -H 64 -S 32 ./img/boot/BOOT echo -e "default system\nlabel system\n\tkernel /EFI/BOOT/BOOTX64.EFI\n\tappend load_ramdisk=1 root=/dev/ram0 quiet" > syslinux.cfg - sudo cp syslinux.cfg ./img/boot/BOOT/ - sudo rm syslinux.cfg + sudo mv syslinux.cfg ./img/boot/BOOT/ sudo umount /dev/nbd0p1 sudo mount /dev/nbd0p2 ./img/routeros/ sudo mkdir -p ./img/routeros/{var/pdb/{system,option},rw/disk,dev,boot} @@ -219,31 +218,63 @@ jobs: sudo rm *.vdi sudo rm *.img - - name: Get install-image-${{ env.LATEST_VERSION }}.img - run: | - sudo wget -nv -O install-image-$LATEST_VERSION.zip https://download.mikrotik.com/routeros/$LATEST_VERSION/install-image-$LATEST_VERSION.zip - sudo unzip install-image-$LATEST_VERSION.zip - sudo rm install-image-$LATEST_VERSION.zip - - - name: Patch install-image-${{ env.LATEST_VERSION }}.img + - name: Create install-image-${{ env.LATEST_VERSION }}.img run: | + truncate --size 128M install-image-$LATEST_VERSION.img + sudo qemu-nbd -c /dev/nbd0 -f raw install-image-$LATEST_VERSION.img + sudo mkfs.vfat -n "Install" /dev/nbd0 sudo mkdir ./install - sudo mount -o loop install-image-$LATEST_VERSION.img ./install - sudo rm ./install/1.npk - NPK_FILES=$(find ./install/*.npk) - for file in $NPK_FILES; do - sudo -E python3 npk.py sign $file $file - done - sudo cp routeros-$LATEST_VERSION.npk ./install/1.npk - sudo cp keygen.zip ./install/ - sudo cp option-$LATEST_VERSION.npk ./install/100.npk - sudo cp python3-$LATEST_VERSION.npk ./install/101.npk + sudo mount /dev/nbd0 ./install + sudo mkdir -p ./install/EFI/BOOT + sudo wget -nv -O refind-bin-0.14.2.zip https://nchc.dl.sourceforge.net/project/refind/0.14.2/refind-bin-0.14.2.zip + sudo unzip refind-bin-0.14.2.zip + sudo rm refind-bin-0.14.2.zip + sudo cp refind-bin-0.14.2/refind/refind_x64.efi ./install/EFI/BOOT/BOOTX64.EFI + echo -e 'timeout 0\ntextonly\ntextmode 0\nshowtools shutdown, reboot, exit\nmenuentry "Install RouterOS" {\n\tloader /linux\n\toptions "load_ramdisk=1 root=/dev/ram0 -install -hdd"\n}\ndefault_selection /EFI/BOOT/BOOTX64.EFI' \ + > refind.conf + sudo mv refind.conf ./install/EFI/BOOT/ + sudo ./extlinux --install -H 64 -S 32 ./install/ + echo -e 'default system\nLABEL system\n\tKERNEL linux\n\tAPPEND load_ramdisk=1 -install -hdd' \ + > syslinux.conf + sudo mv syslinux.conf ./install/ sudo cp linux ./install/ - sudo umount ./install + NPK_FILES=$(find ./new_iso/*.npk) + for ((i=1; i<=${#NPK_FILES[@]}; i++)) + do + sudo cp ${fruits[$i-1]} ./install/$i.npk + done + sudo umount /dev/nbd0 + sudo qemu-nbd -d /dev/nbd0 sudo rm -rf ./install + sudo rm -rf ./new_iso sudo zip install-image-$LATEST_VERSION.zip ./install-image-$LATEST_VERSION.img sudo rm ./install-image-$LATEST_VERSION.img + # - name: Get install-image-${{ env.LATEST_VERSION }}.img + # run: | + # sudo wget -nv -O install-image-$LATEST_VERSION.zip https://download.mikrotik.com/routeros/$LATEST_VERSION/install-image-$LATEST_VERSION.zip + # sudo unzip install-image-$LATEST_VERSION.zip + # sudo rm install-image-$LATEST_VERSION.zip + + # - name: Patch install-image-${{ env.LATEST_VERSION }}.img + # run: | + # sudo mkdir ./install + # sudo mount -o loop install-image-$LATEST_VERSION.img ./install + # sudo rm ./install/1.npk + # NPK_FILES=$(find ./install/*.npk) + # for file in $NPK_FILES; do + # sudo -E python3 npk.py sign $file $file + # done + # sudo cp routeros-$LATEST_VERSION.npk ./install/1.npk + # sudo cp keygen.zip ./install/ + # sudo cp option-$LATEST_VERSION.npk ./install/100.npk + # sudo cp python3-$LATEST_VERSION.npk ./install/101.npk + # sudo cp linux ./install/ + # sudo umount ./install + # sudo rm -rf ./install + # sudo zip install-image-$LATEST_VERSION.zip ./install-image-$LATEST_VERSION.img + # sudo rm ./install-image-$LATEST_VERSION.img + - name: Delete Release tag ${{ env.LATEST_VERSION }} run: | HEADER="Authorization: token ${{ secrets.GITHUB_TOKEN }}"