forked from MailScanner/v5
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Build.debian
executable file
·121 lines (100 loc) · 3.47 KB
/
Build.debian
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
#!/usr/bin/env bash
# Updated: 16 May 2020
# MailScanner Team <https://www.mailscanner.info>
#
#
# this Build.debian script should be located in the base
# directory when run.
# make sure this is run from the base directory
if [ ! -d 'common' ]; then
echo 'This script must be executed from the base directory.';
echo;
exit 192
fi
if [ -z $(which fakeroot) -o -z $(which dpkg) ]; then
echo 'Required build packages are missing.';
echo 'Install fakeroot and dpkg 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/^.*-//')
MSDATE=$(date +"%a %d %B %Y %H:%M:%S %z")
if [ -z $MSVERSION -o -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 )
# where the final file will be copied
FILEOUT="$HOME/msbuilds";
# check to see if the output directory exists
if [ ! -d "$FILEOUT" ]; then
mkdir -p $FILEOUT
fi
# if not set from the "Build.all" script
if [ -z "$DEVBASEDIR" ]; then
DEVBASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
#echo "You current directory is $THISCURDIR"; echo;
#echo "Enter the parent directory of RPM.files without the trailing slash: ";
#read DEVBASEDIR
export DEVBASEDIR
fi
# our working directory
WORK="/tmp/MailScanner-$VERSION";
# delete work tmp if already exists
if [ -d $WORK ]; then
rm -rf $WORK
fi
# make working dir and subs
mkdir -p $WORK
mkdir -p $WORK/{usr,etc}
# etc
cp -fr $DEVBASEDIR/common/etc/* $WORK/etc/
cp -fr $DEVBASEDIR/debian/etc/* $WORK/etc/
# usr
cp -fr $DEVBASEDIR/common/usr/* $WORK/usr/
cp -fr $DEVBASEDIR/debian/usr/* $WORK/usr/
cp -rf $DEVBASEDIR/debian/DEBIAN/ $WORK
perl -pi -e 's/DebianVersionHere/'$VERSION'/;' $WORK/DEBIAN/control
perl -pi -e 's/DebianVersionHere/'$VERSION'/;' $WORK/DEBIAN/changelog
perl -pi -e "s/__Date__/$MSDATE/;" $WORK/DEBIAN/changelog
perl -pi -e 's/VersionNumberHere/'$MSVERSION'/;' $WORK/etc/MailScanner/MailScanner.conf
perl -pi -e 's/VersionNumberHere/'$MSVERSION'/;' $WORK/usr/sbin/MailScanner
# 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 {} \;
cd $WORK
find . -type f -exec chmod 0644 {} \;
find . -type d -exec chmod 0755 {} \;
chmod +x $WORK/usr/sbin/*
chmod +x $WORK/DEBIAN/postinst
chmod +x $WORK/DEBIAN/preinst
chmod +x $WORK/DEBIAN/postrm
chmod +x $WORK/usr/lib/MailScanner/wrapper/*-autoupdate
chmod +x $WORK/usr/lib/MailScanner/wrapper/*-wrapper
chmod +x $WORK/usr/lib/MailScanner/init/*
chmod +x $WORK/usr/lib/MailScanner/systemd/*
chmod +x $WORK/etc/cron.daily/*
chmod +x $WORK/etc/cron.hourly/*
# create a working dir for package
PKGTMP="/tmp/deb.$$/";
mkdir -p $PKGTMP/MailScanner-${VERSION}
mkdir -p $WORK/usr/share/MailScanner/doc
cp $DEVBASEDIR/changelog $WORK/usr/share/MailScanner/doc/
cp $DEVBASEDIR/LICENSE $WORK/usr/share/MailScanner/doc/
cp $DEVBASEDIR/README.md $WORK/usr/share/MailScanner/doc/
fakeroot dpkg -b $WORK $PKGTMP/MailScanner-$VERSION.noarch.deb
#chmod +x $PKGTMP/MailScanner-${FULLMSVER}/install.sh
cd $PKGTMP
#tar czf MailScanner-${FULLMSVER}.deb.tar.gz *
mv -f MailScanner-${VERSION}.noarch.deb $FILEOUT
rm -rf $PKGTMP
rm -rf $WORK
echo;
echo "Completed: $FILEOUT/MailScanner-${VERSION}.noarch.deb";