-
Notifications
You must be signed in to change notification settings - Fork 60
/
Build.suse
executable file
·90 lines (71 loc) · 2.31 KB
/
Build.suse
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
#!/usr/bin/env bash
#
# Updated: 16 May 2020
# MailScanner Team <https://www.mailscanner.info>
#
# This helper script will build the latest SUSE install
# make sure this is run from the base directory
if [ ! -d 'suse' ]; then
echo 'This script must be executed from the base directory.';
echo './suse was not found. Exiting ...';
echo;
exit 192
fi
if [ -z $(which rpmbuild) ]; then
echo 'Required rpmbuild package is missing';
echo 'install rpmbuild before continuing, Exiting ...';
echo;
exit 192
fi
VERSION=$(sed -e 's/\n//' VERSION)
MSVERSION=$(echo $VERSION | sed -e 's/-.*$//')
MSBUILD=$(echo $VERSION | sed -e 's/^.*-//')
if [[ -z $MSVERSION || -z $MSBUILD ]]; then
echo "Could not determine MailScanner version."
echo "Unable to read VERSION file"
echo;
exit 192
fi
# directory we are in
THISCURDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [ -z "$RPMOUT" ]; then
RPMOUT="$HOME/msbuilds";
fi
# setup rpm development dirs
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
# create build output base dir
mkdir -p $RPMOUT
# the work directory
WORK="/tmp/MailScanner-$MSVERSION";
# delete work tmp if already exists
if [ -d $WORK ]; then
rm -rf $WORK
fi
# make working dir and subs
mkdir -p $WORK
# copy everything
cp -fr $THISCURDIR/* $WORK/
# remove svn and git and mac stuff
find $WORK -name '.svn' -exec rm -rf {} \;
find $WORK -name '.git' -exec rm -rf {} \;
find $WORK -name '*.DS_Store' -exec rm -rf {} \;
find $WORK -depth -name '__MACOSX' -exec rm -rf {} \;
# Build the src tarball for RPM construction
cd $WORK
cd ..
tar czf ~/rpmbuild/SOURCES/MailScanner-${MSVERSION}.tar.gz MailScanner-${MSVERSION}
# return to where i started
cd $THISCURDIR
# Build the RPM and SRPMS
cp -f $THISCURDIR/suse/mailscanner.spec ~/rpmbuild/SPECS/mailscanner.spec
perl -pi -e 's/__Version__/'$MSVERSION'/;' ~/rpmbuild/SPECS/mailscanner.spec
perl -pi -e 's/__Release__/'$MSBUILD'/;' ~/rpmbuild/SPECS/mailscanner.spec
rpmbuild -ba ~/rpmbuild/SPECS/mailscanner.spec
# Cleanup
mv ~/rpmbuild/RPMS/noarch/MailScanner-${VERSION}.suse.noarch.rpm $RPMOUT
rm -rf $WORK
# Be mindful that rpmbuild may be present for other things...
rm -f ~/rpmbuild/SOURCES/MailScanner-${MSVERSION}.tar.gz
rm -f ~/rpmbuild/SPECS/mailscanner.spec
echo;
echo "Completed: $RPMOUT/MailScanner-${VERSION}.suse.noarch.rpm";