v5/Build.nix

81 lines
2.1 KiB
Nix
Raw Normal View History

2016-05-03 21:52:08 +08:00
#!/bin/bash
2020-05-17 07:40:06 +08:00
# Updated 16 May 2020
# MailScanner Team <https://www.mailscanner.info>
# this Build.tarball script should be located in the base
2016-05-03 21:42:47 +08:00
# directory when run.
# make sure this is run from the base directory
2016-05-03 21:42:47 +08:00
if [ ! -d 'common' ]; then
echo 'This script must be executed from the base directory.';
2016-05-03 21:42:47 +08:00
echo './common was not found. Exiting ...';
echo;
exit 192
fi
2020-05-17 07:40:06 +08:00
VERSION=$(sed -e 's/\n//' VERSION)
MSVERSION=$(echo $VERSION | sed -e 's/-.*$//')
MSBUILD=$(echo $VERSION | sed -e 's/^.*-//')
2020-05-17 07:40:06 +08:00
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
2020-05-17 07:40:06 +08:00
DEVBASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
fi
# make some dirs
2020-05-17 07:40:06 +08:00
mkdir -p ~/msbuilds
2016-05-03 21:42:47 +08:00
# 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/
2016-05-04 01:09:30 +08:00
cp -fr $DEVBASEDIR/nix/* $WORK/
2016-05-04 01:19:46 +08:00
cp -fr $DEVBASEDIR/LICENSE $WORK/
cp -fr $DEVBASEDIR/README.md $WORK/
# Insert the version number we are building
2016-05-03 21:42:47 +08:00
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 {} \;
2016-05-03 21:42:47 +08:00
# permissions
cd $WORK
find . -type f -exec chmod 0644 {} \;
find . -type d -exec chmod 0755 {} \;
2016-05-04 01:09:30 +08:00
chmod +x install.sh
2016-05-03 21:42:47 +08:00
chmod +x $WORK/usr/sbin/*
2016-05-10 07:45:10 +08:00
chmod +x $WORK/usr/lib/MailScanner/wrapper/*-autoupdate
chmod +x $WORK/usr/lib/MailScanner/wrapper/*-wrapper
chmod +x $WORK/usr/lib/MailScanner/init/*
2016-05-03 21:42:47 +08:00
# Build the MailScanner-version.tar.gz archive
2016-05-03 21:53:15 +08:00
cd /tmp
2020-05-17 07:40:06 +08:00
tar czf ~/msbuilds/MailScanner-${VERSION}.nix.tar.gz MailScanner-$MSVERSION
cd $DEVBASEDIR
2016-05-04 01:09:30 +08:00
rm -rf $WORK
2016-05-03 21:42:47 +08:00
2020-05-17 07:40:06 +08:00
echo;
echo "Completed: $HOME/msbuilds/MailScanner-${VERSION}.nix.tar.gz";