what $subject says,

"add support for pkg-config for migration to the new upstream defined bash-completion directories (prereq for bug 472938)"

http://bugs.gentoo.org/472938

ie. the pkg-config file shipped *now* in portage is a hack from me to postpone this

pretty tired so more eyes is cool ;)
--- bash-completion-r1.eclass	2013-06-13 01:09:24.933961265 +0300
+++ /tmp/bash-completion-r1.eclass	2013-06-13 01:08:51.846963274 +0300
@@ -9,7 +9,7 @@
 # @EXAMPLE:
 #
 # @CODE
-# EAPI=4
+# EAPI=5
 #
 # src_install() {
 # 	default
@@ -17,12 +17,55 @@
 # 	newbashcomp contrib/${PN}.bash-completion ${PN}
 # }
 # @CODE
+#
+# @CODE
+# EAPI=5
+#
+# src_configure() {
+# econf \
+#	--with-udevdir="$(get_bashcompdir)"
+# }
+# @CODE
+
+inherit toolchain-funcs
 
 case ${EAPI:-0} in
 	0|1|2|3|4|5) ;;
 	*) die "EAPI ${EAPI} unsupported (yet)."
 esac
 
+_get_bashdir() {
+	if $($(tc-getPKG_CONFIG) --exists bash-completion); then
+	echo "$($(tc-getPKG_CONFIG) --variable=$1 bash-completion)"
+	else
+		echo $2
+	fi
+}
+
+# @FUNCTION: get_bashcompdir
+# @RETURN: completionsdir value from bash-completion.pc if it's available
+# @DESCRIPTION:
+# If bash-completion.pc pkg-config file is available, query the correct
+# "completionsdir=" value and return it
+# Otherwise fallback to /usr/share/bash-completion/completions
+get_bashcompdir() {
+	if has_version '<app-shells/bash-completion-2.1-r1'; then
+		_get_bashdir completionsdir /usr/share/bash-completion
+	else
+		_get_bashdir completionsdir /usr/share/bash-completion/completions
+	fi
+}
+
+# @FUNCTION: get_bashhelpersdir
+# @RETURN: helpersdir value from bash-completion.pc if it's available
+# @DESCRIPTION:
+# If bash-completion.pc pkg-config file is available, query the correct
+# "helpersdir=" value and return it
+# Otherwise fallback to /usr/share/bash-completion/completions
+get_bashhelpersdir() {
+	_get_bashdir helpersdir /usr/share/bash-completion/helpers
+}
+
 # @FUNCTION: dobashcomp
 # @USAGE: file [...]
 # @DESCRIPTION:
@@ -32,7 +75,7 @@
 	debug-print-function ${FUNCNAME} "${@}"
 
 	(
-		insinto /usr/share/bash-completion
+		insinto "$(get_bashcompdir)"
 		doins "${@}"
 	)
 }
@@ -46,7 +89,7 @@
 	debug-print-function ${FUNCNAME} "${@}"
 
 	(
-		insinto /usr/share/bash-completion
+		insinto "$(get_bashcompdir)"
 		newins "${@}"
 	)
 }

Reply via email to