-
Notifications
You must be signed in to change notification settings - Fork 6
/
rpmbuild.sh
executable file
·47 lines (41 loc) · 1.77 KB
/
rpmbuild.sh
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
#!/bin/sh
# get the version from the spec file
SPECFILE="$(dirname "$(realpath "$0")")/finddata.spec"
echo "Finding version from ${SPECFILE}"
VERSION="$(grep Version "${SPECFILE}" | awk '{print $2}')"
if [ -z "${VERSION}" ]; then
echo "Failed to determine the version from ${SPECFILE}"
exit 127
fi
echo "Version is ${VERSION}"
# create the tarball
echo "building sdist..."
python -m build --sdist --outdir . --no-isolation || exit 127
TARBALL_SRC="finddata-$(versioningit).tar.gz" # created
TARBALL_TGT="finddata-${VERSION}.tar.gz" # what we want
# fixup the tarball if necessary
if [ "${TARBALL_SRC}" != "${TARBALL_TGT}" ]; then
echo "cleaning up tarball"
rm -rf "finddata-${VERSION}"
mkdir "python-finddata-${VERSION}"
tar xzf "${TARBALL_SRC}" --strip 1 -C "python-finddata-${VERSION}" || exit 127
rm "${TARBALL_SRC}"
tar czf "${TARBALL_TGT}" "python-finddata-${VERSION}" || exit 127
rm -rf "python-finddata-${VERSION}"
fi
# setup rpm directories for building - renames the tarball
mkdir -p "${HOME}"/rpmbuild/SOURCES
cp "${TARBALL_TGT}" "${HOME}/rpmbuild/SOURCES/${TARBALL_TGT}" || exit 127
# move the patchfile into position
# it can be created by editing pyproject.toml then having git create it
# git diff -P pyproject.toml > pyproject.patch && git checkout pyproject.toml
cp pyproject.patch "${HOME}/rpmbuild/SOURCES/finddata-pyproject.patch" || exit 127
# build the rpm and give instructions
echo "building the rpm"
rpmbuild -ba finddata.spec || exit 127
# give people a hint on how to verify the rpm
# shellcheck disable=SC1083
DIST=$(rpm --eval %{?dist})
echo "========================================"
echo "Successfully built rpm. To manually inspect package run"
echo "rpm -qilRp ~/rpmbuild/RPMS/noarch/python3.11-finddata-${VERSION}-1${DIST}.noarch.rpm"