/[gentoo-x86]/eclass/fixheadtails.eclass
Gentoo

Contents of /eclass/fixheadtails.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download)
Thu Feb 10 00:08:08 2005 UTC (9 years, 6 months ago) by vapier
Branch: MAIN
Changes since 1.5: +5 -2 lines
some helpful output

1 vapier 1.3 # Copyright 1999-2004 Gentoo Foundation
2 johnm 1.1 # Distributed under the terms of the GNU General Public License v2
3 vapier 1.6 # $Header: /var/cvsroot/gentoo-x86/eclass/fixheadtails.eclass,v 1.5 2005/01/22 00:02:08 langthang Exp $
4 johnm 1.1 #
5     # Author John Mylchreest <johnm@gentoo.org>
6    
7     ECLASS=fixheadtails
8     INHERITED="$INHERITED $ECLASS"
9 mr_bones_ 1.2 DEPEND="${DEPEND} >=sys-apps/sed-4"
10 johnm 1.1
11     # ht_fix_all
12     # This fixes all files within the current directory.
13     # Do be used in src_unpack ; cd ${S}; ht_fix_all
14    
15     # ht_fix_file <param> [<param>] [<param>]..
16     # This fixes the files passed by PARAM
17     # to be used for specific files. ie: ht_fix_file "${FILESDIR}/mypatch.patch"
18    
19 mr_bones_ 1.2 do_sed_fix() {
20 vapier 1.6 einfo " - fixed $1"
21 mr_bones_ 1.2 sed -i \
22 langthang 1.5 -e 's/head \+-\([0-9]\)/head -n \1/g' \
23     -e 's/tail \+\([-+][0-9]\+\)c/tail -c \1/g' \
24     -e 's/tail \+\([-+][0-9]\)/tail -n \1/g' ${1} || \
25 mr_bones_ 1.2 die "sed ${1} failed"
26 johnm 1.1 }
27    
28     ht_fix_file() {
29     local i
30    
31 mr_bones_ 1.2 einfo "Replacing obsolete head/tail with POSIX compliant ones"
32 johnm 1.1 for i in "${@}"
33     do
34 mr_bones_ 1.2 do_sed_fix ${i}
35 johnm 1.1 done
36 mr_bones_ 1.2 }
37    
38     ht_fix_all() {
39     local MATCHES
40     MATCHES="$(grep -l -i -R -e "head -[ 0-9]" -e "tail [+-][ 0-9]" * | sort -u)"
41 vapier 1.6 [[ -n ${MATCHES} ]] \
42     && ht_fix_file ${MATCHES} \
43     || einfo "No need for ht_fix_all anymore !"
44 johnm 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20