#!/bin/sh
# Heavily based on the Slackware 11.0 SlackBuild 
# Packager baldelario ~at~ gmail ~dot~ com
# http://www.slacky.it 
# Note: This is not a source SlackBuild script.  
# Rather, it builds a Slackware package from the 
# the official pre-compiled executables available  
# from the NEdit web site at http://nedit.org.

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-nedit
rm -rf $PKG
mkdir -p $PKG/usr/{bin,man/man1,share/applications}

NAME=nedit
VERSION=5.5
ARCH=${ARCH:-i386}
BUILD=4bj
SRCNAME=$NAME-$VERSION-Linux-x86

cd $TMP
rm -rf $SRCNAME
tar xjvf $CWD/$SRCNAME.tar.bz2
cd $SRCNAME

cat nedit > $PKG/usr/bin/nedit
cat nc > $PKG/usr/bin/ncl
chmod 755 $PKG/usr/bin/*
strip $PKG/usr/bin/*

cat nedit.man > $PKG/usr/man/man1/nedit.1
cat nc.man > $PKG/usr/man/man1/ncl.1
gzip -9 $PKG/usr/man/man?/*

mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a \
  COPYRIGHT *.txt README ReleaseNotes nedit.doc nedit.html\
  $PKG/usr/doc/$NAME-$VERSION
cp -a $CWD/*.desktop $PKG/usr/share/applications

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/slack-desc > $PKG/usr/doc/$NAME-$VERSION/slack-desc
cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/$NAME.SlackBuild

cd $PKG
chown -R root:root .
requiredbuilder -y -v -s $CWD $PKG
makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz

if [ "$1" = "--cleanup" ]; then
  rm -rf $TMP
fi
