# How to build a package:
# Read the guides or at least install the necessary packages as detailed here:
# http://www.debian.org/doc/maint-guide/index.en.html
# https://wiki.ubuntu.com/PackagingGuide/Complete

# Set-up your ~/.bachrc so the package scripts known who you are:
# e.g.
# export DEBFULLNAME='Paul Broadhead'
# export DEBEMAIL='pjbroad@twinmoons.org.uk'

# If you're going to sign the package make sure you have keys set-up:
# https://help.ubuntu.com/community/GnuPrivacyGuardHowto

# Now we're ready:

# Set the version number
elver="1.9.5.1"
packagename="eternallands-data"
debdir="data"

# start in the correct location
cd <the repo diretory>
cd pkgfiles/debs
mkdir -p tmp
cd tmp

# Make a destination directory
tmpdir=${packagename}-${elver}-$(date +"%s")
mkdir $tmpdir
cd $tmpdir
mkdir ${packagename}-${elver}

# Copy packaging files:
cp -a ../../$debdir/debian/ ${packagename}-${elver}/

# Append the licence file and clean up:
wget -O - http://www.eternal-lands.com/page/license.txt | fmt -w 79 >> ${packagename}-${elver}/debian/copyright
less ${packagename}-${elver}/debian/copyright

# Save the source archive:
tar cfz ${packagename}_${elver}.orig.tar.gz ${packagename}-${elver}

# Move into package directory:
cd ${packagename}-${elver}/

# Make any modifications required then update the changelog:
dch --release --force-save-on-release

# Build the package:
debuild
debuild -S -sa
