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

Diff of /eclass/eutils.eclass

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

Revision 1.2 Revision 1.3
1# Copyright 1999-2002 Gentoo Technologies, Inc. 1# Copyright 1999-2002 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# Author: Martin Schlemmer <azarah@gentoo.org> 3# Author: Martin Schlemmer <azarah@gentoo.org>
4# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.2 2002/11/10 19:45:51 azarah Exp $ 4# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.3 2002/11/11 19:51:20 azarah Exp $
5# This eclass is for general purpose functions that most ebuilds 5# This eclass is for general purpose functions that most ebuilds
6# have to implement themselfs. 6# have to implement themselfs.
7# 7#
8# NB: If you add anything, please comment it! 8# NB: If you add anything, please comment it!
9 9
52} 52}
53 53
54 54
55# Default directory where patches are located 55# Default directory where patches are located
56EPATCH_SOURCE="${WORKDIR}/patch" 56EPATCH_SOURCE="${WORKDIR}/patch"
57# Default directory in which patches should be applied
58EPATCH_WORKDIR="${S}"
59# Default extension for patches 57# Default extension for patches
60EPATCH_SUFFIX="patch.bz2" 58EPATCH_SUFFIX="patch.bz2"
61# Default options for patch 59# Default options for patch
62EPATCH_OPTS="" 60EPATCH_OPTS=""
63 61
72# 70#
73# Above EPATCH_* variables can be used to control various defaults, 71# Above EPATCH_* variables can be used to control various defaults,
74# bug they should be left as is to ensure an ebuild can rely on 72# bug they should be left as is to ensure an ebuild can rely on
75# them for. 73# them for.
76# 74#
75# Patches are applied in current directory.
76#
77# Patch/Patches should preferibly have the form of: 77# Bulk Patches should preferibly have the form of:
78# 78#
79# ??_${ARCH}_foo.${EPATCH_SUFFIX} 79# ??_${ARCH}_foo.${EPATCH_SUFFIX}
80# 80#
81# For example: 81# For example:
82# 82#
84# 02_sparc_another-fix.patch.bz2 84# 02_sparc_another-fix.patch.bz2
85# 85#
86# This ensures that there are a set order, and you can have ARCH 86# This ensures that there are a set order, and you can have ARCH
87# specific patches. 87# specific patches.
88# 88#
89# If you however give an argument to epatch(), it will treat it as a
90# single patch that need to be applied if its a file. If on the other
91# hand its a directory, it will set EPATCH_SOURCE to this.
92#
89# <azarah@gentoo.org> (10 Nov 2002) 93# <azarah@gentoo.org> (10 Nov 2002)
90# 94#
91epatch() { 95epatch() {
92 local PIPE_CMD="" 96 local PIPE_CMD=""
93 local STDERR_TARGET="${T}/$$.out" 97 local STDERR_TARGET="${T}/$$.out"
98 local SINGLE_PATCH="no"
99
100 if [ "$#" -gt 1 ]
101 then
102 eerror "Invalid arguments to epatch()"
103 die "Invalid arguments to epatch()"
104 fi
105
106 if [ -n "$1" -a -f "$1" ]
107 then
108 SINGLE_PATCH="yes"
109
110 EPATCH_SOURCE="$1"
111 EPATCH_SUFFIX="${1##*\.}"
112
113 elif [ -n "$1" -a -d "$1" ]
114 then
115 EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}"
116 else
117 EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}"
118 fi
94 119
95 case ${EPATCH_SUFFIX##*\.} in 120 case ${EPATCH_SUFFIX##*\.} in
96 bz2) 121 bz2)
97 PIPE_CMD="bzip2 -dc" 122 PIPE_CMD="bzip2 -dc"
98 ;; 123 ;;
105 *) 130 *)
106 PIPE_CMD="cat" 131 PIPE_CMD="cat"
107 ;; 132 ;;
108 esac 133 esac
109 134
110 cd ${EPATCH_WORKDIR} 135 if [ "${SINGLE_PATCH}" = "no" ]
136 then
111 einfo "Applying various patches (bugfixes/updates)..." 137 einfo "Applying various patches (bugfixes/updates)..."
112 for x in ${EPATCH_SOURCE}/*.${EPATCH_SUFFIX} 138 fi
139 for x in ${EPATCH_SOURCE}
113 do 140 do
114 # New ARCH dependant patch naming scheme... 141 # New ARCH dependant patch naming scheme...
115 # 142 #
116 # ???_arch_foo.patch 143 # ???_arch_foo.patch
117 # 144 #
118 if [ -f ${x} ] && \ 145 if [ -f ${x} ] && \
119 [ "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ] 146 [ -n "$1" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ]
120 then 147 then
121 local count=0 148 local count=0
122 local popts="${EPATCH_OPTS}" 149 local popts="${EPATCH_OPTS}"
150
151 if [ "${SINGLE_PATCH}" = "yes" ]
152 then
153 einfo "Applying ${x##*/}..."
154 else
155 einfo " ${x##*/}..."
156 fi
123 157
124 einfo " ${x##*/}..." 158 echo "*** Patch ${x##*/} ***" > ${STDERR_TARGET}
125
126 > ${STDERR_TARGET}
127 159
128 # Allow for prefix to differ ... im lazy, so shoot me :/ 160 # Allow for prefix to differ ... im lazy, so shoot me :/
129 while [ "${count}" -lt 5 ] 161 while [ "${count}" -lt 5 ]
130 do 162 do
131 if eval ${PIPE_CMD} ${x} | patch ${popts} --dry-run -f -p${count} 2>&1 >> ${STDERR_TARGET} 163 if eval ${PIPE_CMD} ${x} | patch ${popts} --dry-run -f -p${count} 2>&1 >> ${STDERR_TARGET}
145 eerror 177 eerror
146 eerror " ${STDERR_TARGET}" 178 eerror " ${STDERR_TARGET}"
147 eerror 179 eerror
148 die "Failed Patch: ${x##*/}!" 180 die "Failed Patch: ${x##*/}!"
149 fi 181 fi
182
183 eend 0
150 fi 184 fi
151 done 185 done
186 if [ "${SINGLE_PATCH}" = "no" ]
187 then
152 eend 0 "Done with patching" 188 einfo "Done with patching"
189 fi
153} 190}
154 191

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

  ViewVC Help
Powered by ViewVC 1.1.20