Optimize version lookup a bit, and handle the case where $0 is not a full path #38520...
authorMike Frysinger <vapier@gentoo.org>
Sun, 2 Oct 2011 19:39:07 +0000 (19:39 +0000)
committerMike Frysinger <vapier@gentoo.org>
Sun, 2 Oct 2011 19:39:07 +0000 (19:39 +0000)
Package-Manager: portage-2.2.0_alpha59/cvs/Linux x86_64

sys-devel/autoconf-wrapper/ChangeLog
sys-devel/autoconf-wrapper/Manifest
sys-devel/autoconf-wrapper/autoconf-wrapper-12.ebuild [new file with mode: 0644]
sys-devel/autoconf-wrapper/files/ac-wrapper-12.sh [new file with mode: 0755]

index 189ddda77635296c90eedf80736959936db53ebf..ba8818316d60d3c22259115d0a72e3d0e2a45fa6 100644 (file)
@@ -1,6 +1,13 @@
 # ChangeLog for sys-devel/autoconf-wrapper
 # Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-devel/autoconf-wrapper/ChangeLog,v 1.87 2011/06/11 23:37:38 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/autoconf-wrapper/ChangeLog,v 1.88 2011/10/02 19:39:07 vapier Exp $
+
+*autoconf-wrapper-12 (02 Oct 2011)
+
+  02 Oct 2011; Mike Frysinger <vapier@gentoo.org> +autoconf-wrapper-12.ebuild,
+  +files/ac-wrapper-12.sh:
+  Optimize version lookup a bit, and handle the case where $0 is not a full
+  path #385201 by Florian Philipp.
 
 *autoconf-wrapper-11 (11 Jun 2011)
 
index b7ec7c3738bc1d0659b01ddf60ecc9fe65a428cf..ba9f251e7f73ae765164ca686a881ea940876e37 100644 (file)
@@ -3,18 +3,20 @@ Hash: SHA256
 
 AUX ac-wrapper-10.sh 4406 RMD160 ced48c21853b7052f6c460d44bbad3fd97db63c3 SHA1 fac357cc28552b11881e0cc52a7ba65dfe835862 SHA256 398c89d3034e44345e42f8c5c5c0ec7812d7fc3e4d3dc3e110ae80bdb3ef45f0
 AUX ac-wrapper-11.sh 4415 RMD160 d55632be8e2110bb3c2f33614c7acfd55425c4e4 SHA1 029414ea6f5bfc0c3f6ce46ddcc60d91623473c3 SHA256 2fc934060ff42917124aaf3604097463366cd05bf9e350411a9144b31513e53c
+AUX ac-wrapper-12.sh 5091 RMD160 71669ed504742e479172af5afc563531050243d5 SHA1 58f0ef20070457a4a40c4f89dac340d6bfe0a375 SHA256 e11cb556d1c42d577ab8e6985abe3a5e607fe59ad3a22cfa35ddbe1716ad252a
 AUX ac-wrapper-8.sh 4132 RMD160 f68600c5bb48cc7a103efed83f66261fce2475fc SHA1 9626122a8395a4f68259441dd6f65db6b3f5b5c9 SHA256 42dbd01eb411bbe58c590ad63d3e406860ab090cf5c971aeeaa7764f66f20a2d
 AUX ac-wrapper-9.sh 4150 RMD160 aee7a4d7dc8d05f01b306444ef14956743dc11b0 SHA1 40c32c83ed22656f63ecb75ee7013cac99dfc337 SHA256 91ce1047aec2f4ab3f748b91635202b4684985e77cce712573161f8729e04f9b
 EBUILD autoconf-wrapper-10-r1.ebuild 1006 RMD160 3c0a5967e696c92c4b968e4e9b8c6c393be92fb5 SHA1 08a2ec957aa7a605f8c035fc3fe26e4081d94dce SHA256 7b898d2cbbfb2609850424248b5312e9165bf982bfef041ed1a98916cbd98ab3
 EBUILD autoconf-wrapper-11.ebuild 1015 RMD160 ec401baf9a6649213a4cd908a4170585daf2289a SHA1 45d7c9c90a58ea414ad4c18c1aa58abbdd99f4b0 SHA256 3836efc6325593b4b2f5c3e4a1588bacccc3218bcca1dff497072cd8497ff8f4
+EBUILD autoconf-wrapper-12.ebuild 1015 RMD160 a7c057cb81748b054f57a288936373ab28026793 SHA1 5bf46a263263126015b1c7a0dec0d19714880321 SHA256 75e9a9eaed3a9dc234a99cd38e4de2ab6277d6d7a9aff836ceeff798998fec0c
 EBUILD autoconf-wrapper-8.ebuild 1005 RMD160 89c9a05568aa6f677c56ff66dfbe702f4ed7f464 SHA1 8547f3ef1d2ba34b66cef34cc73ba67455eb9fd0 SHA256 9abffe402d5753068757cb98b05025d989ee356897f8dd3bc03d48b1e24c98df
 EBUILD autoconf-wrapper-9-r1.ebuild 1017 RMD160 44bdafb5432ebd53319b831525840089dadff73f SHA1 5b3eecaaeea1373d9085daca9af20577b1d945b2 SHA256 a04d1437b20a431a32a068443b458a4575cffebad1e8dd5f90b796026e495a7d
-MISC ChangeLog 11711 RMD160 700936d232de8eae74500ea5e6d4dd35c3cd0028 SHA1 dcd19ad3af52db83c6bff9d143ff960e2b4b0ce2 SHA256 893303515de1f3ea2bf671bf364fe3792d4d05edaabea5c035e28f112067a97e
+MISC ChangeLog 11965 RMD160 e2252e597fd0ea3e63be3c5b8f7de895507064b8 SHA1 52c2190404dfe1a749d030d7bbc66be1a73350b4 SHA256 ed6b2a6a881224b183675a1b79e0d1ed7c65014d25eb604ec6caeb2b4516f75b
 MISC metadata.xml 164 RMD160 f43cbec30b7074319087c9acffdb9354b17b0db3 SHA1 9c213f5803676c56439df3716be07d6692588856 SHA256 f5f2891f2a4791cd31350bb2bb572131ad7235cd0eeb124c9912c187ac10ce92
 -----BEGIN PGP SIGNATURE-----
-Version: GnuPG v2.0.17 (GNU/Linux)
+Version: GnuPG v2.0.18 (GNU/Linux)
 
-iF4EAREIAAYFAk3z/EkACgkQaC/OocHi7Jap5QD/YEza9RuoDBoJ5pFOWMmBY9Yq
-vz51bJTeemeP9Y2431AA/j4IAitLCthN7g3v9up4967e84x2WORf0pDqEeagej7I
-=EmgN
+iF4EAREIAAYFAk6IveUACgkQaC/OocHi7JZlfAEAlfTFTSOKsizXG+A41Dprpsi8
+dLjzhaUlk1QtxSFCsPUA/juasEJ2YvILpCbHeBZSMZg922D2UvWdfKRfRjfBJe7H
+=T7T9
 -----END PGP SIGNATURE-----
diff --git a/sys-devel/autoconf-wrapper/autoconf-wrapper-12.ebuild b/sys-devel/autoconf-wrapper/autoconf-wrapper-12.ebuild
new file mode 100644 (file)
index 0000000..2c39ee1
--- /dev/null
@@ -0,0 +1,27 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/autoconf-wrapper/autoconf-wrapper-12.ebuild,v 1.1 2011/10/02 19:39:07 vapier Exp $
+
+inherit multilib
+
+DESCRIPTION="wrapper for autoconf to manage multiple autoconf versions"
+HOMEPAGE="http://www.gentoo.org/"
+SRC_URI=""
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~sparc-fbsd ~x86-fbsd ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE=""
+
+S=${WORKDIR}
+
+src_install() {
+       exeinto /usr/$(get_libdir)/misc
+       newexe "${FILESDIR}"/ac-wrapper-${PV}.sh ac-wrapper.sh || die
+
+       dodir /usr/bin
+       local x=
+       for x in auto{conf,header,m4te,reconf,scan,update} ifnames ; do
+               dosym ../$(get_libdir)/misc/ac-wrapper.sh /usr/bin/${x} || die
+       done
+}
diff --git a/sys-devel/autoconf-wrapper/files/ac-wrapper-12.sh b/sys-devel/autoconf-wrapper/files/ac-wrapper-12.sh
new file mode 100755 (executable)
index 0000000..12bb409
--- /dev/null
@@ -0,0 +1,209 @@
+#!/bin/sh
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/autoconf-wrapper/files/ac-wrapper-12.sh,v 1.1 2011/10/02 19:39:07 vapier Exp $
+
+# Based on the ac-wrapper.pl script provided by MandrakeSoft
+# Rewritten in bash by Gregorio Guidi
+#
+# Executes the correct autoconf version.
+#
+# - defaults to newest version available (hopefully autoconf-2.60)
+# - runs autoconf 2.13 if:
+#   - envvar WANT_AUTOCONF is set to `2.1'
+#     -or-
+#   - `ac{local,include}.m4' or `configure.{in,ac}' have AC_PREREQ(2.1) (not higher)
+#     -or-
+#   - `configure' is already present and was generated by autoconf 2.13
+
+warn() { printf "ac-wrapper: $*\n" 1>&2; }
+err() { warn "$@"; exit 1; }
+unset IFS
+which() {
+       local p
+       IFS=: # we don't use IFS anywhere, so don't bother saving/restoring
+       for p in ${PATH} ; do
+               p="${p}/$1"
+               [ -e "${p}" ] && echo "${p}" && return 0
+       done
+       unset IFS
+       return 1
+}
+
+#
+# Sanitize argv[0] since it isn't always a full path #385201
+#
+argv0=${0##*/}
+case ${0} in
+       ${argv0})
+               # find it in PATH
+               if ! full_argv0=$(which "${argv0}") ; then
+                       err "could not locate ${argv0}; file a bug"
+               fi
+               ;;
+       *)
+               # re-use full/relative paths
+               full_argv0=$0
+               ;;
+esac
+
+if [ "${argv0}" = "ac-wrapper.sh" ] ; then
+       err "Don't call this script directly"
+fi
+
+if [ "${WANT_AUTOCONF}" = "2.1" ] && [ "${argv0}" = "autom4te" ] ; then
+       err "Autoconf 2.13 doesn't contain autom4te.\n" \
+           "   Either unset WANT_AUTOCONF or don't execute anything\n" \
+           "   that would use autom4te."
+fi
+
+if ! seq 0 0 2>/dev/null 1>&2 ; then #338518
+       seq() {
+               local f l i
+               case $# in
+                       1) f=1 i=1 l=$1;;
+                       2) f=$1 i=1 l=$2;;
+                       3) f=$1 i=$2 l=$3;;
+               esac
+               while :; do
+                       [ $l -lt $f -a $i -gt 0 ] && break
+                       [ $f -lt $l -a $i -lt 0 ] && break
+                       echo $f
+                       : $(( f += i ))
+               done
+               return 0
+       }
+fi
+
+#
+# Set up bindings between actual version and WANT_AUTOCONF;
+# Start at last known stable to speed up lookup process.
+#
+STABLE_AUTOCONF="2.68:2.5"
+vers="${STABLE_AUTOCONF} 9999:2.5 $(printf '2.%s:2.5 ' `seq 99 -1 59`) 2.13:2.1"
+
+binary=""
+for v in ${vers} ; do
+       auto_ver=${v%:*}
+       if [ -z "${binary}" ] && [ -x "${full_argv0}-${auto_ver}" ] ; then
+               binary="${full_argv0}-${auto_ver}"
+               break
+       fi
+done
+if [ -z "${binary}" ] ; then
+       err "Unable to locate any usuable version of autoconf.\n" \
+           "\tI tried these versions: ${vers}\n" \
+           "\tWith a base name of '${full_argv0}'."
+fi
+
+#
+# Check the WANT_AUTOCONF setting.  We accept a whitespace delimited
+# list of autoconf versions.
+#
+if [ -n "${WANT_AUTOCONF}" ] ; then
+       for v in ${vers} x ; do
+               if [ "${v}" = "x" ] ; then
+                       warn "warning: invalid WANT_AUTOCONF '${WANT_AUTOCONF}'; ignoring."
+                       unset WANT_AUTOCONF
+                       break
+               fi
+
+               auto_ver=${v%:*}
+               want_ver=${v#*:}
+               for wx in ${WANT_AUTOCONF} ; do
+                       if [ "${wx}" = "${want_ver}" ] && [ -x "${full_argv0}-${auto_ver}" ] ; then
+                               binary="${full_argv0}-${auto_ver}"
+                               v="x"
+                       fi
+               done
+               [ "${v}" = "x" ] && break
+       done
+fi
+
+#
+# autodetect helpers
+#
+acprereq_version() {
+       gawk \
+       '($0 !~ /^[[:space:]]*(#|dnl)/) {
+               if (match($0, "AC_PREREQ\\(\\[?([0-9]\\.[0-9])", res))
+                       VERSIONS[COUNT++] = res[1]
+       }
+
+       END {
+               asort(VERSIONS)
+               print VERSIONS[COUNT]
+       }' "$@"
+}
+
+generated_version() {
+       gawk \
+       '{
+               if (match($0,
+                         "^# Generated (by (GNU )?Autoconf|automatically using autoconf version) ([0-9].[0-9])",
+                         res)) {
+                       print res[3]
+                       exit
+               }
+       }' "$@"
+}
+
+#
+# autodetect routine
+#
+if [ "${WANT_AUTOCONF}" = "2.1" ] && [ -f "configure.ac" ] ; then
+       err "Since configure.ac is present, aclocal always use\n" \
+           "\tautoconf 2.59+, which conflicts with your choice and\n" \
+           "\tcauses error. You have two options:\n" \
+           "\t1. Try execute command again after removing configure.ac\n" \
+           "\t2. Don't set WANT_AUTOCONF"
+fi
+
+if [ "${WANT_AUTOCONF}" != "2.5" ] && [ -n "${WANT_AUTOMAKE}" ] ; then
+       # Automake-1.7 and better require autoconf-2.5x so if WANT_AUTOMAKE
+       # is set to an older version, let's do some sanity checks.
+       case "${WANT_AUTOMAKE}" in
+       1.[456])
+               acfiles=$(ls ac{local,include}.m4 configure.{in,ac} 2>/dev/null)
+               [ -n "${acfiles}" ] && confversion=$(acprereq_version ${acfiles})
+
+               [ -z "${confversion}" ] && [ -r "configure" ] \
+                       && confversion=$(generated_version configure)
+
+               if [ "${confversion}" = "2.1" ] && [ ! -f "configure.ac" ] ; then
+                       binary="${full_argv0}-2.13"
+               fi
+       esac
+fi
+
+if [ -n "${WANT_ACWRAPPER_DEBUG}" ] ; then
+       if [ -n "${WANT_AUTOCONF}" ] ; then
+               warn "DEBUG: WANT_AUTOCONF is set to ${WANT_AUTOCONF}"
+       fi
+       warn "DEBUG: will execute <${binary}>"
+fi
+
+#
+# for further consistency
+#
+for v in ${vers} ; do
+       auto_ver=${v%:*}
+       want_ver=${v#*:}
+       if [ "${binary}" = "${full_argv0}-${auto_ver}" ] ; then
+               export WANT_AUTOCONF="${want_ver}"
+               break
+       fi
+done
+
+#
+# Now try to run the binary
+#
+if [ ! -x "${binary}" ] ; then
+       # this shouldn't happen
+       err "${binary} is missing or not executable.\n" \
+           "\tPlease try emerging the correct version of autoconf."
+fi
+
+exec "${binary}" "$@"
+
+err "was unable to exec ${binary} !?"