summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2018-01-03 17:13:16 +0100
committerUlrich Müller <ulm@gentoo.org>2018-01-09 11:21:19 +0100
commite7b3670e435e5e4a7119bce5feaecc27ad46d097 (patch)
tree4e129a11c31635cad2b420afe50af6b306198a8d /eclass/preserve-libs.eclass
parentversionator.eclass: inherit estack rather than eutils. (diff)
downloadgentoo-e7b3670e435e5e4a7119bce5feaecc27ad46d097.tar.gz
gentoo-e7b3670e435e5e4a7119bce5feaecc27ad46d097.tar.bz2
gentoo-e7b3670e435e5e4a7119bce5feaecc27ad46d097.zip
preserve-libs.eclass: Split off preserve_old_lib from eutils.
Split off functions preserve_old_lib and preserve_old_lib_notify from eutils.eclass into a dedicated preserve-libs.eclass. These functions are rarely used and are independent of the rest of eutils, therefore moving them into their own eclass will help clarifying eclass inheritance in ebuilds. For backwards compatibility, eutils inherits the new eclass in existing EAPIs.
Diffstat (limited to 'eclass/preserve-libs.eclass')
-rw-r--r--eclass/preserve-libs.eclass74
1 files changed, 74 insertions, 0 deletions
diff --git a/eclass/preserve-libs.eclass b/eclass/preserve-libs.eclass
new file mode 100644
index 00000000000..548c6411fcf
--- /dev/null
+++ b/eclass/preserve-libs.eclass
@@ -0,0 +1,74 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: preserve-libs.eclass
+# @MAINTAINER:
+# base-system@gentoo.org
+# @BLURB: preserve libraries after SONAME changes
+
+if [[ -z ${_PRESERVE_LIBS_ECLASS} ]]; then
+_PRESERVE_LIBS_ECLASS=1
+
+# @FUNCTION: preserve_old_lib
+# @USAGE: <libs to preserve> [more libs]
+# @DESCRIPTION:
+# These functions are useful when a lib in your package changes ABI SONAME.
+# An example might be from libogg.so.0 to libogg.so.1. Removing libogg.so.0
+# would break packages that link against it. Most people get around this
+# by using the portage SLOT mechanism, but that is not always a relevant
+# solution, so instead you can call this from pkg_preinst. See also the
+# preserve_old_lib_notify function.
+preserve_old_lib() {
+ if [[ ${EBUILD_PHASE} != "preinst" ]] ; then
+ eerror "preserve_old_lib() must be called from pkg_preinst() only"
+ die "Invalid preserve_old_lib() usage"
+ fi
+ [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]"
+
+ # let portage worry about it
+ has preserve-libs ${FEATURES} && return 0
+
+ has "${EAPI:-0}" 0 1 2 && local ED=${D} EROOT=${ROOT}
+
+ local lib dir
+ for lib in "$@" ; do
+ [[ -e ${EROOT}/${lib} ]] || continue
+ dir=${lib%/*}
+ dodir ${dir} || die "dodir ${dir} failed"
+ cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed"
+ touch "${ED}"/${lib}
+ done
+}
+
+# @FUNCTION: preserve_old_lib_notify
+# @USAGE: <libs to notify> [more libs]
+# @DESCRIPTION:
+# Spit helpful messages about the libraries preserved by preserve_old_lib.
+preserve_old_lib_notify() {
+ if [[ ${EBUILD_PHASE} != "postinst" ]] ; then
+ eerror "preserve_old_lib_notify() must be called from pkg_postinst() only"
+ die "Invalid preserve_old_lib_notify() usage"
+ fi
+
+ # let portage worry about it
+ has preserve-libs ${FEATURES} && return 0
+
+ has "${EAPI:-0}" 0 1 2 && local EROOT=${ROOT}
+
+ local lib notice=0
+ for lib in "$@" ; do
+ [[ -e ${EROOT}/${lib} ]] || continue
+ if [[ ${notice} -eq 0 ]] ; then
+ notice=1
+ ewarn "Old versions of installed libraries were detected on your system."
+ ewarn "In order to avoid breaking packages that depend on these old libs,"
+ ewarn "the libraries are not being removed. You need to run revdep-rebuild"
+ ewarn "in order to remove these old dependencies. If you do not have this"
+ ewarn "helper program, simply emerge the 'gentoolkit' package."
+ ewarn
+ fi
+ ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'"
+ done
+}
+
+fi