blob: c06cdb649c3761c2e65d5bf5beda121a018bfa37 (
plain)
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
|
#!/bin/sh
# Assumed directory layout:
# this script sits in the top-level directory. Under which there's
# a subdirectory for each package. There is also the special
# adminitrative subdirectory rpmbuild
set -e
# Make sure we have the necessary tools.
if [ ! -x /usr/bin/mock ]; then
echo "mock not found; you need to install the mock package" >&2
exit 1
fi
#my_dir=`dirname $0`
#top_dir="$my_dir/.."
top_dir=".."
build_dir="$top_dir/rpmbuild"
specs_dir="$build_dir/SPECS"
sources_dir="$build_dir/SOURCES"
srpms_dir="$build_dir/SRPMS"
rpms_pat="results/%(dist)s/%(target_arch)s/"
releases="cpbx-45-x86_64 cpbx-45-i386"
usage() {
me=`basename $0`
echo \
"Usage:
$me <export|build|clean>
$me import path/to/srpm
export: export a source RPM package from git tree
build: build latest source RPM using mock
import: create/update a git repository from source RPM
clean: delete all produced RPM packages under $build_dir
"
}
# There must be a saner way to do that or a reason why this is not required
fix_arch() {
ARCH=${ARCH:-`uname -m`}
case "$ARCH" in
amd64) ARCH='x86_64';;
esac
}
while [ $# != 0 ]; do
case "$1" in
--define) shift ;;
*.spec) SPEC="$1"
esac
shift
done
create_srpm() {
spec=`ls -t $specs_dir/*.spec | head -n1`
mkdir -p "$srpms_dir"
rpmbuild -bs \
--define "_sourcedir $sources_dir" \
--define "_srcrpmdir $srpms_dir" \
"$spec"
}
# Mock wrapper: used internally
git_builder() {
local spec="$SPEC"
local root=${GIT_MOCK_ROOT:-${DIST}-${ARCH}}
if [ ! -d "$GIT_MOCK_EXPORT_DIR" ]; then
echo >&2 "$0: Missing outputs directory (GIT_MOCK_EXPORT_DIR). Aborting."
exit 1
fi
#local export_dir="$GIT_MOCK_EXPORT_DIR"
export_dir="$PWD"
spec="$export_dir/SPECS/$spec"
sources="$export_dir/SOURCES"
srpms="$export_dir/SRPMS"
pat="${GIT_MOCK_RESULTS_PAT-results/%(dist)s/%(target_arch)s/}"
local resultdir="$export_dir/$pat"
local mock="mock -r $root --resultdir=$srpms --spec=$spec --sources=$sources"
set -e
$mock --buildsrpm
#rpmbuild -bs --define "_topdir ." "SPECS/$spec"
# Assuming that nothing was built in this directory since the previous command:
local srpm=`ls -t $PWD/SRPMS/*.src.rpm | head -n1`
$mock --no-cleanup-after --resultdir $resultdir --rebuild "$srpm"
#for rel in $releases; do
# mock -r $rel --resultdir="$PWD/$rpms_pat" \
# --no-cleanup-after \
# --rebuild "$srpm"
#done
}
fix_arch
git_builder
|