#!/bin/bash

# unrar.SlackBuild
# by Stuart Winter <stuart@armedslack.org>
# 08-Jun-2005

# Record toolchain & other info for the build log:
slackbuildinfo

# Paths to skeleton port's source & real Slackware source tree:
export CWD=$PWD PORTCWD=$PWD

# Temporary build locations:
export TMPBUILD=$TMP/build-$PACKAGE
export PKG=$TMP/package-$PACKAGE
mkpkgdirs # Delete & re-create temporary directories then cd into $TMPBUILD

# Extract source:
tar zxvvf $CWD/sources/$PACKAGE*orig.tar.gz
cd $PACKAGE*
# We use the Debian man page from the diff:
zcat $CWD/sources/$PACKAGE*diff* | patch -p1
slackhousekeeping

# Build:
make -f makefile.unix

# Create package framework:
mkdir -p $PKG/usr/{bin,man/man1}

# Install man pages:
install -m644 debian/unrar.1 $PKG/usr/man/man1

# Install binaries:
install -m755 unrar $PKG/usr/bin

# Apply Slackware packaging policies:
cd $PKG
slackstripall   # strip all .a archives and all ELFs
slackgzpages -i # compress man & info pages and delete usr/info/dir
slackslack      # chown -R root:root, chmod -R og-w, slackchown (root:bin), slack644docs
slackdesc       # install slack-desc and doinst.sh

# Build the package:
if [ $PORTARCH = arm ]; then
   . $PORTCWD/arm/pkger
 else
   makepkg -l y -c n $PKGSTORE/$PKGSERIES/$PACKAGE-$VERSION-$ARCH-$BUILD.tgz
fi

# Perform any final checks on the package:
cd $PKG
slackhlinks     # search for any hard links
