summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <karel.koci@nic.cz>2018-10-10 11:18:29 +0200
committerKarel Kočí <karel.koci@nic.cz>2018-10-10 11:19:33 +0200
commit5e854bd1fa80130b58f5cde9595929166b0178eb (patch)
treef5f4a1f6882e4dfc204af49b1ab0aa43af1b4d30
parente80d577eca049b4968d30c77ab646fa4fcd01780 (diff)
parent22ca6212993dec46c1b32df68f91db59ff46605c (diff)
downloadopenwrt-personal-pkgs-5e854bd1fa80130b58f5cde9595929166b0178eb.tar.gz
openwrt-personal-pkgs-5e854bd1fa80130b58f5cde9595929166b0178eb.tar.bz2
openwrt-personal-pkgs-5e854bd1fa80130b58f5cde9595929166b0178eb.zip
Merge branch 'turris3x'
-rw-r--r--updater-ng/Makefile11
-rw-r--r--updater-ng/files/base.lua93
2 files changed, 96 insertions, 8 deletions
diff --git a/updater-ng/Makefile b/updater-ng/Makefile
index 56967b6..3dcbe66 100644
--- a/updater-ng/Makefile
+++ b/updater-ng/Makefile
@@ -32,12 +32,12 @@ define Package/$(PKG_NAME)/install
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/opkg-trans $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/pkgupdate $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/supervisor/updater.sh $(1)/usr/bin/
- $(INSTALL_BIN) .//files/updater-wipe.sh $(1)/usr/bin/
+ $(INSTALL_BIN) ./files/updater-wipe.sh $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/updater
$(INSTALL_CONF) $(PKG_BUILD_DIR)/src/pkgupdate/configs/conf.lua $(1)/etc/updater
$(INSTALL_DIR) $(1)/etc/updater/conf.d
- $(INSTALL_CONF) $(PKG_BUILD_DIR)/src/pkgupdate/configs/base.lua $(1)/etc/updater/conf.d/base.lua
+ $(INSTALL_CONF) ./files/turris.lua $(1)/etc/updater/conf.d/turris.lua
$(INSTALL_CONF) $(PKG_BUILD_DIR)/src/pkgupdate/configs/example.lua $(1)/etc/updater/conf.d/example.lua
$(INSTALL_DIR) $(1)/etc/updater/hook_preupdate
@@ -49,11 +49,6 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/updater.config $(1)/etc/config/updater
-ifneq ($(PKG_BRANCH),)
- echo >> $(1)/etc/config/updater
- echo "config override 'override'" >> $(1)/etc/config/updater
- echo " option branch '$(PKG_BRANCH)'" >> $(1)/etc/config/updater
-endif
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/pkgupdate/init $(1)/etc/init.d/updater
@@ -115,7 +110,7 @@ endef
define Package/$(PKG_NAME)-supervisor
- TITLE:=Next generation updater supervisor and its library
+ TITLE:=Next generation updater supervisor and it's library
DEPENDS:=+updater-ng +vixie-cron +python3-light +python3-uci +userlists +l10n_supported
EXTRA_DEPENDS:=userlists (>=11)
endef
diff --git a/updater-ng/files/base.lua b/updater-ng/files/base.lua
new file mode 100644
index 0000000..1b5e9f3
--- /dev/null
+++ b/updater-ng/files/base.lua
@@ -0,0 +1,93 @@
+--[[
+This file is part of updater-ng. Don't edit it.
+]]
+
+local branch = ""
+local lists
+local datacollection_enabled = false
+if uci then
+ local cursor = uci.cursor()
+ branch = cursor:get("updater", "override", "branch")
+ if branch then
+ WARN("Branch overriden to " .. branch)
+ branch = "-" .. branch
+ else
+ branch = ""
+ end
+ lists = cursor:get("updater", "pkglists", "lists")
+ -- TODO this can also be for example yes but this should work in default
+ datacollection_enabled = cursor:get("foris", "eula", "agreed_collect") == '1'
+else
+ ERROR("UCI library is not available. Not processing user lists.")
+end
+
+-- Verify contract
+if not datacollection_enabled then
+ local contract_valid = io.open('/usr/share/server-uplink/contract_valid', 'r')
+ if not contract_valid then -- Try to generate it
+ os.execute('/usr/share/server-uplink/contract_valid.sh')
+ contract_valid = io.open('/usr/share/server-uplink/contract_valid', 'r')
+ end
+ if contract_valid then
+ local contract_content = contract_valid:read()
+ datacollection_enabled = contract_content == 'valid'
+ contract_valid:close()
+ else
+ WARN("Contract wasn't verified")
+ -- For Turris 1.x expect in default valid contract
+ datacollection_enabled = model:match("^[Tt]urris$")
+ end
+end
+
+-- Guess what board this is.
+local base_model = ""
+if model then
+ if model:match("Turris Mox") then
+ base_model = "mox"
+ elseif model:match("[Oo]mnia") then
+ base_model = "omnia"
+ elseif model:match("[Tt]urris") then
+ base_model = "turris"
+ end
+end
+
+-- Definitions common url base
+local base_url = "https://repo.turris.cz/" .. base_model .. branch .. "/lists/"
+-- Reused options for remotely fetched scripts
+local script_options = {
+ security = "Remote",
+ ca = system_cas,
+ crl = no_crl,
+ pubkey = {
+ "file:///etc/updater/keys/release.pub",
+ "file:///etc/updater/keys/standby.pub",
+ "file:///etc/updater/keys/test.pub" -- It is normal for this one to not be present in production systems
+ }
+}
+
+-- The distribution base script. It contains the repository and bunch of basic packages
+Script("base", base_url .. "base.lua", script_options)
+
+-- Data collection list
+if datacollection_enabled then
+ Script("base", base_url .. "i_agree_datacollect.lua", script_options)
+end
+
+-- Additional enabled distribution lists
+if lists then
+ if type(lists) == "string" then -- if there is single list then uci returns just a string
+ lists = {lists}
+ end
+ -- Go through user lists and pull them in.
+ local exec_list = {} -- We want to run userlist only once even if it's defined multiple times
+ if type(lists) == "table" then
+ for _, l in ipairs(lists) do
+ if exec_list[l] then
+ WARN("User list " .. l .. " specified multiple times")
+ else
+ Script("userlist-" .. l, base_url .. l .. ".lua", script_options)
+ exec_list[l] = true
+ end
+ end
+ end
+end