4 Commits

Author SHA1 Message Date
Attila Lendvai
7a3ae89b20 added a manifest.scm for guix 2023-10-23 00:09:19 +02:00
Attila Lendvai
0d4d33409e set SOURCE_DATE_EPOCH
without this the image builder fails.

this might be connected to the inability of the configure script to
properly detect git on guix, but not likely.
2023-10-22 22:48:41 +02:00
Attila Lendvai
836235e656 use OpenWrt 19.07.9 2023-10-22 22:22:22 +02:00
Attila Lendvai
ab6816284f decrease memory need of dd while erasing the partition table
this was leading to the OOM killer killing dd.
2023-10-22 21:53:49 +02:00
6 changed files with 77 additions and 60 deletions

View File

@@ -5,15 +5,12 @@ It's a script to build a customized
firmware image using firmware image using
[ImageBuilder](https://openwrt.org/docs/guide-user/additional-software/imagebuilder). [ImageBuilder](https://openwrt.org/docs/guide-user/additional-software/imagebuilder).
If the generated image is flashed on a device it will try to If the generated image is flashed on a device it will try to automatically set up
automatically set up
[extroot](https://openwrt.org/docs/guide-user/additional-software/extroot_configuration) [extroot](https://openwrt.org/docs/guide-user/additional-software/extroot_configuration)
on **any (!)** storage device plugged into the USB port (`/dev/sda`), on **any (!)** storage device plugged into the USB port (`/dev/sda`). Keep in
including your working extroot pendrive if you plug it in only later mind that **this will erase any inserted storage device while the
in the boot process. Keep in mind that **this will erase any inserted router is in the initial setup phase**! Unfortunately there's little
storage device while the router is in the initial setup phase**! that can be done at that point to ask the user for confirmation.
Unfortunately there's little that can be done at that point to ask the
user for confirmation.
# Why # Why
@@ -31,20 +28,17 @@ You can read more about the underlying technology on the OpenWRT wiki: see e.g.
page, or the page that lists some other page, or the page that lists some other
[ImageBuilder frontends](https://openwrt.org/docs/guide-developer/imagebuilder_frontends). [ImageBuilder frontends](https://openwrt.org/docs/guide-developer/imagebuilder_frontends).
As for the actual mechanism: custom scripts are baked into the boot As for the actual mechanism: custom scripts are baked into the boot process of the
process of the flashed firmware. If the extroot overlay is properly flashed firmware. If the extroot overlay is properly set up, then these scripts get hidden by it;
set up, then these scripts get hidden by it; i.e. they will only run i.e. they will only run when the extroot has failed to mount early in the boot.
when the extroot has failed to mount early in the boot process.
### Building ### Building
OpenWRT's ImageBuilder only works on Linux x86_64. To build a firmware, issue the following command: OpenWRT's ImageBuilder only works on Linux x86_64. To build a firmware, issue the following command:
`./build.sh architecture variant device-profile`, e.g.: `./build.sh architecture variant device-profile`, e.g.:
* `./build.sh ath79 generic tplink_tl-wr1043nd-v1` * `./build.sh ar71xx generic tplink_tl-wr1043nd-v1`
* `./build.sh ath79 generic tplink_archer-c6-v2` * `./build.sh ath79 generic tplink_archer-c6-v2`
* `./build.sh ath79 generic tplink_tl-wdr4300-v1`
* `./build.sh bcm53xx generic dlink_dir-885l`
Results will be under `build/openwrt-imagebuilder-${release}-${architecture}-${variant}.Linux-x86_64/bin/`. Results will be under `build/openwrt-imagebuilder-${release}-${architecture}-${variant}.Linux-x86_64/bin/`.
@@ -99,12 +93,11 @@ probably want to customize this script here and there; search for
Most importantly, **set up a password and maybe an ssh key**. Most importantly, **set up a password and maybe an ssh key**.
At the time of writing it only supports a few `ath79` routers out of At the time of writing it only supports a few `ar71xx` routers out of the box,
the box, but it's easy to extend it. Support for a new router entails but it's easy to extend it. Support for a new router entails looking up
looking up some led names for `setLedAttribute` so that there's some led names for setLedAttribute for the user feedback through the blinking of
feedback to the user through the blinking of the leds. It should work the leds. It should work fine without that, but it will be less convenient to
fine without that, but it will be less convenient to interact with interact with your router in the initial setup phase.
your router in the initial setup phase.
# Troubleshooting # Troubleshooting
@@ -112,7 +105,7 @@ your router in the initial setup phase.
You should consult the [OpenWRT documentation](https://openwrt.org/docs/guide-user/start). You should consult the [OpenWRT documentation](https://openwrt.org/docs/guide-user/start).
The produced firmware files should be somewhere around The produced firmware files should be somewhere around
```./build/openwrt-imagebuilder-21.02.0-ath79-generic.Linux-x86_64/bin/targets/ath79/generic/```. ```build/openwrt-imagebuilder-17.01.4-ar71xx-generic.Linux-x86_64/bin/ar71xx```.
In short: In short:

View File

@@ -12,7 +12,7 @@ BUILD=`readlink -f $BUILD`
### ###
### chose a release ### chose a release
### ###
RELEASE="21.02.7" RELEASE="19.07.9"
IMGBUILDER_NAME="openwrt-imagebuilder-${RELEASE}-${TARGET_ARCHITECTURE}-${TARGET_VARIANT}.Linux-x86_64" IMGBUILDER_NAME="openwrt-imagebuilder-${RELEASE}-${TARGET_ARCHITECTURE}-${TARGET_VARIANT}.Linux-x86_64"
IMGBUILDER_DIR="${BUILD}/${IMGBUILDER_NAME}" IMGBUILDER_DIR="${BUILD}/${IMGBUILDER_NAME}"
@@ -26,10 +26,9 @@ IMGBUILDERURL="https://downloads.openwrt.org/releases/${RELEASE}/targets/${TARGE
if [ -z ${TARGET_DEVICE} ]; then if [ -z ${TARGET_DEVICE} ]; then
echo "Usage: $0 architecture variant device-profile" echo "Usage: $0 architecture variant device-profile"
echo " e.g.: $0 ath79 generic tplink_tl-wr1043nd-v1" echo " e.g.: $0 ar71xx generic tplink_tl-wr1043nd-v1"
echo " $0 ath79 generic tplink_archer-c6-v2" echo " $0 ath79 generic tplink_archer-c6-v2"
echo " $0 ath79 generic tplink_tl-wdr4300-v1" echo " $0 bcm53xx generic dlink-dir-885l"
echo " $0 bcm53xx generic dlink_dir-885l"
echo " (this last one will not work without editing build.sh, details: https://github.com/attila-lendvai/openwrt-auto-extroot/pull/15#issuecomment-405847440)" echo " (this last one will not work without editing build.sh, details: https://github.com/attila-lendvai/openwrt-auto-extroot/pull/15#issuecomment-405847440)"
echo " to get a list of supported devices issue a 'make info' in the OpenWRT image builder directory:" echo " to get a list of supported devices issue a 'make info' in the OpenWRT image builder directory:"
echo " '${IMGBUILDER_DIR}'" echo " '${IMGBUILDER_DIR}'"
@@ -37,8 +36,8 @@ if [ -z ${TARGET_DEVICE} ]; then
fi fi
# the absolute minimum for extroot to work at all (i.e. when the disk is already set up, for example by hand). # the absolute minimum for extroot to work at all (i.e. when the disk is already set up, for example by hand).
# this list may be smaller and/or different for your router, but it works with my ath79. # this list may be smaller and/or different for your router, but it works with my ar71xx.
PREINSTALLED_PACKAGES="block-mount kmod-fs-ext4 kmod-usb-storage" PREINSTALLED_PACKAGES="block-mount kmod-usb2 kmod-usb-storage kmod-fs-ext4"
# some kernel modules may also be needed for your hardware # some kernel modules may also be needed for your hardware
#PREINSTALLED_PACKAGES+=" kmod-usb-uhci kmod-usb-ohci" #PREINSTALLED_PACKAGES+=" kmod-usb-uhci kmod-usb-ohci"
@@ -71,6 +70,9 @@ fi
pushd ${IMGBUILDER_DIR} pushd ${IMGBUILDER_DIR}
# Without this the image builder fails.
export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD)
make image PROFILE=${TARGET_DEVICE} PACKAGES="${PREINSTALLED_PACKAGES}" FILES=${IMGTEMPDIR} make image PROFILE=${TARGET_DEVICE} PACKAGES="${PREINSTALLED_PACKAGES}" FILES=${IMGTEMPDIR}
pushd bin/targets/${TARGET_ARCHITECTURE}/ pushd bin/targets/${TARGET_ARCHITECTURE}/

View File

@@ -10,34 +10,33 @@ rootUUID=05d615b3-bef8-460c-9a23-52db8d09e000
dataUUID=05d615b3-bef8-460c-9a23-52db8d09e001 dataUUID=05d615b3-bef8-460c-9a23-52db8d09e001
swapUUID=05d615b3-bef8-460c-9a23-52db8d09e002 swapUUID=05d615b3-bef8-460c-9a23-52db8d09e002
. /lib/functions.sh if [ -f /lib/ar71xx.sh ]; then
. /lib/ar71xx.sh
# let's attempt to define some defaults... # let's attempt to define some defaults...
autoprovisionUSBLed="green:usb" autoprovisionUSBLed="tp-link:green:usb"
autoprovisionStatusLed="green:qss" autoprovisionStatusLed="tp-link:green:qss"
echo Board name is [$(board_name)]
# CUSTOMIZE # CUSTOMIZE
case $(board_name) in case $(ar71xx_board_name) in
*tl-wr1043nd*) "tl-wr1043nd")
autoprovisionUSBLed="green:usb" autoprovisionUSBLed="tp-link:green:usb"
autoprovisionStatusLed="green:qss" autoprovisionStatusLed="tp-link:green:qss"
;; ;;
*tl-mr3020*) "tl-mr3020")
autoprovisionUSBLed="green:wps" autoprovisionUSBLed="tp-link:green:wps"
autoprovisionStatusLed="green:wlan" autoprovisionStatusLed="tp-link:green:wlan"
;; ;;
*tl-wr2543n*) "tl-wr2543n")
autoprovisionUSBLed="green:wps" autoprovisionUSBLed="tp-link:green:wps"
autoprovisionStatusLed="green:wlan5g" autoprovisionStatusLed="tp-link:green:wlan5g"
;; ;;
*tl-wdr4300*) "tl-wdr4300")
autoprovisionUSBLed="green:wlan2g" autoprovisionUSBLed="tp-link:blue:wan"
autoprovisionStatusLed="green:wlan5g" autoprovisionStatusLed="tp-link:blue:qss"
;; ;;
esac esac
fi
log() log()
{ {

View File

@@ -73,8 +73,8 @@ EOF
done done
mkswap -L swap -U $swapUUID /dev/sda1 mkswap -L swap -U $swapUUID /dev/sda1
mkfs.ext4 -F -L root -U $rootUUID /dev/sda2 mkfs.ext4 -L root -U $rootUUID /dev/sda2
mkfs.ext4 -F -L data -U $dataUUID /dev/sda3 mkfs.ext4 -L data -U $dataUUID /dev/sda3
log "Finished setting up filesystems" log "Finished setting up filesystems"
} }

View File

@@ -50,9 +50,6 @@ autoprovisionStage2()
else else
signalAutoprovisionWorking signalAutoprovisionWorking
echo Updating system time using ntp; otherwise the openwrt.org certificates are rejected as not yet valid.
ntpd -d -q -n -p 0.openwrt.pool.ntp.org
# CUSTOMIZE: with an empty argument it will set a random password and only ssh key based login will work. # CUSTOMIZE: with an empty argument it will set a random password and only ssh key based login will work.
# please note that stage2 requires internet connection to install packages and you most probably want to log in # please note that stage2 requires internet connection to install packages and you most probably want to log in
# on the GUI to set up a WAN connection. but on the other hand you don't want to end up using a publically # on the GUI to set up a WAN connection. but on the other hand you don't want to end up using a publically

26
manifest.scm Normal file
View File

@@ -0,0 +1,26 @@
;; This is the complete list of Guix packages necessary for building.
;;
;; The following shell command will run the tests:
;;
;; guix shell -m manifest.scm --pure -- ./build.sh ath79 generic tplink_tl-wdr4300-v1
;;
;; TODO ...ideally. some dependencies are not listed, and it fails when using --pure
;;
;; Quircks on Guix: the check for git fails, must edit
;; build/openwrt-imagebuilder-19.07.9-ath79-generic.Linux-x86_64/include/prereq-build.mk
;; and comment out the git check.
;;
(specifications->manifest
'("coreutils"
"bash"
"make"
"perl"
"python2"
"gcc-toolchain"
"git"
"git:gui"
;; "man-pages"
"less"
"time"))