-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathayer-rpm
executable file
·66 lines (52 loc) · 1.7 KB
/
ayer-rpm
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
#!/bin/bash
source /usr/lib/ayer/functions.sh || exit 1
PROG=$(basename "$0")
TEMP=`getopt -n $PROG -o t:,r:,d:,b: -l treeish:,release:,builddir: -- "$@"` || exit 1
eval set -- "$TEMP"
build_treeish=HEAD
build_release=
build_builddir=~/rpmbuild
build_rpmargs=-bs
while [ "$#" -gt 0 ]; do
case "$1" in
-t|--treeish)
build_treeish=$2
shift
;;
-r|--release)
build_release=$2
shift
;;
-d|--builddir)
build_builddir=$2
shift
;;
-b)
build_rpmargs=-b$2
shift
esac
shift
done
src_dir=$build_builddir/SOURCES
spec_dir=$build_builddir/SPECS
mkdir -p "$src_dir" "$spec_dir"
extract_pattern "$build_treeish" "*.spec" "$spec_dir/" --full-tree | while read rel_spec_file; do
spec_file="${spec_dir}/${rel_spec_file}"
if [ -n "$build_release" ]; then
sed -i "s#Release:.*#Release: ${build_release}%{?dist}#" "${spec_file}"
fi
changelog_commit_msg="* $(date '+%a %b %d %Y') Ayer Build System $(rpm_get_tag ${spec_file} version)\\
- build an RPM from commit $(git rev-parse $build_treeish)\\
"
if ! grep -q '%changelog' "$spec_file"; then
echo -e '\n%changelog' >> "$spec_file"
fi
sed -i "s/%changelog.*/%changelog\\
$changelog_commit_msg/" "$spec_file"
rpm_name=$(rpm_get_tag "$spec_file" name)
rpm_version=$(rpm_get_tag "$spec_file" version)
tar_base="${rpm_name}-${rpm_version}"
main_tarball="$src_dir/$tar_base.tar.gz"
git archive --format=tar --prefix="$tar_base"/ "$build_treeish" | gzip -c - > "$main_tarball"
rpmbuild $build_rpmargs "$spec_file" --define "_topdir $build_builddir"
done