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

Diff of /eclass/fixheadtails.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.20