-
Notifications
You must be signed in to change notification settings - Fork 25
/
Build.debian
executable file
·263 lines (233 loc) · 10.3 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
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#!/usr/bin/env bash
# FHS revision
# Jerry Benton
# 23 Jan 2016
# Checked and updated to be more streamlined by
# Jerry Benton
# 24 FEB 2015
# this Build.debian script should be located in the base
# directory when run.
# make sure this is run from the base directory
if [ ! -d 'RPM.files' ]; then
echo 'This script must be executed from the base directory.';
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/deb";
export FILEOUT;
# 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 "$MSVERSION" ]; then
echo "Please tell me the version number (x.xx.x): ";
read MSVERSION
export MSVERSION
fi
# if not set from the "Build.all" script
if [ -z "$MSBUILD" ]; then
echo "And the build number (-x): ";
read MSBUILD
export MSBUILD
fi
# if not set from the "Build.all" script
if [ -z "$FULLMSVER" ]; then
FULLMSVER=$MSVERSION-$MSBUILD
export FULLMSVER
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
# create this if missing
if [ ! -f '/tmp/MailScanner.conf.index.html' ]; then
sh $DEVBASEDIR/config.index/make.sh
fi
# our working directory
WORK="/tmp/MailScanner-$FULLMSVER";
# 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/{var,usr,etc}
mkdir -p $WORK/var/{spool/MailScanner/archive,spool/MailScanner/quarantine,spool/MailScanner/incoming}
mkdir -p $WORK/usr/sbin
mkdir -p $WORK/usr/{share/man/man8,share/man/man5,share/doc/MailScanner,share/lintian/overrides,share/MailScanner/perl/MailScanner,share/MailScanner/perl/custom}
mkdir -p $WORK/var/lib/MailScanner/wrapper
mkdir -p $WORK/usr/share/MailScanner/reports/{hu,de,se,ca,cy+en,pt_br,fr,es,en,cz,it,dk,nl,ro,sk}
mkdir -p $WORK/etc/{default,cron.daily,cron.hourly,init.d,logcheck/ignore.d.workstation,logcheck/ignore.d.server,MailScanner}
mkdir -p $WORK/etc/MailScanner/{rules,mcp,conf.d}
# etc
# cron, default, init.d, logcheck
cp $DEVBASEDIR/Debian.files/etc/cron.daily/mailscanner $WORK/etc/cron.daily/MailScanner
cp $DEVBASEDIR/Debian.files/etc/cron.hourly/mailscanner $WORK/etc/cron.hourly/MailScanner
cp $DEVBASEDIR/Debian.files/etc/default/mailscanner $WORK/etc/default/MailScanner
cp $DEVBASEDIR/Debian.files/etc/init.d/mailscanner $WORK/etc/init.d/MailScanner
cp $DEVBASEDIR/Debian.files/etc/logcheck/ignore.d.server/mailscanner $WORK/etc/logcheck/ignore.d.server/MailScanner
cp $DEVBASEDIR/Debian.files/etc/logcheck/ignore.d.workstation/mailscanner $WORK/etc/logcheck/ignore.d.workstation/MailScanner
# etc/MailScanner
cp $DEVBASEDIR/mailscanner/etc/*.conf $WORK/etc/MailScanner/
cp $DEVBASEDIR/mailscanner/etc/mailscanner.conf.with.mcp $WORK/etc/MailScanner/
cp $DEVBASEDIR/mailscanner/etc/conf.d/README $WORK/etc/MailScanner/conf.d/
cp $DEVBASEDIR/mailscanner/etc/mcp/* $WORK/etc/MailScanner/mcp/
mv $WORK/etc/MailScanner/mailscanner.conf $WORK/etc/MailScanner/MailScanner.conf
cp -f $DEVBASEDIR/mailscanner/etc/virus.scanners.conf $WORK/etc/MailScanner/virus.scanners.conf
# etc/MailScanner/rules
while read f
do
cp $DEVBASEDIR/mailscanner/etc/rules/$f $WORK/etc/MailScanner/rules
done << EOF
EXAMPLES
README
spam.whitelist.rules
bounce.rules
max.message.size.rules
EOF
# etc/MailScanner/reports
for lang in en cy+en de fr es nl pt_br sk dk it ro se cz hu ca
do
while read f
do
cp $DEVBASEDIR/mailscanner/etc/reports/$lang/$f $WORK/usr/share/MailScanner/reports/$lang
done << EOF
deleted.content.message.txt
deleted.filename.message.txt
deleted.size.message.txt
deleted.virus.message.txt
disinfected.report.txt
inline.sig.html
inline.sig.txt
inline.spam.warning.txt
inline.warning.html
inline.warning.txt
languages.conf
recipient.spam.report.txt
recipient.mcp.report.txt
rejection.report.txt
sender.content.report.txt
sender.error.report.txt
sender.filename.report.txt
sender.spam.rbl.report.txt
sender.spam.report.txt
sender.spam.sa.report.txt
sender.mcp.report.txt
sender.size.report.txt
sender.virus.report.txt
stored.content.message.txt
stored.filename.message.txt
stored.size.message.txt
stored.virus.message.txt
EOF
done
# usr/sbin
cp $DEVBASEDIR/mailscanner/bin/analyse_SpamAssassin_cache $WORK/usr/sbin/
cp $DEVBASEDIR/mailscanner/bin/d2mbox $WORK/usr/sbin/
cp $DEVBASEDIR/mailscanner/bin/df2mbox $WORK/usr/sbin/
cp $DEVBASEDIR/mailscanner/bin/check_mailscanner $WORK/usr/sbin/
cp $DEVBASEDIR/mailscanner/bin/mailscanner.sbin $WORK/usr/sbin/MailScanner
cp $DEVBASEDIR/mailscanner/bin/mailscanner_create_locks $WORK/usr/sbin/
cp $DEVBASEDIR/mailscanner/bin/Quick.Peek $WORK/usr/sbin/
cp $DEVBASEDIR/mailscanner/bin/processing_messages_alert $WORK/usr/sbin/
cp $DEVBASEDIR/mailscanner/bin/Quick.Peek $WORK/usr/sbin/
cp $DEVBASEDIR/mailscanner/bin/update_bad_phishing_emails $WORK/usr/sbin/
cp $DEVBASEDIR/mailscanner/bin/update_phishing_sites $WORK/usr/sbin/
cp $DEVBASEDIR/mailscanner/bin/update_spamassassin $WORK/usr/sbin/
cp $DEVBASEDIR/mailscanner/bin/update_bad_phishing_sites $WORK/usr/sbin/
cp $DEVBASEDIR/mailscanner/bin/update_virus_scanners $WORK/usr/sbin/
cp $DEVBASEDIR/mailscanner/bin/upgrade_MailScanner_conf $WORK/usr/sbin/
# usr/share/man
cp $DEVBASEDIR/man/*.8 $WORK/usr/share/man/man8/
cp $DEVBASEDIR/man/*.5 $WORK/usr/share/man/man5/
# usr/share/doc
cp $DEVBASEDIR/README $WORK/usr/share/doc/MailScanner/
cp $DEVBASEDIR/Debian.files/changelog.Debian $WORK/usr/share/doc/MailScanner/
cp /tmp/MailScanner.conf.index.html $WORK/usr/share/doc/MailScanner/
cp $DEVBASEDIR/Debian.files/copyright $WORK/usr/share/doc/MailScanner/
# /usr/share/linitian/overrides
cp $DEVBASEDIR/Debian.files/usr/share/lintian/overrides/mailscanner $WORK/usr/share/lintian/overrides/MailScanner
# wrappers and updates
cp $DEVBASEDIR/mailscanner/lib/avg-* $WORK/var/lib/MailScanner/wrapper
cp $DEVBASEDIR/mailscanner/lib/bitdefender-* $WORK/var/lib/MailScanner/wrapper
cp $DEVBASEDIR/mailscanner/lib/clamav-* $WORK/var/lib/MailScanner/wrapper
cp $DEVBASEDIR/mailscanner/lib/f-secure-* $WORK/var/lib/MailScanner/wrapper
cp $DEVBASEDIR/mailscanner/lib/generic-* $WORK/var/lib/MailScanner/wrapper
cp $DEVBASEDIR/mailscanner/lib/sophos-* $WORK/var/lib/MailScanner/wrapper
# perl modules
cp $DEVBASEDIR/mailscanner/bin/MailScanner.pm $WORK/usr/share/MailScanner/perl/
cp $DEVBASEDIR/mailscanner/bin/MailScanner/*.pm $WORK/usr/share/MailScanner/perl/MailScanner/
cp $DEVBASEDIR/mailscanner/bin/MailScanner/ConfigDefs.pl $WORK/usr/share/MailScanner/perl/MailScanner/
cp $DEVBASEDIR/mailscanner/bin/MailScanner/CustomFunctions/*.pm $WORK/usr/share/MailScanner/perl/custom/
# set correct paths
perl -pi - $WORK/usr/share/MailScanner/perl/MailScanner/ConfigDefs.pl $WORK/usr/share/MailScanner/perl/MailScanner/CustomConfig.pm $WORK/etc/MailScanner/MailScanner.conf $WORK/etc/MailScanner/virus.scanners.conf $WORK/usr/sbin/MailScanner $WORK/usr/sbin/update_virus_scanners $WORK/usr/sbin/update_phishing_sites $WORK/usr/sbin/update_bad_phishing_sites $WORK/usr/sbin/update_bad_phishing_emails <<EOF
s+/etc/MailScanner/mailscanner.conf+/etc/MailScanner/MailScanner.conf+;
s+/etc/MailScanner/virus.scanners.conf+/etc/MailScanner/virus.scanners.conf+;
s./opt/MailScanner/var./var/run.;
s./usr/sbin/mailscanner_create_locks./usr/sbin/mailscanner_create_locks.;
s./usr/sbin/tnef./usr/bin/tnef.;
s#/usr/sbin/Quick.Peek#/usr/sbin/Quick.Peek#;
s./usr/share/MailScanner/reports./usr/share/MailScanner/reports.;
s./etc/MailScanner/rules./etc/MailScanner/rules.;
s./etc/MailScanner./etc/MailScanner.;
s./var/lib/MailScanner./var/lib/MailScanner.;
s./usr/sbin./usr/sbin.;
s./usr/lib/sendmail./usr/sbin/sendmail.;
s+Clamd Socket = /tmp/clamd.socket+Clamd Socket = /var/run/clamav/clamd.ctl+;
EOF
perl -pi - $WORK/usr/sbin/check_mailscanner $WORK/usr/sbin/mailscanner_create_locks $WORK/usr/sbin/processing_messages_alert <<EOF
s+/etc/MailScanner/mailscanner.conf+/etc/MailScanner/MailScanner.conf+;
s./opt/MailScanner/var./var/run.;
s./usr/sbin/tnef./usr/bin/tnef.;
s#/usr/sbin/Quick.Peek#/usr/sbin/Quick.Peek#;
s./usr/share/MailScanner/reports./usr/share/MailScanner/reports.;
s./etc/MailScanner/rules./etc/MailScanner/rules.;
s./etc/MailScanner/mcp./etc/MailScanner/mcp.;
s./etc/MailScanner./etc/MailScanner.;
s./var/lib/MailScanner./var/lib/MailScanner.;
s./usr/sbin./usr/sbin.;
s./usr/lib/sendmail./usr/sbin/sendmail.;
EOF
cp -rf $DEVBASEDIR/Debian.files/DEBIAN/ $WORK
perl -pi -e 's/DebianVersionHere/'$FULLMSVER'/;' $WORK/DEBIAN/control
perl -pi -e 's/VersionNumberHere/'$MSVERSION'/;' $WORK/etc/MailScanner/MailScanner.conf
perl -pi -e 's/VersionNumberHere/'$MSVERSION'/;' $WORK/usr/sbin/MailScanner
perl -pi -e 's/VersionNumberHere/'$MSVERSION'/;' $WORK/DEBIAN/postinst
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/var/lib/MailScanner/wrapper/*-autoupdate
chmod +x $WORK/var/lib/MailScanner/wrapper/*-wrapper
chmod +x $WORK/etc/init.d/MailScanner
chmod +x $WORK/etc/cron.daily/MailScanner
chmod +x $WORK/etc/cron.hourly/MailScanner
for f in $WORK/usr/share/man/man8/*.8 ; do gzip -9 "$f"; done
for f in $WORK/usr/share/man/man5/*.5 ; do gzip -9 "$f"; done
gzip -9 $WORK/usr/share/doc/MailScanner/changelog.Debian
# create a working dir for package
PKGTMP="/tmp/deb.$$/";
mkdir -p $PKGTMP/MailScanner-${FULLMSVER}
fakeroot dpkg -b $WORK $PKGTMP/MailScanner-${FULLMSVER}/MailScanner-$FULLMSVER-noarch.deb
cp $DEVBASEDIR/Debian.files/install.sh $PKGTMP/MailScanner-${FULLMSVER}
cp $DEVBASEDIR/ChangeLog $PKGTMP/MailScanner-${FULLMSVER}
cp $DEVBASEDIR/COPYING $PKGTMP/MailScanner-${FULLMSVER}
cp $DEVBASEDIR/Debian.files/UPGRADE $PKGTMP/MailScanner-${FULLMSVER}
cp $DEVBASEDIR/README $PKGTMP/MailScanner-${FULLMSVER}
chmod +x $PKGTMP/MailScanner-${FULLMSVER}/install.sh
cd $PKGTMP
tar czf MailScanner-${FULLMSVER}.deb.tar.gz *
mv -f MailScanner-${FULLMSVER}.deb.tar.gz $FILEOUT
rm -rf $PKGTMP
rm -rf $WORK