dev-qt/qtx11extras: stable 5.14.2 for ppc, bug #719732
[gentoo.git] / eclass / preserve-libs.eclass
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: preserve-libs.eclass
5 # @MAINTAINER:
6 # base-system@gentoo.org
7 # @BLURB: preserve libraries after SONAME changes
8
9 if [[ -z ${_PRESERVE_LIBS_ECLASS} ]]; then
10 _PRESERVE_LIBS_ECLASS=1
11
12 # @FUNCTION: preserve_old_lib
13 # @USAGE: <libs to preserve> [more libs]
14 # @DESCRIPTION:
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.
21 preserve_old_lib() {
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"
25         fi
26         [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]"
27
28         # let portage worry about it
29         has preserve-libs ${FEATURES} && return 0
30
31         has "${EAPI:-0}" 0 1 2 && local ED=${D} EROOT=${ROOT}
32
33         local lib dir
34         for lib in "$@" ; do
35                 [[ -e ${EROOT}/${lib} ]] || continue
36                 dir=${lib%/*}
37                 dodir ${dir} || die "dodir ${dir} failed"
38                 cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed"
39                 touch "${ED}"/${lib}
40         done
41 }
42
43 # @FUNCTION: preserve_old_lib_notify
44 # @USAGE: <libs to notify> [more libs]
45 # @DESCRIPTION:
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"
51         fi
52
53         # let portage worry about it
54         has preserve-libs ${FEATURES} && return 0
55
56         has "${EAPI:-0}" 0 1 2 && local EROOT=${ROOT}
57
58         local lib notice=0
59         for lib in "$@" ; do
60                 [[ -e ${EROOT}/${lib} ]] || continue
61                 if [[ ${notice} -eq 0 ]] ; then
62                         notice=1
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."
68                         ewarn
69                 fi
70                 ewarn "  # revdep-rebuild --library '${lib}' && rm '${lib}'"
71         done
72 }
73
74 fi