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

Diff of /eclass/eutils.eclass

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

Revision 1.32 Revision 1.35
1# Copyright 1999-2003 Gentoo Technologies, Inc. 1# Copyright 1999-2003 Gentoo Technologies, Inc.
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/eutils.eclass,v 1.32 2003/06/10 17:30:21 danarmak Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.35 2003/06/22 05:44:04 drobbins Exp $
4# 4#
5# Author: Martin Schlemmer <azarah@gentoo.org> 5# Author: Martin Schlemmer <azarah@gentoo.org>
6# 6#
7# This eclass is for general purpose functions that most ebuilds 7# This eclass is for general purpose functions that most ebuilds
8# have to implement themselves. 8# have to implement themselves.
400 ADMINPARAM="${ADMINPARAM/-j}" 400 ADMINPARAM="${ADMINPARAM/-j}"
401 fi 401 fi
402 402
403 export MAKEOPTS="`echo ${MAKEOPTS} | sed -e 's:-j *[0-9]*::g'`" 403 export MAKEOPTS="`echo ${MAKEOPTS} | sed -e 's:-j *[0-9]*::g'`"
404 404
405 if [ "${ARCH}" = "x86" -o "${ARCH}" = "hppa" -o \ 405 if [ "${ARCH}" = "amd64" -o "${ARCH}" = "x86" -o "${ARCH}" = "hppa" -o \
406 "${ARCH}" = "arm" -o "${ARCH}" = "mips" ] 406 "${ARCH}" = "arm" -o "${ARCH}" = "mips" ]
407 then 407 then
408 # these archs will always have "[Pp]rocessor" 408 # these archs will always have "[Pp]rocessor"
409 jobs="$((`grep -c ^[Pp]rocessor /proc/cpuinfo` * 2))" 409 jobs="$((`grep -c ^[Pp]rocessor /proc/cpuinfo` * 2))"
410 410
634# 634#
635# edos2unix(file, <more files>...) 635# edos2unix(file, <more files>...)
636edos2unix() { 636edos2unix() {
637 for f in $@ ; do 637 for f in $@ ; do
638 cp ${f} ${T}/edos2unix 638 cp ${f} ${T}/edos2unix
639 rm -f ${f}
640 sed 's/\r$//' ${T}/edos2unix > ${f} 639 sed 's/\r$//' ${T}/edos2unix > ${f}
641 rm -f ${T}/edos2unix
642 done 640 done
643} 641}
644 642
645# new convinience patch wapper function to eventually replace epatch(), $PATCHES, $PATCHES1, src_unpack:patch, src_unpack:autopatch and /usr/bin/patch 643# new convenience patch wrapper function to eventually replace epatch(),
644# $PATCHES, $PATCHES1, src_unpack:patch, src_unpack:autopatch and
645# /usr/bin/patch
646# Features: 646# Features:
647# - bulk patch handling similar to epatch()'s 647# - bulk patch handling similar to epatch()'s
648# - automatic patch level detection like epatch()'s 648# - automatic patch level detection like epatch()'s
649# - semiautomatic patch uncompression like epatch()'s (may switch to using /usr/bin/file for extra power, instead of just looking at the filename) 649# - automatic patch uncompression like epatch()'s
650# - doesn't have the --dry-run overhead of epatch() - inspects patchfiles manually instead 650# - doesn't have the --dry-run overhead of epatch() - inspects patchfiles
651# - is called from base_src_unpack to handle $PATCHES to avoid defining src_unpack(-) just to use xpatch 651# manually instead
652# - once I decide it's production-ready, it'll be called from base_src_unpack
653# to handle $PATCHES to avoid defining src_unpack just to use xpatch
652 654
653# accepts zero or more parameters specifying patchfiles and/or patchdirs 655# accepts zero or more parameters specifying patchfiles and/or patchdirs
654 656
655# known issues: 657# known issues:
656# - only supports unified style patches (does anyone _really_ use anything else?) 658# - only supports unified style patches (does anyone _really_ use anything
657# - first file addressed in a patch can't have spaces in its name or in the path mentioned in the patchfile 659# else?)
658# (can be easily fixed to be: at least one file addressed in the patch must have no spaces...) 660# - because it doesn't use --dry-run there is a risk of it failing
661# to find the files to patch, ie detect the patchlevel, properly. It doesn't use
662# any of the backup heuristics that patch employs to discover a filename.
663# however, this isn't dangerous because if it works for the developer who's
664# writing the ebuild, it'll always work for the users, and if it doesn't,
665# then we'll fix it :-)
666# - no support as yet for patches applying outside $S (and not directly in $WORKDIR).
659xpatch() { 667xpatch() {
660 668
661 debug-print-function $FUNCNAME $* 669 debug-print-function $FUNCNAME $*
662 670
663 local list="" 671 local list=""
697 *) die "Could not determine filetype of patch $x";; 705 *) die "Could not determine filetype of patch $x";;
698 esac 706 esac
699 debug-print "$FUNCNAME: patchfile=$patchfile" 707 debug-print "$FUNCNAME: patchfile=$patchfile"
700 708
701 # determine patchlevel. supports p0 and higher with either $S or $WORKDIR as base. 709 # determine patchlevel. supports p0 and higher with either $S or $WORKDIR as base.
702 target="`/bin/grep '+++' $patchfile | /usr/bin/tail -1`" 710 target="`/bin/grep -m 1 '^+++ ' $patchfile`"
703 debug-print "$FUNCNAME: raw target=$target" 711 debug-print "$FUNCNAME: raw target=$target"
704 # strip target down to the path/filename. NOTE doesn't support filenames/paths with spaces in them :-( 712 # strip target down to the path/filename, remove leading +++
705 # remove leading +++ 713 target="${target/+++ }"; target="${target%% *}"
706 target="${target/+++ }"
707 # ugly, yes. i dunno why doesn't this work instead: target=${target%% *}
708 for foo in $target; do target="$foo"; break; done
709 # duplicate slashes are discarded by patch wrt the patchlevel. therefore we need to discard them as well 714 # duplicate slashes are discarded by patch wrt the patchlevel. therefore we need
710 # to calculate the correct patchlevel. 715 # to discard them as well to calculate the correct patchlevel.
711 while [ "$target" != "${target/\/\/}" ]; do
712 target="${target/\/\//\/}" 716 target="${target//\/\//\/}"
713 done
714 debug-print "$FUNCNAME: stripped target=$target" 717 debug-print "$FUNCNAME: stripped target=$target"
715 718
716 # look for target 719 # look for target
717 for basedir in "$S" "$WORKDIR" "`pwd`"; do 720 for basedir in "$S" "$WORKDIR" "${PWD}"; do
718 debug-print "$FUNCNAME: looking in basedir=$basedir" 721 debug-print "$FUNCNAME: looking in basedir=$basedir"
719 cd "$basedir" 722 cd "$basedir"
720 723
721 # try stripping leading directories 724 # try stripping leading directories
722 target2="$target" 725 target2="$target"

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.35

  ViewVC Help
Powered by ViewVC 1.1.20