# 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:

# Checkout or update the client
git clone https://github.com/raduprv/Eternal-Lands.git Eternal-Lands

# Set the version number
elver="1.9.5.6"
packagename="eternallands"

# Make an original source tar ball:
cd <the repo diretory>
# optionally using git versioning
# make -f Makefile.linux gen_git_version
bash pkgfiles/maketarball ${packagename} ${elver}
cd pkgfiles/debs
mkdir -p tmp
cd tmp

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

# Unpack the tarball then rename it as the original:
mv ../../../../../${packagename}-${elver}.tar.gz .
mv ../../../../../${packagename}-debian-${elver}.tar.gz .
tar xfz ${packagename}-${elver}.tar.gz
mv ${packagename}-${elver}.tar.gz ${packagename}_${elver}.orig.tar.gz

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

# Unpack the debian files
tar xfz ../${packagename}-debian-${elver}.tar.gz

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

# Build the package:
debuild
debuild -S -sa
