This repository has been archived by the owner on Nov 9, 2023. It is now read-only.
forked from hpcugent/Lmod-UGent
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildrpmfromspec.sh
executable file
·73 lines (62 loc) · 1.75 KB
/
buildrpmfromspec.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
#!/bin/bash
if [[ -z "$1" || -d "$1" ]];then
echo "You didn't specify anything to build";
if [ -d "$1" ]
then
cd $1
fi
spec=`ls *spec | head -1`
if [ -z "$spec" ]
then
echo "No spec file found. Exiting."
exit 1;
else
reg='Name: '
name=`grep "$reg" $spec |sed "s/$reg//" | sed "s/ //g"`
reg='Version: '
vers=`grep "$reg" $spec |sed "s/$reg//" | sed "s/ //g"`
echo "Found spec $spec: name $name version $vers"
fi
else
spec=$1.spec
name="$1"
fi
if [ -z "$2" ]; then
if [ -z "$vers" ]
then
echo "You didn't specify a version to build";
exit 1;
fi
else
vers="$2"
echo "Using spec $spec: name $name version $vers"
fi
grep -E 'Fedora|release [6-9]' /etc/redhat-release >& /dev/null
if [ $? -eq 0 ]
then
myrpmbasedir=$HOME/rpmbuild
else
myrpmbasedir=/usr/src/redhat
fi
rpmbasedir=${BDISTRPMBASEDIR:-$myrpmbasedir}
echo "----> Building rpm for $name"
src_dir_main=$rpmbasedir/SOURCES/
src_dir=$rpmbasedir/SOURCES/${name}-${vers}
echo "----> Using $src_dir"
mkdir -pv $src_dir
# delete older versions of the rpm since there's no point having old
# versions in there when we still have the src.rpms in the SRPMS dir
echo "----> Cleaning up older packages"
find $rpmbasedir/RPMS -name ${name}-[0-9]\* -exec rm -vf {} \;
# Should use rpmspectool here
lmod_src="Lmod-${vers}.tar.gz"
rm $lmod_src
wget -O $lmod_src "https://github.com/TACC/Lmod/archive/${vers}.tar.gz"
mv $lmod_src $src_dir
cp -a *.patch admin.list *.lua macros.Lmod run_lmod_cache.py $src_dir
echo "----> Building the package"
## -ba: source and binary
## no debuginfo
rpmbuild --define "_sourcedir $src_dir" --define "_topdir $rpmbasedir" -ba --without debuginfo $spec
ec=$?
exit $ec