#!/bin/sh
+
+# Slackware build script for neomutt
+
+# Copyright 2016,2017 Maximilian Friedersdorff Aberystwyth, United Kingdom
# Copyright 2002-2015 Patrick J. Volkerding, Sebeka, Minnesota, USA
# All rights reserved.
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-PKGNAM=neomutt
-VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
-BUILD=${BUILD:-1_maf}
+PRGNAM=neomutt
+VERSION=${VERSION:-$(echo $PRGNAM-*.tar.?z* | cut -f 2- -d - | cut -f 1 -d .)}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_maf}
# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
- i?86) export ARCH=i586 ;;
- arm*) export ARCH=arm ;;
+ i?86) ARCH=i586 ;;
+ arm*) ARCH=arm ;;
# Unless $ARCH is already set, use uname -m for all other archs:
- *) export ARCH=$( uname -m ) ;;
+ *) ARCH=$( uname -m ) ;;
esac
fi
-TMP=${TMP:-/tmp}
-CWD=`pwd`
-NUMJOBS=${NUMJOBS:-" -j7 "}
+CWD=$(pwd)
+TMP=${TMP:-/tmp/SBo}
+PKG=$TMP/package-$PRGNAM
+OUTPUT=${OUTPUT:-/tmp} # Drop the package in /tmp
-if [ "$ARCH" = "i486" ]; then
- SLKCFLAGS="-O2 -march=i486 -mcpu=i686"
-elif [ "$ARCH" = "i586" ]; then
+if [ "$ARCH" = "i586" ]; then
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
-elif [ "$ARCH" = "s390" ]; then
- SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "i686" ]; then
+ SLKCFLAGS="-O2 -march=i686 -mtune=i686"
+ LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
fi
-PKG=$TMP/package-neomutt
+set -e # Exit on most errors
+
rm -rf $PKG
-mkdir $PKG
+mkdir -p $TMP $PKG $OUTPUT
cd $TMP
-rm -rf neomutt-$VERSION
-tar xvf $CWD/neomutt-$VERSION.tar.?z* || exit 1
+rm -rf $PRGNAM-$VERSION
+tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
mv neomutt-neomutt-$VERSION neomutt-$VERSION
-cd neomutt-$VERSION || exit 1
+cd $PRGNAM-$VERSION
chown -R root:root .
+find -L . \
+ \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
+ -o -perm 511 \) -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
+ -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
+
CFLAGS="$SLKCFLAGS" \
+CXXFLAGS="$SLKCFLAGS" \
./prepare \
--prefix=/usr \
--mandir=/usr/man \
- --docdir=/usr/doc/mutt-$VERSION \
- --with-docdir=/usr/doc/mutt-$VERSION \
+ --docdir=/usr/doc/neomutt-$VERSION \
+ --with-docdir=/usr/doc/neomutt-$VERSION \
--sysconfdir=/etc/mutt \
--with-mailpath=/var/spool/mail \
--enable-pop \
--enable-gpgme \
--with-gdbm \
--enable-hcache \
- --build=$ARCH-slackware-linux
+ --build=$ARCH-slackware-linux \
--with-slang \
--enable-compressed \
--enable-debug
CFLAGS="$SLKCFLAGS" \
+CXXFLAGS="$SLKCFLAGS" \
./configure \
--prefix=/usr \
--mandir=/usr/man \
- --docdir=/usr/doc/mutt-$VERSION \
- --with-docdir=/usr/doc/mutt-$VERSION \
+ --docdir=/usr/doc/neomutt-$VERSION \
+ --with-docdir=/usr/doc/neomutt-$VERSION \
--sysconfdir=/etc/mutt \
--with-mailpath=/var/spool/mail \
--enable-pop \
--enable-gpgme \
--with-gdbm \
--enable-hcache \
- --build=$ARCH-slackware-linux
+ --build=$ARCH-slackware-linux \
--with-slang \
--enable-compressed \
--enable-debug
-make $NUMJOBS || make || exit 1
-make install DESTDIR=$PKG || exit 1
-
-# Strip binaries:
-( cd $PKG
- find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
- find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
-)
-
-# Compress and link manpages, if any:
-if [ -d $PKG/usr/man ]; then
- ( cd $PKG/usr/man
- for manpagedir in $(find . -type d -name "man*") ; do
- ( cd $manpagedir
- for eachpage in $( find . -type l -maxdepth 1) ; do
- ln -s $( readlink $eachpage ).gz $eachpage.gz
- rm $eachpage
- done
- gzip -9 *.?
- )
- done
- )
-fi
+make
+make install DESTDIR=$PKG
-mkdir -p $PKG/install
-cat $CWD/slack-desc > $PKG/install/slack-desc
-zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
+find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
+ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
+
+find $PKG/usr/man -type f -exec gzip -9 {} \;
+for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
+
+cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
# This stuff is redundant or not useful to most people, IMHO.
# If you want it, use the source, Luke.
touch -r ChangeLog $DOCSDIR/ChangeLog
fi
-mv $PKG/etc/mutt/Muttrc $PKG/etc/mutt/Muttrc.new
-cd $PKG
-/sbin/makepkg -l y -c n ../neomutt-$VERSION-$ARCH-$BUILD.txz
+# Copy the slack-desc (and a custom doinst.sh if necessary) into ./install
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
+cd $PKG
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}