aboutsummaryrefslogtreecommitdiffstats
path: root/platform/rpm/mkrpm.sh
diff options
context:
space:
mode:
Diffstat (limited to 'platform/rpm/mkrpm.sh')
-rwxr-xr-xplatform/rpm/mkrpm.sh34
1 files changed, 19 insertions, 15 deletions
diff --git a/platform/rpm/mkrpm.sh b/platform/rpm/mkrpm.sh
index d32ccd360..0572480c6 100755
--- a/platform/rpm/mkrpm.sh
+++ b/platform/rpm/mkrpm.sh
@@ -3,23 +3,26 @@
3# Copyright (C) 2014-2023 Firejail Authors 3# Copyright (C) 2014-2023 Firejail Authors
4# License GPL v2 4# License GPL v2
5# 5#
6# Usage: ./platform/rpm/mkrpm.sh firejail <version> "<config options>" 6# Usage: ./platform/rpm/mkrpm.sh <config options>
7# 7#
8# Builds rpms in a temporary directory then places the result in the 8# Builds rpms in a temporary directory then places the result in the
9# current working directory. 9# current working directory.
10 10
11name=$1 11# shellcheck source=config.sh
12. "$(dirname "$0")/../../config.sh" || exit 1
13
14name="$TARNAME"
12# Strip any trailing prefix from the version like -rc1 etc 15# Strip any trailing prefix from the version like -rc1 etc
13version=$(echo "$2" | sed 's/\-.*//g') 16version="$(printf '%s\n' "$VERSION" | sed 's/\-.*//g')"
14config_opt=$3 17config_opt="$*"
15 18
16if [[ ! -f platform/rpm/${name}.spec ]]; then 19if [[ ! -f "platform/rpm/${name}.spec" ]]; then
17 echo error: spec file not found for name \"${name}\" 20 printf 'error: spec file not found for name %s\n' "${name}" >&2
18 exit 1 21 exit 1
19fi 22fi
20 23
21if [[ -z "${version}" ]]; then 24if [[ -z "${version}" ]]; then
22 echo error: version must be given 25 printf 'error: version must be given\n' >&2
23 exit 1 26 exit 1
24fi 27fi
25 28
@@ -28,26 +31,27 @@ if [[ -z "${config_opt}" ]]; then
28fi 31fi
29 32
30# Make a temporary directory and arrange to clean up on exit 33# Make a temporary directory and arrange to clean up on exit
31tmpdir=$(mktemp -d) 34tmpdir="$(mktemp -d)"
32mkdir -p ${tmpdir}/{BUILD,RPMS,SOURCES,SPECS,SRPMS} 35mkdir -p "${tmpdir}"/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
33function cleanup { 36function cleanup {
34 rm -rf ${tmpdir} 37 rm -rf "${tmpdir}"
35} 38}
36trap cleanup EXIT 39trap cleanup EXIT
37 40
38# Create the spec file 41# Create the spec file
39tmp_spec_file=${tmpdir}/SPECS/${name}.spec 42tmp_spec_file="${tmpdir}/SPECS/${name}.spec"
40sed -e "s/__NAME__/${name}/g" \ 43sed -e "s/__NAME__/${name}/g" \
41 -e "s/__VERSION__/${version}/g" \ 44 -e "s/__VERSION__/${version}/g" \
42 -e "s/__CONFIG_OPT__/${config_opt}/g" \ 45 -e "s/__CONFIG_OPT__/${config_opt}/g" \
43 platform/rpm/${name}.spec >${tmp_spec_file} 46 "platform/rpm/${name}.spec" >"${tmp_spec_file}"
44# FIXME: We could parse RELNOTES and create a %changelog section here 47# FIXME: We could parse RELNOTES and create a %changelog section here
45 48
46# Copy the source to build into a tarball 49# Copy the source to build into a tarball
47tar --exclude='./.git*' --transform "s/^./${name}-${version}/" -czf ${tmpdir}/SOURCES/${name}-${version}.tar.gz . 50tar --exclude='./.git*' --transform "s/^./${name}-${version}/" \
51 -czf "${tmpdir}/SOURCES/${name}-${version}.tar.gz" .
48 52
49# Build the files (rpm, debug rpm and source rpm) 53# Build the files (rpm, debug rpm and source rpm)
50rpmbuild --quiet --define "_topdir ${tmpdir}" -ba ${tmp_spec_file} 54rpmbuild --quiet --define "_topdir ${tmpdir}" -ba "${tmp_spec_file}"
51 55
52# Copy the results to cwd 56# Copy the results to cwd
53mv ${tmpdir}/SRPMS/*.rpm ${tmpdir}/RPMS/*/*rpm . 57mv "${tmpdir}/SRPMS"/*.rpm "${tmpdir}/RPMS"/*/*rpm .