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

Contents of /eclass/fixheadtails.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Wed Nov 26 22:13:35 2003 UTC (10 years, 4 months ago) by mr_bones_
Branch: MAIN
Changes since 1.1: +15 -21 lines
Fix syntax error

1 johnm 1.1 # Copyright 1999-2003 Gentoo Technologies, Inc.
2     # Distributed under the terms of the GNU General Public License v2
3 mr_bones_ 1.2 # $Header: /home/cvsroot/gentoo-x86/eclass/fixheadtails.eclass,v 1.1 2003/09/17 21:15:18 johnm 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     sed -i \
21     -e 's/head -\(.*\)/head -n \1/' \
22     -e 's/tail \([-+]\)\(.*\)/tail -n \1\2/' ${1} || \
23     die "sed ${1} failed"
24 johnm 1.1 }
25    
26     ht_fix_file() {
27     local i
28    
29 mr_bones_ 1.2 einfo "Replacing obsolete head/tail with POSIX compliant ones"
30 johnm 1.1 for i in "${@}"
31     do
32 mr_bones_ 1.2 do_sed_fix ${i}
33 johnm 1.1 done
34 mr_bones_ 1.2 }
35    
36     ht_fix_all() {
37     local MATCHES
38     MATCHES="$(grep -l -i -R -e "head -[ 0-9]" -e "tail [+-][ 0-9]" * | sort -u)"
39     ht_fix_file ${MATCHES}
40 johnm 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20