-
Notifications
You must be signed in to change notification settings - Fork 13
/
build-srpm.sh
executable file
·47 lines (31 loc) · 1.17 KB
/
build-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
#!/bin/sh
set -e
MYDIR="$(dirname $(readlink -m $0))"
GIT_DIR=$(cd $MYDIR && readlink -m $(git rev-parse --git-dir))
export GIT_DIR
# Functions copied from the specfile
latestcommitstamp() {
git rev-list -n1 --format=format:%ct HEAD | tail -n1
}
releasestr() {
echo $(date -u +%Y%m%dT%H%M%SZ --date=@$(latestcommitstamp)).git$(git rev-list --abbrev-commit -n1 HEAD)
}
if [ -d "rpm" ]; then
echo "A folder called rpm already exists, please delete it before running this script."
exit 1
fi
mkdir -p rpm/SOURCES rpm/SPECS
RPMDIR="$(readlink -m rpm)"
RELEASESTR=$(releasestr)
FOLDER_NAME="s3proxy-${RELEASESTR}"
git archive --format=tar --prefix="${FOLDER_NAME}/" HEAD | bzip2 -c > "$RPMDIR/SOURCES/${FOLDER_NAME}.tar.bz2"
SPECFILE="$RPMDIR/SPECS/s3proxy.spec"
echo -e "# AUTO GENERATED BY build-srpm.sh, DO NOT EDIT BY HAND\n" > $SPECFILE
# We need to expand those macros now, since in the chroot build environment we
# won't have access to git etc.
sed \
-e "/^%define latestcommitstamp /d" \
-e "s/^%define releasestr .\\+/%define releasestr $RELEASESTR/" \
s3proxy.spec >> $SPECFILE
rpmbuild -bs --define "%_topdir $RPMDIR" $SPECFILE
echo "SRPM built in $RPMDIR/SRPMS/"