slackbuilds/ap/nut/SlackBuild
2018-04-20 23:02:35 +02:00

94 lines
2.6 KiB
Bash
Executable file

#!/bin/sh
FLTK=${FLTK:=YES}
PRGNAM=nut
VERSION=${VERSION:-19.2}
BUILD=${BUILD:-3}
ARCH=$(uname -m)
LIBSUFFIX=$(echo $ARCH | grep -o 64)
CWD=$(pwd)
TAG=cyco
TMP=${TMP:-/tmp/$TAG}
PKG=${PKG:-$TMP/pkg-$PRGNAM}
OUTPUT=${OUTPUT:-/tmp}
PREFIX=${PREFIX:-/usr}
# Cleaning
rm -fr $TMP/$PRGNAM-$VERSION
rm -fr $PKG
[ ! -e $TMP/ ] && mkdir -p $TMP
# Fetching sources
cd $TMP
[ ! -e $CWD/$PRGNAM-$VERSION.tar.?z* ] && \
wget -c http://nchc.dl.sourceforge.net/project/$PRGNAM/$PRGNAM/$VERSION/$PRGNAM-$VERSION.tar.gz -O $CWD/$PRGNAM-$VERSION.tar.gz
tar xvf $CWD/$PRGNAM-$VERSION.tar.?z*
# Preparation
cd $PRGNAM-$VERSION
chown -R root:root .
find . \
\( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
-exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \;
# Configuration
sed -i "s|/usr/local/lib|$PREFIX/lib$LIBSUFFIX|g" Makefile fltk/Makefile
# Building
make prefix=$PREFIX libdir=$PREFIX/lib$LIBSUFFIX/nut
[ "x$FLTK" != "xNO" ] && make -C fltk prefix=$PREFIX libdir=$PREFIX/lib$LIBSUFFIX/nut
# Installation
mkdir -p $PKG$PREFIX/{bin,lib$LIBSUFFIX/$PRGNAM,man/man1,doc/$PRGNAM}
cd $TMP/$PRGNAM-$VERSION
cp $PRGNAM $PKG$PREFIX/bin
if [ "x$FLTK" != "xNO" ]; then
cp fltk/Nut $PKG$PREFIX/bin
( cd $PKG$PREFIX/bin
ln -s Nut $PRGNAM-fltk
)
fi
cp $PRGNAM.1 $PKG$PREFIX/man/man1
cp raw.data/* $PKG$PREFIX/lib$LIBSUFFIX/$PRGNAM
cp $(ls | grep "[A-Z][^a-z]") nut.html nut.xpm $PKG$PREFIX/doc/$PRGNAM
# Cleaning
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
find ./man -type f -name "*.?" -exec gzip -9 {} \;
chown -R root:root .
find . \
\( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
-exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \;
# Packaging
mkdir install
cat <<EOF > install/slack-desc
$PRGNAM: $PRGNAM (open-source free nutrition software)
$PRGNAM:
$PRGNAM: $PRGNAM, records what you eat and analyzes your meals for nutrient
$PRGNAM: levels in terms of the "Daily Value" or DV which is the standard for
$PRGNAM: food labeling in the US. The program uses the free food composition
$PRGNAM: database from the USDA.
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM: http://nut.sourceforge.net/
$PRGNAM:
EOF
rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la
makepkg -l y -c n $OUTPUT/$PRGNAM-$(echo $VERSION | tr -d '-')-$ARCH-$BUILD$TAG.txz