blob: 120daa41b353e547b960013f21bfd49f527a6d1c (
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
|
#!/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
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 [options] package.spec - Build package.spec with mock
Options:
--define STRING - Currently ignored
Environment:
ARCH: The architecture of the mock root. Defaults to the oen
of the host system.
DIST: The distribution of the mock host.
GIT_MOCK_ROOT: The mock root. Defaults to "$DIST-$ARCH"
GIT_MOCK_EXPORT_DIR: The top-level directory of the git-
buildpackage results tree.
GIT_MOCK_RESULTS_PAT: The directory template for results under
the exports dir. A default is provided.
"
}
# 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
# 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"
}
fix_arch
git_builder
|