1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#!/bin/sh
# This script is real medkit generator using updater
set -e
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
if [ -z "$VERSION" ]; then
echo "Missing --version argument!" >&2
exit 1
fi
ROOT=root-$MODEL
[ -n "$BRANCH" ] && ROOT=$ROOT-$BRANCH
rm -rf $ROOT
mkdir $ROOT
OUTPUT=medkit-$MODEL
[ -n "$BRANCH" ] && OUTPUT=$OUTPUT-$BRANCH
OUTPUT=$PWD/$OUTPUT-$VERSION.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
|