An error occurred while loading the file. Please try again.
-
The syntax used in the Bash scripts here requires at minimum Bash 5.0. This checks for it and reports reasonable error message instead of failure. There are two discovered issues with older versions of bash. The first issue is the change of empty array expansion in Bash 4.4 resulted in empty arrays not being considered as undefined anymore. We depended on this heavily and thus we can't easily go bellow that version. The second issue is that syntax `[[ -v "foo[key]" ]` works only in Bash 5.0 and newer. This checks if specific key is in the associative array. The replacement could be `[ "${foo[key]:+_}" ]` in some cases but this only works if value is also nonempty. Thus it makes sense to just the more clear and reliable syntax and such depend on Bash 5.0.
Verified3c0b053f
generate_lists 2.60 KiB
#!/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 -eu
FEED_NAME="updater-lists"
src_dir="$(readlink -f "${0%/*}")"
source "$src_dir/helpers/generate_common.sh"
output_path=
sign_key=
prepare="n"
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 " --prepare"
echo " Only prepare in current directory. Do not generate lists."
echo " --debug"
echo " Run this script in debug mode"
exit
;;
--sign)
shift
sign_key="$1"
;;
--prepare)
prepare="y"
;;
--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"
output_path="$(readlink -f "$output_path")"
[ -f "$src_dir/feeds.conf" ] || \
die "This script has to be in the same directory as feeds.conf file."
set_protected_build_dir "lists"
url="$(get_feed "#" "$FEED_NAME" "$src_dir/feeds.conf")"
tos_version="$("$src_dir/helpers/turris-version.sh" version)"
git_clean_checkout "$FEED_NAME" "$url" "$build_dir"
patch_repository "$FEED_NAME" "$build_dir"
(
cd "$build_dir"
./configure \
-f "$src_dir/feeds.conf" \
-v "$tos_version" \
-d "$output_path"
)
[ "$prepare" = "n" ] || exit 0
make -C "$build_dir"
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
echo "$tos_version" > "$output_path/turris-version"
cat > "$output_path/git-hash" <<EOF
Project was build from following repositories:
* turris-build: $(git_remote_hash "$src_dir")
* $FEED_NAME: $(git_remote_hash "$build_dir")
EOF