From 270b98813baea5d3821995088dbe0cb4e7dd1a30 Mon Sep 17 00:00:00 2001
From: Nathan Phillip Brink <binki@gentoo.org>
Date: Tue, 13 Sep 2011 02:55:17 +0000
Subject: [PATCH] Use 'make dist' instead of 'git archive' to create a release or snapshot tarball.

---
 Makefile.am         |   21 ++++++++++++--
 configure.ac        |    2 +-
 scripts/bip-release |   72 ++++++++++++++++++++++++++++++++------------------
 src/bip.c           |    5 +--
 src/irc.c           |    3 +-
 src/version.h       |    1 -
 6 files changed, 68 insertions(+), 36 deletions(-)
 delete mode 100644 src/version.h

diff --git a/Makefile.am b/Makefile.am
index ba4d009..c2dae4d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,15 @@
 bin_PROGRAMS = src/bip src/bipmkpw
-src_bip_SOURCES = src/conf.y src/lex.l src/bip.c src/connection.c src/irc.c src/line.c src/log.c src/md5.c src/util.c
+src_bip_SOURCES = src/conf.y src/lex.l \
+	src/bip.c src/bip.h \
+	src/connection.c src/connection.h \
+	src/defaults.h \
+	src/irc.c src/irc.h \
+	src/line.c src/line.h \
+	src/log.c src/log.h \
+	src/md5.c src/md5.h \
+	src/moduli.h \
+	src/tuple.h \
+	src/util.c src/util.h
 src_bipmkpw_SOURCES = src/bipmkpw.c src/md5.c src/util.c
 AM_YFLAGS= -d
 BUILT_SOURCES = src/conf.c src/conf.h src/lex.c
@@ -11,7 +21,12 @@ else
 endif
 
 
-man_MANS = bip.1 bip.conf.5
+dist_man_MANS = bip.1 bip.conf.5 bipmkpw.1
 
 examplesdir = $(prefix)/share/doc/bip/examples/
-examples_DATA = samples/bip.conf samples/bip.vim
+dist_examples_DATA = samples/bip.conf samples/bip.vim
+
+EXTRA_DIST = \
+	BUGS \
+	scripts/bip-release \
+	scripts/bipgenconfig
diff --git a/configure.ac b/configure.ac
index f61a9ed..7bf9dbe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
 AC_PREREQ([2.64])
-AC_INIT([bip], [0.8.2], [nohar@t1r.net])
+AC_INIT([bip], [0.8.8-git], [https://projects.duckcorp.org/issues], [], [http://bip.milkypond.org/])
 AM_INIT_AUTOMAKE([subdir-objects])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
 AC_CONFIG_SRCDIR([src/bip.h])
diff --git a/scripts/bip-release b/scripts/bip-release
index ebc4778..0e312b5 100755
--- a/scripts/bip-release
+++ b/scripts/bip-release
@@ -8,35 +8,55 @@ if [ ! -d src ] ; then
 fi
 
 release="$1"
+: ${MAKEOPTS:=-j -l4}
 
-if [ -n "$release" ]
-then
-	git log > ChangeLog
-	echo '#define BIP_VERSION "'$release'"' > src/version.h
-	git commit -a -m "Update src/version.h and Changelog for release."
+set_version() {
+	local release
+	release="${1}"
+	sed -i -e '/^AC_INIT/s/\(, \[\)[^]]*/\1'${release}'/' configure.ac
+}
+
+get_version() {
+	grep -e '^AC_INIT' configure.ac | cut -d [ -f 3 | cut -d ] -f 1
+}
+
+make_distcheck() {
+	if ! make ${MAKEOPTS} distcheck; then
+	    echo "'make distcheck' fails, please try again." >&2
+		return 1
+	else
+		true
+	fi
+}
+
+git log > ChangeLog
+if [ -n "$release" ]; then
+	set_version "${release}"
+	make_distcheck || exit 1
+
+	git commit -a -m "Update version and ChangeLog for bip-${release} release."
 	git tag release-$release
-	prefix=bip-$release
+
+	set_version "${release}-git"
+	git commit -a -m "Add -git to version string."
+
+	echo "See bip-${release}.tar.gz"
 else
+	make_distcheck || exit 1
+
+	tarname=bip-$(get_version)
 	prefix=bip-$(date +%y%m%d)
-fi
 
-olddir=$(pwd)
-tmpdir=$(mktemp -d /var/tmp/bip-XXXXXX)
-git archive --format=tar --prefix=$prefix/ HEAD > $tmpdir/$prefix.tar
-cd $tmpdir
-tar xf $prefix.tar
-cd $prefix
-./bootstrap
-rm -rf autom4te.cache
-cd ..
-tar czf $olddir/../$prefix.tar.gz $prefix
-cd $olddir
-rm -rf $tmpdir
-echo "See ../$prefix.tar.gz"
-
-if [ -n "$release" ]
-then
-	echo '#define BIP_VERSION "'$release'-git"' > src/version.h
-	git commit -a -m "Add -git to version string."
-fi
+	rm -rf "${tarname}"  "${prefix}"
+	tar -xzf "${tarname}".tar.gz
+	rm -rf "${tarname}".tar.gz
 
+	mv "${tarname}" "${prefix}"
+	tar -czf "${prefix}".tar.gz "${prefix}"
+	rm -rf "${prefix}"
+
+	# Revert the ChangeLog.
+	git checkout HEAD -- ChangeLog
+
+	echo "See ${prefix}.tar.gz"
+fi
diff --git a/src/bip.c b/src/bip.c
index b25bd9c..e154b33 100644
--- a/src/bip.c
+++ b/src/bip.c
@@ -29,7 +29,6 @@
 #include "log.h"
 #include "bip.h"
 #include "line.h"
-#include "version.h"
 #include "defaults.h"
 
 int sighup = 0;
@@ -277,9 +276,9 @@ static void usage(char *name)
 static void version()
 {
 	printf(
-"Bip IRC Proxy - %s\n"
+"Bip IRC Proxy - " PACKAGE_VERSION "\n"
 "Copyright © Arnaud Cornet and Loïc Gomez (2004 - 2008)\n"
-"Distributed under the GNU Public License Version 2\n", BIP_VERSION);
+"Distributed under the GNU Public License Version 2\n");
 }
 
 bip_t *_bip;
diff --git a/src/irc.c b/src/irc.c
index 98744ea..edcb96e 100644
--- a/src/irc.c
+++ b/src/irc.c
@@ -22,7 +22,6 @@
 #include "log.h"
 #include "connection.h"
 #include "md5.h"
-#include "version.h"
 
 #define S_CONN_DELAY (10)
 
@@ -1836,7 +1835,7 @@ static void irc_privmsg_check_ctcp(struct link_server *server,
 	nick = nick_from_ircmask(line->origin);
 	if (irc_line_elem_equals(line, 2, "\001VERSION\001")) {
 		WRITE_LINE2(CONN(server), NULL, "NOTICE", nick,
-				"\001VERSION bip-" BIP_VERSION "\001");
+				"\001VERSION bip-" PACKAGE_VERSION "\001");
 	}
 	free(nick);
 }
diff --git a/src/version.h b/src/version.h
deleted file mode 100644
index 721e182..0000000
--- a/src/version.h
+++ /dev/null
@@ -1 +0,0 @@
-#define BIP_VERSION "0.8.8-git"
-- 
1.7.3.4

