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

Contents of /eclass/fixheadtails.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Wed Jul 6 20:20:03 2005 UTC (9 years, 3 months ago) by agriffis
Branch: MAIN
Changes since 1.6: +1 -2 lines
Remove ECLASS= and INHERITED= which haven't been necessary for a long time now

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

  ViewVC Help
Powered by ViewVC 1.1.20