-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate_lists
executable file
·89 lines (81 loc) · 2.56 KB
/
generate_lists
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
#!/bin/bash
# Updater-ng configuration lists generating script
# (C) 2018-2020 CZ.NIC, z.s.p.o.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
src_dir="$(dirname "$(readlink -f "$0")")"
. "$src_dir/helpers/common.sh"
. "$src_dir/helpers/generate_common.sh"
output_path=
sign_key=
while [ $# -gt 0 ]; do
case "$1" in
-h|--help)
echo "This script generates updater-ng configuration lists from Turris OS build repository."
echo "Usage: $0 [OPTION]... [OUTPUT_PATH]"
echo
echo "Options:"
echo " --help, -h"
echo " Prints this help text."
echo " --sign KEY"
echo " Sign lists with given KEY and usign utility"
echo " --debug"
echo " Run this script in debug mode"
exit
;;
--sign)
shift
sign_key="$1"
;;
--debug)
set -x
;;
*)
if [ -z "$output_path" ]; then
output_path="$1"
else
echo "Unknown option: $1"
exit 1
fi
;;
esac
shift
done
[ -n "$output_path" ] || output_path="generated_lists"
[ -d "$src_dir/lists" -a -f "$src_dir/feeds.conf" ] || \
die "This script has to be in the same direstory as feeds.conf and lists directory."
rm -rf "$output_path"
mkdir -p "$output_path"
"$src_dir/helpers/turris-version.sh" version > "$output_path/turris-version"
( cd "$src_dir" && git rev-parse HEAD > "$output_path/git-hash" )
lists_dir="$src_dir/lists"
m4args=( "--include=$lists_dir" "-D_INCLUDE_=$lists_dir/" "-D_FEEDS_=$src_dir/feeds.conf" )
m4args+=( "-D_TURRIS_OS_VERSION_=$("${0%/*}/helpers/turris-version.sh" version)" )
find "$lists_dir" -name '*.lua.m4' -print0 | while read -r -d '' f; do
output="$output_path/${f##$lists_dir/}"
mkdir -p "${output%/*}"
m4 "${m4args[@]}" "$f" > "${output%.m4}"
done
find "$lists_dir" -name '*.lua' -print0 | while read -r -d '' f; do
output="$output_path/${f##$lists_dir/}"
mkdir -p "${output%/*}"
cp "$f" "${output}"
done
if [ -n "$sign_key" ]; then
get_usign
find "$output_path" -name '*.lua' -print0 | while read -r -d '' f; do
"$USIGN" -S -m "$f" -s "$sign_key"
done
fi