-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
prepare_obs
executable file
·189 lines (179 loc) · 4.89 KB
/
prepare_obs
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/bin/sh
#
# This script prepares artifacts that can be downloaded for openSUSE build service
# It creates name.tar.gz, debian.tar.gz, name.spec name.changes and PKGBUILD
#
set -e
if [ $# -ne 1 ] ; then
echo "USAGE: prepare_obs name" 1>&2
exit 1
fi
name=$1
curdir=$PWD
version=$(cat conf-version)
stage=$HOME/stage
mkdir -p $stage
meta_pkg=0
if [ ! -f conf-release ] ; then
echo 1.1 > conf-release
fi
if [ -f $name.packages ] ; then
meta_pkg=1
for dir in `cat $name.packages`
do
real_dir=$(basename $dir)
echo $dir|grep "/" >/dev/null
if [ $? -eq 0 ] ; then
pkg_name=$(basename $dir|sed -e 's{-x{{g')
else
pkg_name=$(echo $dir|sed -e 's{-x{{g')
fi
if [ -d $dir ] ; then
cd $dir
else
echo "$dir: No such file or directory" 1>&2
exit 1
fi
ver=$(cat conf-version)
if [ -z "$ver" ] ; then
echo "no version found for package $pkg_name" 1>&2
exit 1
fi
echo Preparing $pkg_name-$ver
cp -rpf . $stage/$pkg_name-$ver
cd $stage/$pkg_name-$ver
if [ -f default.configure -a ! -f ./configure -o ! -f ./Makefile ] ; then
echo reconfiguring $pkg_name-$ver
./default.configure >/dev/null 2>&1
fi
if [ -f Makefile ] ; then
echo cleaning $pkg_name-$ver
set +e
make clean && make distclean >/dev/null 2>&1
find . -type d -name autom4te.cache -exec /bin/rm -rf '{}' '+'
set -e
fi
# remove debian directory from archive
#/bin/rm -rf debian .git RCS
cd ..
echo "creating archive $pkg_name-$ver.tar.gz"
tar cfz $pkg_name-$ver.tar.gz $pkg_name-$ver
if [ ! "$real_dir" = "$pkg_name" -a ! -L $real_dir ] ; then
ln -sr $pkg_name-$ver $real_dir
fi
cd $curdir
done
fi
echo "Preparing $name-$version"
cp -rp . $stage/$name-$version
if [ -L $stage/$name-$version/catChangeLog ] ; then
/bin/rm -f $stage/$name-$version/catChangeLog
cp catChangeLog $stage/$name-$version # for spec file, changes, debian/changelog to get built
fi
cd $stage/$name-$version
if [ -f default.configure -a ! -f ./configure -o ! -f ./Makefile ] ; then
echo reconfiguring $name-$version
./default.configure >/dev/null 2>&1
fi
if [ ! -f $name.changes ] ; then
make $name.changes
fi
if [ ! -f $name.changes ] ; then
# This will build the $name.changes file
./catChangeLog --changes > $name.changes
fi
# now build the spec, PKGBUILD and dsc files
# rpm distributions
if [ -f $name.spec.in -a -f Makefile -a ! -f $name.$spec ] ; then
make $name.spec
fi
for i in permissions.easy permissions.secure permissions.paranoid rpmlintrc
do
if [ -f $name-$i.in -a -f Makefile -a ! -f $name-$i ] ; then
make $name-$i
fi
if [ -f $name-$i ] ; then
cp $name-$i $stage
fi
done
# debian
if [ -f debian/Makefile.in ] ; then
make debian/Makefile
fi
if [ -f debian/Makefile ] ; then
make -C debian
cp debian/debian.tar.gz $stage
cp debian/*.dsc $stage
make -C debian clean >/dev/null
fi
# arch linux
if [ -f PKGBUILD.in -a -f Makefile -a ! -f PKGBUILD ] ; then
make PKGBUILD
fi
if [ -f PKGBUILD ] ; then
sed -i 's/_build_on_obs=.*/_build_on_obs=1/g' PKGBUILD
total=$(grep "#### INSTALL.* ####" PKGBUILD | wc -l)
if [ $total -le 1 ] ; then
sed -n '/#### INSTALL SCRIPTS ####/,$p' PKGBUILD \
| grep -v "^####" > archpkg.install || true
if [ ! -s archpkg.install ] ; then
/bin/rm -f archpkg.install
fi
else
count=1
while true
do
sed -n "/#### INSTALL$count SCRIPTS ####/,/#### END ####/p" PKGBUILD \
| grep -v "^####" > archpkg"$count".install || true
if [ ! -s archpkg"$count".install ] ; then
/bin/rm -f archpkg"$count".install
fi
if [ $count -eq $total ] ; then
break
fi
count=$(expr $count + 1)
done
fi
fi
for i in $name.spec $name.changes PKGBUILD archpkg*.install
do
if [ -f $i ] ; then
cp $i $stage
fi
done
if [ -f extra_src ] ; then
make `grep -h -v "^#" extra_src`
cp -rpf `grep -h -v "^#" extra_src` $stage
fi
if [ -f Makefile ] ; then
echo cleaning $name-$version
set +e
make clean && make distclean >/dev/null 2>&1
find . -type d -name autom4te.cache -exec /bin/rm -rf '{}' '+'
set -e
fi
# clean meta packages
if [ $meta_pkg -eq 1 ] ; then
for dir in `cat $name.packages`
do
real_dir=$(basename $dir)
echo $dir | grep "/" >/dev/null
if [ $? -eq 0 ] ; then
pkg_name=$(echo $real_dir | sed -e 's{-x{{g')
else
pkg_name=$(echo $dir | sed -e 's{-x{{g')
fi
ver=$(cat $dir/conf-version)
/bin/rm -rf $stage/$pkg_name-$ver
if [ ! "$real_dir" = "$pkg_name" -a -L $stage/$real_dir ] ; then
/bin/rm -f $stage/$real_dir
fi
done
/bin/rm -rf $stage/$name-$version
else
/bin/rm -rf debian .git RCS
cd ..
echo "creating archive $name-$version.tar.gz"
tar cfz $name-$version.tar.gz $name-$version
/bin/rm -rf $name-$version
fi