Skip to content

Commit

Permalink
www-apache/mod_python: fix version generation #531154
Browse files Browse the repository at this point in the history
  • Loading branch information
vapier committed Feb 15, 2016
1 parent b15198f commit bb28715
Show file tree
Hide file tree
Showing 2 changed files with 175 additions and 0 deletions.
121 changes: 121 additions & 0 deletions www-apache/mod_python/files/mod_python-3.5.0-version.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
taken from upstream

https://bugs.gentoo.org/531154

From 976a674b42f9647865d40fa417e7a3dc56a16e6e Mon Sep 17 00:00:00 2001
From: Grisha Trubetskoy <[email protected]>
Date: Thu, 19 Dec 2013 12:23:18 -0500
Subject: [PATCH] Fixes for compile without git, correct how git revision hash
is generated (skip it if it's a tag or no git available or we are not working
with a checkin), also fix a bash-dependency (helps on Solaris), and a couple
of cross-platform awk fixes in configure.

---
configure.in | 6 +++---
dist/version.sh | 15 +++++++++++++--
src/Makefile.in | 14 +++++---------
src/include/mod_python.h | 1 -
src/include/mod_python.h.in | 1 -
src/include/mp_version.h | 2 --
6 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/dist/version.sh b/dist/version.sh
index 1060b4f..e50000d 100755
--- a/dist/version.sh
+++ b/dist/version.sh
@@ -5,6 +5,17 @@ MPV_PATH="`dirname $0`/../src/include/mp_version.h"
MAJ=`awk '/MP_VERSION_MAJOR/ {print $3}' $MPV_PATH`
MIN=`awk '/MP_VERSION_MINOR/ {print $3}' $MPV_PATH`
PCH=`awk '/MP_VERSION_PATCH/ {print $3}' $MPV_PATH`
-GIT=`git describe --always`

-echo $MAJ.$MIN.$PCH-$GIT
+# if git exists in path
+if type git >/dev/null 2>&1; then
+ # and we are in a checkout
+ if git rev-parse 2>/dev/null; then
+ # but not on a tag (which means this is a release)
+ if test -z "`git log 'HEAD^!' --format=%d 2>/dev/null | grep 'tag: '`"; then
+ # append git revision hash to version
+ GIT="-`git describe --always`"
+ fi
+ fi
+fi
+
+echo $MAJ.$MIN.$PCH$GIT
diff --git a/src/Makefile.in b/src/Makefile.in
index c3b3fb2..081c954 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -50,7 +50,7 @@ psp_parser.c: psp_parser.l

dso: mod_python.so

-mod_python.so: $(SRCS) @SOLARIS_HACKS@
+mod_python.so: $(SRCS) @SOLARIS_HACKS@
@echo
@echo 'Building mod_python.so.'
@echo
@@ -64,21 +64,17 @@ distclean: clean
rm -f Makefile .depend

version.c:
- @MP_GIT_SHA=$$(git describe --always); \
- echo > version.c ; \
+ @echo > version.c ; \
echo "/* THIS FILE IS AUTO-GENERATED BY Makefile */" >> version.c ; \
echo "#include \"mp_version.h\"" >> version.c ; \
- echo "const char * const mp_git_sha = \"$${MP_GIT_SHA}\";" >> version.c ; \
echo "const int mp_version_major = MP_VERSION_MAJOR;" >> version.c ; \
echo "const int mp_version_minor = MP_VERSION_MINOR;" >> version.c ; \
echo "const int mp_version_patch = MP_VERSION_PATCH;" >> version.c ; \
- echo "const char * const mp_version_string = MP_VERSION_STRING(MP_VERSION_MAJOR,MP_VERSION_MINOR,MP_VERSION_PATCH) \"-$${MP_GIT_SHA}\";" >> version.c ; \
- echo "const char * const mp_version_component = \"mod_python/\" MP_VERSION_STRING(MP_VERSION_MAJOR,MP_VERSION_MINOR,MP_VERSION_PATCH) \"-$${MP_GIT_SHA}\";" >> version.c
-
-# echo "const char * const mp_version_component = \"mod_python/\" #MP_VERSION_MAJOR \".\" #MP_VERSION_MINOR \".\" #MP_VERSION_PATCH \"-$${MP_GIT_SHA}\";" >> version.c
+ echo "const char * const mp_version_string = \"`../dist/version.sh`\";" >> version.c ; \
+ echo "const char * const mp_version_component = \"mod_python/\" \"`../dist/version.sh`\";" >> version.c

# this is a hack to help avoid a gcc/solaris problem
-# python uses assert() which needs _eprintf(). See
+# python uses assert() which needs _eprintf(). See
# SOLARIS_HACKS above
_eprintf.o:
ar -x `gcc -print-libgcc-file-name` _eprintf.o
diff --git a/src/include/mod_python.h b/src/include/mod_python.h
index 061146b..68a77d4 100644
--- a/src/include/mod_python.h
+++ b/src/include/mod_python.h
@@ -156,7 +156,6 @@ extern module AP_MODULE_DECLARE_DATA python_module;
#define MUTEX_DIR "/tmp"

/* version stuff */
-extern const char * const mp_git_sha;
extern const int mp_version_major;
extern const int mp_version_minor;
extern const int mp_version_patch;
diff --git a/src/include/mod_python.h.in b/src/include/mod_python.h.in
index 4b6f1fb..7d536c5 100644
--- a/src/include/mod_python.h.in
+++ b/src/include/mod_python.h.in
@@ -156,7 +156,6 @@ extern module AP_MODULE_DECLARE_DATA python_module;
#define MUTEX_DIR "@MUTEX_DIR@"

/* version stuff */
-extern const char * const mp_git_sha;
extern const int mp_version_major;
extern const int mp_version_minor;
extern const int mp_version_patch;
diff --git a/src/include/mp_version.h b/src/include/mp_version.h
index 4b3a494..5ed83a1 100644
--- a/src/include/mp_version.h
+++ b/src/include/mp_version.h
@@ -10,5 +10,3 @@
#define MP_VERSION_MINOR 5
#define MP_VERSION_PATCH 0

-#define STR(x) #x
-#define MP_VERSION_STRING(maj, min, p) STR(maj) "." STR(min) "." STR(p)
--
2.6.2

54 changes: 54 additions & 0 deletions www-apache/mod_python/mod_python-3.5.0-r1.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI="5"

PYTHON_COMPAT=( python2_7 python3_3 python3_4 )

inherit apache-module eutils python-single-r1

DESCRIPTION="An Apache2 module providing an embedded Python interpreter"
HOMEPAGE="http://modpython.org/"
SRC_URI="http://dist.modpython.org/dist/${P}.tgz"

LICENSE="Apache-2.0"
KEYWORDS="~alpha ~amd64 ~ia64 ~mips ~ppc ~sparc ~x86"
IUSE="doc test"
SLOT="0"

APACHE2_MOD_CONF="16_${PN}"
APACHE2_MOD_DEFINE="PYTHON"
need_apache2

RDEPEND="${RDEPEND}"
DEPEND="${DEPEND}
test? (
app-admin/apache-tools
net-misc/curl
)"

src_prepare() {
epatch "${FILESDIR}"/${P}-buildsystem.patch
epatch "${FILESDIR}"/${P}-version.patch #531154

export CFLAGS="$(apxs2 -q CFLAGS)"
export LDFLAGS="$(apxs2 -q LDFLAGS)"
}

src_compile() {
default
}

src_test() {
cd test || die
PYTHONPATH="$(ls -d ${S}/dist/build/lib.*)" ${PYTHON} test.py || die
}

src_install() {
default

use doc && dohtml -r doc-html/*

apache-module_src_install
}

0 comments on commit bb28715

Please sign in to comment.