summaryrefslogtreecommitdiff
path: root/base64c
diff options
context:
space:
mode:
Diffstat (limited to 'base64c')
-rw-r--r--base64c/Makefile52
-rw-r--r--base64c/files/turris.lua80
-rwxr-xr-xbase64c/files/update_alternatives.sh23
-rw-r--r--base64c/files/updater.config4
4 files changed, 159 insertions, 0 deletions
diff --git a/base64c/Makefile b/base64c/Makefile
new file mode 100644
index 0000000..41ca862
--- /dev/null
+++ b/base64c/Makefile
@@ -0,0 +1,52 @@
+#
+## Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
+#
+## This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+# #
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=base64c
+#PKG_VERSION:=0.2.0
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=https://gitlab.nic.cz/turris/updater/updater.git
+#PKG_SOURCE_VERSION:=v$(PKG_VERSION)
+
+PKG_MAINTAINER:=CZ.NIC <packaging@turris.cz>
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=LICENSE
+
+PKG_INSTALL:=1
+PKG_FIXUP:=autoreconf
+
+include $(INCLUDE_DIR)/autopkg-branch.mk
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/autotools.mk
+
+define Package/base64c
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=base64c
+endef
+
+CONFIGURE_ARGS += \
+ --disable-tests \
+ --disable-linters
+
+define Package/base64c/install
+ $(INSTALL_DIR) $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libbase64c.so* $(1)/usr/lib/
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_BUILD_DIR)/include/* $(1)/usr/include/
+
+ $(INSTALL_DIR) $(1)/usr/lib/
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,base64c))
diff --git a/base64c/files/turris.lua b/base64c/files/turris.lua
new file mode 100644
index 0000000..7555813
--- /dev/null
+++ b/base64c/files/turris.lua
@@ -0,0 +1,80 @@
+--[[
+This file is part of updater-ng. Don't edit it.
+]]
+
+local uci_cursor = nil
+if uci then
+ uci_cursor = uci.cursor(root_dir .. "/etc/config")
+else
+ ERROR("UCI library is not available. Configuration not used.")
+end
+local function uci_cnf(name, default)
+ if uci_cursor then
+ return uci_cursor:get("updater", "turris", name) or default
+ else
+ return default
+ end
+end
+
+-- Configuration variables
+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
+
+-- Verify that we have sensible configuration
+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
+
+-- Detect host board
+local product = os_release["OPENWRT_DEVICE_PRODUCT"] or 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 .. "/" .. board .. "/lists/"
+elseif mode == "version" then
+ base_url = "https://repo.turris.cz/archive/" .. version .. "/" .. board .. "/lists/"
+else
+ DIE("Invalid updater.turris.mode specified: " .. mode)
+end
+
+-- Common connection settings for Turris OS scripts
+local script_options = {
+ security = "Remote",
+ 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_url .. "base.lua", script_options)
+
+-- Additional enabled distribution 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
+ Script(base_url .. list .. ".lua", script_options)
+ end
+ end
+ end
+ cmdf:close()
+ end
+end
diff --git a/base64c/files/update_alternatives.sh b/base64c/files/update_alternatives.sh
new file mode 100755
index 0000000..c93ae45
--- /dev/null
+++ b/base64c/files/update_alternatives.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+set -e
+
+if [ $# -gt 0 ]; then
+ echo "This script is part of updater and allows user to manually fix alternative links in system." >&2
+ exit 0
+fi
+
+if [ ! -d /usr/lib/opkg/info ]; then
+ echo "OPKG info directory not located. This is OpenWrt system, isn't it?" >&2
+ exit 1
+fi
+
+# Fist install all busybox applets and then overwite them with alternatives
+
+busybox --install /bin
+
+sed -n 's/^Alternatives://p' /usr/lib/opkg/info/*.control | \
+ tr , '\n' | \
+ sort -n | \
+ while IFS=: read PRIO TRG SRC; do
+ ln -sf "$SRC" "$TRG"
+ done
diff --git a/base64c/files/updater.config b/base64c/files/updater.config
new file mode 100644
index 0000000..82e220e
--- /dev/null
+++ b/base64c/files/updater.config
@@ -0,0 +1,4 @@
+
+config turris 'turris'
+ option mode 'branch'
+