Gentoo Archives: gentoo-dev

From: "Ulrich Müller" <ulm@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] [PATCH 1/2] preserve-libs.eclass: Split off preserve_old_lib from eutils.
Date: Wed, 03 Jan 2018 16:25:48
Message-Id: 23117.1020.645368.780891@a1i15.kph.uni-mainz.de
1 Split off functions preserve_old_lib and preserve_old_lib_notify from
2 eutils.eclass into a dedicated preserve-libs.eclass. These functions
3 are rarely used and are independent of the rest of eutils, therefore
4 moving them into their own eclass will help clarifying eclass
5 inheritance in ebuilds.
6
7 For backwards compatibility, eutils inherits the new eclass in
8 existing EAPIs.
9 ---
10 eclass/eutils.eclass | 65 ++-------------------------------------
11 eclass/preserve-libs.eclass | 74 +++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 76 insertions(+), 63 deletions(-)
13 create mode 100644 eclass/preserve-libs.eclass
14
15 diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass
16 index 7d4193e76b51..91d329e99c9e 100644
17 --- a/eclass/eutils.eclass
18 +++ b/eclass/eutils.eclass
19 @@ -1,4 +1,4 @@
20 -# Copyright 1999-2017 Gentoo Foundation
21 +# Copyright 1999-2018 Gentoo Foundation
22 # Distributed under the terms of the GNU General Public License v2
23
24 # @ECLASS: eutils.eclass
25 @@ -20,7 +20,7 @@ _EUTILS_ECLASS=1
26 # implicitly inherited (now split) eclasses
27 case ${EAPI:-0} in
28 0|1|2|3|4|5|6)
29 - inherit desktop epatch estack ltprune multilib toolchain-funcs
30 + inherit desktop epatch estack ltprune multilib preserve-libs toolchain-funcs
31 ;;
32 esac
33
34 @@ -172,67 +172,6 @@ _eutils_eprefix_init() {
35 has "${EAPI:-0}" 0 1 2 && : ${ED:=${D}} ${EPREFIX:=} ${EROOT:=${ROOT}}
36 }
37
38 -# @FUNCTION: preserve_old_lib
39 -# @USAGE: <libs to preserve> [more libs]
40 -# @DESCRIPTION:
41 -# These functions are useful when a lib in your package changes ABI SONAME.
42 -# An example might be from libogg.so.0 to libogg.so.1. Removing libogg.so.0
43 -# would break packages that link against it. Most people get around this
44 -# by using the portage SLOT mechanism, but that is not always a relevant
45 -# solution, so instead you can call this from pkg_preinst. See also the
46 -# preserve_old_lib_notify function.
47 -preserve_old_lib() {
48 - _eutils_eprefix_init
49 - if [[ ${EBUILD_PHASE} != "preinst" ]] ; then
50 - eerror "preserve_old_lib() must be called from pkg_preinst() only"
51 - die "Invalid preserve_old_lib() usage"
52 - fi
53 - [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]"
54 -
55 - # let portage worry about it
56 - has preserve-libs ${FEATURES} && return 0
57 -
58 - local lib dir
59 - for lib in "$@" ; do
60 - [[ -e ${EROOT}/${lib} ]] || continue
61 - dir=${lib%/*}
62 - dodir ${dir} || die "dodir ${dir} failed"
63 - cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed"
64 - touch "${ED}"/${lib}
65 - done
66 -}
67 -
68 -# @FUNCTION: preserve_old_lib_notify
69 -# @USAGE: <libs to notify> [more libs]
70 -# @DESCRIPTION:
71 -# Spit helpful messages about the libraries preserved by preserve_old_lib.
72 -preserve_old_lib_notify() {
73 - if [[ ${EBUILD_PHASE} != "postinst" ]] ; then
74 - eerror "preserve_old_lib_notify() must be called from pkg_postinst() only"
75 - die "Invalid preserve_old_lib_notify() usage"
76 - fi
77 -
78 - # let portage worry about it
79 - has preserve-libs ${FEATURES} && return 0
80 -
81 - _eutils_eprefix_init
82 -
83 - local lib notice=0
84 - for lib in "$@" ; do
85 - [[ -e ${EROOT}/${lib} ]] || continue
86 - if [[ ${notice} -eq 0 ]] ; then
87 - notice=1
88 - ewarn "Old versions of installed libraries were detected on your system."
89 - ewarn "In order to avoid breaking packages that depend on these old libs,"
90 - ewarn "the libraries are not being removed. You need to run revdep-rebuild"
91 - ewarn "in order to remove these old dependencies. If you do not have this"
92 - ewarn "helper program, simply emerge the 'gentoolkit' package."
93 - ewarn
94 - fi
95 - ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'"
96 - done
97 -}
98 -
99 # @FUNCTION: built_with_use
100 # @USAGE: [--hidden] [--missing <action>] [-a|-o] <DEPEND ATOM> <List of USE flags>
101 # @DESCRIPTION:
102 diff --git a/eclass/preserve-libs.eclass b/eclass/preserve-libs.eclass
103 new file mode 100644
104 index 000000000000..548c6411fcf0
105 --- /dev/null
106 +++ b/eclass/preserve-libs.eclass
107 @@ -0,0 +1,74 @@
108 +# Copyright 1999-2018 Gentoo Foundation
109 +# Distributed under the terms of the GNU General Public License v2
110 +
111 +# @ECLASS: preserve-libs.eclass
112 +# @MAINTAINER:
113 +# base-system@g.o
114 +# @BLURB: preserve libraries after SONAME changes
115 +
116 +if [[ -z ${_PRESERVE_LIBS_ECLASS} ]]; then
117 +_PRESERVE_LIBS_ECLASS=1
118 +
119 +# @FUNCTION: preserve_old_lib
120 +# @USAGE: <libs to preserve> [more libs]
121 +# @DESCRIPTION:
122 +# These functions are useful when a lib in your package changes ABI SONAME.
123 +# An example might be from libogg.so.0 to libogg.so.1. Removing libogg.so.0
124 +# would break packages that link against it. Most people get around this
125 +# by using the portage SLOT mechanism, but that is not always a relevant
126 +# solution, so instead you can call this from pkg_preinst. See also the
127 +# preserve_old_lib_notify function.
128 +preserve_old_lib() {
129 + if [[ ${EBUILD_PHASE} != "preinst" ]] ; then
130 + eerror "preserve_old_lib() must be called from pkg_preinst() only"
131 + die "Invalid preserve_old_lib() usage"
132 + fi
133 + [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]"
134 +
135 + # let portage worry about it
136 + has preserve-libs ${FEATURES} && return 0
137 +
138 + has "${EAPI:-0}" 0 1 2 && local ED=${D} EROOT=${ROOT}
139 +
140 + local lib dir
141 + for lib in "$@" ; do
142 + [[ -e ${EROOT}/${lib} ]] || continue
143 + dir=${lib%/*}
144 + dodir ${dir} || die "dodir ${dir} failed"
145 + cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed"
146 + touch "${ED}"/${lib}
147 + done
148 +}
149 +
150 +# @FUNCTION: preserve_old_lib_notify
151 +# @USAGE: <libs to notify> [more libs]
152 +# @DESCRIPTION:
153 +# Spit helpful messages about the libraries preserved by preserve_old_lib.
154 +preserve_old_lib_notify() {
155 + if [[ ${EBUILD_PHASE} != "postinst" ]] ; then
156 + eerror "preserve_old_lib_notify() must be called from pkg_postinst() only"
157 + die "Invalid preserve_old_lib_notify() usage"
158 + fi
159 +
160 + # let portage worry about it
161 + has preserve-libs ${FEATURES} && return 0
162 +
163 + has "${EAPI:-0}" 0 1 2 && local EROOT=${ROOT}
164 +
165 + local lib notice=0
166 + for lib in "$@" ; do
167 + [[ -e ${EROOT}/${lib} ]] || continue
168 + if [[ ${notice} -eq 0 ]] ; then
169 + notice=1
170 + ewarn "Old versions of installed libraries were detected on your system."
171 + ewarn "In order to avoid breaking packages that depend on these old libs,"
172 + ewarn "the libraries are not being removed. You need to run revdep-rebuild"
173 + ewarn "in order to remove these old dependencies. If you do not have this"
174 + ewarn "helper program, simply emerge the 'gentoolkit' package."
175 + ewarn
176 + fi
177 + ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'"
178 + done
179 +}
180 +
181 +fi
182 --
183 2.15.1

Replies