From 89d627d380cab3c115a43ee78584503c981b8af8 Mon Sep 17 00:00:00 2001 From: Florian Maurer Date: Mon, 28 Oct 2024 08:49:55 +0100 Subject: [PATCH] use new image-customization-helper --- image-customization-helper.lua | 225 +++++++++++++++++++++++++++++++++ image-customization.lua | 90 +++---------- patches/3148.patch | 133 +++++++++++++++++++ 3 files changed, 374 insertions(+), 74 deletions(-) create mode 100644 image-customization-helper.lua create mode 100644 patches/3148.patch diff --git a/image-customization-helper.lua b/image-customization-helper.lua new file mode 100644 index 0000000..f9487f4 --- /dev/null +++ b/image-customization-helper.lua @@ -0,0 +1,225 @@ +#!/usr/bin/lua +has_usb = false +if device('cudy-wr1300-v1', +'ravpower-rp-wd009', +'enterasys-ws-ap3715i', +'d-link-dir-860l-b1', +'d-link-dir-882-a1', +'d-link-dir-505', +'gl.inet-gl-mt1300', +'gl.inet-gl-xe300', +'gl.inet-gl-usb150', +'gl.inet-gl-ar150', +'gl.inet-vixmini', +'gl.inet-gl-b1300', +'gl.inet-gl-ar750', +'gl.inet-gl-mt3000', +'gl.inet-gl-ar300m-lite', +'devolo-wifi-pro-1750e', +'onion-omega', +'asus-tuf-ax4200', +'asus-rt-ac51u', +'asus-tuf-ax6000', +'asus-rt-ax53u', +'linksys-wrt1200ac', +'aerohive-hiveap-330', +'netgear-wndr3800', +'netgear-wndrmac-v2', +'netgear-wndr3700-v2', +'netgear-wndr3700-v5', +'netgear-wndr3700-v4', +'netgear-r6260', +'netgear-r6120', +'netgear-dgn3500b', +'netgear-r6220', +'extreme-networks-ws-ap3825i', +'8devices-jalapeno', +'lemaker-banana-pro', +'ocedo-panda', +'aruba-ap-303h', +'aruba-ap-365', +'avm-fritz-box-7360-v2', +'avm-fritz-box-4040', +'avm-fritz-box-4020', +'avm-fritz-box-7530', +'xiaomi-mi-router-4c', +'tp-link-archer-c7-v5', +'tp-link-archer-d50-v1', +'tp-link-tl-wr1043nd-v3', +'tp-link-tl-wr842n-v3', +'tp-link-tl-wr902ac-v1', +'tp-link-tl-mr3420-v5', +'tp-link-archer-c50-v3', +'tp-link-archer-c7-v4', +'tp-link-tl-wr1043nd-v4', +'tp-link-tl-wr1043nd-v2', +'tp-link-tl-wr902ac-v3', +'tp-link-archer-a7-v5', +'tp-link-tl-wdr4900-v1', +'tp-link-td-w8980', +'tp-link-tl-mr3020-v3', +'tp-link-archer-c2600', +'tp-link-tl-wdr3600-v1', +'tp-link-archer-c59-v1', +'tp-link-tl-wdr3500-v1', +'zyxel-nbg6617', +'buffalo-wzr-600dhp', +'plasma-cloud-pa1200') then + has_usb = true +end + +has_lte = false +if device('zte-mf281', +'zte-mf289f', +'gl.inet-gl-xe300', +'wavlink-ws-wn572hp3-4g', +'tp-link-tl-mr6400-v5') then + has_lte = true +end + +is_outdoor = false +if device('devolo-wifi-pro-1750x', +'aruba-ap-365', +'wavlink-ws-wn572hp3-4g', +'tp-link-wbs210-v2', +'tp-link-cpe510-v3', +'tp-link-archer-c50-v4', +'tp-link-eap225-outdoor-v1', +'tp-link-archer-c50-v3', +'tp-link-wbs210-v1', +'tp-link-cpe510-v1', +'tp-link-cpe210-v1', +'tp-link-archer-c20-v5', +'tp-link-cpe220-v3', +'tp-link-cpe710-v1', +'tp-link-wbs510-v1', +'tp-link-cpe510-v2', +'tp-link-eap225-outdoor-v3', +'tp-link-cpe210-v3', +'tp-link-cpe210-v2', +'zyxel-nwa55axe', +'mikrotik-sxtsq-5-ac-rbsxtsqg-5acd', +'plasma-cloud-pa1200') then + is_outdoor = true +end + +no_wifi24 = false +if device('ubiquiti-edgerouter-x', +'ubiquiti-edgerouter-x-sfp', +'tp-link-cpe510-v3', +'tp-link-cpe510-v1', +'tp-link-cpe710-v1', +'tp-link-wbs510-v1', +'tp-link-cpe510-v2', +'mikrotik-sxtsq-5-ac-rbsxtsqg-5acd') then + no_wifi24 = true +end + +no_wifi50 = false +if device('sophos-ap15', +'d-link-dap-1365-a1', +'d-link-dap-1330-a1', +'d-link-dir-505', +'gl.inet-gl-xe300', +'gl.inet-gl-usb150', +'gl.inet-gl-ar150', +'gl.inet-vixmini', +'gl.inet-microuter-n300', +'gl.inet-gl-ar300m-lite', +'alfa-network-ap121f', +'onion-omega', +'netgear-dgn3500b', +'lemaker-banana-pro', +'ubiquiti-edgerouter-x', +'ubiquiti-unifi-ap', +'ubiquiti-edgerouter-x-sfp', +'avm-fritz-box-7360-v2', +'avm-fritz-box-7412', +'avm-fritz-box-7312', +'avm-fritz-wlan-repeater-450e', +'avm-fritz-box-4020', +'xiaomi-mi-router-4c', +'tp-link-wbs210-v2', +'tp-link-tl-wr1043nd-v3', +'tp-link-tl-wr842n-v3', +'tp-link-tl-mr3420-v5', +'tp-link-tl-wa801nd-v5', +'tp-link-tl-wr841n-v13', +'tp-link-wbs210-v1', +'tp-link-tl-wr1043nd-v4', +'tp-link-tl-wr1043nd-v2', +'tp-link-cpe210-v1', +'tp-link-cpe220-v3', +'tp-link-tl-wr1043n-v5', +'tp-link-tl-mr3020-v3', +'tp-link-cpe210-v3', +'tp-link-tl-mr6400-v5', +'tp-link-cpe210-v2', +'plasma-cloud-pa300', +'plasma-cloud-pa300e') then + no_wifi50 = true +end + +atmost_64mb_ram = false +if device('ravpower-rp-wd009', +'d-link-dap-1365-a1', +'d-link-dap-1330-a1', +'d-link-dir-505', +'gl.inet-gl-usb150', +'gl.inet-gl-ar150', +'gl.inet-vixmini', +'alfa-network-ap121f', +'onion-omega', +'asus-rt-ac51u', +'netgear-wndr3700-v2', +'netgear-ex6130', +'netgear-r6020', +'netgear-ex3700', +'netgear-ex6150', +'netgear-r6120', +'netgear-dgn3500b', +'ubiquiti-unifi-ap', +'avm-fritz-wlan-repeater-300e', +'avm-fritz-wlan-repeater-1750e', +'avm-fritz-box-7312', +'avm-fritz-wlan-repeater-450e', +'xiaomi-mi-router-4c', +'tp-link-archer-d50-v1', +'tp-link-wbs210-v2', +'tp-link-cpe510-v3', +'tp-link-archer-c50-v4', +'tp-link-re200-v2', +'tp-link-tl-wr1043nd-v3', +'tp-link-tl-wr842n-v3', +'tp-link-tl-wr902ac-v1', +'tp-link-tl-mr3420-v5', +'tp-link-re200-v3', +'tp-link-tl-wa801nd-v5', +'tp-link-tl-wr841n-v13', +'tp-link-archer-c50-v3', +'tp-link-archer-c50-v1', +'tp-link-archer-c60-v1', +'tp-link-archer-c2-v3', +'tp-link-wbs210-v1', +'tp-link-tl-wr1043nd-v4', +'tp-link-cpe510-v1', +'tp-link-re200-v4', +'tp-link-tl-wr1043nd-v2', +'tp-link-cpe210-v1', +'tp-link-archer-c20-v5', +'tp-link-tl-wr902ac-v3', +'tp-link-cpe220-v3', +'tp-link-wbs510-v1', +'tp-link-cpe510-v2', +'tp-link-tl-wr1043n-v5', +'tp-link-td-w8980', +'tp-link-tl-mr3020-v3', +'tp-link-cpe210-v3', +'tp-link-tl-mr6400-v5', +'tp-link-archer-c58-v1', +'tp-link-archer-c25-v1', +'tp-link-cpe210-v2', +'plasma-cloud-pa300', +'plasma-cloud-pa300e') then + atmost_64mb_ram = true +end diff --git a/image-customization.lua b/image-customization.lua index 874430f..b215af8 100644 --- a/image-customization.lua +++ b/image-customization.lua @@ -17,15 +17,15 @@ features { packages { 'iwinfo', - 'ffac-ssid-changer', 'ffac-wg-registration', - 'ff-web-ap-timer', 'respondd-module-airtime', 'tecff-general-workaround', - 'tecff-broken-wlan-workaround', } -if not device_class('tiny') then +include('image-customization-helper.lua') + +-- only add if not tiny and at more than 64MB RAM +if not device_class('tiny') and not atmost_64mb_ram then features { 'tls', 'wireless-encryption-wpa3', @@ -37,15 +37,17 @@ if not device_class('tiny') then } end -if device({ - 'zte-mf281', - 'glinet-gl-xe300', - 'glinet-gl-ap1300', - 'zte-mf289f', - 'zte-mf286r', - 'wavlink-ws-wn572hp3-4g', - 'tp-link-tl-mr6400-v5', - }) then + +-- include packages only if any wifi is available +if not no_wifi24 and not no_wifi50 then + packages { + 'ff-web-ap-timer', + 'ffac-ssid-changer', + 'tecff-broken-wlan-workaround', + } +end + +if has_lte then features { 'web-cellular', } @@ -113,68 +115,8 @@ pkgs_pci = { 'kmod-bnx2', -- Broadcom NetExtreme BCM5706/5708/5709/5716 } -include_usb = true - -- rtl838x has no USB support as of Gluon v2023.2 -if target('realtek', 'rtl838x') or target('ramips', 'mt7620') then - include_usb = false -end - --- 7M usable firmware space + USB port -if target('ath79', 'generic') and not device({ - 'devolo-wifi-pro-1750e', - 'gl.inet-gl-ar150', - 'gl.inet-gl-ar300m-lite', - 'gl.inet-gl-ar750', - 'joy-it-jt-or750i', - 'netgear-wndr3700-v2', - 'tp-link-archer-a7-v5', - 'tp-link-archer-c5-v1', - 'tp-link-archer-c7-v2', - 'tp-link-archer-c7-v5', - 'tp-link-archer-c59-v1', - 'tp-link-tl-wr842n-v3', - 'tp-link-tl-wr1043nd-v4', - 'tp-link-tl-wr1043n-v5', -}) then - include_usb = false -end - -if target('ramips', 'mt76x8') and not device({ - 'gl-mt300n-v2', - 'gl.inet-microuter-n300', - 'netgear-r6120', - 'ravpower-rp-wd009', -}) then - include_usb = false -end - --- 7M usable firmware space + USB port -if device({ - 'avm-fritz-box-7412', - 'tp-link-td-w8970', - 'tp-link-td-w8980', - 'gl-mt300n-v2', - 'gl.inet-microuter-n300', - 'netgear-r6120', - 'ravpower-rp-wd009' -}) then - include_usb = false -end - --- devices without usb ports -if device({ - 'ubiquiti-unifi-6-lr-v1', - 'netgear-ex6150', - 'netgear-ex3700', - 'ubiquiti-edgerouter-x', - 'ubiquiti-edgerouter-x-sfp', - 'zyxel-nwa55axe', -}) then - include_usb = false -end - -if include_usb then +if has_usb and not target('realtek', 'rtl838x') or target('ramips', 'mt7620') then packages(pkgs_usb) packages(pkgs_usb_net) packages(pkgs_usb_serial) diff --git a/patches/3148.patch b/patches/3148.patch new file mode 100644 index 0000000..03333a2 --- /dev/null +++ b/patches/3148.patch @@ -0,0 +1,133 @@ +From 7d735b599d06e690cbad8dd4566d96b8e71380f6 Mon Sep 17 00:00:00 2001 +From: Matthias Schiffer +Date: Fri, 5 Jan 2024 12:07:04 +0100 +Subject: [PATCH 1/3] Makefile: remove duplicate `.` from error messages + +$(error ...) already adds a `.` to the end of error messages. +--- + Makefile | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Makefile b/Makefile +index 5fa37a4322..21964c16b1 100644 +--- a/Makefile ++++ b/Makefile +@@ -36,11 +36,11 @@ ifneq ($(GLUON_BRANCH),) + endif + + ifneq ($(GLUON_FEATURES)$(GLUON_FEATURES_standard)$(GLUON_FEATURES_tiny),) +- $(error *** Warning: GLUON_FEATURES has been obsolete, please use the image-customization.lua file instead.) ++ $(error *** Warning: GLUON_FEATURES has been obsolete, please use the image-customization.lua file instead) + endif + + ifneq ($(GLUON_SITE_PACKAGES)$(GLUON_SITE_PACKAGES_standard)$(GLUON_SITE_PACKAGES_tiny),) +- $(error *** Warning: GLUON_SITE_PACKAGES has been obsolete, please use the image-customization.lua file instead.) ++ $(error *** Warning: GLUON_SITE_PACKAGES has been obsolete, please use the image-customization.lua file instead) + endif + + GLUON_AUTOUPDATER_ENABLED ?= 0 + +From 19ea52062139517d9b387305df42238765d400dc Mon Sep 17 00:00:00 2001 +From: Matthias Schiffer +Date: Fri, 5 Jan 2024 12:05:54 +0100 +Subject: [PATCH 2/3] scripts: image_customization_lib: make error messages + lowercase + +Error messages generated by Lua usually start with a lowercase letter. +Let's make our own messages match. +--- + scripts/image_customization_lib.lua | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/scripts/image_customization_lib.lua b/scripts/image_customization_lib.lua +index 3abe9d6943..1303714217 100644 +--- a/scripts/image_customization_lib.lua ++++ b/scripts/image_customization_lib.lua +@@ -33,7 +33,7 @@ local function evaluate_device(env, dev) + function funcs.broken(broken) + assert( + type(broken) == 'boolean', +- 'Incorrect use of broken(): has to be a boolean value') ++ 'incorrect use of broken(): has to be a boolean value') + add_override('broken', broken) + end + +@@ -48,7 +48,7 @@ local function evaluate_device(env, dev) + function funcs.device(device_names) + assert( + type(device_names) == 'table', +- 'Incorrect use of device(): pass a list of device names as argument') ++ 'incorrect use of device(): pass a list of device names as argument') + + for _, device_name in ipairs(device_names) do + if device_name == dev.image then +@@ -62,7 +62,7 @@ local function evaluate_device(env, dev) + function funcs.target(target, subtarget) + assert( + type(target) == 'string', +- 'Incorrect use of target(): pass a target name as first argument') ++ 'incorrect use of target(): pass a target name as first argument') + + if target ~= env.BOARD then + return false + +From fa09986e54a6a8730c0003febd7bc6fc87783b96 Mon Sep 17 00:00:00 2001 +From: Matthias Schiffer +Date: Fri, 5 Jan 2024 11:40:11 +0100 +Subject: [PATCH 3/3] scripts: image_customization_lib: add include() function + +Add a simple way to include image customization Lua snippets. +Can be used to split long files, to include the same options multiple +times in different conditional branches, or even to pass values back to +the including file using return. + +Relative paths are interpreted relative to the site root (where +image-customization.lua is located). Relative includes would become +confusing when subdirectories are involved (as they are still interpreted +relative to the site root, and proper tracking of current directory for +each include seems fairly complex for a very niche use case), so we simply +reject this case for now; this way, we can implement this however we +want in the future if deemed necessary, without a breaking change. +--- + docs/user/site.rst | 4 ++++ + scripts/image_customization_lib.lua | 12 ++++++++++++ + 2 files changed, 16 insertions(+) + +diff --git a/docs/user/site.rst b/docs/user/site.rst +index 7f8f544be6..fcd245e4f3 100644 +--- a/docs/user/site.rst ++++ b/docs/user/site.rst +@@ -728,6 +728,10 @@ disable_factory() + Disables factory image generation. Sysupgrade images are still generated and stored in the image + output directory. + ++include(path) ++ Includes another image customization file. Relative paths are interpreted relative to the site ++ repository root. Values returned from the included file become the return value of ``include``. ++ + Technically, the image customzation file is evaluated once for each device, allowing + to make use of regular Lua *if* statements for device-specific configuration as + can be seen in the example. +diff --git a/scripts/image_customization_lib.lua b/scripts/image_customization_lib.lua +index 1303714217..3a4677aca0 100644 +--- a/scripts/image_customization_lib.lua ++++ b/scripts/image_customization_lib.lua +@@ -79,6 +79,18 @@ local function evaluate_device(env, dev) + return dev.options.class == class + end + ++ function funcs.include(path) ++ if string.sub(path, 1, 1) ~= '/' then ++ assert( ++ string.find(path, '/') == nil, ++ 'incorrect use of include(): including files from subdirectories is unsupported') ++ path = env.GLUON_SITEDIR .. '/' .. path ++ end ++ local f = assert(loadfile(path)) ++ setfenv(f, funcs) ++ return f() ++ end ++ + -- Evaluate the feature definition files + setfenv(M.customization_file, funcs) + M.customization_file()