From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1SYvsf-0002oI-27 for garchives@archives.gentoo.org; Mon, 28 May 2012 09:04:49 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 38E29E0795; Mon, 28 May 2012 09:04:30 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id BDF0FE07E8 for ; Mon, 28 May 2012 09:03:24 +0000 (UTC) Received: from [192.168.1.33] (10.Red-2-137-247.dynamicIP.rima-tde.net [2.137.247.10]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: pacho) by smtp.gentoo.org (Postfix) with ESMTPSA id 56AEE1B4031 for ; Mon, 28 May 2012 09:03:23 +0000 (UTC) Subject: Re: [gentoo-dev] [PATCH eutils] Move remove_libtool_files() from autotools-utils for wider use. From: Pacho Ramos To: gentoo-dev@lists.gentoo.org In-Reply-To: <1338191936-2091-1-git-send-email-mgorny@gentoo.org> References: <1338191936-2091-1-git-send-email-mgorny@gentoo.org> Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-NcoVIC+7PMMje+zqEG8S" Date: Mon, 28 May 2012 11:03:19 +0200 Message-ID: <1338195799.6537.2.camel@belkin4> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org Mime-Version: 1.0 X-Mailer: Evolution 2.32.3 X-Archives-Salt: 3c916b5d-1348-40ff-acc1-972f115ca360 X-Archives-Hash: c1dd6fb4d1367546482de21a2e647ef5 --=-NcoVIC+7PMMje+zqEG8S Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable El lun, 28-05-2012 a las 09:58 +0200, Micha=C5=82 G=C3=B3rny escribi=C3=B3: > As autotools-utils exports phase functions, it will be better if > remove_libtool_files() functions would be somewhere else. > --- > eutils.eclass | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++ > 1 file changed, 68 insertions(+) >=20 > diff --git a/eutils.eclass b/eutils.eclass > index c88ef35..fb92256 100644 > --- a/eutils.eclass > +++ b/eutils.eclass > @@ -1330,6 +1330,74 @@ makeopts_jobs() { > echo ${jobs:-1} > } > =20 > +# @FUNCTION: remove_libtool_files > +# @USAGE: [all] > +# @DESCRIPTION: > +# Determines unnecessary libtool files (.la) and libtool static archives= (.a), > +# and removes them from installation image. > +# > +# To unconditionally remove all libtool files, pass 'all' as an argument= . > +# Otherwise, libtool archives required for static linking will be preser= ved. > +remove_libtool_files() { > + debug-print-function ${FUNCNAME} "$@" > + local removing_all > + [[ ${#} -le 1 ]] || die "Invalid number of args to ${FUNCNAME}()" > + if [[ ${#} -eq 1 ]]; then > + case "${1}" in > + all) > + removing_all=3D1 > + ;; > + *) > + die "Invalid argument to ${FUNCNAME}(): ${1}" > + esac > + fi > + > + local pc_libs=3D() > + if [[ ! ${removing_all} ]]; then > + local arg > + for arg in $(find "${D}" -name '*.pc' -exec \ > + sed -n -e 's;^Libs:;;p' {} +); do > + [[ ${arg} =3D=3D -l* ]] && pc_libs+=3D(lib${arg#-l}.la) > + done > + fi > + > + local f > + find "${D}" -type f -name '*.la' -print0 | while read -r -d '' f; do > + local shouldnotlink=3D$(sed -ne '/^shouldnotlink=3Dyes$/p' "${f}") > + local archivefile=3D${f/%.la/.a} > + [[ "${f}" !=3D "${archivefile}" ]] || die 'regex sanity check failed' > + > + # Remove static libs we're not supposed to link against. > + if [[ ${shouldnotlink} ]]; then > + einfo "Removing unnecessary ${archivefile#${D%/}}" > + rm -f "${archivefile}" || die > + # The .la file may be used by a module loader, so avoid removing it > + # unless explicitly requested. > + [[ ${removing_all} ]] || continue > + fi > + > + # Remove .la files when: > + # - user explicitly wants us to remove all .la files, > + # - respective static archive doesn't exist, > + # - they are covered by a .pc file already, > + # - they don't provide any new information (no libs & no flags). > + local removing > + if [[ ${removing_all} ]]; then removing=3D'forced' > + elif [[ ! -f ${archivefile} ]]; then removing=3D'no static archive' > + elif has "$(basename "${f}")" "${pc_libs[@]}"; then > + removing=3D'covered by .pc' > + elif [[ ! $(sed -n -e \ > + "s/^\(dependency_libs\|inherited_linker_flags\)=3D'\(.*\)'$/\2/p" \ > + "${f}") ]]; then removing=3D'no libs & flags' > + fi > + > + if [[ ${removing} ]]; then > + einfo "Removing unnecessary ${f#${D%/}} (${removing})" > + rm -f "${f}" || die > + fi > + done > +} > + > check_license() { die "you no longer need this as portage supports ACCEP= T_LICENSE itself"; } > =20 > fi +1 This was the main reason for me still doing manually cleaning over using this function=20 --=-NcoVIC+7PMMje+zqEG8S Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iEYEABECAAYFAk/DP1cACgkQCaWpQKGI+9SnTQCdEeh9Iyd1Dpd7spPdd7+w+TAm /fIAn3n0FImrFSFJ8p+E8la8aRzJZCa3 =wogu -----END PGP SIGNATURE----- --=-NcoVIC+7PMMje+zqEG8S--