strip remaining libraries for the distribution size
[dragora.git] / recipes / modules / perl / xml-parser / recipe
blob768dd00c3455666520251b50e07b41aad70eb177
1 # Build recipe for xml-parser.
3 # Copyright (c) 2017 Mateus P. Rodrigues, <mprodrigues@dragora.org>.
4 # Copyright (c) 2017 Matias Fonzo, <selk@dragora.org>.
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 #    http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
18 program=XML-Parser
19 version=2.44_01
20 release=1
22 description="
23 A perl module for parsing XML documents.
25 This is a Perl interface to the expat library.
28 homepage=http://search.cpan.org/~toddr/XML-Parser/
29 license="The Perl 5 License"
31 tarname=${program}-${version}.tar.gz
33 # Remote source(s)
34 fetch=http://search.cpan.org/CPAN/authors/id/T/TO/TODDR/$tarname
36 pkgname=xml-parser
38 # Source documentation
39 docs="Changes README"
40 docsdir="${docdir}/${program}-${version}"
42 build() {
43     set -e
45     unpack "${tardir}/$tarname"
47     cd "$srcdir"
49     perl Makefile.PL INSTALLDIRS=vendor
51     make -j${jobs} V=1 docdir=$docsdir
52     make -j${jobs} DESTDIR="$destdir" install
54     # Strip remaining binaries and libraries
55     find "$destdir" -type f | xargs file | \
56      awk '/ELF/ && /executable/ || /shared object/' | \
57       cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
59     # Clean up inventory file for Perl
61     # This line removes 'destdir' adding the suffix '.lz' for manpages
62     find "${destdir}/" -type f -name '.packlist' | while read -r file
63     do
64          sed -i \
65           -e "s|${destdir}||g" \
66           -e "s|\.[0-9][a-z]*|&.lz|g" \
67           $file
68     done
70     find "${destdir}/" -type f -name 'perllocal.pod' -exec rm -f {} +
72     # Compress manual pages
73     if [ -d "${destdir}/$mandir" ] ; then
74         (
75             cd "${destdir}/$mandir"
76             find . -type f -exec lzip -9 '{}' +
77             find . -type l | while read -r file
78             do
79                 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
80                 rm -- "$file"
81             done
82         )
83     fi
85     # Copy documentation
86     mkdir -p "${destdir}${docsdir}"
87     cp -p $docs "${destdir}${docsdir}/"