1 |
El lun, 28-05-2012 a las 09:58 +0200, Michał Górny escribió: |
2 |
> As autotools-utils exports phase functions, it will be better if |
3 |
> remove_libtool_files() functions would be somewhere else. |
4 |
> --- |
5 |
> eutils.eclass | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
6 |
> 1 file changed, 68 insertions(+) |
7 |
> |
8 |
> diff --git a/eutils.eclass b/eutils.eclass |
9 |
> index c88ef35..fb92256 100644 |
10 |
> --- a/eutils.eclass |
11 |
> +++ b/eutils.eclass |
12 |
> @@ -1330,6 +1330,74 @@ makeopts_jobs() { |
13 |
> echo ${jobs:-1} |
14 |
> } |
15 |
> |
16 |
> +# @FUNCTION: remove_libtool_files |
17 |
> +# @USAGE: [all] |
18 |
> +# @DESCRIPTION: |
19 |
> +# Determines unnecessary libtool files (.la) and libtool static archives (.a), |
20 |
> +# and removes them from installation image. |
21 |
> +# |
22 |
> +# To unconditionally remove all libtool files, pass 'all' as an argument. |
23 |
> +# Otherwise, libtool archives required for static linking will be preserved. |
24 |
> +remove_libtool_files() { |
25 |
> + debug-print-function ${FUNCNAME} "$@" |
26 |
> + local removing_all |
27 |
> + [[ ${#} -le 1 ]] || die "Invalid number of args to ${FUNCNAME}()" |
28 |
> + if [[ ${#} -eq 1 ]]; then |
29 |
> + case "${1}" in |
30 |
> + all) |
31 |
> + removing_all=1 |
32 |
> + ;; |
33 |
> + *) |
34 |
> + die "Invalid argument to ${FUNCNAME}(): ${1}" |
35 |
> + esac |
36 |
> + fi |
37 |
> + |
38 |
> + local pc_libs=() |
39 |
> + if [[ ! ${removing_all} ]]; then |
40 |
> + local arg |
41 |
> + for arg in $(find "${D}" -name '*.pc' -exec \ |
42 |
> + sed -n -e 's;^Libs:;;p' {} +); do |
43 |
> + [[ ${arg} == -l* ]] && pc_libs+=(lib${arg#-l}.la) |
44 |
> + done |
45 |
> + fi |
46 |
> + |
47 |
> + local f |
48 |
> + find "${D}" -type f -name '*.la' -print0 | while read -r -d '' f; do |
49 |
> + local shouldnotlink=$(sed -ne '/^shouldnotlink=yes$/p' "${f}") |
50 |
> + local archivefile=${f/%.la/.a} |
51 |
> + [[ "${f}" != "${archivefile}" ]] || die 'regex sanity check failed' |
52 |
> + |
53 |
> + # Remove static libs we're not supposed to link against. |
54 |
> + if [[ ${shouldnotlink} ]]; then |
55 |
> + einfo "Removing unnecessary ${archivefile#${D%/}}" |
56 |
> + rm -f "${archivefile}" || die |
57 |
> + # The .la file may be used by a module loader, so avoid removing it |
58 |
> + # unless explicitly requested. |
59 |
> + [[ ${removing_all} ]] || continue |
60 |
> + fi |
61 |
> + |
62 |
> + # Remove .la files when: |
63 |
> + # - user explicitly wants us to remove all .la files, |
64 |
> + # - respective static archive doesn't exist, |
65 |
> + # - they are covered by a .pc file already, |
66 |
> + # - they don't provide any new information (no libs & no flags). |
67 |
> + local removing |
68 |
> + if [[ ${removing_all} ]]; then removing='forced' |
69 |
> + elif [[ ! -f ${archivefile} ]]; then removing='no static archive' |
70 |
> + elif has "$(basename "${f}")" "${pc_libs[@]}"; then |
71 |
> + removing='covered by .pc' |
72 |
> + elif [[ ! $(sed -n -e \ |
73 |
> + "s/^\(dependency_libs\|inherited_linker_flags\)='\(.*\)'$/\2/p" \ |
74 |
> + "${f}") ]]; then removing='no libs & flags' |
75 |
> + fi |
76 |
> + |
77 |
> + if [[ ${removing} ]]; then |
78 |
> + einfo "Removing unnecessary ${f#${D%/}} (${removing})" |
79 |
> + rm -f "${f}" || die |
80 |
> + fi |
81 |
> + done |
82 |
> +} |
83 |
> + |
84 |
> check_license() { die "you no longer need this as portage supports ACCEPT_LICENSE itself"; } |
85 |
> |
86 |
> fi |
87 |
|
88 |
+1 |
89 |
|
90 |
This was the main reason for me still doing manually cleaning over using |
91 |
this function |