public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-x86 commit in sys-devel/automake-wrapper/files: am-wrapper-8.sh
@ 2013-01-02  7:40 Mike Frysinger (vapier)
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger (vapier) @ 2013-01-02  7:40 UTC (permalink / raw
  To: gentoo-commits

vapier      13/01/02 07:40:04

  Added:                am-wrapper-8.sh
  Log:
  Rewrite logic to be more friendly to missing versions #417745 by Toralf Förster.
  
  (Portage version: 2.2.0_alpha144/cvs/Linux x86_64, signed Manifest commit with key FB7C4156)

Revision  Changes    Path
1.1                  sys-devel/automake-wrapper/files/am-wrapper-8.sh

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/automake-wrapper/files/am-wrapper-8.sh?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/automake-wrapper/files/am-wrapper-8.sh?rev=1.1&content-type=text/plain

Index: am-wrapper-8.sh
===================================================================
#!/bin/sh
# Copyright 1999-2013 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-8.sh,v 1.1 2013/01/02 07:40:04 vapier Exp $

# Executes the correct automake version.
#
# If WANT_AUTOMAKE is set (can be a whitespace delimited list of versions):
#  - attempt to find an installed version using those
#  - if magic keyword 'latest' is found, pick the latest version that exists
#  - if nothing found, warn, and proceed as if WANT_AUTOMAKE was not set (below)
# If WANT_AUTOMAKE is not set:
#  - Try to detect the version of automake used to generate things (look at
#    Makefile.in and aclocal.m4 and any other useful file)
#  - If detected version is not found, warn and proceed as if blank slate
#  - Try to locate the latest version of automake that exists and run it

(set -o posix) 2>/dev/null && set -o posix

_stderr() { printf 'am-wrapper: %s: %b\n' "${argv0}" "$*" 1>&2; }
warn() { _stderr "warning: $*"; }
err() { _stderr "error: $*"; 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 ! 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_AUTOMAKE;
# Start with last known versions to speed up lookup process.
#
LAST_KNOWN_AUTOMAKE_VER="13"
vers=$(printf '1.%s ' `seq ${LAST_KNOWN_AUTOMAKE_VER} -1 4`)

#
# Helper to scan for a usable program based on version.
#
binary=
all_vers=
find_binary() {
	local v
	all_vers="${all_vers} $*" # For error messages.
	for v ; do
		if [ -x "${full_argv0}-${v}" ] ; then
			binary="${full_argv0}-${v}"
			binary_ver=${v}
			return 0
		fi
	done
	return 1
}

#
# Try and find a usable automake version.  First check the WANT_AUTOMAKE
# setting (whitespace delimited list), then fallback to the latest.
#
find_latest() {
	if ! find_binary ${vers} ; then
		# Brute force it.
		find_binary $(printf '1.%s ' `seq 99 -1 ${LAST_KNOWN_AUTOMAKE_VER}`)
	fi
}
for wx in ${WANT_AUTOMAKE:-latest} ; do
	if [ "${wx}" = "latest" ] ; then
		find_latest && break
	else
		find_binary ${wx} && break
	fi
done

if [ -z "${binary}" ] && [ -n "${WANT_AUTOMAKE}" ] ; then
	warn "could not locate installed version for WANT_AUTOMAKE='${WANT_AUTOMAKE}'; ignoring"
	unset WANT_AUTOMAKE
	find_latest
fi

if [ -z "${binary}" ] ; then
	err "Unable to locate any usuable version of automake.\n" \
	    "\tI tried these versions:${all_vers}\n" \
	    "\tWith a base name of '${full_argv0}'."
fi

#
# autodetect helpers
#
do_awk() {
	local file=$1 ; shift
	local arg=$1 ; shift
	local v=$(awk "{ if (match(\$0, \"$*\", res)) { print res[${arg}]; exit } }" "${file}")
	case " ${auto_vers} " in
	*" ${v} "*) ;;
	*) auto_vers="${auto_vers:+${auto_vers} }${v}" ;;
	esac
}

#
# autodetect routine
#
if [ -z "${WANT_AUTOMAKE}" ] ; then
	auto_vers=
	if [ -r "Makefile.in" ] ; then
		do_awk Makefile.in 2 "^# Makefile.in generated (automatically )?by automake ([0-9].[0-9]+)"
	fi
	if [ -r "aclocal.m4" ] ; then
		do_awk aclocal.m4 1 'generated automatically by aclocal ([0-9].[0-9]+)'
		do_awk aclocal.m4 1 '[[:space:]]*\\[?AM_AUTOMAKE_VERSION\\(\\[?([0-9].[0-9]+)[^)]*\\]?\\)'
	fi
	# We don't need to set $binary here as it has already been setup for us
	# earlier to the latest available version.
	if [ -n "${auto_vers}" ] ; then
		if ! find_binary ${auto_vers} ; then
			warn "auto-detected versions not found (${auto_vers}); falling back to latest available"
		fi
	fi
fi

if [ -n "${WANT_AMWRAPPER_DEBUG}" ] ; then
	if [ -n "${WANT_AUTOMAKE}" ] ; then
		warn "DEBUG: WANT_AUTOMAKE is set to ${WANT_AUTOMAKE}"
	fi
	warn "DEBUG: will execute <${binary}>"
fi

#
# for further consistency
#
export WANT_AUTOMAKE="${binary_ver}"

#
# Now try to run the binary
#
if [ ! -x "${binary}" ] ; then
	# this shouldn't happen
	err "${binary} is missing or not executable.\n" \
	    "\tPlease try installing the correct version of automake."
fi

exec "${binary}" "$@"
# The shell will error out if `exec` failed.





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gentoo-commits] gentoo-x86 commit in sys-devel/automake-wrapper/files: am-wrapper-8.sh
@ 2013-02-04 14:00 Alexis Ballier (aballier)
  0 siblings, 0 replies; 2+ messages in thread
From: Alexis Ballier (aballier) @ 2013-02-04 14:00 UTC (permalink / raw
  To: gentoo-commits

aballier    13/02/04 14:00:24

  Modified:             am-wrapper-8.sh
  Log:
  Call gawk as before since GNU awk is required and breaks with e.g. BSD awk. Bug #455436
  
  (Portage version: 2.2.0_alpha161/cvs/Linux x86_64, signed Manifest commit with key 160F534A)

Revision  Changes    Path
1.2                  sys-devel/automake-wrapper/files/am-wrapper-8.sh

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/automake-wrapper/files/am-wrapper-8.sh?rev=1.2&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/automake-wrapper/files/am-wrapper-8.sh?rev=1.2&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/automake-wrapper/files/am-wrapper-8.sh?r1=1.1&r2=1.2

Index: am-wrapper-8.sh
===================================================================
RCS file: /var/cvsroot/gentoo-x86/sys-devel/automake-wrapper/files/am-wrapper-8.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- am-wrapper-8.sh	2 Jan 2013 07:40:04 -0000	1.1
+++ am-wrapper-8.sh	4 Feb 2013 14:00:23 -0000	1.2
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Copyright 1999-2013 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-8.sh,v 1.1 2013/01/02 07:40:04 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/automake-wrapper/files/am-wrapper-8.sh,v 1.2 2013/02/04 14:00:23 aballier Exp $
 
 # Executes the correct automake version.
 #
@@ -128,7 +128,7 @@
 do_awk() {
 	local file=$1 ; shift
 	local arg=$1 ; shift
-	local v=$(awk "{ if (match(\$0, \"$*\", res)) { print res[${arg}]; exit } }" "${file}")
+	local v=$(gawk "{ if (match(\$0, \"$*\", res)) { print res[${arg}]; exit } }" "${file}")
 	case " ${auto_vers} " in
 	*" ${v} "*) ;;
 	*) auto_vers="${auto_vers:+${auto_vers} }${v}" ;;





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-02-04 14:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-04 14:00 [gentoo-commits] gentoo-x86 commit in sys-devel/automake-wrapper/files: am-wrapper-8.sh Alexis Ballier (aballier)
  -- strict thread matches above, loose matches on Subject: below --
2013-01-02  7:40 Mike Frysinger (vapier)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox