From b5ba291b54b628724786eb8d72096c8a705f2f07 Mon Sep 17 00:00:00 2001
From: Florian Maurer <f.maurer@outlook.de>
Date: Fri, 27 Dec 2024 00:47:09 +0100
Subject: [PATCH] readd moved xrx200_legacy target

replace only the first underscore in target_config_lib

Signed-off-by: Florian Maurer <f.maurer@outlook.de>
---
 .github/filters.yml             | 10 ++++++++++
 docs/user/supported_devices.rst |  3 +++
 scripts/target_config_lib.lua   |  2 +-
 targets/lantiq-xrx200_legacy    | 30 ++++++++++++++++++++++++++++++
 targets/targets.mk              |  1 +
 5 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 targets/lantiq-xrx200_legacy

diff --git a/.github/filters.yml b/.github/filters.yml
index 41e4b5a21..aa6ea75da 100644
--- a/.github/filters.yml
+++ b/.github/filters.yml
@@ -115,6 +115,16 @@
     "targets/generic",
     "targets/targets.mk"
   ],
+  "lantiq-xrx200_legacy": [
+    "targets/lantiq-xrx200_legacy",
+    ".github/workflows/build-gluon.yml",
+    "modules",
+    "Makefile",
+    "patches/**",
+    "scripts/**",
+    "targets/generic",
+    "targets/targets.mk"
+  ],
   "lantiq-xway": [
     "targets/lantiq-xway",
     ".github/workflows/build-gluon.yml",
diff --git a/docs/user/supported_devices.rst b/docs/user/supported_devices.rst
index 2946a3e21..4d99d7e6e 100644
--- a/docs/user/supported_devices.rst
+++ b/docs/user/supported_devices.rst
@@ -287,6 +287,9 @@ lantiq-xrx200
   - FRITZ!Box 7362 SL [#eva_ramboot]_ [#lan_as_wan]_
   - FRITZ!Box 7412 [#eva_ramboot]_
 
+lantiq-xrx200_legacy
+--------------------
+
 * TP-Link
 
   - TD-W8970 (v1) [#lan_as_wan]_
diff --git a/scripts/target_config_lib.lua b/scripts/target_config_lib.lua
index c20e64013..750a419e9 100644
--- a/scripts/target_config_lib.lua
+++ b/scripts/target_config_lib.lua
@@ -150,7 +150,7 @@ local function handle_target_pkgs(pkgs)
 end
 
 local function get_default_pkgs()
-	local targetinfo_target = string.gsub(openwrt_config_target, '_', '/')
+	local targetinfo_target = string.gsub(openwrt_config_target, '_', '/', 1)
 	local target_matches = false
 	for line in io.lines('openwrt/tmp/.targetinfo') do
 		local target_match = string.match(line, '^Target: (.+)$')
diff --git a/targets/lantiq-xrx200_legacy b/targets/lantiq-xrx200_legacy
new file mode 100644
index 000000000..c0ff62b02
--- /dev/null
+++ b/targets/lantiq-xrx200_legacy
@@ -0,0 +1,30 @@
+packages {
+	'-ltq-vdsl-vr9-vectoring-fw-installer',
+	'-kmod-ltq-vdsl-vr9-mei',
+	'-kmod-ltq-vdsl-vr9',
+	'-kmod-ltq-atm-vr9',
+	'-kmod-ltq-ptm-vr9',
+	'-kmod-ltq-deu-vr9',
+	'-ltq-vdsl-vr9-app',
+	'-dsl-vrx200-firmware-xdsl-a',
+	'-dsl-vrx200-firmware-xdsl-b-patch',
+	'-ppp-mod-pppoa',
+	'-ltq-dsl-base',
+}
+
+-- TP-Link
+
+-- CAVEAT: These devices don't have a dedicated WAN port.
+--         All ethernet ports on the device are bridged and
+--         used as WAN ports. Clients connected to these
+--         ports will be connected to your private network.
+
+device('tp-link-td-w8970', 'tplink_tdw8970', {
+	factory = false,
+})
+
+device('tp-link-td-w8980', 'tplink_tdw8980', {
+	factory = false,
+	aliases = {'tp-link-td-w9980'},
+	broken = true, -- 5GHz unsupported
+})
diff --git a/targets/targets.mk b/targets/targets.mk
index 45a9f395f..1ee2fe7c3 100644
--- a/targets/targets.mk
+++ b/targets/targets.mk
@@ -9,6 +9,7 @@ $(eval $(call GluonTarget,ipq40xx,generic))
 $(eval $(call GluonTarget,ipq40xx,mikrotik))
 $(eval $(call GluonTarget,ipq806x,generic))
 $(eval $(call GluonTarget,lantiq,xrx200))
+$(eval $(call GluonTarget,lantiq,xrx200_legacy))
 $(eval $(call GluonTarget,lantiq,xway))
 $(eval $(call GluonTarget,mediatek,filogic))
 $(eval $(call GluonTarget,mediatek,mt7622))
-- 
GitLab