-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathbuild_rpm_from_git.sh
executable file
·57 lines (44 loc) · 1.59 KB
/
build_rpm_from_git.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
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
set -e
SCRIPTS_DIR=$(dirname "$0")
PROJECT_DIR=$(realpath "${SCRIPTS_DIR}/..")
PACKAGE=$1
if [ -z "${PACKAGE}" ]
then
echo "package name is required"
exit 1
else
echo "Building temp rpm package for ${PACKAGE}"
fi
cd "${PROJECT_DIR}"
echo "Generate license files for bundled crates"
cargo metadata --format-version 1 | scripts/release/bundle_license.py > LICENSE-BUNDLED
if [ -f ${PACKAGE}/doc/conf.py ]
then
echo "Building sphinx docs"
sphinx-build -q -b html ${PACKAGE}/doc ${PACKAGE}/doc/_build/html
fi
SPEC_FILE="${PACKAGE}.spec"
[ ! -e "${SPEC_FILE}" ] || rm "${SPEC_FILE}"
cp "${PACKAGE}/${PACKAGE}.spec" "${SPEC_FILE}"
SRC_VERSION=$(cargo read-manifest --offline --manifest-path "${PACKAGE}"/Cargo.toml | jq -r '.version')
VERSION=$(rpmspec -q --srpm --qf "%{version}" "${SPEC_FILE}")
echo "Looking for previous release tag"
TAG_REF_NAME=$(git describe --match "${PACKAGE}-v${SRC_VERSION}" || :)
VERSION_SYMBOL=""
if [ -n "${TAG_REF_NAME}" ]
then
VERSION_SYMBOL="^"
echo "This is an update for formal version ${VERSION}"
else
VERSION_SYMBOL="~"
echo "This is an pre-release for version ${VERSION}"
fi
GIT_VER=$(git log -1 --pretty=format:%cdgit%h --date=format:%Y%m%d)
echo "Git version: ${GIT_VER}"
echo "Finalize ${SPEC_FILE}"
# see https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/
NEW_VERSION="${VERSION}${VERSION_SYMBOL}${GIT_VER}"
rpmdev-bumpspec -n "${NEW_VERSION}" -c "new git snapshot build" -u "G3proxy Maintainers <[email protected]>" "${SPEC_FILE}"
export RUSTFLAGS="--remap-path-prefix ${HOME}=~"
rpmbuild -bb --build-in-place "${SPEC_FILE}"