blob: c6d1818591ae79faa82fa3eb95c0bd4ff39a5891 (
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
#!/bin/sh
DESTDIR=.build
CLEAN=0
DIST=fedora-18-local-x86_64
PACKAGE_PATH_BASE=$HOME/devel/specs
MOCKDIR=/var/lib/mock
MOCKCONF=/etc/mock
PACKAGES=
function die
{
echo $@ >&2
exit 1
}
function get_mock_path
{
FILE="$MOCKCONF/$1.cfg"
NAME=$(sed -n "s,^config_opts\['root'\]\s*=\s*'\(.*\)'.*$,\1,p" $FILE)
echo $MOCKDIR/$NAME
}
while [ $# -gt 0 ]
do
OPTION=$1
shift
case $OPTION in
-b|--build)
DESTDIR=$1
shift
;;
-c|--clean)
CLEAN=1
;;
-d|--dist)
DIST=$1
shift
;;
--list-pkgs)
for path in $(find $PACKAGE_PATH_BASE -maxdepth 2 -name '*.spec')
do
echo $(basename $(dirname $path))
done
exit 0
;;
--list-dists)
for profile in $(find $MOCKCONF -name '*.cfg' -printf '%f\n')
do
echo ${profile:0: -4}
done
exit 0
;;
-h|--help)
echo "Create a local repository from the RPMs found in the scan-path.
usage: $0 [ options ] < package name >
options:
-b --build Specify output for source/built RPMs (default: $DESTDIR)
-c --clean Clean build directory before building
-d --dist Specify distribution (mock profile name) (default: $DIST)
--list-pkgs List packages that can be built
--list-dists List available distributions
-h --help Show this help file"
exit 1
;;
--)
PACKAGES="$PACKAGES $@"
break
;;
-*)
echo "Unkown option $OPTION" >&2
exit 1
;;
*)
PACKAGES="$PACKAGES $OPTION"
;;
esac
done
[ "x$PACKAGES" = "x" ] && die Missing package name
#set -x
if [ $CLEAN -eq 1 ]
then
rm -rf $DESTDIR/*
fi
if [ ! -d $DESTDIR ]
then
mkdir -p $REPODIR
elif [ ! -w $REPODIR ]
then
die "You don't have access to $REPODIR"
fi
mkdir -p $DESTDIR/srpm
mkdir -p $DESTDIR/rpm
BASE_DIR=$(pwd)
cd $DESTDIR
DESTDIR=$(pwd)
cd $BASE_DIR
for PACKAGE in $PACKAGES
do
PACKAGE_PATH=$PACKAGE_PATH_BASE/$PACKAGE
if [ ! -d $PACKAGE_PATH ]
then
echo "$PACKAGE_PATH not found"
continue
fi
SPECFILE=$(find $PACKAGE_PATH -name '*.spec' | head -1)
if [ "x$SPECFILE" = "x" ]
then
echo "$PACKAGE_PATH contains no spec file"
continue
fi
mock --buildsrpm --spec $SPECFILE --sources $PACKAGE_PATH -r $DIST
if [ $? -ne 0 ]
then
echo "Mock failed to create srpm from $SPECFILE"
continue
fi
DISTPATH=$(get_mock_path $DIST)/result
SRPM=$(find $DISTPATH -name '*.src.rpm' -printf '%f\n' | head -1)
cp $DISTPATH/$SRPM $DESTDIR/srpm
mock -r $DIST --rebuild $DESTDIR/srpm/$SRPM
if [ $? -ne 0 ]
then
echo "Mock failed to build $SRPM"
continue
fi
find $DISTPATH \( -name '*.rpm' -a ! -name '*.src.rpm' \) -exec cp {} $DESTDIR/rpm \;
cd $BASE_DIR
done
|