summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <karel.koci@nic.cz>2018-02-28 16:46:09 +0100
committerKarel Kočí <karel.koci@nic.cz>2018-02-28 16:46:09 +0100
commit0252e35c9c3b08884074aec710fe5ada32a89a82 (patch)
tree056cfd79678fa7127c4e0342a184c7a38858b90e
parent4d2d3a789e83ec6e7951cd938ee6526bd5cab30a (diff)
downloadturris-mymedkit-0252e35c9c3b08884074aec710fe5ada32a89a82.tar.gz
turris-mymedkit-0252e35c9c3b08884074aec710fe5ada32a89a82.tar.bz2
turris-mymedkit-0252e35c9c3b08884074aec710fe5ada32a89a82.zip
Allow more customization of generated medkit
-rwxr-xr-xbuild_medkit.sh72
1 files 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" <<EOF
+Script('user-script', 'file://./$UPDATER_CONFIG')
+EOF
+fi
# Create /tmp/sysinfo files
# TODO we should use some internal option of updater it self
@@ -185,9 +224,6 @@ fi
echo "rtunknown" > /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 <<EOF
@@ -208,15 +244,33 @@ mkdir -p "$ROOT/usr/share/updater"
.updater/bin/pkgupdate --out-of-root --usign=.usign/usign -R "$ROOT" \
--batch "file://$UPDATER_CONFIG"
+## Change /etc/config/updater to match given preferences
+sed -i '/^config pkglist/,/^$/d;/^config l10n/,/^$/d' "$ROOT/etc/config/updater"
+echo >> "$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