1 |
#!/bin/bash |
#!/bin/bash |
2 |
|
# $Id$ |
3 |
|
|
4 |
# compiles/installs .smage2 source install scripts |
# compiles/installs .smage2 source install scripts |
5 |
# needs pkgbuild_dir (mage) |
# needs pkgbuild_dir (mage) |
6 |
|
|
7 |
# SMAGE2 |
# TODO: record dynlib, gz | xz database |
|
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.40 2005-12-26 23:16:38 niro Exp $ |
|
8 |
|
|
9 |
#01.10.2004 |
|
10 |
# added ccache support |
# set default user mage.rc |
11 |
# added distcc support |
: ${MAGERC="/etc/mage.rc"} |
12 |
|
|
13 |
## setup ## |
## setup ## |
|
PKGSUFFIX="mpk" |
|
14 |
SMAGENAME="$1" |
SMAGENAME="$1" |
|
SMAGESUFFIX="smage2" |
|
|
#SOURCEDIR="/bootstrap/sources" |
|
|
#SMAGESCRIPTSDIR="/bootstrap/smage2-install-scripts" |
|
|
#SMAGE2RSYNC="rsync://192.168.0.2/smage2-scripts" |
|
|
MLIBDIR=/usr/lib/mage |
|
15 |
SMAGEVERSION="$( < ${MLIBDIR}/version)" |
SMAGEVERSION="$( < ${MLIBDIR}/version)" |
16 |
|
|
17 |
# export default C locale |
# export default C locale |
18 |
export LC_ALL=C |
export LC_ALL=C |
19 |
|
|
20 |
source /etc/mage.rc |
source /etc/mage.rc.global |
21 |
|
source ${MAGERC} |
22 |
|
source ${MLIBDIR}/mage4.functions.sh |
23 |
|
|
24 |
|
# set PKGDIR and BUILDDIR and BINDIR to MROOT |
25 |
|
if [[ -n ${MROOT} ]] |
26 |
|
then |
27 |
|
export PKGDIR=${MROOT}/${PKGDIR} |
28 |
|
export BUILDDIR=${MROOT}/${BUILDDIR} |
29 |
|
export BINDIR=${MROOT}/${BINDIR} |
30 |
|
fi |
31 |
|
|
32 |
|
# sources the smage file and uses state from distribution file if exist |
33 |
|
# may helpful for repository support later on |
34 |
|
smagesource() |
35 |
|
{ |
36 |
|
local file="$1" |
37 |
|
local mystate |
38 |
|
local mycodename |
39 |
|
|
40 |
|
source ${file} |
41 |
|
|
42 |
|
[[ -n ${STATE} ]] && mystate="${STATE}" |
43 |
|
|
44 |
|
# do not overide if local state was broken or disabled! |
45 |
|
case ${STATE} in |
46 |
|
broken) return ;; |
47 |
|
disabled) return ;; |
48 |
|
esac |
49 |
|
|
50 |
|
if [ -f ${SMAGESCRIPTSDIR}/distribution ] |
51 |
|
then |
52 |
|
source ${SMAGESCRIPTSDIR}/distribution |
53 |
|
[[ -n ${STATE} ]] && mystate="${STATE}" |
54 |
|
fi |
55 |
|
# now switch state and export it |
56 |
|
STATE="${mystate}" |
57 |
|
} |
58 |
|
|
59 |
showversion() |
showversion() |
60 |
{ |
{ |
65 |
die() |
die() |
66 |
{ |
{ |
67 |
xtitleclean |
xtitleclean |
68 |
|
echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT} |
69 |
echo "SMAGE failed: $@" |
echo "SMAGE failed: $@" |
70 |
exit 1 |
exit 1 |
71 |
} |
} |
72 |
|
|
73 |
|
die_pipestatus() |
74 |
|
{ |
75 |
|
# the status change if we do any parameter declarations!! |
76 |
|
# dont do this anymore, keep this in mind! |
77 |
|
# |
78 |
|
# local pos="$1" |
79 |
|
# local comment="$2" |
80 |
|
# |
81 |
|
# [ ${PIPESTATUS[${pos}]} -ne 0 ] && die "${comment}" |
82 |
|
# |
83 |
|
[ ${PIPESTATUS[$1]} -ne 0 ] && die "$2" |
84 |
|
} |
85 |
|
|
86 |
xtitle() |
xtitle() |
87 |
{ |
{ |
88 |
if [[ ${TERM} = xterm ]] |
if [[ ${TERM} = xterm ]] |
107 |
local i |
local i |
108 |
for i in ${SMAGE2RSYNC} |
for i in ${SMAGE2RSYNC} |
109 |
do |
do |
110 |
rsync \ |
rsync ${RSYNC_FETCH_OPTIONS} ${i} ${SMAGESCRIPTSDIR} |
|
--recursive \ |
|
|
--links \ |
|
|
--perms \ |
|
|
--times \ |
|
|
--devices \ |
|
|
--timeout=600 \ |
|
|
--verbose \ |
|
|
--compress \ |
|
|
--progress \ |
|
|
--stats \ |
|
|
--delete \ |
|
|
--delete-after \ |
|
|
${i} ${SMAGESCRIPTSDIR} |
|
|
|
|
111 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
112 |
then |
then |
113 |
break |
break |
114 |
else |
else |
115 |
continue |
continue |
116 |
fi |
fi |
|
|
|
117 |
done |
done |
118 |
|
|
119 |
# clean up backup files (foo~) |
# clean up backup files (foo~) |
139 |
|
|
140 |
download_sources() |
download_sources() |
141 |
{ |
{ |
|
|
|
142 |
[ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0 |
[ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0 |
143 |
|
|
144 |
local EOA=${#SRC_URI[*]} |
local count=${#SRC_URI[*]} |
145 |
local my_SRC_URI |
local uri |
146 |
local my_SRC_URI_DEST |
local subdir |
147 |
local my_SRC_URI_MIRROR |
local outputdir |
148 |
local my_SOURCEDIR |
local db_md5_file="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
149 |
local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
local fetching |
150 |
local FETCHING |
local i |
|
local i mirror |
|
|
|
|
|
|
|
|
# install SRCDIR/PNAME if not exist |
|
|
[ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} |
|
151 |
|
|
152 |
# check if FETCHING is needed |
# check if FETCHING is needed |
153 |
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null ) |
if mchecksum --rundir "${SOURCEDIR}/${PNAME}" --file "${db_md5_file}" --method md5 |
|
if [[ $? = 0 ]] |
|
154 |
then |
then |
155 |
# md5's ok, not fetching needed |
# md5's ok, no fetching needed |
156 |
FETCHING=false |
fetching=false |
157 |
else |
else |
158 |
FETCHING=true |
fetching=true |
159 |
fi |
fi |
160 |
|
|
161 |
for ((i=0; i < EOA; i++)) |
if [[ ${fetching} = true ]] |
162 |
do |
then |
163 |
# url to file |
for ((i=0; i < count; i++)) |
164 |
my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" |
do |
165 |
|
# url to file |
166 |
# subdir in sources dir; the my_SRCI_URI file goes to there |
uri="${SRC_URI[${i}]%%' '*}" |
|
my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" |
|
|
|
|
|
# if my_src_uri_dest is not equal my_src_uri; than an other dir is used |
|
|
if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] |
|
|
then |
|
|
my_SOURCEDIR="${SOURCEDIR}/${PNAME}/${my_SRC_URI_DEST}" |
|
|
else |
|
|
my_SOURCEDIR="${SOURCEDIR}/${PNAME}" |
|
|
fi |
|
167 |
|
|
168 |
# if an mirrored file than replace first the mirror uri |
# subdir in sources dir; the my_SRCI_URI file goes to there |
169 |
if [ -n "$(echo ${my_SRC_URI} | grep 'mirror://')" ] |
subdir="${SRC_URI[${i}]##*' '}" |
|
then |
|
|
for mirror in ${MIRRORS} |
|
|
do |
|
|
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")" |
|
170 |
|
|
171 |
#echo "DEBUG: ${MY_SRC_URI}" |
# if $subdir is not equal with $uri then an other dir is used |
172 |
if [[ ${FETCHING} = true ]] |
if [[ ${uri} != ${subdir} ]] |
|
then |
|
|
echo "==> fetching ${my_SRC_URI_MIRROR}" |
|
|
wget \ |
|
|
--passive-ftp \ |
|
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
|
--directory-prefix="${my_SOURCEDIR}" \ |
|
|
"${my_SRC_URI_MIRROR}" |
|
|
if [[ $? = 0 ]] |
|
|
then |
|
|
break |
|
|
else |
|
|
continue |
|
|
fi |
|
|
fi |
|
|
done |
|
|
else |
|
|
#echo "DEBUG: ${SRC_URI[${i}]}" |
|
|
if [[ ${FETCHING} = true ]] |
|
173 |
then |
then |
174 |
echo "==> fetching ${my_SRC_URI}" |
outputdir="${SOURCEDIR}/${PNAME}/${subdir}" |
175 |
wget \ |
else |
176 |
--passive-ftp \ |
outputdir="${SOURCEDIR}/${PNAME}" |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
|
--directory-prefix="${my_SOURCEDIR}" \ |
|
|
"${my_SRC_URI}" |
|
|
# only needed to run through a list of mirrors |
|
|
# if [ "$?" == "0" ] |
|
|
# then |
|
|
# break |
|
|
# else |
|
|
# continue |
|
|
# fi |
|
177 |
fi |
fi |
|
fi |
|
178 |
|
|
179 |
# unset them to be shure |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${uri}${COLDEFAULT}" |
180 |
unset my_SRC_URI |
mdownload --uri "${uri}" --dir "${outputdir}" || die "Could not download '${uri}'" |
|
unset my_SRC_URI_DEST |
|
|
unset my_SRC_URI_MIRROR |
|
|
unset my_SOURCEDIR |
|
|
done |
|
181 |
|
|
182 |
# recheck md5 sums |
# unset them to be sure |
183 |
echo |
unset uri |
184 |
echo ">== Checking MD5 sums:" |
unset subdir |
185 |
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed" |
unset outputdir |
186 |
echo |
done |
187 |
|
|
188 |
|
# recheck md5 sums after download |
189 |
|
echo |
190 |
|
echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}" |
191 |
|
mchecksum --rundir "${SOURCEDIR}/${PNAME}" --file "${db_md5_file}" --method md5 || die "md5 failed" |
192 |
|
echo |
193 |
|
else |
194 |
|
echo -e "${COLBLUE}===${COLGREEN} All sources already fetched, nothing to do${COLDEFAULT}" |
195 |
|
fi |
196 |
|
|
197 |
# not needed anymore |
# not needed anymore |
198 |
unset SRC_URI |
unset SRC_URI |
199 |
} |
} |
200 |
|
|
201 |
# dummy function, used if that not exist in smage file |
# dummy function, used if that does not exist in smage file |
202 |
src_prepare() |
src_prepare() |
203 |
{ |
{ |
204 |
echo "no src_prepare defined" |
echo "no src_prepare defined" |
|
sleep 2 |
|
205 |
return 0 |
return 0 |
206 |
} |
} |
207 |
|
|
208 |
# dummy function, used if that not exist in smage file |
# dummy function, used if that does not exist in smage file |
209 |
src_compile() |
src_compile() |
210 |
{ |
{ |
211 |
echo "no src_compile defined" |
echo "no src_compile defined" |
|
sleep 2 |
|
212 |
return 0 |
return 0 |
213 |
} |
} |
214 |
|
|
215 |
# dummy function, used if that not exist in smage file |
# dummy function, used if that does not exist in smage file |
216 |
|
src_check() |
217 |
|
{ |
218 |
|
echo "no src_check defined" |
219 |
|
return 0 |
220 |
|
} |
221 |
|
|
222 |
|
# dummy function, used if that does not exist in smage file |
223 |
src_install() |
src_install() |
224 |
{ |
{ |
225 |
echo "no src_install defined" |
echo "no src_install defined" |
|
sleep 2 |
|
226 |
return 0 |
return 0 |
227 |
} |
} |
228 |
|
|
229 |
|
mlibdir() |
230 |
|
{ |
231 |
|
local libdir=lib |
232 |
|
[[ ${ARCH} = x86_64 ]] && libdir=lib64 |
233 |
|
|
234 |
|
echo "${libdir}" |
235 |
|
} |
236 |
|
|
237 |
mconfigure() |
mconfigure() |
238 |
{ |
{ |
239 |
if [ -x ./configure ] |
if [ -x ./configure ] |
241 |
./configure \ |
./configure \ |
242 |
--prefix=/usr \ |
--prefix=/usr \ |
243 |
--host=${CHOST} \ |
--host=${CHOST} \ |
244 |
|
--build=${CHOST} \ |
245 |
--mandir=/usr/share/man \ |
--mandir=/usr/share/man \ |
246 |
--infodir=/usr/share/info \ |
--infodir=/usr/share/info \ |
247 |
--datadir=/usr/share \ |
--datadir=/usr/share \ |
248 |
--sysconfdir=/etc \ |
--sysconfdir=/etc \ |
249 |
--localstatedir=/var/lib \ |
--localstatedir=/var/lib \ |
250 |
|
--libdir=/usr/$(mlibdir) \ |
251 |
"$@" || die "mconfigure failed" |
"$@" || die "mconfigure failed" |
252 |
else |
else |
253 |
echo "configure is not an executable ..." |
echo "configure is not an executable ..." |
265 |
localstatedir=${BINDIR}/var/lib \ |
localstatedir=${BINDIR}/var/lib \ |
266 |
mandir=${BINDIR}/usr/share/man \ |
mandir=${BINDIR}/usr/share/man \ |
267 |
sysconfdir=${BINDIR}/etc \ |
sysconfdir=${BINDIR}/etc \ |
268 |
|
libdir=${BINDIR}/usr/$(mlibdir) \ |
269 |
"$@" install || die "minstall failed" |
"$@" install || die "minstall failed" |
270 |
else |
else |
271 |
die "no Makefile found" |
die "no Makefile found" |
285 |
|
|
286 |
SRCFILE=$1 |
SRCFILE=$1 |
287 |
|
|
288 |
if [ -z "$2" ] |
if [[ -z $2 ]] |
289 |
then |
then |
290 |
DEST=${BUILDDIR} |
DEST=${BUILDDIR} |
291 |
else |
else |
292 |
DEST=$2 |
DEST=$2 |
293 |
fi |
fi |
294 |
|
|
295 |
|
[[ ! -d ${DEST} ]] && install -d ${DEST} |
296 |
|
|
297 |
case "${SRCFILE##*.}" in |
case "${SRCFILE##*.}" in |
298 |
bz2) |
bz2) |
299 |
IFTAR="$(basename $SRCFILE .bz2)" |
IFTAR="$(basename $SRCFILE .bz2)" |
300 |
IFTAR="${IFTAR##*.}" |
IFTAR="${IFTAR##*.}" |
301 |
if [[ ${IFTAR} = tar ]] |
if [[ ${IFTAR} = tar ]] |
302 |
then |
then |
303 |
tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} |
tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.bz2 unpack failed." |
304 |
|
else |
305 |
|
pushd ${DEST} > /dev/null |
306 |
|
bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed." |
307 |
|
popd > /dev/null |
308 |
fi |
fi |
309 |
;; |
;; |
310 |
gz) |
gz) |
312 |
IFTAR="${IFTAR##*.}" |
IFTAR="${IFTAR##*.}" |
313 |
if [[ ${IFTAR} = tar ]] |
if [[ ${IFTAR} = tar ]] |
314 |
then |
then |
315 |
tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} |
tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.gz unpack failed." |
316 |
|
else |
317 |
|
pushd ${DEST} > /dev/null |
318 |
|
zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed." |
319 |
|
popd > /dev/null |
320 |
|
fi |
321 |
|
;; |
322 |
|
xz) |
323 |
|
IFTAR="$(basename $SRCFILE .xz)" |
324 |
|
IFTAR="${IFTAR##*.}" |
325 |
|
if [[ ${IFTAR} = tar ]] |
326 |
|
then |
327 |
|
tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.xz unpack failed." |
328 |
|
else |
329 |
|
pushd ${DEST} > /dev/null |
330 |
|
xzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .xz) || die ".xz unpack failed." |
331 |
|
popd > /dev/null |
332 |
fi |
fi |
333 |
;; |
;; |
334 |
tbz2) |
tbz2|mpks|mpk) |
335 |
tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} |
tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed." |
336 |
;; |
;; |
337 |
tgz) |
tgz) |
338 |
tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} |
tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed." |
339 |
|
;; |
340 |
|
txz|mpkzs|mpkz) |
341 |
|
tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed." |
342 |
|
;; |
343 |
|
rar) |
344 |
|
unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed." |
345 |
|
;; |
346 |
|
zip|xpi) |
347 |
|
unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed." |
348 |
|
;; |
349 |
|
rpm) |
350 |
|
pushd ${DEST} > /dev/null |
351 |
|
rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed." |
352 |
|
tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed." |
353 |
|
if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]] |
354 |
|
then |
355 |
|
rm ${DEST}/${SRCFILE/.rpm/.tar.gz} |
356 |
|
fi |
357 |
;; |
;; |
358 |
*) |
*) |
359 |
die "munpack failed" |
die "munpack failed" |
365 |
{ |
{ |
366 |
local PATCHOPTS |
local PATCHOPTS |
367 |
local PATCHFILE |
local PATCHFILE |
368 |
|
local i |
369 |
|
|
370 |
PATCHOPTS=$1 |
PATCHOPTS=$1 |
371 |
PATCHFILE=$2 |
PATCHFILE=$2 |
372 |
|
|
373 |
|
if [[ -z $2 ]] |
374 |
|
then |
375 |
|
PATCHFILE=$1 |
376 |
|
|
377 |
|
## patch level auto-detection, get patch level |
378 |
|
for ((i=0; i < 10; i++)) |
379 |
|
do |
380 |
|
patch --dry-run -Np${i} -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} > /dev/null |
381 |
|
if [[ $? = 0 ]] |
382 |
|
then |
383 |
|
PATCHOPTS="-Np${i}" |
384 |
|
break |
385 |
|
fi |
386 |
|
done |
387 |
|
fi |
388 |
|
|
389 |
|
echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}" |
390 |
patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} |
patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} |
391 |
} |
} |
392 |
|
|
393 |
|
mlibtoolize() |
394 |
|
{ |
395 |
|
local opts="$@" |
396 |
|
[[ -z ${opts} ]] && opts="--verbose --install --force" |
397 |
|
|
398 |
|
libtoolize ${opts} || die "running: mlibtoolize ${opts}" |
399 |
|
} |
400 |
|
|
401 |
|
mautoreconf() |
402 |
|
{ |
403 |
|
local opts="$@" |
404 |
|
[[ -z ${opts} ]] && opts="--verbose --install --force" |
405 |
|
|
406 |
|
autoreconf ${opts} || die "running: mautoreconf ${opts}" |
407 |
|
} |
408 |
|
|
409 |
minstalldocs() |
minstalldocs() |
410 |
{ |
{ |
411 |
local docfiles |
local docfiles |
412 |
|
local doc |
413 |
docfiles="$@" |
docfiles="$@" |
414 |
|
|
415 |
if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ] |
if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ] |
417 |
install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." |
install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." |
418 |
fi |
fi |
419 |
|
|
420 |
for i in ${docfiles} |
for doc in ${docfiles} |
421 |
do |
do |
422 |
cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs." |
if [ -f ${doc} ] |
423 |
install -m 0644 ${SRCDIR}/${i}.gz \ |
then |
424 |
${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs." |
if [[ ${SMAGE_COMPRESSDOC} = true ]] |
425 |
|
then |
426 |
|
cat ${doc} | gzip -9c > ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/${doc}.gz || die "gzipping +installing ${doc}." |
427 |
|
chmod 0644 ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/${doc}.gz || die "fixing permissions of ${doc}." |
428 |
|
else |
429 |
|
install -m 0644 ${SRCDIR}/${i} ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "installing ${doc}." |
430 |
|
fi |
431 |
|
fi |
432 |
done |
done |
433 |
} |
} |
434 |
|
|
436 |
{ |
{ |
437 |
local stripdir="$@" |
local stripdir="$@" |
438 |
|
|
439 |
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
[[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
440 |
find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
[[ -z ${STRIP_DYN_LIB} ]] && STRIP_DYN_LIB="--strip-debug" |
441 |
|
find ${stripdir} ! -type d | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_LIB} 2> /dev/null |
442 |
} |
} |
443 |
|
|
444 |
mstripbins() |
mstripbins() |
445 |
{ |
{ |
446 |
local stripdir="$@" |
local stripdir="$@" |
447 |
|
|
448 |
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
[[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
449 |
find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
[[ -z ${STRIP_DYN_BIN} ]] && STRIP_DYN_BIN="--strip-debug" |
450 |
|
find ${stripdir} ! -type d | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_BIN} 2> /dev/null |
451 |
|
} |
452 |
|
|
453 |
|
mstripstatic() |
454 |
|
{ |
455 |
|
local stripdir="$@" |
456 |
|
|
457 |
|
[[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
458 |
|
[[ -z ${STRIP_STATIC_LIB} ]] && STRIP_STATIC_LIB="--strip-debug" |
459 |
|
find ${stripdir} ! -type d | xargs file | grep "ar archive" | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_STATIC_LIB} 2> /dev/null |
460 |
|
} |
461 |
|
|
462 |
|
mstriplibtoolarchive() |
463 |
|
{ |
464 |
|
local stripdir="$@" |
465 |
|
|
466 |
|
[[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
467 |
|
find ${stripdir} ! -type d -name \*.la | xargs file | grep "libtool library" | cut -f 1 -d : | xargs --no-run-if-empty rm -f -- 2> /dev/null |
468 |
|
} |
469 |
|
|
470 |
|
mpurgetargets() |
471 |
|
{ |
472 |
|
local stripdir="$@" |
473 |
|
local target |
474 |
|
|
475 |
|
[[ -z ${stripdir} ]] && stripdir=${BINDIR} |
476 |
|
# nothing to do in this case |
477 |
|
[[ -z ${PURGE_TARGETS[*]} ]] && return |
478 |
|
|
479 |
|
for target in ${PURGE_TARGETS[*]} |
480 |
|
do |
481 |
|
# check if target is a regex pattern without any slashes |
482 |
|
if [[ ${target} = ${target//\/} ]] |
483 |
|
then |
484 |
|
find ${BINDIR} -type f -name "${target}" | xargs --no-run-if-empty rm -f -- 2> /dev/null |
485 |
|
else |
486 |
|
rm -f -- ${target} 2> /dev/null |
487 |
|
fi |
488 |
|
done |
489 |
|
} |
490 |
|
|
491 |
|
mcompressdocs() |
492 |
|
{ |
493 |
|
local bindir="$@" |
494 |
|
|
495 |
|
if [ -d ${bindir}/usr/share/man ] |
496 |
|
then |
497 |
|
echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}" |
498 |
|
${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man |
499 |
|
fi |
500 |
|
|
501 |
|
if [ -d ${bindir}/usr/share/info ] |
502 |
|
then |
503 |
|
echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}" |
504 |
|
${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info |
505 |
|
fi |
506 |
} |
} |
507 |
|
|
508 |
sminclude() |
sminclude() |
524 |
{ |
{ |
525 |
if [ -x /usr/bin/distcc ] |
if [ -x /usr/bin/distcc ] |
526 |
then |
then |
527 |
echo "Using DistCC for compilation ..." |
echo -e "${COLBLUE}---${COLGREEN} Using DistCC for compilation ...${COLDEFAULT}" |
528 |
export PATH=/usr/lib/distcc/bin:${PATH} || die "distcc: could not export new $PATH" |
export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH" |
|
|
|
|
# export distcc as compiler |
|
|
# export CC="distcc" |
|
|
# export CXX=distcc |
|
529 |
|
|
530 |
export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed" |
export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed" |
531 |
|
|
|
# ccache + distcc together |
|
|
if [[ ${SMAGE_USE_CCACHE} = true ]] |
|
|
then |
|
|
if [ -x /usr/bin/ccache ] |
|
|
then |
|
|
echo "Preparing DistCC to work together with CCache ..." |
|
|
#export CCACHE_PREFIX="distcc" || die "distcc: could not set ccach_prefix" |
|
|
# export CC="ccache distcc" |
|
|
# export CXX="ccache distcc" |
|
|
fi |
|
|
fi |
|
|
|
|
532 |
# creating distcc tempdir |
# creating distcc tempdir |
533 |
install -o distcc -g daemon -d ${DISTCC_DIR} |
install -o distcc -g daemon -d ${DISTCC_DIR} |
534 |
chmod 1777 ${DISTCC_DIR} |
chmod 1777 ${DISTCC_DIR} |
539 |
{ |
{ |
540 |
if [ -x /usr/bin/ccache ] |
if [ -x /usr/bin/ccache ] |
541 |
then |
then |
542 |
echo "Using CCache for compilation ..." |
echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}" |
543 |
export PATH=/usr/lib/ccache/bin:${PATH} || die "ccache: could not export new $PATH" |
export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH" |
|
#unset CC CXX |
|
544 |
fi |
fi |
545 |
} |
} |
546 |
|
|
563 |
# fix DEPEND |
# fix DEPEND |
564 |
while read sym dep |
while read sym dep |
565 |
do |
do |
566 |
|
# ignore empty lines |
567 |
|
[[ -z ${dep} ]] && continue |
568 |
|
|
569 |
cat="$(dirname ${dep})" |
cat="$(dirname ${dep})" |
570 |
# change if not virtual |
# change if not virtual |
571 |
if [[ ${cat} = virtual ]] |
if [[ ${cat} = virtual ]] |
618 |
# special tags: |
# special tags: |
619 |
# PKGTYPE type of pkg |
# PKGTYPE type of pkg |
620 |
# INHERITS which functions get included |
# INHERITS which functions get included |
621 |
# SPECIAL_FUNCTIONS special functions wich should also be added |
# SPECIAL_FUNCTIONS special functions which should also be added |
622 |
# warning: they get killed before the build starts ! |
# warning: they get killed before the build starts ! |
623 |
|
# SPLIT_PACKAGES names of all subpackages which are splitted from parent |
624 |
|
# SPLIT_PACKAGE_BASE base package name for splitpackages |
625 |
|
# (only in the resulting magefile} |
626 |
# |
# |
627 |
# MAGE_TREE_DEST target destination of the generated tree |
# MAGE_TREE_DEST target destination of the generated tree |
628 |
# REGEN_MAGE_TREE set to 'true' to enable this |
# REGEN_MAGE_TREE set to 'true' to enable this |
633 |
local magefile |
local magefile |
634 |
local dest |
local dest |
635 |
local target |
local target |
636 |
|
local split_pkg_base |
637 |
local sym |
local sym |
638 |
local depname |
local depname |
639 |
|
|
641 |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
642 |
|
|
643 |
# determinate which suffix this mage file should get, if any |
# determinate which suffix this mage file should get, if any |
644 |
[ -n "$1" ] && target="-$1" |
[[ $1 = --target ]] && shift && target="-$1" |
645 |
|
|
646 |
|
# mark package as splitpackage |
647 |
|
[[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1" |
648 |
|
|
649 |
# name of magefile |
# name of magefile |
650 |
magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
653 |
dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}" |
dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}" |
654 |
|
|
655 |
# show what we are doing |
# show what we are doing |
656 |
echo "Generating Mage file:" |
echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}" |
657 |
echo " ${dest}" |
echo "${dest}" |
658 |
|
|
659 |
install -d "$(dirname ${dest})" |
install -d "$(dirname ${dest})" |
660 |
# now build the mage file |
# now build the mage file |
661 |
> ${dest} |
> ${dest} |
662 |
|
|
|
# header |
|
|
echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.40 2005-12-26 23:16:38 niro Exp $' >> ${dest} |
|
|
echo >> ${dest} |
|
|
|
|
663 |
# pgkname and state |
# pgkname and state |
664 |
echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
665 |
echo "STATE=\"${STATE}\"" >> ${dest} |
echo "STATE=\"${STATE}\"" >> ${dest} |
|
echo >> ${dest} |
|
666 |
|
|
667 |
# description and homepage |
# description and homepage |
668 |
echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} |
echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} |
669 |
echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
|
echo >> ${dest} |
|
670 |
|
|
671 |
# special tags and vars |
# special tags and vars |
672 |
echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
673 |
|
|
674 |
# echo MAGE_TARGETS ## note -target is needed ! |
# echo MAGE_TARGETS ## note -target is needed ! |
675 |
echo "MAGE_TARGETS=\"${target}\"" >> ${dest} |
echo "MAGE_TARGETS=\"${target}\"" >> ${dest} |
676 |
echo >> ${dest} |
|
677 |
|
# split package base |
678 |
|
echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest} |
679 |
|
|
680 |
# add special vars |
# add special vars |
681 |
if [ -n "${SPECIAL_VARS}" ] |
if [ -n "${SPECIAL_VARS}" ] |
686 |
# being tricky here :) |
# being tricky here :) |
687 |
echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} |
echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} |
688 |
done |
done |
|
echo >> ${dest} |
|
689 |
fi |
fi |
690 |
|
|
691 |
# add at least all includes |
# add at least all includes |
697 |
do |
do |
698 |
echo -n " ${i}" >> ${dest} |
echo -n " ${i}" >> ${dest} |
699 |
done |
done |
700 |
echo >> ${dest} |
# a CRLF is needed here! |
701 |
|
echo >> ${dest} |
702 |
fi |
fi |
|
echo >> ${dest} |
|
703 |
|
|
704 |
# deps and provides |
# deps and provides |
705 |
echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
|
echo >> ${dest} |
|
706 |
echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
|
echo >> ${dest} |
|
707 |
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
|
echo >> ${dest} |
|
708 |
|
|
709 |
# add special functions |
# add special functions |
710 |
if [ -n "${SPECIAL_FUNCTIONS}" ] |
if [ -n "${SPECIAL_FUNCTIONS}" ] |
714 |
do |
do |
715 |
# add to mage (quotes needed !) |
# add to mage (quotes needed !) |
716 |
typeset -f "${i}" >> ${dest} |
typeset -f "${i}" >> ${dest} |
|
echo >> ${dest} |
|
717 |
# unset to be safe (quotes needed !) |
# unset to be safe (quotes needed !) |
718 |
#unset "${i}" <-- later to get every target built |
#unset "${i}" <-- later to get every target built |
719 |
done |
done |
|
echo >> ${dest} |
|
720 |
fi |
fi |
721 |
|
|
722 |
# pre|post-install|removes |
# pre|post-install|removes |
723 |
typeset -f preinstall >> ${dest} |
typeset -f preinstall >> ${dest} |
|
echo >> ${dest} |
|
724 |
typeset -f postinstall >> ${dest} |
typeset -f postinstall >> ${dest} |
|
echo >> ${dest} |
|
725 |
typeset -f preremove >> ${dest} |
typeset -f preremove >> ${dest} |
|
echo >> ${dest} |
|
726 |
typeset -f postremove >> ${dest} |
typeset -f postremove >> ${dest} |
|
echo >> ${dest} |
|
727 |
} |
} |
728 |
|
|
729 |
regen_mage_tree() |
regen_mage_tree() |
730 |
{ |
{ |
731 |
local i |
local subpackage |
732 |
|
|
733 |
# build them only if requested |
# build them only if requested |
734 |
if [[ ${REGEN_MAGE_TREE} = true ]] |
if [[ ${REGEN_MAGE_TREE} = true ]] |
735 |
then |
then |
736 |
# run it without targets |
# run it without targets |
737 |
if [ -z "${MAGE_TARGETS}" ] |
if [[ -n ${MAGE_TARGETS} ]] |
738 |
then |
then |
739 |
|
# build for each target a mage file |
740 |
|
# run it with several targets |
741 |
echo |
echo |
742 |
build_mage_script |
for subpackage in ${MAGE_TARGETS} |
743 |
|
do |
744 |
|
build_mage_script --target "${subpackage}" |
745 |
|
done |
746 |
echo |
echo |
|
else |
|
747 |
|
|
748 |
# build for each target an mage file |
# run it for splitpackages |
749 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
750 |
|
then |
751 |
|
local split_pkg_base="${PNAME}" |
752 |
|
# save smage environment |
753 |
|
split_save_variables |
754 |
|
# build for each subpackage a mage file |
755 |
# run it with several targets |
# run it with several targets |
756 |
for i in ${MAGE_TARGETS} |
echo |
757 |
|
for subpackage in ${SPLIT_PACKAGES} |
758 |
do |
do |
759 |
echo |
# get the right variables for the split |
760 |
build_mage_script "${i}" |
export PNAME="${subpackage}" |
761 |
echo |
split_info_${subpackage} |
762 |
|
# get the preinstall etc |
763 |
|
split_export_inherits ${subpackage} |
764 |
|
build_mage_script --split-pkg-base "${split_pkg_base}" |
765 |
|
# delete split preinstall etc |
766 |
|
split_delete_inherits ${subpackage} |
767 |
|
# restore smage environment |
768 |
|
split_restore_variables |
769 |
done |
done |
770 |
|
echo |
771 |
|
# unset all saved smage variables |
772 |
|
split_unset_variables |
773 |
|
|
774 |
|
else |
775 |
|
echo |
776 |
|
build_mage_script |
777 |
|
echo |
778 |
fi |
fi |
779 |
fi |
fi |
780 |
|
|
781 |
# now unset all uneeded vars to be safe |
# now unset all uneeded vars to be safe |
782 |
# unset PKGNAME <-- don't do that; smage needs this var |
# unset PKGNAME <-- don't do that; smage needs this var |
783 |
# unset to be safe (quotes needed !) |
# unset to be safe (quotes needed !) |
784 |
for i in ${SPECIAL_FUNCTIONS} |
# for i in ${SPECIAL_FUNCTIONS} |
785 |
do |
# do |
786 |
unset "${i}" |
# unset "${i}" |
787 |
done |
# done |
788 |
unset SPECIAL_FUNCTIONS |
unset SPECIAL_FUNCTIONS |
789 |
for i in ${SPECIAL_VARS} |
# for i in ${SPECIAL_VARS} |
790 |
do |
# do |
791 |
unset "${i}" |
# unset "${i}" |
792 |
done |
# done |
793 |
unset SPECIAL_VARS |
unset SPECIAL_VARS |
794 |
unset STATE |
unset STATE |
795 |
unset DESCRIPTION |
unset DESCRIPTION |
805 |
unset postremove |
unset postremove |
806 |
} |
} |
807 |
|
|
808 |
|
split_save_variables() |
809 |
|
{ |
810 |
|
export SAVED_PNAME="${PNAME}" |
811 |
|
export SAVED_PVER="${PVER}" |
812 |
|
export SAVED_PBUILD="${PBUILD}" |
813 |
|
export SAVED_PCATEGORIE="${PCATEGORIE}" |
814 |
|
export SAVED_DESCRIPTION="${DESCRIPTION}" |
815 |
|
export SAVED_HOMEPAGE="${HOMEPAGE}" |
816 |
|
export SAVED_SPECIAL_VARS="${SPECIAL_VARS}" |
817 |
|
export SAVED_STATE="${STATE}" |
818 |
|
export SAVED_PKGTYPE="${PKGTYPE}" |
819 |
|
export SAVED_INHERITS="${INHERITS}" |
820 |
|
export SAVED_DEPEND="${DEPEND}" |
821 |
|
export SAVED_SDEPEND="${SDEPEND}" |
822 |
|
export SAVED_PROVIDE="${PROVIDE}" |
823 |
|
export SAVED_NOPKGBUILD="${NOPKGBUILD}" |
824 |
|
|
825 |
|
# bindir too |
826 |
|
export SAVED_BINDIR="${BINDIR}" |
827 |
|
|
828 |
|
# export the SPLIT_PACKAGE_BASE |
829 |
|
export SPLIT_PACKAGE_BASE="${SAVED_PNAME}" |
830 |
|
|
831 |
|
# functions |
832 |
|
if [[ ! -z $(typeset -f preinstall) ]] |
833 |
|
then |
834 |
|
# rename the old one |
835 |
|
local saved_preinstall |
836 |
|
saved_preinstall=SAVED_$(typeset -f preinstall) |
837 |
|
eval "${saved_preinstall}" |
838 |
|
export -f SAVED_preinstall |
839 |
|
fi |
840 |
|
|
841 |
|
if [[ ! -z $(typeset -f postinstall) ]] |
842 |
|
then |
843 |
|
# rename the old one |
844 |
|
local saved_postinstall |
845 |
|
saved_postinstall=SAVED_$(typeset -f postinstall) |
846 |
|
eval "${saved_postinstall}" |
847 |
|
export -f SAVED_postinstall |
848 |
|
fi |
849 |
|
|
850 |
|
if [[ ! -z $(typeset -f preremove) ]] |
851 |
|
then |
852 |
|
# rename the old one |
853 |
|
local saved_preremove |
854 |
|
saved_preremove=SAVED_$(typeset -f preremove) |
855 |
|
eval "${saved_preremove}" |
856 |
|
export -f SAVED_preremove |
857 |
|
fi |
858 |
|
|
859 |
|
if [[ ! -z $(typeset -f postremove) ]] |
860 |
|
then |
861 |
|
# rename the old one |
862 |
|
local saved_postremove |
863 |
|
saved_postremove=SAVED_$(typeset -f postremove) |
864 |
|
eval "${saved_postremove}" |
865 |
|
export -f SAVED_postremove |
866 |
|
fi |
867 |
|
} |
868 |
|
|
869 |
|
split_restore_variables() |
870 |
|
{ |
871 |
|
export PNAME="${SAVED_PNAME}" |
872 |
|
export PVER="${SAVED_PVER}" |
873 |
|
export PBUILD="${SAVED_PBUILD}" |
874 |
|
export PCATEGORIE="${SAVED_PCATEGORIE}" |
875 |
|
export DESCRIPTION="${SAVED_DESCRIPTION}" |
876 |
|
export HOMEPAGE="${SAVED_HOMEPAGE}" |
877 |
|
export SPECIAL_VARS="${SAVED_SPECIAL_VARS}" |
878 |
|
export STATE="${SAVED_STATE}" |
879 |
|
export PKGTYPE="${SAVED_PKGTYPE}" |
880 |
|
export INHERITS="${SAVED_INHERITS}" |
881 |
|
export DEPEND="${SAVED_DEPEND}" |
882 |
|
export SDEPEND="${SAVED_SDEPEND}" |
883 |
|
export PROVIDE="${SAVED_PROVIDE}" |
884 |
|
export NOPKGBUILD="${SAVED_NOPKGBUILD}" |
885 |
|
|
886 |
|
# bindir too |
887 |
|
export BINDIR="${SAVED_BINDIR}" |
888 |
|
|
889 |
|
# functions |
890 |
|
if [[ ! -z $(typeset -f SAVED_preinstall) ]] |
891 |
|
then |
892 |
|
# rename the old one |
893 |
|
local saved_preinstall |
894 |
|
saved_preinstall=$(typeset -f SAVED_preinstall) |
895 |
|
eval "${saved_preinstall/SAVED_/}" |
896 |
|
export -f preinstall |
897 |
|
fi |
898 |
|
|
899 |
|
if [[ ! -z $(typeset -f SAVED_postinstall) ]] |
900 |
|
then |
901 |
|
# rename the old one |
902 |
|
local saved_postinstall |
903 |
|
saved_postinstall=$(typeset -f SAVED_postinstall) |
904 |
|
eval "${saved_postinstall/SAVED_/}" |
905 |
|
export -f postinstall |
906 |
|
fi |
907 |
|
|
908 |
|
if [[ ! -z $(typeset -f SAVED_preremove) ]] |
909 |
|
then |
910 |
|
# rename the old one |
911 |
|
local saved_preremove |
912 |
|
saved_preremove=$(typeset -f SAVED_preremove) |
913 |
|
eval "${saved_preremove/SAVED_/}" |
914 |
|
export -f preremove |
915 |
|
fi |
916 |
|
|
917 |
|
if [[ ! -z $(typeset -f SAVED_postremove) ]] |
918 |
|
then |
919 |
|
# rename the old one |
920 |
|
local saved_postremove |
921 |
|
saved_postremove=$(typeset -f SAVED_postremove) |
922 |
|
eval "${saved_postremove/SAVED_/}" |
923 |
|
export -f postremove |
924 |
|
fi |
925 |
|
} |
926 |
|
|
927 |
|
split_unset_variables() |
928 |
|
{ |
929 |
|
# unset saved vars; not needed anymore |
930 |
|
unset SAVED_PNAME |
931 |
|
unset SAVED_PVER |
932 |
|
unset SAVED_PBUILD |
933 |
|
unset SAVED_PCATEGORIE |
934 |
|
unset SAVED_DESCRIPTION |
935 |
|
unset SAVED_HOMEPAGE |
936 |
|
unset SAVED_SPECIAL_VARS |
937 |
|
unset SAVED_STATE |
938 |
|
unset SAVED_PKGTYPE |
939 |
|
unset SAVED_INHERITS |
940 |
|
unset SAVED_DEPEND |
941 |
|
unset SAVED_SDEPEND |
942 |
|
unset SAVED_PROVIDE |
943 |
|
unset SAVED_BINDIR |
944 |
|
unset SAVED_NOPKGBUILD |
945 |
|
unset SPLIT_PACKAGE_BASE |
946 |
|
unset -f SAVED_preinstall |
947 |
|
unset -f SAVED_postinstall |
948 |
|
unset -f SAVED_preremove |
949 |
|
unset -f SAVED_postremove |
950 |
|
} |
951 |
|
|
952 |
|
split_export_inherits() |
953 |
|
{ |
954 |
|
local subpackage="$1" |
955 |
|
local func |
956 |
|
local newfunc |
957 |
|
|
958 |
|
for func in preinstall postinstall preremove postremove |
959 |
|
do |
960 |
|
if [[ ! -z $(typeset -f ${func}_${subpackage}) ]] |
961 |
|
then |
962 |
|
newfunc=$(typeset -f ${func}_${subpackage}) |
963 |
|
newfunc="${newfunc/_${subpackage} (/ (}" |
964 |
|
eval "${newfunc}" |
965 |
|
fi |
966 |
|
done |
967 |
|
} |
968 |
|
|
969 |
|
split_delete_inherits() |
970 |
|
{ |
971 |
|
local subpackage="$1" |
972 |
|
local func |
973 |
|
|
974 |
|
for func in preinstall postinstall preremove postremove |
975 |
|
do |
976 |
|
if [[ ! -z $(typeset -f ${func}_${subpackage}) ]] |
977 |
|
then |
978 |
|
unset -f ${func} |
979 |
|
fi |
980 |
|
done |
981 |
|
} |
982 |
|
|
983 |
export_inherits() |
export_inherits() |
984 |
{ |
{ |
985 |
local include="$1" |
local include="$1" |
1041 |
# fix target as it may be empty ! |
# fix target as it may be empty ! |
1042 |
[ -n "${target}" ] && target="-${target}" |
[ -n "${target}" ] && target="-${target}" |
1043 |
|
|
1044 |
|
|
1045 |
# build pkgname |
# build pkgname |
1046 |
pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" |
pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" |
1047 |
|
|
1048 |
# build pkg-md5-sum only if requested |
# build pkg-md5-sum only if requested |
1049 |
if [[ ${REGEN_MAGE_TREE} = true ]] |
if [[ ${REGEN_MAGE_TREE} = true ]] |
1050 |
then |
then |
1051 |
echo -n "Generating a md5sum for ${pkgname}.${PKGSUFFIX} ... " |
echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}" |
1052 |
|
|
1053 |
# abort if not exist |
# abort if not exist |
1054 |
if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ] |
if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ] |
1055 |
then |
then |
1056 |
echo "! exists" |
echo -e "${COLRED}! exists${COLDEFAULT}" |
1057 |
return 0 |
return 0 |
1058 |
fi |
fi |
1059 |
|
|
1061 |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
1062 |
|
|
1063 |
# setup md5 dir |
# setup md5 dir |
1064 |
dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5" |
dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5" |
1065 |
install -d ${dest} |
install -d ${dest} |
1066 |
|
|
1067 |
# gen md5sum |
# gen md5sum |
1068 |
( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \ |
( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \ |
1069 |
> ${dest}/${pkgname}.md5 |
> ${dest}/${pkgname}.md5 |
1070 |
echo "done" |
echo -e "${COLGREEN}done${COLDEFAULT}" |
1071 |
fi |
fi |
1072 |
} |
} |
1073 |
|
|
1074 |
|
source_pkg_build() |
1075 |
|
{ |
1076 |
|
if [[ ${PKGTYPE} = virtual ]] |
1077 |
|
then |
1078 |
|
echo "Virtual package detected; src-pkg-tarball not necessary ..." |
1079 |
|
return 0 |
1080 |
|
fi |
1081 |
|
|
1082 |
|
if [[ ! -d ${SOURCEDIR}/${PNAME} ]] |
1083 |
|
then |
1084 |
|
echo "No SRC_URI defined; src-pkg-tarball not necessary ..." |
1085 |
|
return 0 |
1086 |
|
fi |
1087 |
|
|
1088 |
|
[ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your ${MAGERC} correctly." |
1089 |
|
|
1090 |
|
echo -e "${COLGREEN}Creating source package tarball ... ${COLDEFAULT}" |
1091 |
|
|
1092 |
|
# include the smage2 file |
1093 |
|
cp ${SMAGENAME} ${SOURCEDIR}/${PNAME} |
1094 |
|
|
1095 |
|
( cd ${SOURCEDIR}; tar cvjf ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${PNAME}; ) |
1096 |
|
[[ ! -d ${SRCPKGDIR} ]] && install -d ${SRCPKGDIR} |
1097 |
|
mv ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${SRCPKGDIR}/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} |
1098 |
|
|
1099 |
|
echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}" |
1100 |
|
} |
1101 |
|
|
1102 |
|
step_by_step() |
1103 |
|
{ |
1104 |
|
if [[ ${STEP_BY_STEP} = true ]] |
1105 |
|
then |
1106 |
|
echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}" |
1107 |
|
echo "Press [enter] to continue" |
1108 |
|
read |
1109 |
|
fi |
1110 |
|
} |
1111 |
|
|
1112 |
|
|
1113 |
# print out our version |
# print out our version |
1114 |
showversion |
showversion |
1115 |
echo |
echo |
1135 |
# creates md5sums for smages to given dir |
# creates md5sums for smages to given dir |
1136 |
if [[ $1 = calcmd5 ]] |
if [[ $1 = calcmd5 ]] |
1137 |
then |
then |
1138 |
if [ $# -ge 3 ] |
if [ $# -ge 2 ] |
1139 |
then |
then |
1140 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1141 |
MD5DIR="$3" |
MD5DIR="$3" |
1142 |
source ${SMAGENAME} || die "download source failed" |
[[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5" |
1143 |
|
|
1144 |
|
smagesource ${SMAGENAME} || die "download source failed" |
1145 |
|
|
1146 |
# overridable sourcedir; must be declared after source of the smage2 |
# overridable sourcedir; must be declared after source of the smage2 |
1147 |
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
1193 |
echo |
echo |
1194 |
else |
else |
1195 |
echo "Usage: Calculating MD5 Sums:" |
echo "Usage: Calculating MD5 Sums:" |
1196 |
echo " $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR" |
echo " $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]" |
1197 |
echo |
echo |
1198 |
echo |
echo |
1199 |
echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." |
echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." |
1215 |
# get smage |
# get smage |
1216 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1217 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1218 |
source ${SMAGENAME} || die "download source failed" |
smagesource ${SMAGENAME} || die "download source failed" |
1219 |
|
|
1220 |
download_sources |
download_sources |
1221 |
exit 0 |
exit 0 |
1227 |
# set correct SMAGENAME |
# set correct SMAGENAME |
1228 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1229 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1230 |
source ${SMAGENAME} || die "regen: smage2 not found" |
smagesource ${SMAGENAME} || die "regen: smage2 not found" |
1231 |
|
|
1232 |
regen_mage_tree |
regen_mage_tree |
1233 |
|
|
1234 |
# build md5sum for existing packages |
# build several targets |
1235 |
generate_package_md5sum \ |
if [[ -n ${MAGE_TARGETS} ]] |
1236 |
--pcat "${PCATEGORIE}" \ |
then |
1237 |
--pname "${PNAME}" \ |
for target in ${MAGE_TARGETS} |
1238 |
--pver "${PVER}" \ |
do |
1239 |
--pbuild "${PBUILD}" \ |
# build md5sum for existing packages |
1240 |
--parch "${ARCH}" \ |
generate_package_md5sum \ |
1241 |
--target "${target}" |
--pcat "${PCATEGORIE}" \ |
1242 |
|
--pname "${PNAME}" \ |
1243 |
|
--pver "${PVER}" \ |
1244 |
|
--pbuild "${PBUILD}" \ |
1245 |
|
--parch "${ARCH}" \ |
1246 |
|
--target "${target}" |
1247 |
|
done |
1248 |
|
|
1249 |
|
# build several subpackages |
1250 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
1251 |
|
then |
1252 |
|
split_save_variables |
1253 |
|
for subpackage in ${SPLIT_PACKAGES} |
1254 |
|
do |
1255 |
|
# get the right variables for the split |
1256 |
|
export PNAME="${subpackage}" |
1257 |
|
split_info_${subpackage} |
1258 |
|
# build md5sum for existing packages |
1259 |
|
generate_package_md5sum \ |
1260 |
|
--pcat "${PCATEGORIE}" \ |
1261 |
|
--pname "${PNAME}" \ |
1262 |
|
--pver "${PVER}" \ |
1263 |
|
--pbuild "${PBUILD}" \ |
1264 |
|
--parch "${ARCH}" |
1265 |
|
# restore smage environment |
1266 |
|
split_restore_variables |
1267 |
|
done |
1268 |
|
# unset all saved smage variables |
1269 |
|
split_unset_variables |
1270 |
|
|
1271 |
|
else |
1272 |
|
# build md5sum for existing packages |
1273 |
|
generate_package_md5sum \ |
1274 |
|
--pcat "${PCATEGORIE}" \ |
1275 |
|
--pname "${PNAME}" \ |
1276 |
|
--pver "${PVER}" \ |
1277 |
|
--pbuild "${PBUILD}" \ |
1278 |
|
--parch "${ARCH}" |
1279 |
|
fi |
1280 |
|
|
1281 |
|
exit 0 |
1282 |
|
fi |
1283 |
|
|
1284 |
|
if [ "$1" == "--create-src-tarball" -a -n "$2" ] |
1285 |
|
then |
1286 |
|
# set correct SMAGENAME |
1287 |
|
SMAGENAME="$2" |
1288 |
|
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1289 |
|
|
1290 |
|
echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}" |
1291 |
|
|
1292 |
|
smagesource ${SMAGENAME} || die "regen: smage2 not found" |
1293 |
|
|
1294 |
|
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
1295 |
|
then |
1296 |
|
echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" |
1297 |
|
rm -rf ${SOURCEDIR}/${PKGNAME} |
1298 |
|
fi |
1299 |
|
|
1300 |
|
download_sources |
1301 |
|
source_pkg_build ${SMAGENAME} |
1302 |
exit 0 |
exit 0 |
1303 |
fi |
fi |
1304 |
|
|
1305 |
|
if [ "$1" == "--src-tarball" -a -n "$2" ] || [ "$1" == "-st" -a -n "$2" ] |
1306 |
|
then |
1307 |
|
SRCPKGTARBALL="${2}" |
1308 |
|
USE_SRC_PKG_TARBALL=true |
1309 |
|
|
1310 |
|
# abort if given file is not a source pkg |
1311 |
|
[[ ${SRCPKGTARBALL##*.} != ${SRCPKGSUFFIX} ]] && die "${SRCPKGTARBALL} is not a valid src-pkg file." |
1312 |
|
|
1313 |
|
# set correct SMAGENAME; use the one that the src_pkg provide |
1314 |
|
# /path/to/SOURCEDIR/PNAME/SMAGENAME |
1315 |
|
SMAGENAME="${SOURCEDIR}/$(basename ${SRCPKGTARBALL%-*-*})/$(basename ${SRCPKGTARBALL} .${SRCPKGSUFFIX}).${SMAGESUFFIX}" |
1316 |
|
|
1317 |
|
echo -e "${COLGREEN}Using src-tarball ${COLBLUE}${SRCPKGTARBALL}${COLGREEN} ...${COLDEFAULT}" |
1318 |
|
|
1319 |
|
[[ ! -d ${SOURCEDIR} ]] && install -d ${SOURCEDIR} |
1320 |
|
|
1321 |
|
# unpack srctarball |
1322 |
|
[[ ! -f ${SRCPKGTARBALL} ]] && die "Error: ${SRCPKGTARBALL} does not exist. Aborting." |
1323 |
|
|
1324 |
|
tar xvjf ${SRCPKGTARBALL} -C ${SOURCEDIR} || die "Error unpackung src-tarball ${SRCPKGTARBALL}" |
1325 |
|
|
1326 |
|
[[ ! -f ${SMAGENAME} ]] && die "Included smage2 file in src-tarball not found: ${SMAGENAME}" |
1327 |
|
fi |
1328 |
|
|
1329 |
|
|
1330 |
[ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting." |
[ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting." |
1331 |
[ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] && |
[ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] && |
1332 |
die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting." |
die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting." |
1333 |
[ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your mage.rc correctly." |
[ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your ${MAGERC} correctly." |
1334 |
[ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your mage.rc correctly." |
[ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your ${MAGERC} correctly." |
1335 |
[ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your mage.rc correctly." |
[ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your ${MAGERC} correctly." |
1336 |
[ -z "${BINDIR}" ] && die "no BINDIR variable found in /etc/mage.rc" |
[ -z "${BINDIR}" ] && die "no BINDIR variable found in ${MAGERC}" |
1337 |
[ -z "${CHOST}" ] && die "no CHOST variable found in /etc/mage.rc" |
[ -z "${CHOST}" ] && die "no CHOST variable found in ${MAGERC}" |
1338 |
[ -z "${CFLAGS}" ] && die "no CFLAGS variable found in /etc/mage.rc" |
[ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}" |
1339 |
[ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in /etc/mage.rc" |
[ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}" |
1340 |
|
|
1341 |
source ${SMAGENAME} || die "source failed" |
smagesource ${SMAGENAME} || die "source failed" |
1342 |
PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
1343 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1344 |
|
SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log" |
1345 |
|
|
1346 |
xtitle "Compiling ${PKGNAME}" |
xtitle "Compiling ${PKGNAME}" |
1347 |
echo "Compiling ${PKGNAME}" |
echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}" |
1348 |
|
|
1349 |
# auto regen mage tree if requested |
# auto regen mage tree if requested |
1350 |
regen_mage_tree |
regen_mage_tree |
1351 |
|
|
1352 |
|
if [[ ${CREATE_SRC_PKG_TARBALL} = true ]] |
1353 |
|
then |
1354 |
|
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
1355 |
|
then |
1356 |
|
echo -e "${COLBLUE}===${COLGREEN} deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" |
1357 |
|
rm -rf ${SOURCEDIR}/${PNAME} |
1358 |
|
fi |
1359 |
|
fi |
1360 |
|
|
1361 |
# download sources |
# download sources |
1362 |
download_sources |
[[ ${USE_SRC_PKG_TARBALL} != true ]] && download_sources |
1363 |
|
|
1364 |
# fixes some issues with these functions |
# fixes some issues with these functions |
1365 |
export -f src_prepare || die "src_prepare export failed" |
export -f src_prepare || die "src_prepare export failed" |
1366 |
export -f src_compile || die "src_compile export failed" |
export -f src_compile || die "src_compile export failed" |
1367 |
|
export -f src_check || die "src_check export failed" |
1368 |
export -f src_install || die "src_install export failed" |
export -f src_install || die "src_install export failed" |
1369 |
|
|
1370 |
# fixes some compile issues |
# fixes some compile issues |
1376 |
|
|
1377 |
|
|
1378 |
# setup distcc |
# setup distcc |
1379 |
# distcc mus be setup *before* ccache, as ccache need to be before distcc in path |
# setup for distcc goes *before* ccache, so ccache comes before distcc in path |
1380 |
[[ ${SMAGE_USE_DISTCC} = true ]] && setup_distcc_environment |
[[ ${SMAGE_USE_DISTCC} = true ]] && setup_distcc_environment |
1381 |
|
|
1382 |
# setup ccache |
# setup ccache |
1383 |
[[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment |
[[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment |
1384 |
|
|
1385 |
# small sleep to show our settings |
# clean up builddir if a previously one exist |
|
sleep 1 |
|
|
|
|
|
#debug |
|
|
#echo "CC=${CC}" |
|
|
#echo "CXX=${CXX}" |
|
|
#echo "DISTCC_DIR=${DISTCC_DIR}" |
|
|
#echo "PATH: ${PATH}" |
|
|
#echo "--------------------------------------" |
|
|
#env |
|
|
#echo "--------------------------------------" |
|
|
#read |
|
|
#debug end |
|
|
|
|
|
# cleans up build if a previously one exists |
|
1386 |
if [ -d ${BUILDDIR} ] |
if [ -d ${BUILDDIR} ] |
1387 |
then |
then |
1388 |
rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." |
rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." |
1389 |
fi |
fi |
1390 |
install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." |
install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." |
1391 |
|
|
1392 |
# cleans up srcdir if a previously unpacked one exists |
# clean up srcdir if a previously unpacked one exist |
1393 |
if [ -d ${SRCDIR} ] |
if [ -d ${SRCDIR} ] |
1394 |
then |
then |
1395 |
rm -rf ${SRCDIR} |
rm -rf ${SRCDIR} |
1396 |
fi |
fi |
1397 |
|
|
1398 |
# cleans up bindir if a previous build exists or creates a new one |
# clean up bindir if a previous build exist or create a new one |
1399 |
if [ -d ${BINDIR} ] |
if [ -d ${BINDIR} ] |
1400 |
then |
then |
1401 |
rm -rf ${BINDIR} |
rm -rf ${BINDIR} |
1402 |
fi |
fi |
1403 |
install -d ${BINDIR} || die "couldn't create \$BINDIR." |
install -d ${BINDIR} || die "couldn't create \$BINDIR." |
1404 |
|
|
1405 |
# cleans up package temp dir if a previous build exists |
# clean up package temp dir if a previous build exist |
1406 |
if [ -d ${BUILDDIR}/${PKGNAME} ] |
if [ -d ${BUILDDIR}/${PKGNAME} ] |
1407 |
then |
then |
1408 |
rm -rf ${BUILDDIR}/${PKGNAME} |
rm -rf ${BUILDDIR}/${PKGNAME} |
1409 |
fi |
fi |
1410 |
|
|
1411 |
# cleans up timestamp if one exists |
# setup build logging |
1412 |
if [ -f /var/tmp/timestamp ] |
[[ ! -d /var/log/smage ]] && install -d /var/log/smage |
1413 |
|
echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log |
1414 |
|
|
1415 |
|
src_prepare | ${SMAGE_LOG_CMD} |
1416 |
|
die_pipestatus 0 "src_prepare failed" |
1417 |
|
step_by_step $_ |
1418 |
|
|
1419 |
|
src_compile | ${SMAGE_LOG_CMD} |
1420 |
|
die_pipestatus 0 "src_compile failed" |
1421 |
|
step_by_step $_ |
1422 |
|
|
1423 |
|
# only run checks if requested |
1424 |
|
if [[ ${MAGE_CHECK} != true ]] |
1425 |
then |
then |
1426 |
mage rmstamp |
echo "MAGE_CHECK not requested; src_check() will not be run!" | ${SMAGE_LOG_CMD} |
1427 |
|
step_by_step src_check |
1428 |
|
else |
1429 |
|
src_check | ${SMAGE_LOG_CMD} |
1430 |
|
die_pipestatus 0 "src_check failed" |
1431 |
|
step_by_step $_ |
1432 |
fi |
fi |
1433 |
|
|
1434 |
src_prepare || die "src_prepare failed" |
# build several subpackages |
1435 |
src_compile || die "src_compile failed" |
if [[ -n ${SPLIT_PACKAGES} ]] |
1436 |
src_install || die "src_install failed" |
then |
1437 |
|
# save bindir & pname |
1438 |
|
split_save_variables |
1439 |
|
export SAVED_BINDIR="${BINDIR}" |
1440 |
|
for subpackage in ${SPLIT_PACKAGES} |
1441 |
|
do |
1442 |
|
if typeset -f src_install_${subpackage} > /dev/null |
1443 |
|
then |
1444 |
|
# export subpackage bindir |
1445 |
|
export BINDIR="${SAVED_BINDIR}_${subpackage}" |
1446 |
|
# export PNAME, several internal function and include |
1447 |
|
# rely on this variable |
1448 |
|
export PNAME="${subpackage}" |
1449 |
|
|
1450 |
|
echo |
1451 |
|
echo -en "${COLBLUE}*** ${COLDEFAULT}" |
1452 |
|
echo -en " Running ${COLGREEN}split src_install()${COLDEFAULT}" |
1453 |
|
echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}" |
1454 |
|
echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..." |
1455 |
|
|
1456 |
|
src_install_${subpackage} | ${SMAGE_LOG_CMD} |
1457 |
|
die_pipestatus 0 "src_install_${subpackage} failed" |
1458 |
|
step_by_step $_ |
1459 |
|
fi |
1460 |
|
done |
1461 |
|
# restore bindir & pname |
1462 |
|
split_restore_variables |
1463 |
|
# unset all saved smage variables |
1464 |
|
split_unset_variables |
1465 |
|
else |
1466 |
|
src_install | ${SMAGE_LOG_CMD} |
1467 |
|
die_pipestatus 0 "src_install failed" |
1468 |
|
step_by_step $_ |
1469 |
|
fi |
1470 |
|
|
1471 |
# compressing doc, info & man files |
# compressing doc, info & man files |
1472 |
echo -e "Compressing man-pages ..." |
if [[ -n ${SPLIT_PACKAGES} ]] |
|
if [ -d ${BUILDDIR}/builded/usr/share/man ] |
|
1473 |
then |
then |
1474 |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man |
for subpackage in ${SPLIT_PACKAGES} |
1475 |
|
do |
1476 |
|
mcompressdocs ${BINDIR}_${subpackage} |
1477 |
|
done |
1478 |
|
else |
1479 |
|
mcompressdocs ${BINDIR} |
1480 |
fi |
fi |
1481 |
|
|
1482 |
echo -e "Compressing info-pages ..." |
if [[ ${SMAGE_STRIP_LIBTOOL} = true ]] |
|
if [ -d ${BUILDDIR}/builded/usr/share/info ] |
|
1483 |
then |
then |
1484 |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info |
if [[ -n ${SPLIT_PACKAGES} ]] |
1485 |
|
then |
1486 |
|
for subpackage in ${SPLIT_PACKAGES} |
1487 |
|
do |
1488 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives for '${subpackage}' ...${COLDEFAULT}" |
1489 |
|
mstriplibtoolarchive ${BINDIR}_${subpackage} |
1490 |
|
done |
1491 |
|
else |
1492 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives ...${COLDEFAULT}" |
1493 |
|
mstriplibtoolarchive ${BINDIR} |
1494 |
|
fi |
1495 |
|
fi |
1496 |
|
|
1497 |
|
if [[ ${SMAGE_PURGE} = true ]] |
1498 |
|
then |
1499 |
|
if [[ -n ${SPLIT_PACKAGES} ]] |
1500 |
|
then |
1501 |
|
for subpackage in ${SPLIT_PACKAGES} |
1502 |
|
do |
1503 |
|
echo -e "${COLBLUE}===${COLGREEN} purging all purge targets in '${subpackage}' ...${COLDEFAULT}" |
1504 |
|
mpurgetargets ${BINDIR}_${subpackage} |
1505 |
|
done |
1506 |
|
else |
1507 |
|
echo -e "${COLBLUE}===${COLGREEN} purging all purge targets ...${COLDEFAULT}" |
1508 |
|
mpurgetargets ${BINDIR} |
1509 |
|
fi |
1510 |
fi |
fi |
1511 |
|
|
1512 |
# stripping all bins and libs |
# stripping all bins and libs |
1515 |
echo -e "NOSTRIP=true detected; Package will not be stripped ..." |
echo -e "NOSTRIP=true detected; Package will not be stripped ..." |
1516 |
;; |
;; |
1517 |
*) |
*) |
1518 |
echo -e "Stripping binaries ..." |
if [[ -n ${SPLIT_PACKAGES} ]] |
1519 |
mstripbins ${BINDIR} |
then |
1520 |
echo -e "Stripping libraries ..." |
for subpackage in ${SPLIT_PACKAGES} |
1521 |
mstriplibs ${BINDIR} |
do |
1522 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" |
1523 |
|
mstripbins ${BINDIR}_${subpackage} |
1524 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}" |
1525 |
|
mstriplibs ${BINDIR}_${subpackage} |
1526 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}" |
1527 |
|
mstripstatic ${BINDIR}_${subpackage} |
1528 |
|
done |
1529 |
|
else |
1530 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" |
1531 |
|
mstripbins ${BINDIR} |
1532 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}" |
1533 |
|
mstriplibs ${BINDIR} |
1534 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}" |
1535 |
|
mstripstatic ${BINDIR} |
1536 |
|
fi |
1537 |
;; |
;; |
1538 |
esac |
esac |
1539 |
|
|
1544 |
;; |
;; |
1545 |
*) |
*) |
1546 |
# build several targets |
# build several targets |
1547 |
if [ -n "${MAGE_TARGETS}" ] |
if [[ -n ${MAGE_TARGETS} ]] |
1548 |
then |
then |
1549 |
for target in ${MAGE_TARGETS} |
for target in ${MAGE_TARGETS} |
1550 |
do |
do |
1551 |
# check if an special target_pkgbuild exists |
# check if a special target_pkgbuild exists |
1552 |
if typeset -f ${target}_pkgbuild > /dev/null |
if typeset -f ${target}_pkgbuild > /dev/null |
1553 |
then |
then |
1554 |
# run it |
# run it |
1568 |
--parch "${ARCH}" \ |
--parch "${ARCH}" \ |
1569 |
--target "${target}" |
--target "${target}" |
1570 |
|
|
1571 |
echo -e "\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n" |
echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" |
1572 |
|
done |
1573 |
|
|
1574 |
|
# build several subpackages |
1575 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
1576 |
|
then |
1577 |
|
split_save_variables |
1578 |
|
for subpackage in ${SPLIT_PACKAGES} |
1579 |
|
do |
1580 |
|
# get the right variables for the split |
1581 |
|
export PNAME="${subpackage}" |
1582 |
|
split_info_${PNAME} |
1583 |
|
|
1584 |
|
# jump to next one if NOPKGBUILD is set in split_info |
1585 |
|
case ${NOPKGBUILD} in |
1586 |
|
true|TRUE|yes|y) continue ;; |
1587 |
|
esac |
1588 |
|
|
1589 |
|
# check if an special subpackage_pkgbuild exists |
1590 |
|
if typeset -f ${PNAME}_pkgbuild > /dev/null |
1591 |
|
then |
1592 |
|
# run it |
1593 |
|
${PNAME}_pkgbuild |
1594 |
|
fi |
1595 |
|
# now create the target package |
1596 |
|
${MLIBDIR}/pkgbuild_dir.sh \ |
1597 |
|
"${PNAME}-${PVER}-${ARCH}-${PBUILD}" \ |
1598 |
|
"${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed" |
1599 |
|
|
1600 |
|
# build pkg-md5-sum if requested |
1601 |
|
generate_package_md5sum \ |
1602 |
|
--pcat "${PCATEGORIE}" \ |
1603 |
|
--pname "${PNAME}" \ |
1604 |
|
--pver "${PVER}" \ |
1605 |
|
--pbuild "${PBUILD}" \ |
1606 |
|
--parch "${ARCH}" |
1607 |
|
|
1608 |
|
echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" |
1609 |
|
|
1610 |
|
# restore smage environment |
1611 |
|
split_restore_variables |
1612 |
done |
done |
1613 |
|
# unset all saved smage variables |
1614 |
|
split_unset_variables |
1615 |
|
|
1616 |
else |
else |
1617 |
${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
1618 |
|
|
1624 |
--pbuild "${PBUILD}" \ |
--pbuild "${PBUILD}" \ |
1625 |
--parch "${ARCH}" |
--parch "${ARCH}" |
1626 |
|
|
1627 |
echo -e "\nPackage ${PKGNAME} successfully builded.\n" |
echo -e "${COLGREEN}\nPackage ${PKGNAME} successfully builded.\n${COLDEFAULT}" |
1628 |
fi |
fi |
1629 |
|
|
1630 |
|
# build src-pkg-tarball if requested |
1631 |
|
[[ ${CREATE_SRC_PKG_TARBALL} = true ]] && source_pkg_build ${SMAGENAME} |
1632 |
;; |
;; |
1633 |
esac |
esac |
1634 |
|
|
1635 |
|
if [[ ${SMAGE_BUILD_LOGGING} != false ]] |
1636 |
|
then |
1637 |
|
bzip2 -9f /var/log/smage/${PKGNAME}.log |
1638 |
|
else |
1639 |
|
[[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log |
1640 |
|
fi |
1641 |
|
|
1642 |
# for sure |
# for sure |
1643 |
unset NOPKGBUILD |
unset NOPKGBUILD |
1644 |
unset NOSTRIP |
unset NOSTRIP |
1645 |
|
|
1646 |
xtitleclean |
xtitleclean |
|
#echo -e "\nPackage ${PKGNAME} successfully builded.\n" |
|