-
Notifications
You must be signed in to change notification settings - Fork 60
/
Build.nix
executable file
·81 lines (64 loc) · 2.08 KB
/
Build.nix
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
#!/bin/bash
# Updated 16 May 2020
# MailScanner Team <https://www.mailscanner.info>
# this Build.tarball 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 './common was not found. 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 -o -z $MSBUILD ]; then
echo "Could not determine MailScanner version."
echo "Unable read VERSION file"
echo;
exit 192
fi
# if not set from the "Build.all" script
if [ -z "$DEVBASEDIR" ]; then
DEVBASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
fi
# make some dirs
mkdir -p ~/msbuilds
# 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
# etc
cp -fr $DEVBASEDIR/common/* $WORK/
cp -fr $DEVBASEDIR/nix/* $WORK/
cp -fr $DEVBASEDIR/LICENSE $WORK/
cp -fr $DEVBASEDIR/README.md $WORK/
# Insert the version number we are building
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 {} \;
# permissions
cd $WORK
find . -type f -exec chmod 0644 {} \;
find . -type d -exec chmod 0755 {} \;
chmod +x install.sh
chmod +x $WORK/usr/sbin/*
chmod +x $WORK/usr/lib/MailScanner/wrapper/*-autoupdate
chmod +x $WORK/usr/lib/MailScanner/wrapper/*-wrapper
chmod +x $WORK/usr/lib/MailScanner/init/*
# Build the MailScanner-version.tar.gz archive
cd /tmp
tar czf ~/msbuilds/MailScanner-${VERSION}.nix.tar.gz MailScanner-$MSVERSION
cd $DEVBASEDIR
rm -rf $WORK
echo;
echo "Completed: $HOME/msbuilds/MailScanner-${VERSION}.nix.tar.gz";