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:51:17 +0000 (19:51 +0000)
committerMike Frysinger <vapier@gentoo.org>
Sun, 2 Oct 2011 19:51:17 +0000 (19:51 +0000)
Package-Manager: portage-2.2.0_alpha59/cvs/Linux x86_64

sys-devel/automake-wrapper/ChangeLog
sys-devel/automake-wrapper/Manifest
sys-devel/automake-wrapper/automake-wrapper-6.ebuild [new file with mode: 0644]
sys-devel/automake-wrapper/files/am-wrapper-6.sh [new file with mode: 0755]

index 33e88dec1a1bf55b761e6a1562468540babbb547..dbe385bc98531838d8c3b6002aad001c3a582b4c 100644 (file)
@@ -1,6 +1,13 @@
 # ChangeLog for sys-devel/automake-wrapper
 # Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-devel/automake-wrapper/ChangeLog,v 1.47 2011/02/06 11:29:37 leio Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/automake-wrapper/ChangeLog,v 1.48 2011/10/02 19:51:17 vapier Exp $
+
+*automake-wrapper-6 (02 Oct 2011)
+
+  02 Oct 2011; Mike Frysinger <vapier@gentoo.org> +automake-wrapper-6.ebuild,
+  +files/am-wrapper-6.sh:
+  Optimize version lookup a bit, and handle the case where $0 is not a full
+  path #385201 by Florian Philipp.
 
   06 Feb 2011; Mart Raudsepp <leio@gentoo.org> automake-wrapper-3-r1.ebuild:
   Drop to ~mips
index 3ccd372ed34bb1ea8b8abcd63dbce2d1874423dc..e7511a059d42f91a94af5d980bd30223b50539ca 100644 (file)
@@ -1,8 +1,20 @@
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA256
+
 AUX am-wrapper-3.sh 4342 RMD160 fcd76fcca6209c6705a5398d99ae9011bc01e579 SHA1 3af0a2f00e09463aa3d7604ebefd0141aa693799 SHA256 b18f4938a53c8c86100f41aedb88ff43568e5a4a4329b87ffa118b66e2983e25
 AUX am-wrapper-4.sh 4354 RMD160 0dc2880dc64e639500a38ac04c0f0345eb9175ac SHA1 2da9888c74a68bb5ba6d4a2b189e04693bf4bfca SHA256 882eb17bd3b8d195143eecfbc533ddaf8bef77f719ff070de855ae337e4b7504
 AUX am-wrapper-5.sh 4130 RMD160 eab77be481f142c3d7918bd8c53162c1a1d95d23 SHA1 a66b2d390546da297b68ae8a4385e43a8554dba7 SHA256 0546150d48e71d25ed3c909982fe30bdaccc6c79382ad1989538c2b0ce7a0d77
+AUX am-wrapper-6.sh 4715 RMD160 ede6f852269975a9e5871c59811d6e4b4d74db67 SHA1 cab65b108bc72c59e43a3138193b4ce51d6af88b SHA256 6606032f25ef1253caa6ecb38ae8f196581157db1d83a6e2475001ab38c589b1
 EBUILD automake-wrapper-3-r1.ebuild 785 RMD160 2cb5ca9a18addd67ea5763b7746efd7bb7356d5c SHA1 e9971e483bd29786f7ea35c994c8cbfce6a56be4 SHA256 1d198667a858c507ecb0c28f07aa27a141d70c3d1707f759d568b96363af9a57
 EBUILD automake-wrapper-4.ebuild 991 RMD160 4d02bfe5ca2bcf088905ca9c4bc647e2d0eb47f0 SHA1 b7fd47b0aa6e93e1a51b1e19a317d7b2cf3119bc SHA256 0fc2b9d42af0586fba0da45aa723da93a92159d72f29a232ef4e8457277f60fe
 EBUILD automake-wrapper-5.ebuild 1225 RMD160 1c6d79bfc392f6ba5b703ac1d50d0628defeae5b SHA1 326a4684c54b6eca9a1f86908b16537686ccab40 SHA256 fc7911c3f041708aa4633fd38cb4a29750d5e7d3a9d53af84215400d66db88d8
-MISC ChangeLog 5582 RMD160 d1e26815d385e2f8449e2e8044018cc587cc8196 SHA1 9663b307df3704016f3a3dce6bec68b17961e828 SHA256 db1d16eb33067530c703b187dc4b83cc0d0b936ba25345f0bdc486c2c093d642
+EBUILD automake-wrapper-6.ebuild 1224 RMD160 6708aaaaedba6877a98cf5aff4b7d9151550888d SHA1 5358a51c7cc7226086616372a8dbbb29bf9ffe2d SHA256 ee1fd59c5887535d841b8c34941f2d18b4fa71bede6d4ab0db4ed6a6a7361308
+MISC ChangeLog 5835 RMD160 8462dbd2e0006eec62ce3e8c09e11853adf39ee8 SHA1 e45339939cf6150045d09f8731c8b0afcb9e6cf4 SHA256 ebdccf0e1c57ea44116ff4743147d05f8cf7ad018813e48224b8413c5bb5e89a
 MISC metadata.xml 164 RMD160 f43cbec30b7074319087c9acffdb9354b17b0db3 SHA1 9c213f5803676c56439df3716be07d6692588856 SHA256 f5f2891f2a4791cd31350bb2bb572131ad7235cd0eeb124c9912c187ac10ce92
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v2.0.18 (GNU/Linux)
+
+iF4EAREIAAYFAk6IwL8ACgkQaC/OocHi7JbiDgD/RBWDCkw0EU8DzfuVVSBydmSb
+YS6FBimMoacuUp2cBPUBAJwLrAU7Am4newrZ77QJRFOWggAmj4vQD0xPDrh6yiDz
+=OmLP
+-----END PGP SIGNATURE-----
diff --git a/sys-devel/automake-wrapper/automake-wrapper-6.ebuild b/sys-devel/automake-wrapper/automake-wrapper-6.ebuild
new file mode 100644 (file)
index 0000000..c712eed
--- /dev/null
@@ -0,0 +1,37 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/automake-wrapper/automake-wrapper-6.ebuild,v 1.1 2011/10/02 19:51:17 vapier Exp $
+
+inherit multilib
+
+DESCRIPTION="wrapper for automake to manage multiple automake 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_unpack() {
+       cp "${FILESDIR}"/am-wrapper-${PV}.sh "${T}"/
+       # usr/bin/aclocal: bad substitution -> /bin/sh != POSIX shell
+       if use prefix ; then
+               sed -i -e '1c\#!'"${EPREFIX}"'/bin/sh' "${T}"/am-wrapper-${PV}.sh || die
+       fi
+}
+
+src_install() {
+       exeinto /usr/$(get_libdir)/misc
+       newexe "${T}"/am-wrapper-${PV}.sh am-wrapper.sh || die
+
+       keepdir /usr/share/aclocal
+
+       dodir /usr/bin
+       local x=
+       for x in aclocal automake ; do
+               dosym ../$(get_libdir)/misc/am-wrapper.sh /usr/bin/${x}
+       done
+}
diff --git a/sys-devel/automake-wrapper/files/am-wrapper-6.sh b/sys-devel/automake-wrapper/files/am-wrapper-6.sh
new file mode 100755 (executable)
index 0000000..f3704d5
--- /dev/null
@@ -0,0 +1,184 @@
+#!/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/automake-wrapper/files/am-wrapper-6.sh,v 1.1 2011/10/02 19:51:17 vapier Exp $
+
+# Based on the am-wrapper.pl script provided by MandrakeSoft
+# Rewritten in bash by Gregorio Guidi
+#
+# Executes the correct automake version.
+#
+# - defaults to newest version available (hopefully automake-1.10)
+# - runs automake-1.9 if:
+#   - envvar WANT_AUTOMAKE is set to `1.9'
+#     -or-
+#   - `Makefile.in' was generated by automake-1.9
+#     -or-
+#   - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.9
+# - runs automake-1.8 if:
+#   - envvar WANT_AUTOMAKE is set to `1.8'
+#     -or-
+#   - `Makefile.in' was generated by automake-1.8
+#     -or-
+#   - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.8
+# - runs automake-1.7 if:
+#   - envvar WANT_AUTOMAKE is set to `1.7'
+#     -or-
+#   - `Makefile.in' was generated by automake-1.7
+#     -or-
+#   - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.7
+# - runs automake-1.6 if:
+#   - envvar WANT_AUTOMAKE is set to `1.6'
+#     -or-
+#   - `Makefile.in'
+#     -or-
+#   - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.6
+# - runs automake-1.5 if:
+#   - envvar WANT_AUTOMAKE is set to `1.5'
+#     -or-
+#   - `Makefile.in' was generated by automake-1.5
+#     -or-
+#   - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.5
+# - runs automake-1.4 if:
+#   - envvar WANT_AUTOMAKE is set to `1.4'
+#     -or-
+#   - `Makefile.in' was generated by automake-1.4
+#     -or-
+#   - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.4
+
+warn() { printf 'am-wrapper: %s: %b\n' "${argv0}" "$*" 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}" = "am-wrapper.sh" ] ; then
+       err "Don't call this script directly"
+fi
+
+vers="1.11 1.10 1.9 1.8 1.7 1.6 1.5 1.4"
+
+#
+# Export the proper variable/versions and try to locate a usuable
+# default (newer versions are preferred)
+#
+binary=""
+for v in ${vers} ; do
+       if [ -z "${binary}" ] && [ -x "${full_argv0}-${v}" ] ; then
+               binary="${full_argv0}-${v}"
+               break
+       fi
+done
+if [ -z "${binary}" ] ; then
+       err "Unable to locate any usuable version of automake.\n" \
+           "\tI tried these versions: ${vers}\n" \
+           "\tWith a base name of '${full_argv0}'."
+fi
+
+#
+# Check the WANT_AUTOMAKE setting.  We accept a whitespace delimited
+# list of automake versions.
+#
+if [ -n "${WANT_AUTOMAKE}" ] ; then
+       for v in ${vers} x ; do
+               if [ "${v}" = "x" ] ; then
+                       warn "warning: invalid WANT_AUTOMAKE '${WANT_AUTOMAKE}'; ignoring."
+                       unset WANT_AUTOMAKE
+                       break
+               fi
+
+               for wx in ${WANT_AUTOMAKE} ; do
+                       if [ "${wx}" = "${v}" ] ; then
+                               binary="${full_argv0}-${v}"
+                               v="x"
+                       fi
+               done
+               [ "${v}" = "x" ] && break
+       done
+fi
+
+#
+# autodetect helpers
+#
+do_awk() {
+       local file=$1 ; shift
+       local arg=$1 ; shift
+       echo $(gawk "{ if (match(\$0, \"$*\", res)) { print res[${arg}]; exit } }" ${file})
+}
+
+#
+# autodetect routine
+#
+if [ -z "${WANT_AUTOMAKE}" ] ; then
+       if [ -r "Makefile.in" ] ; then
+               confversion_mf=$(do_awk Makefile.in 2 "^# Makefile.in generated (automatically )?by automake ([0-9].[0-9]+)")
+       fi
+       if [ -r "aclocal.m4" ] ; then
+               confversion_ac=$(do_awk aclocal.m4 1 'generated automatically by aclocal ([0-9].[0-9]+)')
+               confversion_am=$(do_awk aclocal.m4 1 '[[:space:]]*\\[?AM_AUTOMAKE_VERSION\\(\\[?([0-9].[0-9]+)[^)]*\\]?\\)')
+       fi
+
+       for v in ${vers} ; do
+               if [ "${confversion_mf}" = "${v}" ] || \
+                  [ "${confversion_ac}" = "${v}" ] || \
+                  [ "${confversion_am}" = "${v}" ]
+               then
+                       binary="${full_argv0}-${v}"
+                       break
+               fi
+       done
+fi
+
+if [ "${WANT_AMWRAPPER_DEBUG}" ] ; then
+       if [ "${WANT_AUTOMAKE}" ] ; then
+               warn "DEBUG: WANT_AUTOMAKE is set to ${WANT_AUTOMAKE}"
+       fi
+       warn "DEBUG: will execute <$binary>"
+fi
+
+#
+# for further consistency
+#
+for v in ${vers} ; do
+       if [ "${binary}" = "${full_argv0}-${v}" ] ; then
+               export WANT_AUTOMAKE="${v}"
+               break
+       fi
+done
+
+#
+# Now try to run the binary
+#
+if [ ! -x "${binary}" ] ; then
+       err "$binary is missing or not executable.\n" \
+           "\tPlease try emerging the correct version of automake."
+fi
+
+exec "$binary" "$@"
+
+err "was unable to exec $binary !?"