-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathrecreate_srpm.sh
executable file
·72 lines (57 loc) · 1.65 KB
/
recreate_srpm.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function usage ()
{
echo "USAGE:"
echo "recreate_srpm.sh <NVR> [--bumpspec]"
}
NVR=$1
if [ "x$NVR" = "x" ]; then
echo "Missing NVR"
usage
exit 1
fi
PKG_AND_GIT=($($SCRIPT_DIR/get_package_hashes.py $NVR | \
awk '{ match($0, /\/([^:]+):([a-f0-9]+)\)/, arr); \
if(arr[1] != "") print arr[1]; \
if(arr[2] != "") print arr[2] }'))
if [ $? -ne 0 ]; then
echo "Error getting buildinfo"
exit 1
fi
# trim any .git suffix that koji may have mysteriously appended
DIST_GIT_REPO=${PKG_AND_GIT[0]%.git}
if [ "x$DIST_GIT_REPO" = "x" ]; then
echo "Invalid NVR"
exit 1
fi
PKG=`basename $DIST_GIT_REPO`
GIT_COMMIT=${PKG_AND_GIT[1]}
if [ "x$GIT_COMMIT" = "x" ]; then
echo "Git commit not found"
exit 1
fi
echo "Generating $PKG SRPMs from commit $GIT_COMMIT"
OUTPUT_DIR=`pwd`
WORKING_DIR=`mktemp -d`
pushd $WORKING_DIR
fedpkg clone -a $DIST_GIT_REPO
pushd $PKG
git reset --hard $GIT_COMMIT
fedpkg sources
if [ "x$2" = "x--bumpspec" ]; then
# Bump the version so it's guaranteed to sort higher
rpmdev-bumpspec -s 0.override. \
-c "Regenerating SRPM for each architecture." \
-u "Base Runtime Team <[email protected]>" \
$PKG.spec
fi
for arch in "aarch64" "armv7hl" "i686" "ppc64" "ppc64le" "s390x" "x86_64"; do
mkdir -p $OUTPUT_DIR/$arch
rpmbuild -bs --build-in-place --target=$arch \
--define "_sourcedir $WORKING_DIR/$PKG" \
--define "_srcrpmdir $OUTPUT_DIR/$arch" $PKG.spec
done
popd
popd
rm -Rf $WORKING_DIR