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

Contents of /eclass/eutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations) (download)
Mon Nov 25 04:20:07 2002 UTC (12 years, 1 month ago) by vapier
Branch: MAIN
Changes since 1.6: +2 -2 lines
typo fix

1 azarah 1.1 # Copyright 1999-2002 Gentoo Technologies, Inc.
2     # Distributed under the terms of the GNU General Public License v2
3     # Author: Martin Schlemmer <azarah@gentoo.org>
4 vapier 1.7 # $Header: /home/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.6 2002/11/12 18:25:37 azarah Exp $
5 azarah 1.1 # This eclass is for general purpose functions that most ebuilds
6 vapier 1.7 # have to implement themselves.
7 azarah 1.1 #
8     # NB: If you add anything, please comment it!
9    
10     ECLASS=eutils
11     INHERITED="$INHERITED $ECLASS"
12    
13     newdepend sys-devel/patch
14    
15     DESCRIPTION="Based on the ${ECLASS} eclass"
16    
17     # This function generate linker scripts in /usr/lib for dynamic
18     # libs in /lib. This is to fix linking problems when you have
19     # the .so in /lib, and the .a in /usr/lib. What happens is that
20     # in some cases when linking dynamic, the .a in /usr/lib is used
21     # instead of the .so in /lib due to gcc/libtool tweaking ld's
22     # library search path. This cause many builds to fail.
23     # See bug #4411 for more info.
24     #
25     # To use, simply call:
26     #
27     # gen_usr_ldscript libfoo.so
28     #
29     # Note that you should in general use the unversioned name of
30     # the library, as ldconfig should usually update it correctly
31     # to point to the latest version of the library present.
32     #
33     # <azarah@gentoo.org> (26 Oct 2002)
34     #
35     gen_usr_ldscript() {
36    
37     # Just make sure it exists
38     dodir /usr/lib
39    
40     cat > ${D}/usr/lib/$1 <<"END_LDSCRIPT"
41     /* GNU ld script
42     Because Gentoo have critical dynamic libraries
43     in /lib, and the static versions in /usr/lib, we
44     need to have a "fake" dynamic lib in /usr/lib,
45     otherwise we run into linking problems.
46     See bug #4411 on http://bugs.gentoo.org/ for
47     more info. */
48     GROUP ( /lib/libxxx )
49     END_LDSCRIPT
50    
51     dosed "s:libxxx:$1:" /usr/lib/$1
52 azarah 1.5
53     return 0
54 azarah 1.2 }
55    
56 azarah 1.5 # Simple function to draw a line consisting of '=' the same length as $*
57     #
58     # <azarah@gentoo.org> (11 Nov 2002)
59     #
60     draw_line() {
61     local i=0
62     local str_length=""
63    
64     # Handle calls that do not have args, or wc not being installed ...
65     if [ -z "$1" -o ! -x "$(which wc 2>/dev/null)" ]
66     then
67     echo "==============================================================="
68     return 0
69     fi
70    
71     # Get the length of $*
72     str_length="$(echo -n "$*" | wc -m)"
73    
74     while [ "$i" -lt "${str_length}" ]
75     do
76     echo -n "="
77    
78     i=$((i + 1))
79     done
80    
81     echo
82    
83     return 0
84     }
85 azarah 1.2
86     # Default directory where patches are located
87     EPATCH_SOURCE="${WORKDIR}/patch"
88     # Default extension for patches
89     EPATCH_SUFFIX="patch.bz2"
90     # Default options for patch
91     EPATCH_OPTS=""
92 azarah 1.6 # List of patches not to apply. Not this is only file names,
93     # and not the full path ..
94     EPATCH_EXCLUDE=""
95 azarah 1.2
96     # This function is for bulk patching, or in theory for just one
97     # or two patches.
98     #
99     # It should work with .bz2, .gz, .zip and plain text patches.
100     # Currently all patches should be the same format.
101     #
102     # You do not have to specify '-p' option to patch, as it will
103     # try with -p0 to -p5 until it succeed, or fail at -p5.
104     #
105     # Above EPATCH_* variables can be used to control various defaults,
106     # bug they should be left as is to ensure an ebuild can rely on
107     # them for.
108     #
109 azarah 1.3 # Patches are applied in current directory.
110     #
111     # Bulk Patches should preferibly have the form of:
112 azarah 1.2 #
113     # ??_${ARCH}_foo.${EPATCH_SUFFIX}
114     #
115     # For example:
116     #
117     # 01_all_misc-fix.patch.bz2
118     # 02_sparc_another-fix.patch.bz2
119     #
120     # This ensures that there are a set order, and you can have ARCH
121     # specific patches.
122     #
123 azarah 1.3 # If you however give an argument to epatch(), it will treat it as a
124     # single patch that need to be applied if its a file. If on the other
125     # hand its a directory, it will set EPATCH_SOURCE to this.
126     #
127 azarah 1.2 # <azarah@gentoo.org> (10 Nov 2002)
128     #
129     epatch() {
130     local PIPE_CMD=""
131     local STDERR_TARGET="${T}/$$.out"
132 azarah 1.3 local SINGLE_PATCH="no"
133 azarah 1.4 local x=""
134 azarah 1.3
135     if [ "$#" -gt 1 ]
136     then
137     eerror "Invalid arguments to epatch()"
138     die "Invalid arguments to epatch()"
139     fi
140    
141     if [ -n "$1" -a -f "$1" ]
142     then
143     SINGLE_PATCH="yes"
144    
145 azarah 1.4 local EPATCH_SOURCE="$1"
146     local EPATCH_SUFFIX="${1##*\.}"
147 azarah 1.3
148     elif [ -n "$1" -a -d "$1" ]
149     then
150 azarah 1.4 local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}"
151 azarah 1.3 else
152 azarah 1.4 local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}"
153 azarah 1.3 fi
154 azarah 1.2
155     case ${EPATCH_SUFFIX##*\.} in
156     bz2)
157     PIPE_CMD="bzip2 -dc"
158     ;;
159 azarah 1.6 gz|Z|z)
160 azarah 1.2 PIPE_CMD="gzip -dc"
161     ;;
162 azarah 1.6 ZIP|zip)
163 azarah 1.2 PIPE_CMD="unzip -p"
164     ;;
165     *)
166     PIPE_CMD="cat"
167     ;;
168     esac
169    
170 azarah 1.3 if [ "${SINGLE_PATCH}" = "no" ]
171     then
172     einfo "Applying various patches (bugfixes/updates)..."
173     fi
174     for x in ${EPATCH_SOURCE}
175 azarah 1.2 do
176     # New ARCH dependant patch naming scheme...
177     #
178     # ???_arch_foo.patch
179     #
180     if [ -f ${x} ] && \
181 azarah 1.3 [ -n "$1" -o "${x/_all_}" != "${x}" -o "`eval echo \$\{x/_${ARCH}_\}`" != "${x}" ]
182 azarah 1.2 then
183     local count=0
184     local popts="${EPATCH_OPTS}"
185 azarah 1.6
186     if [ -n "${EPATCH_EXCLUDE}" ]
187     then
188     if [ "${EPATCH_EXCLUDE/${x##*/}}" != "${EPATCH_EXCLUDE}" ]
189     then
190     continue
191     fi
192     fi
193 azarah 1.3
194     if [ "${SINGLE_PATCH}" = "yes" ]
195     then
196     einfo "Applying ${x##*/}..."
197     else
198     einfo " ${x##*/}..."
199     fi
200 azarah 1.2
201 azarah 1.5 echo "***** ${x##*/} *****" > ${STDERR_TARGET}
202     echo >> ${STDERR_TARGET}
203 azarah 1.2
204     # Allow for prefix to differ ... im lazy, so shoot me :/
205     while [ "${count}" -lt 5 ]
206     do
207 azarah 1.5 # Generate some useful debug info ...
208     draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET}
209     echo >> ${STDERR_TARGET}
210    
211     echo -n "PATCH COMMAND: " >> ${STDERR_TARGET}
212     echo "${PIPE_CMD} ${x} | patch ${popts} -p${count}" >> ${STDERR_TARGET}
213    
214     echo >> ${STDERR_TARGET}
215     draw_line "***** ${x##*/} *****" >> ${STDERR_TARGET}
216    
217 azarah 1.2 if eval ${PIPE_CMD} ${x} | patch ${popts} --dry-run -f -p${count} 2>&1 >> ${STDERR_TARGET}
218     then
219     eval ${PIPE_CMD} ${x} | patch ${popts} -p${count} 2>&1 >> ${STDERR_TARGET}
220     break
221     fi
222    
223     count=$((count + 1))
224     done
225    
226     if [ "${count}" -eq 5 ]
227     then
228     eerror "Failed Patch: ${x##*/}!"
229     eerror
230     eerror "Include in your bugreport the contents of:"
231     eerror
232     eerror " ${STDERR_TARGET}"
233     eerror
234     die "Failed Patch: ${x##*/}!"
235     fi
236 azarah 1.3
237     eend 0
238 azarah 1.2 fi
239     done
240 azarah 1.3 if [ "${SINGLE_PATCH}" = "no" ]
241     then
242     einfo "Done with patching"
243     fi
244 azarah 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20