summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <karel.koci@nic.cz>2017-05-22 10:53:42 +0200
committerKarel Kočí <karel.koci@nic.cz>2017-05-22 11:01:41 +0200
commit9f154e163451844bfe692ca81b966ab9b963e8f4 (patch)
tree590a01da60ecbeab8841ffb762b3a0d3a69afe83
downloadturris-mymedkit-9f154e163451844bfe692ca81b966ab9b963e8f4.tar.gz
turris-mymedkit-9f154e163451844bfe692ca81b966ab9b963e8f4.tar.bz2
turris-mymedkit-9f154e163451844bfe692ca81b966ab9b963e8f4.zip
Initial commit
Some basic usage implemented but parent script is missing.
-rw-r--r--.gitignore7
-rw-r--r--l10n2
-rwxr-xr-xscripts/build_tools.sh53
-rwxr-xr-xscripts/updater-medkit.sh121
-rw-r--r--userlists4
5 files changed, 187 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3865932
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+.*
+!.gitignore
+
+medkit-*.tar.gz
+root-*
+l10n
+userlists
diff --git a/l10n b/l10n
new file mode 100644
index 0000000..65acf69
--- /dev/null
+++ b/l10n
@@ -0,0 +1,2 @@
+cs
+de
diff --git a/scripts/build_tools.sh b/scripts/build_tools.sh
new file mode 100755
index 0000000..2adb27b
--- /dev/null
+++ b/scripts/build_tools.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+# This tool pulls down and builds updater-ng and usign
+# It expects to be executed in root directory of this project
+set -e
+
+git_pull() {
+ if [ ! -d $1 ]; then
+ git clone $2 $1
+ pushd $1 >/dev/null
+ git submodule update --init --recursive
+ popd >/dev/null
+ else
+ pushd $1 >/dev/null
+ git fetch
+ if ! git diff --quiet HEAD origin/master; then
+ git clean -Xdf
+ git reset --hard origin/master
+ git submodule update --init --recursive
+ fi
+ popd >/dev/null
+ fi
+}
+
+wget_pull() {
+ if [ ! -e $1 ] || [ $(expr $(date -u +%s) - $(stat -c %Z $1)) -gt 86400 ]; then
+ wget $2 -O $1
+ fi
+}
+
+## Usign ##
+git_pull .usign git://git.openwrt.org/project/usign.git
+
+if [ ! -x .usign/usign ]; then
+ pushd .usign >/dev/null
+ cmake .
+ make
+ popd >/dev/null
+fi
+
+## Updater-ng ##
+git_pull .updater https://kkoci@gitlab.labs.nic.cz/turris/updater.git
+
+if [ ! -x .updater/bin/pkgupdate ]; then
+ make -C .updater NO_DOC=1 LUA_COMPILE:=no
+fi
+
+## get-api-crl ##
+wget_pull .get-api-crl https://gitlab.labs.nic.cz/turris/misc/raw/master/cacerts/get-api-crl
+
+## Get certificates ##
+for K in release standby test; do
+ wget_pull .$K.pub https://gitlab.labs.nic.cz/turris/turris-os-packages/raw/test/cznic/cznic-repo-keys/files/$K.pub
+done
diff --git a/scripts/updater-medkit.sh b/scripts/updater-medkit.sh
new file mode 100755
index 0000000..0ab5078
--- /dev/null
+++ b/scripts/updater-medkit.sh
@@ -0,0 +1,121 @@
+#!/bin/sh
+# This script is real medkit generator using updater
+set -e
+
+VERSION="3.7"
+MODEL=omnia
+BRANCH=
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --version)
+ shift
+ VERSION="$1"
+ ;;
+ --model)
+ shift
+ MODE="$1"
+ ;;
+ --branch)
+ shift
+ BRANCH="$1"
+ ;;
+ *)
+ echo "Unknown option: $1" >&2
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+ROOT=root-$MODEL
+[ -n "$BRANCH" ] && ROOT=$ROOT-$BRANCH
+rm -rf $ROOT
+mkdir $ROOT
+
+OUTPUT=medkit-$MODEL
+[ -n "$BRANCH" ] && OUTPUT=$OUTPUT-$BRANCH
+OUTPUT=$PWD/$OUTPUT.tar.gz
+
+## Create base filesystem for updater
+ln -s tmp $ROOT/var
+# Create lock required by updater
+mkdir -p $ROOT/tmp/lock
+# Create opkg status file and info file
+mkdir -p $ROOT/usr/lib/opkg/info
+touch $ROOT/usr/lib/opkg/status
+# And updater directory
+mkdir -p $ROOT/usr/share/updater
+# Copy additional files
+[ -e files/* ] && cp -r files/* $ROOT/
+
+# Create fake reboot to not potentially reboot host if requested
+mkdir -p .fake_bin
+echo "#!/bin/sh
+echo Reboot faked!" > .fake_bin/reboot
+chmod +x .fake_bin/reboot
+export PATH="$(readlink -f $PWD/.fake_bin):$PATH"
+
+# TODO we migh need base files installed first
+
+ABSOUT="$(readlink -f $ROOT)"
+## Dump our entry file
+UPDATER_CONF=".entry-$MODEL-$BRANCH.lua"
+rm -f "$UPDATER_CONF" && touch "$UPDATER_CONF"
+if [ -e l10n ]; then
+ echo "l10n = {" >> "$UPDATER_CONF"
+ while read L; do
+ echo "'$L'," >> "$UPDATER_CONF"
+ done < l10n
+ echo "}" >> "$UPDATER_CONF"
+else
+ # Use no localizations
+ echo "l10n = {} -- table with selected localizations" >> "$UPDATER_CONF"
+fi
+[ -n "$BRANCH" ] && CBRANCH="/$BRANCH"
+echo "Export 'l10n'
+-- This is helper function for including localization packages.
+function for_l10n(fragment)
+ for _, lang in pairs(l10n or {}) do
+ Install(fragment .. lang, {ignore = {'missing'}})
+ end
+end
+Export 'for_l10n'
+
+local script_options = {
+ security = 'Remote',
+ ca = 'file://$PWD/.updater/legacy/updater.pem',
+ crl = 'file:///tmp/crl.pem',
+ ocsp = false,
+ pubkey = {
+ 'file://$PWD/.release.pub',
+ 'file://$PWD/.standby.pub',
+ 'file://$PWD/.test.pub'
+ }
+}
+base_url = 'https://api.turris.cz/updater-defs/$VERSION/$MODEL$CBRANCH/'
+
+Script('base', base_url .. 'base.lua', script_options)
+" >> "$UPDATER_CONF"
+if [ -e userlists ]; then
+ while read L; do
+ echo "Script('userlist-$L', base_url .. 'userlists/$L.lua', script_options)" >> "$UPDATER_CONF"
+ done < userlists
+fi
+# Run updater to pull in packages from base list
+.updater/bin/pkgupdate --no-replan --usign=.usign/usign -R $ABSOUT --batch file://$UPDATER_CONF
+
+# Tar it to archive in current directory
+(
+ cd $ROOT
+ # Do cleanups first
+ rm -f var/lock/opkg.lock
+ rm -f usr/share/updater/flags
+ rm -rf usr/share/updater/unpacked
+ rm -rf var/opkg-collided
+ # Now create archive
+ tar -czf "$OUTPUT" *
+)
+
+# Do cleanups
+rm -rf .fake_bin
+rm -f $UPDATER_CONF
diff --git a/userlists b/userlists
new file mode 100644
index 0000000..c48b5a2
--- /dev/null
+++ b/userlists
@@ -0,0 +1,4 @@
+luci-controls
+nas
+printserver
+netutils