diff options
author | Karel Kočí <karel.koci@nic.cz> | 2019-05-27 13:39:13 +0200 |
---|---|---|
committer | Karel Kočí <karel.koci@nic.cz> | 2019-05-27 13:39:13 +0200 |
commit | 8511bca8daa08ac5b89bdfe014da6df38957e96d (patch) | |
tree | 396a5148491799c50c6acd1e4ebc779bd5a022e7 | |
parent | cbc43166090e05a8d992e66fea4ed7eb0b7651f4 (diff) | |
download | openwrt-personal-pkgs-8511bca8daa08ac5b89bdfe014da6df38957e96d.tar.gz openwrt-personal-pkgs-8511bca8daa08ac5b89bdfe014da6df38957e96d.tar.bz2 openwrt-personal-pkgs-8511bca8daa08ac5b89bdfe014da6df38957e96d.zip |
updater-ng: sync config with upstream
-rw-r--r-- | updater-ng/files/turris.lua | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/updater-ng/files/turris.lua b/updater-ng/files/turris.lua index a957a8f..427d6e7 100644 --- a/updater-ng/files/turris.lua +++ b/updater-ng/files/turris.lua @@ -20,25 +20,58 @@ end local mode = uci_cnf("mode", "branch") -- should we follow branch or version? local branch = uci_cnf("branch", "hbs") -- which branch to follow local version = uci_cnf("version", nil) -- which version to follow -local lists = uci_cnf("pkglists", {}) -- what additional lists should we use -minimal_builds = uci_cnf("use_minimal", "0") == "1" -- if packages-minimal should be used -Export('minimal_builds') +local pkglists = uci_cnf("pkglists", {}) -- what additional lists should we use -- Verify that we have sensible configuration -if type(lists) == "string" then -- if there is single list then uci returns just a string - lists = {lists} -end if mode == "version" and not version then WARN("Mode configured to be 'version' but no version provided. Changing mode to 'branch' instead.") mode = "branch" end +-- Convert pkglists to set set of lists (ensures uniqueness) +if type(pkglists) == "string" then -- if there is single list then uci returns just a string + pkglists = {pkglists} +end +local lists = {} +for list in pairs(pkglists) do + lists["pkglists/" .. list] = true +end + +-- Load lists forced by boot arguments +if root_dir == "/" then + local cmdf = io.open("/proc/cmdline") + if cmdf then + for cmdarg in cmdf:read():gmatch('[^ ]+') do + local key, value = cmdarg:match('([^=]+)=(.*)') + if key == "turris_lists" then + for list in value:gmatch('[^,]+') do + lists[list] = true + end + end + end + cmdf:close() + end +end + +-- Detect host board +local product = os_release["LEDE_DEVICE_PRODUCT"] +if product:match("[Mm]ox") then + board = "mox" +elseif product:match("[Oo]mnia") then + board = "omnia" +elseif product:match("[Tt]urris 1.x") then + board = "turris1x" +else + DIE("Unsupported Turris board: " .. tostring(product)) +end +Export('board') + -- Common URI to Turris OS lists local base_url if mode == "branch" then - base_url = "https://repo.turris.cz/" .. branch .. "/lists/" + base_url = "https://repo.turris.cz/" .. branch .. "/" .. board .. "/lists/" elseif mode == "version" then - base_url = "https://repo.turris.cz/archive/" .. version .. "/lists/" + base_url = "https://repo.turris.cz/archive/" .. version .. "/" .. board .. "/lists/" else DIE("Invalid updater.turris.mode specified: " .. mode) end @@ -57,12 +90,6 @@ local script_options = { Script(base_url .. "base.lua", script_options) -- Additional enabled distribution lists -local exec_list = {} -- We want to run userlist only once even if it's defined multiple times -for _, l in ipairs(lists) do - if exec_list[l] then - WARN("Turris package list '" .. l .. "' specified multiple times") - else - Script(base_url .. l .. ".lua", script_options) - exec_list[l] = true - end +for l in pairs(lists) do + Script(base_url .. l .. ".lua", script_options) end |