2024-06-12 08:44:04 -04:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
## SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
|
|
|
|
##
|
|
|
|
## SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
2024-06-13 07:14:41 -04:00
|
|
|
command -v git >/dev/null || { echo "Missing program: git" >&2; exit 1; }
|
2024-07-10 08:36:05 -04:00
|
|
|
repo_toplevel="$(git rev-parse --show-toplevel)"
|
|
|
|
test -d "${repo_toplevel}" || exit 1
|
|
|
|
unset repo_toplevel
|
2024-06-13 07:14:41 -04:00
|
|
|
|
2024-06-12 08:44:04 -04:00
|
|
|
template=".qubesbuilder.template"
|
|
|
|
target=".qubesbuilder"
|
|
|
|
intended_target="${target}"
|
|
|
|
if test "${1-}" = "test"; then
|
|
|
|
tmpdir="$(mktemp -d)"
|
|
|
|
target="${tmpdir}/.qubesbuilder"
|
2024-07-06 16:25:54 -04:00
|
|
|
# shellcheck disable=SC2154
|
2024-07-10 08:36:05 -04:00
|
|
|
trap 'ec="$?"; rm -rf -- "${tmpdir}"; exit "${ec}"' EXIT INT HUP QUIT ABRT
|
2024-06-12 08:44:04 -04:00
|
|
|
fi
|
2024-06-21 11:00:06 -04:00
|
|
|
ignored="$(git ls-files --exclude-standard --others --ignored salt/)"
|
|
|
|
untracked="$(git ls-files --exclude-standard --others salt/)"
|
2024-07-09 11:42:07 -04:00
|
|
|
unwanted="$(printf %s"${ignored}\n${untracked}\n" |
|
|
|
|
grep "^salt/\S\+/README.md" | cut -d "/" -f2 | sort -u)"
|
2024-06-12 08:44:04 -04:00
|
|
|
group="$(./scripts/spec-get.sh dom0 group)"
|
2024-07-09 11:42:07 -04:00
|
|
|
projects="$(find salt/ -mindepth 1 -maxdepth 1 -type d | sort -d |
|
|
|
|
sed "s|^salt/\(\S\+\)| - rpm_spec/${group}-\1.spec|")"
|
2024-06-12 08:44:04 -04:00
|
|
|
for unwanted_project in ${unwanted}; do
|
2024-07-09 11:42:07 -04:00
|
|
|
projects="$(echo "${projects}" |
|
|
|
|
sed "\@rpm_spec/${group}-${unwanted_project}.spec@d")"
|
2024-06-12 08:44:04 -04:00
|
|
|
done
|
|
|
|
|
2024-06-13 07:14:41 -04:00
|
|
|
if test "${1-}" = "print"; then
|
|
|
|
echo "${projects}"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2024-06-12 08:44:04 -04:00
|
|
|
sed -e "/@SPEC@/d" "${template}" | tee "${target}" >/dev/null
|
|
|
|
echo "${projects}" | tee -a "${target}" >/dev/null
|
|
|
|
if test "${1-}" = "test"; then
|
|
|
|
if ! cmp -s "${target}" "${intended_target}"; then
|
|
|
|
echo "${0##*/}: error: File ${intended_target} is not up to date" >&2
|
2024-06-21 11:00:06 -04:00
|
|
|
echo "${0##*/}: error: Update the builder file with: ${0##/*}" >&2
|
2024-06-12 08:44:04 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|