forked from Xilinx-CNS/tcpdirect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzf_make_official_srpm
executable file
·104 lines (85 loc) · 2.38 KB
/
zf_make_official_srpm
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: (c) 2022 Advanced Micro Devices, Inc.
######################################################################
me=$(basename "$0")
err() { echo >&2 "$*"; }
log() { err "$me: $*"; }
fail() { log "$*"; exit 1; }
try() { "$@" || fail "FAILED: $*"; }
my_dir=$(cd "$(dirname "$0")" && /bin/pwd)
top_dir=$(dirname "${my_dir}")
tarball_files_from="
versions.env
Makefile
Makefile.onload
Makefile-top.inc
doc
src
scripts/debian-templ
scripts/tcpdirect_misc/tcpdirect-extract-notes
scripts/zf_debug
scripts/zf_install
scripts/zf_make_official_deb
scripts/zf_make_official_srpm
scripts/zf_make_tarball
scripts/zf_mkdist
scripts/zf_uninstall
"
usage() {
echo
echo "usage:"
echo " $(basename "$0") [options]"
echo
echo "options:"
echo " --version <version>"
echo " --outdir <path> - Location for the output srpm file."
echo
exit 1
}
cleanup() {
echo "Deleting ${tmpdir}"
rm -rf "${tmpdir}"
}
######################################################################
# main()
version=
outdir=
while [ $# -gt 0 ]; do
case "$1" in
--version) shift; version="$1";;
--outdir) shift; outdir="$1";;
*) usage;;
esac
shift
done
if [ -z "${version}" ]; then
version=$(git rev-parse HEAD)
fi
tmpdir=$(mktemp -d "/tmp/${me}.XXXXXXXX")
zf_prefix="tcpdirect-${version}"
zf_spec="scripts/tcpdirect_misc/tcpdirect.spec"
zf_tarball="${tmpdir}/${zf_prefix}.tar"
zf_tgz="${tmpdir}/${zf_prefix}.tgz"
trap cleanup EXIT
# Create a tarball in tmpdir.
# shellcheck disable=SC2086
try tar -c -C "${top_dir}" --owner=root --group=root --transform "s,^,${zf_prefix}/,S" -f "${zf_tarball}" -- ${tarball_files_from}
# Patch and put the SPEC file in tmpdir.
# shellcheck disable=SC2046
mkdir -pv $(dirname "${tmpdir}/${zf_prefix}/${zf_spec}")
try sed \
-E "s/^.*(%global pkgversion).*$/%define pkgversion ${version}/" "${top_dir}/${zf_spec}" \
> "${tmpdir}/${zf_prefix}/${zf_spec}"
# Add the patched SPEC file in the tarball.
try tar -v -C "${tmpdir}" --owner=root --group=root --append -f "${zf_tarball}" -- "${zf_prefix}/${zf_spec}"
# Compress the tarball.
try gzip -v "${zf_tarball}"
# Rename the compressed file extension tar.gz -> tgz.
try mv -v "${zf_tarball}.gz" "${zf_tgz}"
# Create SRPM.
rpmbuild_args=()
if [ -n "$outdir" ]; then
rpmbuild_args=(--define "_topdir $outdir");
fi
try rpmbuild -ts "${zf_tgz}" "${rpmbuild_args[@]}"