From c0bcdbcab937f8b80c4dedb82f7b298ab16a160b Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Thu, 4 Jan 2018 23:43:29 +0100
Subject: [PATCH] main/graphviz: fix source tarball, old one is N/A anymore

URL http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.40.1.tar.gz
does not work anymore. :( The new tarball does not contain generated
configure.sh script etc.
---
 main/graphviz/APKBUILD            | 23 ++++++++++++++++++-----
 main/graphviz/ungit-autogen.patch | 24 ++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 5 deletions(-)
 create mode 100644 main/graphviz/ungit-autogen.patch

diff --git a/main/graphviz/APKBUILD b/main/graphviz/APKBUILD
index 203bb83b54c6..ab1c8bb0a082 100644
--- a/main/graphviz/APKBUILD
+++ b/main/graphviz/APKBUILD
@@ -3,7 +3,7 @@
 # Maintainer: Natanael Copa <ncopa@alpinelinux.org>
 pkgname=graphviz
 pkgver=2.40.1
-pkgrel=0
+pkgrel=1
 pkgdesc="Graph Visualization Tools"
 url="http://www.graphviz.org/"
 arch="all"
@@ -12,17 +12,28 @@ depends_dev="zlib-dev libpng-dev libjpeg-turbo-dev expat-dev
 	fontconfig-dev libsm-dev libxext-dev cairo-dev pango-dev
 	librsvg-dev gmp-dev freetype-dev"
 makedepends="$depends_dev flex swig python2-dev m4 libtool
-	bison gtk+2.0-dev lua5.2-dev libltdl"
+	bison gtk+2.0-dev lua5.2-dev libltdl tcl autoconf automake"
 install="$pkgname.pre-deinstall"
 triggers="$pkgname.trigger=/usr/lib/graphviz"
 subpackages="$pkgname-dev $pkgname-doc py-gv:py lua-$pkgname:_lua
 	$pkgname-gtk $pkgname-graphs::noarch"
-source="http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-$pkgver.tar.gz
+source="$pkgname-$pkgver.tar.bz2::https://gitlab.com/graphviz/$pkgname/repository/stable_release_$pkgver/archive.tar.bz2
 	$pkgname.trigger
 	0001-clone-nameclash.patch
+	ungit-autogen.patch
 	"
 builddir="$srcdir/$pkgname-$pkgver"
 
+prepare() {
+	# Rename unpacked directory with hash in the name to something sane...
+	mv "$srcdir"/$pkgname-stable_release_$pkgver-* "$builddir"
+
+	default_prepare
+
+	cd "$builddir"
+	./autogen.sh NOCONFIG
+}
+
 build() {
 	cd "$builddir"
 
@@ -43,6 +54,7 @@ build() {
 		--disable-static \
 		--disable-dependency-tracking \
 		--enable-lua=yes \
+		--enable-tcl=no \
 		--without-mylibgd \
 		--with-ipsepcola \
 		--with-pangocairo \
@@ -108,6 +120,7 @@ graphs() {
 		"$subpkgdir"/usr/share/graphviz/
 }
 
-sha512sums="a3f358a7050523a39b91a259563a95925b37853ffec799e571211af5b686d3af42457c937882954482785745d90416b1abd945caf05f8abb52b3876e07aa70f5  graphviz-2.40.1.tar.gz
+sha512sums="4e819b3906f3b8e31245a021acd6fae4a1bc55df0a4df6b57a3578a62017e9db0b474a38f3f54682b9e9136d332f2374feee308af489e2848f8bc303ffab58ac  graphviz-2.40.1.tar.bz2
 50947e6a11929f724759266f7716d52d10923eba6d59704ab39e4bdf18f8471d548c2b11ab051dd4b67cb82742aaf54d6358890d049d5b5982f3383b65f7ae8c  graphviz.trigger
-aa4cbc341906a949a6bf78cadd96c437d6bcc90369941fe03519aa4447731ecbf6063a0dd0366d3e7aaadf22b69e4bcab3f8632a7da7a01f8e08a3be05c2bc5d  0001-clone-nameclash.patch"
+aa4cbc341906a949a6bf78cadd96c437d6bcc90369941fe03519aa4447731ecbf6063a0dd0366d3e7aaadf22b69e4bcab3f8632a7da7a01f8e08a3be05c2bc5d  0001-clone-nameclash.patch
+fef7cd142c7a50b91d57b717142d3c0655450a68e00f4932fca944c684007b2e34f1ce4ddc454559cbbdba7415321b37ff4eeab8dc3c9923f469b0e7bfa3b120  ungit-autogen.patch"
diff --git a/main/graphviz/ungit-autogen.patch b/main/graphviz/ungit-autogen.patch
new file mode 100644
index 000000000000..419a4da27c9c
--- /dev/null
+++ b/main/graphviz/ungit-autogen.patch
@@ -0,0 +1,24 @@
+--- a/autogen.sh
++++ b/autogen.sh
+@@ -1,20 +1,6 @@
+ #! /bin/sh
+ 
+-if ! GRAPHVIZ_GIT_DATE=$( git log -n 1 --format=%ci ) ; then
+-    GRAPHVIZ_VERSION_DATE="0"
+-    echo "Warning: build not started in a Git clone, or Git is not installed: setting version date to 0." >&2
+-else
+-    if ! GRAPHVIZ_VERSION_DATE=$( date -u +%Y%m%d.%H%M -d "$GRAPHVIZ_GIT_DATE" 2>/dev/null ) ; then
+-        # try date with FreeBSD syntax
+-        if ! GRAPHVIZ_VERSION_DATE=$( date -u -j -f "%Y-%m-%d %H:%M:%S %z" "$GRAPHVIZ_GIT_DATE" +%Y%m%d.%H%M ); then
+-            echo "Warning: we do not know how to invoke date correctly." >&2
+-        fi    
+-    fi
+-    echo "Graphviz: version date is based on time of last commit: $GRAPHVIZ_VERSION_DATE"
+-
+-    GRAPHVIZ_VERSION_COMMIT=$( git log -n 1 --format=%h )
+-    echo "Graphviz: abbreviated hash of last commit: $GRAPHVIZ_VERSION_COMMIT"
+-fi
++GRAPHVIZ_VERSION_DATE=0
+ 
+ # initialize version for a "stable" build
+ cat >./version.m4 <<EOF
-- 
GitLab