1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: preserve-libs.eclass
6 # base-system@gentoo.org
7 # @BLURB: preserve libraries after SONAME changes
9 if [[ -z ${_PRESERVE_LIBS_ECLASS} ]]; then
10 _PRESERVE_LIBS_ECLASS=1
12 # @FUNCTION: preserve_old_lib
13 # @USAGE: <libs to preserve> [more libs]
15 # These functions are useful when a lib in your package changes ABI SONAME.
16 # An example might be from libogg.so.0 to libogg.so.1. Removing libogg.so.0
17 # would break packages that link against it. Most people get around this
18 # by using the portage SLOT mechanism, but that is not always a relevant
19 # solution, so instead you can call this from pkg_preinst. See also the
20 # preserve_old_lib_notify function.
22 if [[ ${EBUILD_PHASE} != "preinst" ]] ; then
23 eerror "preserve_old_lib() must be called from pkg_preinst() only"
24 die "Invalid preserve_old_lib() usage"
26 [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]"
28 # let portage worry about it
29 has preserve-libs ${FEATURES} && return 0
31 has "${EAPI:-0}" 0 1 2 && local ED=${D} EROOT=${ROOT}
35 [[ -e ${EROOT}/${lib} ]] || continue
37 dodir ${dir} || die "dodir ${dir} failed"
38 cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed"
43 # @FUNCTION: preserve_old_lib_notify
44 # @USAGE: <libs to notify> [more libs]
46 # Spit helpful messages about the libraries preserved by preserve_old_lib.
47 preserve_old_lib_notify() {
48 if [[ ${EBUILD_PHASE} != "postinst" ]] ; then
49 eerror "preserve_old_lib_notify() must be called from pkg_postinst() only"
50 die "Invalid preserve_old_lib_notify() usage"
53 # let portage worry about it
54 has preserve-libs ${FEATURES} && return 0
56 has "${EAPI:-0}" 0 1 2 && local EROOT=${ROOT}
60 [[ -e ${EROOT}/${lib} ]] || continue
61 if [[ ${notice} -eq 0 ]] ; then
63 ewarn "Old versions of installed libraries were detected on your system."
64 ewarn "In order to avoid breaking packages that depend on these old libs,"
65 ewarn "the libraries are not being removed. You need to run revdep-rebuild"
66 ewarn "in order to remove these old dependencies. If you do not have this"
67 ewarn "helper program, simply emerge the 'gentoolkit' package."
70 ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'"