summaryrefslogtreecommitdiff
path: root/development/cc65/git2targz.sh
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2017-01-30 00:08:19 -0500
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2017-02-04 07:00:06 +0700
commita32f0ee37044b314da00013b9fc688ad8f7189a0 (patch)
treed51285cd871359013c7025666c9ebac37801447e /development/cc65/git2targz.sh
parented20b637b19b8fce0d0e75f98f5e86142e080a00 (diff)
downloadslackbuilds-a32f0ee37044b314da00013b9fc688ad8f7189a0.tar.gz
development/cc65: Updated for version 2.15_20170126.
Diffstat (limited to 'development/cc65/git2targz.sh')
-rw-r--r--development/cc65/git2targz.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/development/cc65/git2targz.sh b/development/cc65/git2targz.sh
new file mode 100644
index 0000000000..c86e2d9412
--- /dev/null
+++ b/development/cc65/git2targz.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# Create source tarball from cc65 git repo, with generated version
+# number. We don't want to include the whole git history in the tarball,
+# but we do want to build the git hash into the binary (for --version),
+# so there's a bit of extra stuff here.
+
+# Note that this script doesn't need to be run as root. It does
+# need to be able to write to the current directory it's run from.
+
+PRGNAM=cc65
+CLONE_URL=https://github.com/$PRGNAM/$PRGNAM.git
+
+set -e
+
+GITDIR=$( mktemp -dt cc65.git.XXXXXX )
+rm -rf $GITDIR
+git clone $CLONE_URL $GITDIR
+
+CWD="$( pwd )"
+cd $GITDIR
+GIT_SHA=$( git rev-parse --short HEAD )
+sed -i "1iGIT_SHA=$GIT_SHA" src/Makefile
+
+# 6878ede and earlier commits are missing a \ in src/Makefile, which
+# causes the git hash *not* to be part of --version output. Fix, if
+# needed.
+sed -i '/-DLD65_LIB[^\\]*$/s,$, \\,' src/Makefile
+
+DATE=$( git log --date=format:%Y%m%d --format=%cd | head -1 )
+
+VERFILE=src/common/version.c
+MAJOR=$( sed -n 's,#define\s\+VER_MAJOR\s\+\([0-9]\+\)U.*,\1,p' $VERFILE )
+MINOR=$( sed -n 's,#define\s\+VER_MINOR\s\+\([0-9]\+\)U.*,\1,p' $VERFILE )
+
+VERSION=${MAJOR}.${MINOR}_$DATE
+
+rm -rf .git
+find . -name .gitignore -print0 | xargs -0 rm -f
+
+cd "$CWD"
+rm -rf $PRGNAM-$VERSION $PRGNAM-$VERSION.tar.xz
+mv $GITDIR $PRGNAM-$VERSION
+tar cvfJ $PRGNAM-$VERSION.tar.xz $PRGNAM-$VERSION