k03rader's avatar
k03rader 11 months ago
### Using the image-builder in practice Earlier we explained the ins and outs of building packages and images for OpenWRT. Now lets actually build a package rather than just talking about it. ##### Lets clone the image-builder ``` git clone ``` ##### Lets install a tool to interact with blossom servers ``` curl -sSL https://raw.githubusercontent.com/OpenTollGate/tollgate-sdk/refs/heads/main/blossom-installer.sh | sudo bash ``` ##### Lets install a python library for interacting with nostr relays ``` pip3 install nostr ``` ##### Lets prepare a file containing the keys for these tools ``` cat blossom_secrets.json { "servers": [ "https://files.v0l.io/", "https://nostr.download/", "https://blossom.poster.place/" ], "relays": [ "wss://orangesync.tech", "wss://nostr.mom", "wss://nostr.chaima.info" ], "secret_key": "nsec[your_secret_key]", "secret_key_hex": "[hex_version_of_your_secret_key]", "public_key": "npub[your_public_key]", "public_key_hex": "[hex_version_of_your_public_key]" } ``` ##### Lets go! ``` ./build-firmware gl-mt3000 ``` The above script * downloads the OpenWRT image-builder * downloads your [custom packages]( from blossom * [installs all the packages]( in an OpenWRT image > [!Known bug] > You might get an error saying that the websocket connection to your nostr relays can't be opened. In that case, just abort and run the above command again. It often works on the second try. > ``` > DEBUG: Error getting event: socket is already closed. No valid events found for architecture: aarch64_cortex-a53 > ``` > Pull requests welcome.. ##### Are you winning? Eventually you should see the following output. This is the nostr event that your npub just broadcasted to announce that you compiled your custom feed successfully and that your packages are available on this listed blossom servers. Maybe @franzap has advice on how we can improve this workflow. ``` Number of ids (unique uids + gids) 1 Number of uids 1 unknown (0) Number of gids 1 unknown (0) Exportable Squashfs 4.0 filesystem, xz compressed, data block size 262144 compressed data, compressed metadata, compressed fragments, no xattrs, compressed ids duplicates are removed Filesystem size 64302.32 Kbytes (62.80 Mbytes) 24.24% of uncompressed filesystem size (265222.92 Kbytes) Inode table size 109854 bytes (107.28 Kbytes) 20.87% of uncompressed inode table size (526354 bytes) Directory table size 140778 bytes (137.48 Kbytes) 38.40% of uncompressed directory table size (366654 bytes) Number of duplicate files found 494 Number of inodes 16283 Number of files 14440 Number of fragments 371 Number of symbolic links 242 Number of device nodes 1 Number of fifo nodes 0 Number of socket nodes 0 Number of directories 1600 Number of hard-links 0 Number of ids (unique uids + gids) 1 Number of uids 1 unknown (0) Number of gids 1 unknown (0) 64302+1 records in 64303+0 records out 65846272 bytes (66 MB, 63 MiB) copied, 0.091405 s, 720 MB/s 64302+1 records in 64303+0 records out 65846272 bytes (66 MB, 63 MiB) copied, 0.091405 s, 720 MB/s /tmp/openwrt-build/openwrt-imagebuilder-23.05.3-mediatek-filogic.Linux-x86_64/staging_dir/host/bin/tar: Option --mtime: Treating date '@1711145382' as 2024-03-22 23:09:42 sysupgrade-glinet_gl-mt3000/ sysupgrade-glinet_gl-mt3000/CONTROL sysupgrade-glinet_gl-mt3000/kernel /tmp/openwrt-build/openwrt-imagebuilder-23.05.3-mediatek-filogic.Linux-x86_64/staging_dir/host/bin/tar: Option --mtime: Treating date '@1711145382' as 2024-03-22 23:09:42 sysupgrade-glinet_gl-mt3000/ sysupgrade-glinet_gl-mt3000/CONTROL sysupgrade-glinet_gl-mt3000/kernel sysupgrade-glinet_gl-mt3000/root sysupgrade-glinet_gl-mt3000/root Calculating checksums... Calculating checksums... Build successful! Firmware image created at: Image size (62.7952 62.7952MB) /tmp/openwrt-build/openwrt-imagebuilder-23.05.3-mediatek-filogic.Linux-x86_64/bin/targets/mediatek/filogic/openwrt-23.05.3-mediatek-filogic-glinet_gl-mt3000-squashfs-sysupgrade.bin ``` image ##### How do I install this thing? Copy the `sysupgrade.bin` file to the `/tmp` directory of your router. ``` scp /tmp/openwrt-build/openwrt-imagebuilder-23.05.3-mediatek-filogic.Linux-x86_64/bin/targets/mediatek/filogic/openwrt-23.05.3-mediatek-filogic-glinet_gl-mt3000-squashfs-sysupgrade.bin root@[routers-ip-address]:/tmp ``` > [!NOTE] > The `/tmp` directory is part of your device's RAM rather than its (small) flash storage, so it should have a lot of space for such binaries. Now lets install it ``` sysupgrade -n [your-sysupgrade-file].bin ``` Please leave your router plugged in and give it a minute or two of time to install the new image. It might show up with a new IP address and you will be prompted to delete the old router from your cached `ssh` keys when you try to log in to it. ##### How can you help? #help * do you know how to make git actions for this? * we are [struggling](View quoted note →) to build images for the `gl-ar300m` target. This might be connected with the fact that there are two similar devices (`gl-ar300m` and `gl-ar300m16`) that don't have the exact same architecture * have you fixed that bug already? * please DM us if you have questions or your looking for other ways to contribute