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

Contents of /eclass/fixheadtails.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (hide annotations) (download)
Tue Dec 20 01:31:53 2005 UTC (8 years, 7 months ago) by vapier
Branch: MAIN
Changes since 1.9: +2 -2 lines
silence warnings

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.10 # $Header: /var/cvsroot/gentoo-x86/eclass/fixheadtails.eclass,v 1.9 2005/07/11 15:08:06 swegener Exp $
4 johnm 1.1 #
5     # Author John Mylchreest <johnm@gentoo.org>
6    
7 swegener 1.9 DEPEND=">=sys-apps/sed-4"
8 johnm 1.1
9     # ht_fix_all
10     # This fixes all files within the current directory.
11     # Do be used in src_unpack ; cd ${S}; ht_fix_all
12    
13     # ht_fix_file <param> [<param>] [<param>]..
14     # This fixes the files passed by PARAM
15     # to be used for specific files. ie: ht_fix_file "${FILESDIR}/mypatch.patch"
16    
17 mr_bones_ 1.2 do_sed_fix() {
18 vapier 1.6 einfo " - fixed $1"
19 mr_bones_ 1.2 sed -i \
20 langthang 1.5 -e 's/head \+-\([0-9]\)/head -n \1/g' \
21     -e 's/tail \+\([-+][0-9]\+\)c/tail -c \1/g' \
22     -e 's/tail \+\([-+][0-9]\)/tail -n \1/g' ${1} || \
23 mr_bones_ 1.2 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 vapier 1.10 MATCHES=$(grep -l -s -i -R -e "head -[ 0-9]" -e "tail [+-][ 0-9]" * | sort -u)
39 vapier 1.6 [[ -n ${MATCHES} ]] \
40     && ht_fix_file ${MATCHES} \
41     || einfo "No need for ht_fix_all anymore !"
42 johnm 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20