From 0252e35c9c3b08884074aec710fe5ada32a89a82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Wed, 28 Feb 2018 16:46:09 +0100 Subject: Allow more customization of generated medkit --- build_medkit.sh | 72 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 9 deletions(-) diff --git a/build_medkit.sh b/build_medkit.sh index 2c715ef..e039723 100755 --- a/build_medkit.sh +++ b/build_medkit.sh @@ -7,6 +7,9 @@ MODEL= L10N=en,cs LISTS= VERSION= +OVERLAY= +UPDATER_SCRIPT= +TEST_BRANCH=false ## Parse arguments ## while [ $# -gt 0 ]; do @@ -38,6 +41,14 @@ while [ $# -gt 0 ]; do echo " If you do so then archive will be used for generating medkit" echo " (this means that using latest version won't work with this" echo " option)." + echo " --updater-script FILE" + echo " Run file as updater's script. It is executed after primary" + echo " entry script of this tool." + echo " --overlay PATH" + echo " This allows you to overwrite or add some files to medkit." + echo " PATH is expected to be directory and whole content is copied" + echo " to newly generated root. This is handy if you want to change" + echo " some default settings for example." exit 0 ;; --localization|-l) @@ -54,6 +65,14 @@ while [ $# -gt 0 ]; do echo "Version option is not yet implemented." exit 1 ;; + --updater-script) + shift + UPDATER_SCRIPT="$1" + ;; + --overlay) + shift + OVERLAY="$1" + ;; *) if [ -z "$MODEL" ]; then MODEL="$1" @@ -62,6 +81,12 @@ while [ $# -gt 0 ]; do BRANCH= else BRANCH="-$1" + TEST_BRANCH=true + case "$1" in + rc) + TEST_BRANCH=false + ;; + esac fi else echo "Unknown option: $1" >&2 @@ -129,6 +154,8 @@ done ## Export some variables that are used by pkgupdate lua script export L10N export LISTS +export OVERLAY +export TEST_BRANCH export ROOT="$(readlink -f "root-$MODEL$BRANCH")" @@ -156,9 +183,9 @@ local script_options = { ca = system_cas, crl = no_crl, pubkey = { - 'file://$PWD/.release.pub', - 'file://$PWD/.standby.pub', - 'file://$PWD/.test.pub' + 'file://./.release.pub', + 'file://./.standby.pub', + 'file://./.test.pub' } } base_url = 'https://repo.turris.cz/$MODEL$BRANCH/lists/' @@ -169,9 +196,21 @@ Script('base', base_url .. 'base.lua', script_options) -- Now include any additional lists local userlists_file = io.open('userlists', 'r') for list in os.getenv('LISTS'):gmatch('[^,]+') do - Script('userlist-' .. list, base_url .. list, script_options) + Script('userlist-' .. list, base_url .. list .. '.lua', script_options) +end + +-- If branch was detected as testing one then also add test keys +if os.getenv('TEST_BRANCH') then + WARN('Branch detected as testing. Adding test keys') + Install('cznic-repo-keys-test') end EOF +# Append user specified script (if given) +if [ -n "$UPDATER_SCRIPT" ]; then + cat >> "$UPDATER_CONFIG" < /tmp/sysinfo/board_name -# TODO we should also hack /etc/config/updater because of languages, branch and -# lists. - ## Generate root ## echo "==== Building new root ====" fakeroot -- sh -s <> "$ROOT/etc/config/updater" +echo "config pkglists 'pkglists'" >> "$ROOT/etc/config/updater" +while IFS=',' read LIST; do + echo " list lists '\$LIST'" >> "$ROOT/etc/config/updater" +done <<< "\$LISTS" +echo >> "$ROOT/etc/config/updater" +echo "config l10n 'l10n'" >> "$ROOT/etc/config/updater" +while IFS=',' read LANG; do + echo " list langs '\$LANG'" >> "$ROOT/etc/config/updater" +done <<< "\$L10N" + +## Overlay user's files +if [ -n "$OVERLAY" ]; then + cp -r "$OVERLAY/." "$ROOT/" +fi + ## Tar root in current directory ( cd "$ROOT" -# Do cleanups first +# Do cleanups 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 +# Create archive tar -czf "../medkit-$MODEL$BRANCH.tar.gz" . ) EOF -- cgit v1.2.3