edi/data/extra/skeleton/eflproject/packaging/slackware/${edi_name}.SlackBuild

107 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
#
# Begin ${edi_name}.SlackBuild
#
# Copyright (C) 2012-2013 Jerome Pinot <ngc891@gmail.com>
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 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
# 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,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NAME=${edi_name}
BUILD=${BUILD:-1jp}
CWD=$(pwd)
TMP=${TMP:-/tmp}
PKG=${TMP}/package-${NAME}
# First check if we are in the right folder
if [ -f ./${NAME}.SlackBuild ]; then
echo 'Found SlackBuild'
else
echo 'Error: You must run this script from the packaging/slackware sub-folder!'
exit 1
fi
# Get the version number from configure.ac
if [ -f ../../configure.ac ];then
VERSION=`grep "AC_INIT" ../../configure.ac | cut -d' ' -f2 | sed -e 's/\[//' -e 's/\],//'`
else
echo "Error: can't find configure.ac!"
exit 2
fi
# if ${ARCH} is unset, we have to guess it with uname
if [ -z "${ARCH}" ]; then
case "$(uname -m)" in
i?86) export ARCH=i486 ;;
arm*) export ARCH=arm ;;
*) export ARCH=$(uname -m) ;;
esac
fi
# Set generic flags for gcc
SCFLAGS='-O2'
if [ "${ARCH}" = "i486" ]; then
SCFLAGS="${SCFLAGS} -march=i486 -mtune=i686"
LIBDIR="/usr/lib"
elif [ "${ARCH}" = "x86_64" ]; then
SCFLAGS="${SCFLAGS} -fPIC"
LIBDIR="/usr/lib64"
elif [ "${ARCH}" = "arm" ]; then
SCFLAGS="${SCFLAGS} -march=armv4 -mtune=xscale"
LIBDIR="/usr/lib"
fi
# Creating directories
if [ ! -d ${TMP} ]; then
mkdir -p ${TMP}
fi
rm -rf ${PKG}
mkdir -p ${PKG}
# Configuring
cd ../..
CFLAGS="${SCFLAGS}" \
./configure \
--prefix=/usr \
--libdir=${LIBDIR} \
--mandir=/usr/man \
--docdir=/usr/doc/${NAME}-${VERSION}
# Building
make
# Installing
make DESTDIR=${PKG} install
# Cleaning
cd ${PKG}
gzip -9 usr/man/man1/${NAME}.1
find ${PKG} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
find ${PKG} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
# Building the package
mkdir install
install -m644 ${CWD}/doinst.sh install/
install -m644 ${CWD}/slack-desc install/
install -m644 ${CWD}/slack-required install/
makepkg -l y -c n ${CWD}/${NAME}-${VERSION}-${ARCH}-${BUILD}.txz
rm -rf ${PKG}
# End ${edi_name}.SlackBuild