From 486d31f9de0134947551c39ed133f24f1844493a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= <karel.koci@nic.cz>
Date: Thu, 6 Aug 2020 14:24:54 +0200
Subject: [PATCH] lists: fix increased priority from l10n packages

Standard for_l10n function provided by root updater script is creating
requests with default priority 50. This effectively increases priority
of all packages using it to include their languages.

The solution here is to decrease priority for language packages to
something very small (10 was chosen).

Also because we had to have copy of for_l10n function in bootstrap it
was instead moved from there to utils and provided as our own version
instead of updater's one.
Original function can potentially be dropped later on as Turris lists
are no longer using it thanks to this change.
---
 lists/bootstrap.lua | 9 ---------
 lists/foris.lua.m4  | 4 ++--
 lists/luci.lua.m4   | 7 +++----
 lists/utils.m4      | 7 +++++++
 4 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/lists/bootstrap.lua b/lists/bootstrap.lua
index 29ebc63a5..d1fc33472 100644
--- a/lists/bootstrap.lua
+++ b/lists/bootstrap.lua
@@ -27,15 +27,6 @@ if env_l10n then
 end
 Export('l10n')
 
--- This is helper function for including localization packages.
--- (This is copy of standard entry function that can be found in pkgupdate conf.lua)
-function for_l10n(fragment)
-	for _, lang in pairs(l10n or {}) do
-		Install(fragment .. lang, {optional = true})
-	end
-end
-Export('for_l10n')
-
 -- Aways include base script
 Script('base.lua')
 -- Include any additional lists
diff --git a/lists/foris.lua.m4 b/lists/foris.lua.m4
index 799c1b3ea..df432930a 100644
--- a/lists/foris.lua.m4
+++ b/lists/foris.lua.m4
@@ -31,7 +31,7 @@ if for_l10n and features.request_condition then
 		for _, plugin in pairs(foris_plugins) do
 			local fplugin = "foris-" .. plugin .. "-plugin"
 			Install(fplugin .. "-l10n-" .. lang, {
-				priority = 40,
+				priority = 10,
 				optional = true,
 				condition = fplugin
 			})
@@ -39,7 +39,7 @@ if for_l10n and features.request_condition then
 		for _, plugin in pairs(reforis_plugins) do
 			local refplugin = "reforis-" .. plugin .. "-plugin"
 			Install(refplugin .. "-l10n-" .. lang, {
-				priority = 40,
+				priority = 10,
 				optional = true,
 				condition = refplugin
 			})
diff --git a/lists/luci.lua.m4 b/lists/luci.lua.m4
index 727063a0d..a6ebf5e01 100644
--- a/lists/luci.lua.m4
+++ b/lists/luci.lua.m4
@@ -88,11 +88,11 @@ local luci_apps = {
 }
 
 -- Conditional install requests for language packages
-if for_l10n and features.request_condition then
+if features.request_condition then
 	for _, lang in pairs({"en", unpack(l10n or {})}) do
 		for _, name in pairs(luci_apps) do
 			Install("luci-i18n-" .. name .. "-" .. lang, {
-				priority = 40,
+				priority = 10,
 				optional = true,
 				condition = "luci-app-" .. name
 			})
@@ -103,13 +103,12 @@ end
 
 Install("luci", "luci-base", "luci-lighttpd", { priority = 40 })
 if for_l10n then
-	Install("luci-i18n-base-en", { optional = true })
+	Install("luci-i18n-base-en", { optional = true, priority = 10 })
 	for_l10n("luci-i18n-base-")
 end
 
 Install("luci-app-commands", { priority = 40 })
 Install("luci-proto-ipv6", "luci-proto-ppp", { priority = 40 })
-
 -- Install resolver-debug for DNS debuging
 Install("resolver-debug", { priority = 40 })
 
diff --git a/lists/utils.m4 b/lists/utils.m4
index 8023dc262..87d0fa0e7 100644
--- a/lists/utils.m4
+++ b/lists/utils.m4
@@ -54,4 +54,11 @@ function list_script(list)
 		Script((repo_base_uri or "https://repo.turris.cz/hbs") .. "/" .. board .. "/lists/" .. list)
 	end
 end
+
+-- Our own version of for_l10n to override priority
+function for_l10n(fragment)
+	for _, lang in pairs(l10n or {}) do
+		Install(fragment .. lang, {optional = true, priority = 10})
+	end
+end
 ----------------------------------------------------------------------------------
-- 
GitLab