From 35fe4bbf31f4f66d11db546c5f43f2a18e047a7f Mon Sep 17 00:00:00 2001
From: Nico <github@nicoboehr.de>
Date: Fri, 29 Dec 2023 20:28:21 +0000
Subject: [PATCH] migrate from site.mk to image-customization.lua

---
 image-customization.lua | 172 ++++++++++++++++++++++++++++++++++++++++
 site.mk                 |  94 ----------------------
 2 files changed, 172 insertions(+), 94 deletions(-)
 create mode 100644 image-customization.lua

diff --git a/image-customization.lua b/image-customization.lua
new file mode 100644
index 000000000..7a0d08861
--- /dev/null
+++ b/image-customization.lua
@@ -0,0 +1,172 @@
+-- Generic features and packages for all devices
+features({
+	'autoupdater',
+	'ebtables-filter-multicast',
+	'ebtables-filter-ra-dhcp',
+	'ebtables-limit-arp',
+	'mesh-batman-adv-15',
+	'mesh-vpn-fastd-l2tp',
+	'radvd',
+	'radv-filterd',
+	'respondd',
+	'status-page',
+	'web-advanced',
+	'web-logging',
+	'web-private-wifi',
+	'web-wizard',
+})
+
+packages({
+	'iwinfo',
+	'respondd-module-airtime',
+	'ffs-set-segment',
+	'gluon-config-mode-zip',
+	'gluon-ssid-changer',
+	'iwinfo',
+	'gluon-web-cellular',
+})
+
+-- Packages and features for devices which are not flagged as tiny
+if not device_class('tiny') then
+	features({
+		'mesh-vpn-sqm',
+		'tls',
+		'web-cellular',
+		'wireless-encryption-wpa3'
+	})
+end
+
+-- Custom package lists
+local pkgs_usb_hid = {
+	'kmod-usb-hid',
+	'kmod-hid-generic'
+}
+
+local pkgs_usb_serial = {
+	'kmod-usb-serial',
+	'kmod-usb-serial-ch341',
+	'kmod-usb-serial-cp210x',
+	'kmod-usb-serial-ftdi',
+	'kmod-usb-serial-pl2303'
+}
+
+local pkgs_usb_storage = {
+	'block-mount',
+	'blkid',
+	'kmod-fs-ext4',
+	'kmod-fs-ntfs',
+	'kmod-fs-vfat',
+	'kmod-usb-storage',
+	'kmod-usb-storage-extras',  -- Card Readers
+	'kmod-usb-storage-uas',     -- USB Attached SCSI (UAS/UASP)
+	'kmod-nls-base',
+	'kmod-nls-cp1250',          -- NLS Codepage 1250 (Eastern Europe)
+	'kmod-nls-cp437',           -- NLS Codepage 437 (United States, Canada)
+	'kmod-nls-cp850',           -- NLS Codepage 850 (Europe)
+	'kmod-nls-cp852',           -- NLS Codepage 852 (Europe)
+	'kmod-nls-iso8859-1',       -- NLS ISO 8859-1 (Latin 1)
+	'kmod-nls-iso8859-13',      -- NLS ISO 8859-13 (Latin 7; Baltic)
+	'kmod-nls-iso8859-15',      -- NLS ISO 8859-15 (Latin 9)
+	'kmod-nls-iso8859-2',       -- NLS ISO 8859-2 (Latin 2)
+	'kmod-nls-utf8'             -- NLS UTF-8
+}
+
+local pkgs_usb_net = {
+	'kmod-mii',
+	'kmod-usb-net',
+	'kmod-usb-net-asix',
+	'kmod-usb-net-asix-ax88179',
+	'kmod-usb-net-cdc-eem',
+	'kmod-usb-net-cdc-ether',
+	'kmod-usb-net-cdc-mbim',
+	'kmod-usb-net-cdc-ncm',
+	'kmod-usb-net-cdc-subset',
+	'kmod-usb-net-dm9601-ether',
+	'kmod-usb-net-hso',
+	'kmod-usb-net-huawei-cdc-ncm',
+	'kmod-usb-net-ipheth',
+	'kmod-usb-net-kalmia',
+	'kmod-usb-net-kaweth',
+	'kmod-usb-net-mcs7830',
+	'kmod-usb-net-pegasus',
+	'kmod-usb-net-qmi-wwan',
+	'kmod-usb-net-rndis',
+	'kmod-usb-net-rtl8152',
+	'kmod-usb-net-sierrawireless',
+	'kmod-usb-net-smsc95xx',
+}
+
+local pkgs_pci = {
+	'pciutils'
+}
+
+local pkgs_pci_net = {
+	'kmod-bnx2'
+}
+
+if target('ath79') then
+	packages(pkgs_usb_serial)
+end
+
+if target('ipq40xx') then
+	packages(pkgs_usb_serial)
+	packages(pkgs_usb_storage)
+end
+
+if target('ipq806x') then
+	packages(pkgs_usb_serial)
+	packages(pkgs_usb_storage)
+end
+
+if target('mediatek') then
+	packages(pkgs_usb_serial)
+	packages(pkgs_usb_storage)
+end
+
+if target('mpc85xx') then
+	packages(pkgs_usb_serial)
+	packages(pkgs_usb_storage)
+end
+
+if target('ramips', 'mt7621') then
+	packages(pkgs_usb_serial)
+end
+
+if target('rockchip') then
+	-- No PCI / video
+	packages(pkgs_usb_net)
+	packages(pkgs_usb_serial)
+	packages(pkgs_usb_storage)
+end
+
+if target('sunxi') then
+	-- No PCI / video
+	packages(pkgs_usb_serial)
+	packages(pkgs_usb_storage)
+end
+
+-- Include all custom packages for RaspberryPi
+if target('bcm27xx') then
+	packages(pkgs_pci)
+	packages(pkgs_pci_net)
+	packages(pkgs_usb_hid)
+	packages(pkgs_usb_net)
+	packages(pkgs_usb_serial)
+	packages(pkgs_usb_storage)
+end
+
+-- Include all custom packages for x86
+if target('x86') then
+	packages(pkgs_pci)
+	packages(pkgs_pci_net)
+	packages(pkgs_usb_hid)
+	packages(pkgs_usb_net)
+	packages(pkgs_usb_serial)
+	packages(pkgs_usb_storage)
+end
+
+-- Network-activated setup-mode for NWA55AXE
+if device({'zyxel-nwa55axe'}) then
+	packages({'ffda-network-setup-mode'})
+	broken(false)
+end
diff --git a/site.mk b/site.mk
index f96e0b47f..91b412719 100644
--- a/site.mk
+++ b/site.mk
@@ -1,97 +1,3 @@
-GLUON_FEATURES := \
-	autoupdater \
-	ebtables-filter-multicast \
-	ebtables-filter-ra-dhcp \
-	mesh-batman-adv-15 \
-	mesh-vpn-fastd \
-	mesh-vpn-fastd-l2tp \
-	radv-filterd \
-	respondd \
-	status-page \
-	web-advanced \
-	web-wizard
-
-GLUON_FEATURES_standard := \
-	wireless-encryption-wpa3
-
-GLUON_SITE_PACKAGES := \
-	ffs-set-segment \
-	ffs-watchdog \
-	gluon-config-mode-zip \
-	gluon-mesh-vpn-fastd \
-	gluon-neighbour-info \
-	gluon-ssid-changer \
-	gluon-web-mesh-vpn-fastd \
-	gluon-web-private-wifi \
-	iwinfo
-
-GLUON_SITE_PACKAGES_standard := \
-	gluon-web-cellular \
-	respondd-module-airtime \
-	libustream-wolfssl \
-	ca-bundle
-
-ADD_DRIVERS_X86 := \
-	kmod-8139too \
-	kmod-ath \
-	kmod-ath9k-common \
-	kmod-ath9k-htc \
-	kmod-atl2 \
-	kmod-brcmfmac \
-	kmod-carl9170 \
-	kmod-forcedeth \
-	kmod-igb \
-	kmod-mii \
-	kmod-nls-base \
-	kmod-r8169 \
-	kmod-rtlwifi-usb \
-	kmod-rtl8192cu \
-	kmod-skge \
-	kmod-sky2 \
-	kmod-usb-core \
-	kmod-usb-hid \
-	kmod-usb-net \
-	kmod-usb-net-asix \
-	kmod-usb-net-asix \
-	kmod-usb-net-asix-ax88179 \
-	kmod-usb-net-cdc-eem \
-	kmod-usb-net-cdc-ether \
-	kmod-usb-net-cdc-mbim \
-	kmod-usb-net-cdc-ncm \
-	kmod-usb-net-cdc-subset \
-	kmod-usb-net-dm9601-ether \
-	kmod-usb-net-hso \
-	kmod-usb-net-huawei-cdc-ncm \
-	kmod-usb-net-ipheth \
-	kmod-usb-net-kalmia \
-	kmod-usb-net-kaweth \
-	kmod-usb-net-mcs7830 \
-	kmod-usb-net-pegasus \
-	kmod-usb-net-qmi-wwan \
-	kmod-usb-net-rndis \
-	kmod-usb-net-rtl8152 \
-	kmod-usb-net-sierrawireless \
-	kmod-usb-net-smsc95xx \
-	kmod-usb-ohci-pci \
-	kmod-usb2
-
-# add addition network drivers and usb support only to targes where disk space does not matter.
-ifeq ($(GLUON_TARGET),x86-generic)
-GLUON_SITE_PACKAGES += \
-	$(ADD_DRIVERS_X86)
-endif
-
-ifeq ($(GLUON_TARGET),x86-64)
-GLUON_SITE_PACKAGES += \
-	$(ADD_DRIVERS_X86)
-endif
-
-# networked setup mode for NWA55AXE
-ifeq ($(GLUON_TARGET),ramips-mt7621)
-GLUON_SITE_PACKAGES += \
-	ffda-network-setup-mode
-endif
-
 DEFAULT_BUILD_DATE := $(shell date '+%Y-%m-%d')
 
 FFS_BUILD_DATE ?= $(DEFAULT_BUILD_DATE)
-- 
GitLab