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

Contents of /eclass/fixheadtails.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show 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 # Copyright 1999-2004 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/fixheadtails.eclass,v 1.5 2005/01/22 00:02:08 langthang Exp $
4 #
5 # Author John Mylchreest <johnm@gentoo.org>
6
7 ECLASS=fixheadtails
8 INHERITED="$INHERITED $ECLASS"
9 DEPEND="${DEPEND} >=sys-apps/sed-4"
10
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 do_sed_fix() {
20 einfo " - fixed $1"
21 sed -i \
22 -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 die "sed ${1} failed"
26 }
27
28 ht_fix_file() {
29 local i
30
31 einfo "Replacing obsolete head/tail with POSIX compliant ones"
32 for i in "${@}"
33 do
34 do_sed_fix ${i}
35 done
36 }
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 [[ -n ${MATCHES} ]] \
42 && ht_fix_file ${MATCHES} \
43 || einfo "No need for ht_fix_all anymore !"
44 }

  ViewVC Help
Powered by ViewVC 1.1.20