diff options
Diffstat (limited to 'platform/rpm/mkrpm.sh')
-rwxr-xr-x | platform/rpm/mkrpm.sh | 34 |
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 | ||
11 | name=$1 | 11 | # shellcheck source=config.sh |
12 | . "$(dirname "$0")/../../config.sh" || exit 1 | ||
13 | |||
14 | name="$TARNAME" | ||
12 | # Strip any trailing prefix from the version like -rc1 etc | 15 | # Strip any trailing prefix from the version like -rc1 etc |
13 | version=$(echo "$2" | sed 's/\-.*//g') | 16 | version="$(printf '%s\n' "$VERSION" | sed 's/\-.*//g')" |
14 | config_opt=$3 | 17 | config_opt="$*" |
15 | 18 | ||
16 | if [[ ! -f platform/rpm/${name}.spec ]]; then | 19 | if [[ ! -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 |
19 | fi | 22 | fi |
20 | 23 | ||
21 | if [[ -z "${version}" ]]; then | 24 | if [[ -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 |
24 | fi | 27 | fi |
25 | 28 | ||
@@ -28,26 +31,27 @@ if [[ -z "${config_opt}" ]]; then | |||
28 | fi | 31 | fi |
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 |
31 | tmpdir=$(mktemp -d) | 34 | tmpdir="$(mktemp -d)" |
32 | mkdir -p ${tmpdir}/{BUILD,RPMS,SOURCES,SPECS,SRPMS} | 35 | mkdir -p "${tmpdir}"/{BUILD,RPMS,SOURCES,SPECS,SRPMS} |
33 | function cleanup { | 36 | function cleanup { |
34 | rm -rf ${tmpdir} | 37 | rm -rf "${tmpdir}" |
35 | } | 38 | } |
36 | trap cleanup EXIT | 39 | trap cleanup EXIT |
37 | 40 | ||
38 | # Create the spec file | 41 | # Create the spec file |
39 | tmp_spec_file=${tmpdir}/SPECS/${name}.spec | 42 | tmp_spec_file="${tmpdir}/SPECS/${name}.spec" |
40 | sed -e "s/__NAME__/${name}/g" \ | 43 | sed -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 |
47 | tar --exclude='./.git*' --transform "s/^./${name}-${version}/" -czf ${tmpdir}/SOURCES/${name}-${version}.tar.gz . | 50 | tar --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) |
50 | rpmbuild --quiet --define "_topdir ${tmpdir}" -ba ${tmp_spec_file} | 54 | rpmbuild --quiet --define "_topdir ${tmpdir}" -ba "${tmp_spec_file}" |
51 | 55 | ||
52 | # Copy the results to cwd | 56 | # Copy the results to cwd |
53 | mv ${tmpdir}/SRPMS/*.rpm ${tmpdir}/RPMS/*/*rpm . | 57 | mv "${tmpdir}/SRPMS"/*.rpm "${tmpdir}/RPMS"/*/*rpm . |