forked from hpcugent/VSC-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbdist_rpm.sh
executable file
·89 lines (79 loc) · 3.23 KB
/
bdist_rpm.sh
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
#!/bin/bash
# Copyright 2012 Ghent University
# Copyright 2012 Andy Georges
#
# This file is part of VSC-tools,
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
# with support of Ghent University (http://ugent.be/hpc),
# the Flemish Supercomputer Centre (VSC) (https://vscentrum.be/nl/en),
# the Hercules foundation (http://www.herculesstichting.be/in_English)
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).
#
# http://github.com/hpcugent/VSC-tools
#
# VSC-tools is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation v2.
#
# VSC-tools is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with VSC-tools. If not, see <http://www.gnu.org/licenses/>.
##
# This script will generate the RPMs for deployment on some system, prefixing the Python package names with python-
# to indicate their contents in a more appropriate way. We do not do this for the packages when shipped to
# PyPi, since it is pretty obvious these are Python packages in any case.
all_packages=
edit=
release=
which rpmrebuild >& /dev/null
if [ $? -gt 0 ]
then
echo "Missing rpmrebuild"
exit 1
fi
while getopts er:p:h name
do
case $name in
e) edit="-e";;
r) release="$OPTARG";;
p) all_packages="$OPTARG";;
h) printf "Usage: %s [-e] [-r RELEASE] [-p PACKAGE]" $0
echo
echo " -e Edit the generated spec file before rebuilding the RPM"
echo " -r [RELEASE] Specify the RELEASE tag given to the RPM. Automagically adds .ug.noarch"
echo " -p [PACKAGE] Specify a single PACKAGE to be built. Default builds all packages."
exit 1;;
esac
done
if [ -z "$all_packages" ]; then
ALL_PACKAGES=`python ./shared_setup.py`
else
ALL_PACKAGES=$all_packages
fi
for package in $ALL_PACKAGES; do
echo "Building RPM for $package"
setup=`echo ${package#vsc-} |tr '-' '_'`
python ./setup_${setup}.py bdist_rpm
# get latest one (name-version syntax)
rpm_target=`ls -t dist/${package}-[0-9]*noarch.rpm | head -1`
rpm_target_name=`basename ${rpm_target}`
# user specified requirements can be found in setup.cfg
requirements=`grep "requires" setup.cfg | cut -d" " -f3- | tr "," "\n" | grep -v "^python-" | tr "\n" "|" | sed -e 's/|$//'`
if [ -z "$requirements" ]; then
requirements="no-match-etc-etc-etc"
fi
if [ -z "$release" ]; then
release="\\2"
fi
rpmrebuild --define "_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
--change-spec-preamble="sed -e 's/^Name:\(\s\s*\)\(.*\)/Name:\1python-\2/'" \
--change-spec-provides="sed -e 's/${package}/python-${package}/g'" \
--change-spec-requires="sed -r 's/^Requires:(\s\s*)(${requirements})/Requires:\1python-\2/'" \
--change-spec-preamble="sed -e 's/^\(Release:\s\s*\)\(.*\)\s*$/\1${release}.ug/'" \
${edit} -n -p ${rpm_target}
echo "Finished building RPM for $package"
done