42 lines
1.6 KiB
Bash
42 lines
1.6 KiB
Bash
#!/usr/bin/env bash
|
|
# SPDX-License-Identifier: MIT
|
|
set -euo pipefail
|
|
repo_root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)
|
|
work=$(mktemp -d)
|
|
trap 'rm -rf -- "$work"' EXIT
|
|
mkdir -p "$work/repo/scripts" "$work/bin"
|
|
cp "$repo_root/LICENSE" "$repo_root/README.md" "$work/repo/"
|
|
# Exercise source preparation, without building or installing RPMs.
|
|
printf '#!/bin/sh\nexit 0\n' > "$work/bin/rpmbuild"
|
|
chmod +x "$work/bin/rpmbuild"
|
|
export PATH="$work/bin:$PATH"
|
|
|
|
for tool in plasma-task-group-shortcuts fedora-tools-settings; do
|
|
cp -a "$repo_root/$tool" "$work/repo/"
|
|
cp "$repo_root/scripts/build-$tool-rpm" "$work/repo/scripts/"
|
|
source_dir="$work/repo/rpmbuild/SOURCES/$tool-0.1.0"
|
|
mkdir -p "$source_dir"
|
|
touch "$source_dir/obsolete.cpp"
|
|
bash "$work/repo/scripts/build-$tool-rpm"
|
|
archive="$work/repo/rpmbuild/SOURCES/$tool-0.1.0.tar.gz"
|
|
files=$(tar -tzf "$archive")
|
|
if [[ $files == *obsolete.cpp* ]]; then
|
|
printf 'Stale source included in %s\n' "$archive" >&2
|
|
exit 1
|
|
fi
|
|
mkdir -p "$work/extracted/$tool"
|
|
tar -xzf "$archive" -C "$work/extracted/$tool"
|
|
extracted="$work/extracted/$tool/$tool-0.1.0"
|
|
cmp "$work/repo/$tool/CMakeLists.txt" "$extracted/CMakeLists.txt"
|
|
diff -r "$work/repo/$tool/tests" "$extracted/tests"
|
|
if [[ $tool == fedora-tools-settings ]]; then
|
|
diff -r "$work/repo/$tool/src" "$extracted/src"
|
|
else
|
|
for source in "$work/repo/$tool/"*.cpp "$work/repo/$tool/"*.h \
|
|
"$work/repo/$tool/"*.qml "$work/repo/$tool/"*.desktop; do
|
|
cmp "$source" "$extracted/${source##*/}"
|
|
done
|
|
fi
|
|
done
|
|
printf 'Source archive tests passed.\n'
|