polycat/run.sh
askiiart 8aef7b8886
All checks were successful
continuous-integration/drone Build is passing
testttt
2025-02-26 00:38:59 -06:00

43 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euxo pipefail
built_dir=${COMPILED_DIR:-/compiled}/polycat
version=$(cat $built_dir/version)
repo_dir=${REPO_DIR:-/repo}
# skip if already up-to-date
# TODO: use the repo instead and check the version with dnf
if $(ls polycat-* | grep -q "$version"); then
echo "package is already up to date, exiting"
exit
fi
# prep
dnf install fedora-packager rpmdevtools createrepo_c -y
rpmdev-setuptree
# update spec file
sed -i "s/Version:.*/Version: $version/g" polycat.spec
sed -i "s/DATE_HERE/$(date '+%a %b %d %Y')/g" polycat.spec
sed -i "s/CHANGELOG_MESSAGE_HERE/Update to $version/g" polycat.spec
sed -i "s/RPM_PACKAGER_NAME/$RPM_PACKAGER_NAME/g" polycat.spec
sed -i "s/RPM_PACKAGER_EMAIL/$RPM_PACKAGER_EMAIL/g" polycat.spec
# build package and move to the repo
rpmbuild -bb polycat.spec
mv ~/rpmbuild/RPMS/x86_64/polycat-$version-* $repo_dir/
ls ~/rpmbuild/RPMS/x86_64/
exit
# remove old versions
cd $repo_dir
# this is the easiest way to make sure it doesn't just fail because no polycat-* exists
# (which only happens on first run)
touch polycat-tmp.rpm
rm $(ls polycat-*.rpm | sort --version-sort | sed '$d')
rm polycat-tmp.rpm
# update repo
createrepo_c .
echo "package is at $repo_dir/$(ls $repo_dir/polycat-*.rpm)"