Magellan Linux

Contents of /smage/trunk/core/include/alx.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (show annotations) (download)
Sun Jan 11 21:39:37 2009 UTC (15 years, 3 months ago) by niro
File size: 7978 byte(s)
-use relative pathes from '${SMAGENAME%/*}' to support our svn trees (trunk/${repo} structure!)
1 # $Header: /alx-cvs/smage-eglibc/include/alx.sminc,v 1.4 2008/06/24 11:18:19 niro Exp $
2 # alx functions
3
4
5 # some global includes
6 sminclude cleanutils mtools
7
8 # always include alx in mage files
9 INHERITS="${INHERITS} alx"
10
11 # to build a stripped down package version
12 # you must call 'package_all_targets' in src_install().
13 # be sure you have the strip-target-alx() function defined,
14 # get stuff stripped from the package.
15 #
16 # the dev version will be always build when including this file
17 #
18 # The only way to change the behavior is to set ALX_PKGTYPE
19 # ALX_PKGTYPE=only-alx-dev -> means that *only* the alx-dev package gets build
20 # ALX_PKGTYPE=only-alx -> means that *only* the stripped alx package gets build
21 #
22
23 # all targets for alx
24 MAGE_TARGETS="alx_dev alx"
25
26 # dummy functions, should be overrided in smage
27 alx_dev_pkgbuild() { return 0; }
28 alx_pkgbuild() { return 0; }
29
30
31 # checks if compilation should be against alx
32 target_alx_dev()
33 {
34 local i
35
36 if [ -n "${MAGE_TARGETS}" ]
37 then
38 for i in ${MAGE_TARGETS}
39 do
40 [[ ${i} = alx_dev ]] && return 0
41
42 # alx-dev will always build when building target alx,
43 # so target alx ist also allowed to be alx-dev
44 [[ ${i} = alx ]] && return 0
45
46 # same for alx_livecd
47 [[ ${i} = alx_livecd ]] && return 0
48 done
49 fi
50
51 # nothing match, we are *not* on alx linux
52 return 1
53 }
54
55 # check if compilation should be against stripped down alx
56 target_alx()
57 {
58 if [ -n "${MAGE_TARGETS}" ]
59 then
60 for i in ${MAGE_TARGETS}
61 do
62 [[ ${i} = alx ]] && return 0
63 done
64 fi
65
66 # nothing match, we are *not* on alx linux
67 return 1
68 }
69
70
71 #
72 # file injections:
73 #
74 # injects files to given path (defaults to /usr/bin)
75 # alxinjectfile file {/path/to/dest}
76 alxinjectfile()
77 {
78 local file
79 local dest
80
81 [[ -z $1 ]] && die "No etc file given"
82
83 file="${SMAGENAME%/*}/alx/files/$1"
84 dest="$2"
85 if [[ -z $2 ]]
86 then
87 dest=/usr/bin
88 install -d ${BINDIR}/${dest} || die
89 fi
90
91 # install our configfile
92 install -m 0644 -o root -g root ${file} ${BINDIR}/${dest} || die
93 }
94
95 # injects executables to given path
96 # alxinjectexec exec {/path/to/dest}
97 alxinjectexec()
98 {
99 local file
100 local dest
101
102 [[ -z $1 ]] && die "No etc file given"
103
104 file="${SMAGENAME%/*}/alx/files/$1"
105 dest="$2"
106 if [[ -z $2 ]]
107 then
108 dest=/usr/bin
109 install -d ${BINDIR}/${dest} || die
110 fi
111
112 # install our configfile
113 install -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die
114 }
115
116 # injects a patch to the sourcecode
117 # - basically the same like mpatch() but uses patches from ${SMAGESCRIPTSDIR}/${PNAME}/alx/files
118 # alxinjectpatch patch
119 alxinjectpatch()
120 {
121 local PATCHOPTS
122 local PATCHFILE
123 local i
124
125 PATCHOPTS=$1
126 PATCHFILE=$2
127
128 if [[ -z $2 ]]
129 then
130 PATCHFILE=$1
131
132 ## patch level auto-detection, get patch level
133 for ((i=0; i < 10; i++))
134 do
135 patch --dry-run -Np${i} -i ${SMAGENAME%/*}/alx/files/${PATCHFILE} > /dev/null
136 if [[ $? = 0 ]]
137 then
138 PATCHOPTS="-Np${i}"
139 break
140 fi
141 done
142 fi
143
144 echo -e "${COLBLUE}*** ${COLGREEN}Applying ALX patch '${PATCHFILE}'${COLDEFAULT}"
145 patch "${PATCHOPTS}" -i ${SMAGENAME%/*}/alx/files/${PATCHFILE}
146 }
147
148 #############################
149 ##### compile functions ####
150 #############################
151
152 # respect multilib!
153 if [[ -z $(typeset -f oldconfigure) ]]
154 then
155 alx_old_mconfigure=alx_old$(typeset -f mconfigure)
156 else
157 alx_old_mconfigure=alx_old$(typeset -f oldmconfigure)
158 fi
159 eval ${alx_old_mconfigure}
160 mconfigure()
161 {
162 local myconf
163 local configurefile
164
165 # get configure instructions from smage dir
166 if [[ -f ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.cfg ]]
167 then
168 # version specific configure files
169 configurefile=${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.cfg
170 elif [[ -f ${SMAGENAME%/*}/alx/${PNAME}.cfg ]]
171 then
172 # generic configure files for a package
173 configurefile=${SMAGENAME%/*}/alx/${PNAME}.cfg
174 else
175 configurefile=""
176 fi
177
178 # now read the content
179 if [[ -f ${configurefile} ]]
180 then
181 echo -e "${COLBLUE}*** ${COLGREEN}Using configure info from ${configurefile}${COLDEFAULT}"
182 local line
183 while read line
184 do
185 # ignore empty and commeted lines
186 case "${line}" in
187 \#*|"") continue ;;
188 esac
189
190 echo -e " adding ${COLGREEN}${line}${COLDEFAULT} to ALX_CONFIGURE_OPTS"
191 ALX_CONFIGURE_OPTS="${ALX_CONFIGURE_OPTS} ${line}"
192 done < ${configurefile}
193 fi
194
195 alx_oldmconfigure --disable-nls ${myconf} $@ ${ALX_CONFIGURE_OPTS} || die
196 }
197
198 alx_pkgbuild()
199 {
200 local ALX_ZAPMOST
201 local zapmostfile
202 local ALX_REMOVE
203 local removefile
204 local i
205
206 if [[ -d ${BINDIR}/usr/$(mlibdir) ]]
207 then
208 find ${BINDIR}/usr/$(mlibdir) -name '*'.a -exec rm '{}' ';'
209 find ${BINDIR}/usr/$(mlibdir) -name '*'.la -exec rm '{}' ';'
210 fi
211
212 [[ -d ${BINDIR}/usr/include ]] && rm -rf ${BINDIR}/usr/include
213 [[ -d ${BINDIR}/usr/$(mlibdir)/pkgconfig ]] && rm -rf ${BINDIR}/usr/$(mlibdir)/pkgconfig
214 [[ -d ${BINDIR}/usr/share/aclocal ]] && rm -rf ${BINDIR}/usr/share/aclocal
215 [[ -d ${BINDIR}/usr/share/doc ]] && rm -rf ${BINDIR}/usr/share/doc
216 [[ -d ${BINDIR}/usr/share/info ]] && rm -rf ${BINDIR}/usr/share/info
217 [[ -d ${BINDIR}/usr/share/man ]] && rm -rf ${BINDIR}/usr/share/man
218 #[[ -d ${BINDIR}/usr/lib/X11/locale ]] && rm -rf ${BINDIR}/usr/lib/X11/locale
219
220 # get zapmost instructions from smage dir
221 if [[ -f ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.zap ]]
222 then
223 # version specific zap files
224 zapmostfile=${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.zap
225 elif [[ -f ${SMAGENAME%/*}/alx/${PNAME}.zap ]]
226 then
227 # generic zapmost files for a package
228 zapmostfile=${SMAGENAME%/*}/${PNAME}/alx/${PNAME}.zap
229 else
230 zapmostfile=""
231 fi
232
233 # now read the content
234 if [[ -f ${zapmostfile} ]]
235 then
236 echo -e "${COLBLUE}*** ${COLGREEN}Using zapmost info from ${zapmostfile}${COLDEFAULT}"
237 local line
238 while read line
239 do
240 # ignore empty and commeted lines
241 case "${line}" in
242 \#*|"") continue ;;
243 esac
244
245 ALX_ZAPMOST="${ALX_ZAPMOST} ${line}"
246 done < ${zapmostfile}
247 fi
248
249 # finally run zapmost
250 if [[ -n ${ALX_ZAPMOST} ]]
251 then
252 echo -e "${COLBLUE}*** ${COLGREEN}Running zapmost() ...${COLDEFAULT}"
253 zapmost ${BINDIR} ${ALX_ZAPMOST} || die
254 fi
255
256
257 # same goes for the remove file
258 # get remove instructions from smage dir
259 if [[ -f ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.rm ]]
260 then
261 # version specific remove files
262 removefile=${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.rm
263 elif [[ -f ${SMAGENAME%/*}/alx/${PNAME}.rm ]]
264 then
265 # generic remove files for a package
266 removefile=${SMAGENAME%/*}/alx/${PNAME}.rm
267 else
268 removefile=""
269 fi
270
271 # now read the content
272 if [[ -f ${removefile} ]]
273 then
274 echo -e "${COLBLUE}*** ${COLGREEN}Using remove info from ${removefile}${COLDEFAULT}"
275 local line
276 while read line
277 do
278 # ignore empty and commeted lines
279 case "${line}" in
280 \#*|"") continue ;;
281 esac
282
283 ALX_REMOVE="${ALX_REMOVE} ${line}"
284 done < ${removefile}
285 fi
286
287 # finally run zapmost
288 if [[ -n ${ALX_REMOVE} ]]
289 then
290 echo -e "${COLBLUE}*** ${COLGREEN}Running remove() ...${COLDEFAULT}"
291 for i in ${ALX_REMOVE}
292 do
293 if [[ -e ${BINDIR}/${i} ]]
294 then
295 echo -e " ${COLGREEN}<<<${COLDEFAULT} removing ${BINDIR}/${i}"
296 rm -rf ${BINDIR}/${i}
297 fi
298 done
299 fi
300
301
302 # check if /usr/share is empty
303 if [[ -d ${BINDIR}/usr/share ]] && ! rmdir ${BINDIR}/usr/share &> /dev/null
304 then
305 echo -e "${COLBLUE}*** ${COLRED}WARNING: ${BINDIR}/usr/share is *not* empty. Please check!${COLDEFAULT}"
306 fi
307 }
308
309 alx_livecd_pkgbuild()
310 {
311 alx_pkgbuild || die
312 }
313
314 # get custom alx functions
315 if [[ -f ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.custom ]]
316 then
317 echo -e "${COLBLUE}*** ${COLGREEN}Using custom build info from ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.custom${COLDEFAULT}"
318 source ${SMAGENAME%/*}/alx/${PNAME}-${PVER}-${PBUILD}.custom
319 elif [[ -f ${SMAGENAME%/*}/alx/${PNAME}.custom ]]
320 then
321 echo -e "${COLBLUE}*** ${COLGREEN}Using custom build info from ${SMAGENAME%/*}/alx/${PNAME}.custom${COLDEFAULT}"
322 source ${SMAGENAME%/*}/alx/${PNAME}.custom
323 fi
324
325 # overrides
326 [[ ${ALX_PKGTYPE} = only-alx-dev ]] && MAGE_TARGETS="alx_dev"
327 [[ ${ALX_PKGTYPE} = only-alx ]] && MAGE_TARGETS="alx"