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.57 2007-04-23 16:41:44 niro Exp $ |
|
8 |
|
|
|
#01.10.2004 |
|
|
# added ccache support |
|
|
# added distcc support |
|
9 |
|
|
10 |
# set default user mage.rc |
# set default user mage.rc |
11 |
: ${MAGERC="/etc/mage.rc"} |
: ${MAGERC="/etc/mage.rc"} |
12 |
|
|
|
## setup ## |
|
|
PKGSUFFIX="mpk" |
|
|
SRCPKGSUFFIX="mpks" |
|
|
SMAGENAME="$1" |
|
|
SMAGESUFFIX="smage2" |
|
|
MLIBDIR=/usr/lib/mage |
|
|
SMAGEVERSION="$( < ${MLIBDIR}/version)" |
|
|
|
|
|
## only for tests -> normally in /etc/rc.d/init.d/functions |
|
|
COLRED="\033[1;6m\033[31m" |
|
|
COLGREEN="\033[1;6m\033[32m" |
|
|
COLYELLOW="\033[1;6m\033[33m" |
|
|
COLBLUE="\033[1;6m\033[34m" |
|
|
COLMAGENTA="\033[1;6m\033[35m" |
|
|
COLWHITE="\033[1;6m\033[37m" |
|
|
COLGRAY="\033[0;6m\033[37m" |
|
|
COLBOLD="\033[1m" |
|
|
COLDEFAULT="\033[0m" |
|
|
|
|
|
if [[ ${NOCOLORS} = true ]] |
|
|
then |
|
|
COLRED="" |
|
|
COLGREEN="" |
|
|
COLYELLOW="" |
|
|
COLBLUE="" |
|
|
COLMAGENTA="" |
|
|
COLWHITE="" |
|
|
COLGRAY="" |
|
|
COLBOLD="" |
|
|
COLDEFAULT="" |
|
|
fi |
|
|
|
|
13 |
# export default C locale |
# export default C locale |
14 |
export LC_ALL=C |
export LC_ALL=C |
15 |
|
|
16 |
source /etc/mage.rc.global |
source /etc/mage.rc.global |
17 |
source ${MAGERC} |
source ${MAGERC} |
18 |
|
source ${MLIBDIR}/mage4.functions.sh |
19 |
|
|
20 |
|
## setup ## |
21 |
|
SMAGENAME="$1" |
22 |
|
SMAGEVERSION="$(< ${MLIBDIR}/version)" |
23 |
|
|
24 |
# set PKGDIR and BUILDDIR and BINDIR to MROOT |
# set PKGDIR and BUILDDIR and BINDIR to MROOT |
25 |
if [[ -n ${MROOT} ]] |
if [[ -n ${MROOT} ]] |
29 |
export BINDIR=${MROOT}/${BINDIR} |
export BINDIR=${MROOT}/${BINDIR} |
30 |
fi |
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 |
{ |
{ |
61 |
echo -en "Magellan Source Install v${SMAGEVERSION} " |
echo -en "Magellan Source Install v${SMAGEVERSION} " |
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 ]] |
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, no 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 |
|
|
|
|
|
# if an mirrored file than replace first the mirror uri |
|
|
if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]] |
|
|
then |
|
|
for mirror in ${MIRRORS} |
|
|
do |
|
|
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")" |
|
|
|
|
|
if [[ ${FETCHING} = true ]] |
|
|
then |
|
|
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
|
|
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 |
|
|
elif [[ -n $(echo ${my_SRC_URI} | grep 'sourceforge://') ]] |
|
|
then |
|
|
for mirror in ${SOURCEFORGE_MIRRORS} |
|
|
do |
|
|
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|sourceforge:/|${mirror}|g")" |
|
|
|
|
|
if [[ ${FETCHING} = true ]] |
|
|
then |
|
|
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
|
|
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 |
|
|
elif [[ -n $(echo ${my_SRC_URI} | grep 'gnu://') ]] |
|
|
then |
|
|
for mirror in ${GNU_MIRRORS} |
|
|
do |
|
|
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnu:/|${mirror}|g")" |
|
|
|
|
|
if [[ ${FETCHING} = true ]] |
|
|
then |
|
|
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
|
|
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 |
|
|
elif [[ -n $(echo ${my_SRC_URI} | grep 'kde://') ]] |
|
|
then |
|
|
for mirror in ${KDE_MIRRORS} |
|
|
do |
|
|
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|kde:/|${mirror}|g")" |
|
167 |
|
|
168 |
if [[ ${FETCHING} = true ]] |
# subdir in sources dir; the my_SRCI_URI file goes to there |
169 |
then |
subdir="${SRC_URI[${i}]##*' '}" |
|
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
|
|
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 |
|
|
elif [[ -n $(echo ${my_SRC_URI} | grep 'gnome://') ]] |
|
|
then |
|
|
for mirror in ${GNOME_MIRRORS} |
|
|
do |
|
|
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnome:/|${mirror}|g")" |
|
170 |
|
|
171 |
if [[ ${FETCHING} = true ]] |
# if $subdir is not equal with $uri then an other dir is used |
172 |
then |
if [[ ${uri} != ${subdir} ]] |
|
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
|
|
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 |
|
|
if [[ ${FETCHING} = true ]] |
|
173 |
then |
then |
174 |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}" |
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}" |
|
177 |
fi |
fi |
|
fi |
|
178 |
|
|
179 |
# unset them to be shure |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${uri}${COLDEFAULT}" |
180 |
unset my_SRC_URI |
# do not die here, mchecksum catches download errors |
181 |
unset my_SRC_URI_DEST |
mdownload --uri "${uri}" --dir "${outputdir}" |
182 |
unset my_SRC_URI_MIRROR |
|
183 |
unset my_SOURCEDIR |
# unset them to be sure |
184 |
done |
unset uri |
185 |
|
unset subdir |
186 |
|
unset outputdir |
187 |
|
done |
188 |
|
|
189 |
# recheck md5 sums |
# recheck md5 sums after download |
190 |
echo |
echo |
191 |
echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}" |
192 |
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed" |
mchecksum --rundir "${SOURCEDIR}/${PNAME}" --file "${db_md5_file}" --method md5 || die "md5 failed" |
193 |
echo |
echo |
194 |
|
else |
195 |
|
echo -e "${COLBLUE}===${COLGREEN} All sources already fetched, nothing to do${COLDEFAULT}" |
196 |
|
fi |
197 |
|
|
198 |
# not needed anymore |
# not needed anymore |
199 |
unset SRC_URI |
unset SRC_URI |
200 |
} |
} |
201 |
|
|
202 |
# dummy function, used if that not exist in smage file |
# dummy function, used if that does not exist in smage file |
203 |
src_prepare() |
src_prepare() |
204 |
{ |
{ |
205 |
echo "no src_prepare defined" |
echo "no src_prepare defined; doing nothing ..." |
|
sleep 2 |
|
206 |
return 0 |
return 0 |
207 |
} |
} |
208 |
|
|
209 |
# dummy function, used if that not exist in smage file |
# dummy function, used if that does not exist in smage file |
210 |
src_compile() |
src_compile() |
211 |
{ |
{ |
212 |
echo "no src_compile defined" |
echo "no src_compile defined; doing nothing ..." |
|
sleep 2 |
|
213 |
return 0 |
return 0 |
214 |
} |
} |
215 |
|
|
216 |
# dummy function, used if that not exist in smage file |
# dummy function, used if that does not exist in smage file |
217 |
|
src_check() |
218 |
|
{ |
219 |
|
echo "no src_check defined; doing nothing ..." |
220 |
|
return 0 |
221 |
|
} |
222 |
|
|
223 |
|
# dummy function, used if that does not exist in smage file |
224 |
src_install() |
src_install() |
225 |
{ |
{ |
226 |
echo "no src_install defined" |
echo "no src_install defined; doing nothing ..." |
|
sleep 2 |
|
227 |
return 0 |
return 0 |
228 |
} |
} |
229 |
|
|
237 |
|
|
238 |
mconfigure() |
mconfigure() |
239 |
{ |
{ |
240 |
|
local myopts |
241 |
|
if [[ ! -z ${CTARGET} ]] |
242 |
|
then |
243 |
|
myopts="--target=${CTARGET}" |
244 |
|
fi |
245 |
|
|
246 |
if [ -x ./configure ] |
if [ -x ./configure ] |
247 |
then |
then |
248 |
./configure \ |
./configure \ |
249 |
--prefix=/usr \ |
--prefix=/usr \ |
250 |
--host=${CHOST} \ |
--host=${CHOST} \ |
251 |
|
--build=${CHOST} \ |
252 |
--mandir=/usr/share/man \ |
--mandir=/usr/share/man \ |
253 |
--infodir=/usr/share/info \ |
--infodir=/usr/share/info \ |
254 |
--datadir=/usr/share \ |
--datadir=/usr/share \ |
255 |
--sysconfdir=/etc \ |
--sysconfdir=/etc \ |
256 |
--localstatedir=/var/lib \ |
--localstatedir=/var/lib \ |
257 |
--libdir=/usr/$(mlibdir) \ |
--libdir=/usr/$(mlibdir) \ |
258 |
|
${myopts} \ |
259 |
"$@" || die "mconfigure failed" |
"$@" || die "mconfigure failed" |
260 |
else |
else |
261 |
echo "configure is not an executable ..." |
echo "configure is not an executable ..." |
293 |
|
|
294 |
SRCFILE=$1 |
SRCFILE=$1 |
295 |
|
|
296 |
if [ -z "$2" ] |
if [[ -z $2 ]] |
297 |
then |
then |
298 |
DEST=${BUILDDIR} |
DEST=${BUILDDIR} |
299 |
else |
else |
308 |
IFTAR="${IFTAR##*.}" |
IFTAR="${IFTAR##*.}" |
309 |
if [[ ${IFTAR} = tar ]] |
if [[ ${IFTAR} = tar ]] |
310 |
then |
then |
311 |
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." |
312 |
|
else |
313 |
|
pushd ${DEST} > /dev/null |
314 |
|
bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed." |
315 |
|
popd > /dev/null |
316 |
fi |
fi |
317 |
;; |
;; |
318 |
gz) |
gz) |
320 |
IFTAR="${IFTAR##*.}" |
IFTAR="${IFTAR##*.}" |
321 |
if [[ ${IFTAR} = tar ]] |
if [[ ${IFTAR} = tar ]] |
322 |
then |
then |
323 |
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." |
324 |
|
else |
325 |
|
pushd ${DEST} > /dev/null |
326 |
|
zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed." |
327 |
|
popd > /dev/null |
328 |
|
fi |
329 |
|
;; |
330 |
|
xz) |
331 |
|
IFTAR="$(basename $SRCFILE .xz)" |
332 |
|
IFTAR="${IFTAR##*.}" |
333 |
|
if [[ ${IFTAR} = tar ]] |
334 |
|
then |
335 |
|
tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.xz unpack failed." |
336 |
|
else |
337 |
|
pushd ${DEST} > /dev/null |
338 |
|
xzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .xz) || die ".xz unpack failed." |
339 |
|
popd > /dev/null |
340 |
fi |
fi |
341 |
;; |
;; |
342 |
tbz2) |
tbz2|mpks|mpk) |
343 |
tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} |
tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed." |
344 |
;; |
;; |
345 |
tgz) |
tgz) |
346 |
tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} |
tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed." |
347 |
|
;; |
348 |
|
txz|mpkzs|mpkz) |
349 |
|
tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed." |
350 |
|
;; |
351 |
|
rar) |
352 |
|
unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed." |
353 |
|
;; |
354 |
|
zip|xpi|jar) |
355 |
|
unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed." |
356 |
|
;; |
357 |
|
rpm) |
358 |
|
pushd ${DEST} > /dev/null |
359 |
|
rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed." |
360 |
|
tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed." |
361 |
|
if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]] |
362 |
|
then |
363 |
|
rm ${DEST}/${SRCFILE/.rpm/.tar.gz} |
364 |
|
fi |
365 |
;; |
;; |
366 |
*) |
*) |
367 |
die "munpack failed" |
die "munpack failed" |
398 |
patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} |
patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} |
399 |
} |
} |
400 |
|
|
401 |
|
mlibtoolize() |
402 |
|
{ |
403 |
|
local opts="$@" |
404 |
|
[[ -z ${opts} ]] && opts="--verbose --install --force" |
405 |
|
|
406 |
|
libtoolize ${opts} || die "running: mlibtoolize ${opts}" |
407 |
|
} |
408 |
|
|
409 |
|
mautoreconf() |
410 |
|
{ |
411 |
|
local opts="$@" |
412 |
|
[[ -z ${opts} ]] && opts="--verbose --install --force" |
413 |
|
|
414 |
|
autoreconf ${opts} || die "running: mautoreconf ${opts}" |
415 |
|
} |
416 |
|
|
417 |
minstalldocs() |
minstalldocs() |
418 |
{ |
{ |
419 |
local docfiles |
local docfiles |
420 |
|
local doc |
421 |
docfiles="$@" |
docfiles="$@" |
422 |
|
|
423 |
if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ] |
if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ] |
425 |
install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." |
install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." |
426 |
fi |
fi |
427 |
|
|
428 |
for i in ${docfiles} |
for doc in ${docfiles} |
429 |
do |
do |
430 |
cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs." |
if [ -f ${doc} ] |
431 |
install -m 0644 ${SRCDIR}/${i}.gz \ |
then |
432 |
${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs." |
if mqueryfeature "compressdoc" |
433 |
|
then |
434 |
|
cat ${doc} | gzip -9c > ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/$(basename ${doc}).gz || die "gzipping +installing ${doc}." |
435 |
|
chmod 0644 ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/$(basename ${doc}).gz || die "fixing permissions of ${doc}." |
436 |
|
else |
437 |
|
install -m 0644 ${SRCDIR}/${i} ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "installing ${doc}." |
438 |
|
fi |
439 |
|
fi |
440 |
done |
done |
441 |
} |
} |
442 |
|
|
444 |
{ |
{ |
445 |
local stripdir="$@" |
local stripdir="$@" |
446 |
|
|
447 |
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
[[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
448 |
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" |
449 |
|
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 |
450 |
} |
} |
451 |
|
|
452 |
mstripbins() |
mstripbins() |
453 |
{ |
{ |
454 |
local stripdir="$@" |
local stripdir="$@" |
455 |
|
|
456 |
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
[[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
457 |
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" |
458 |
|
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 |
459 |
|
} |
460 |
|
|
461 |
|
mstripstatic() |
462 |
|
{ |
463 |
|
local stripdir="$@" |
464 |
|
|
465 |
|
[[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
466 |
|
[[ -z ${STRIP_STATIC_LIB} ]] && STRIP_STATIC_LIB="--strip-debug" |
467 |
|
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 |
468 |
|
} |
469 |
|
|
470 |
|
mstriplibtoolarchive() |
471 |
|
{ |
472 |
|
local stripdir="$@" |
473 |
|
|
474 |
|
[[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
475 |
|
find ${stripdir} ! -type d -name \*.la | xargs | grep "libtool library" | cut -f 1 -d : | xargs --no-run-if-empty rm -f -- 2> /dev/null |
476 |
|
} |
477 |
|
|
478 |
|
mpurgetargets() |
479 |
|
{ |
480 |
|
local stripdir="$@" |
481 |
|
local target |
482 |
|
|
483 |
|
[[ -z ${stripdir} ]] && stripdir=${BINDIR} |
484 |
|
# nothing to do in this case |
485 |
|
[[ -z ${PURGE_TARGETS[*]} ]] && return |
486 |
|
|
487 |
|
for target in ${PURGE_TARGETS[*]} |
488 |
|
do |
489 |
|
# check if target is a regex pattern without any slashes |
490 |
|
if [[ ${target} = ${target//\/} ]] |
491 |
|
then |
492 |
|
find ${BINDIR} -type f -name "${target}" | xargs --no-run-if-empty rm -f -- 2> /dev/null |
493 |
|
else |
494 |
|
rm -f -- ${target} 2> /dev/null |
495 |
|
fi |
496 |
|
done |
497 |
|
} |
498 |
|
|
499 |
|
mcompressdocs() |
500 |
|
{ |
501 |
|
local bindir="$@" |
502 |
|
|
503 |
|
if [ -d ${bindir}/usr/share/man ] |
504 |
|
then |
505 |
|
echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}" |
506 |
|
${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man |
507 |
|
fi |
508 |
|
|
509 |
|
if [ -d ${bindir}/usr/share/info ] |
510 |
|
then |
511 |
|
echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}" |
512 |
|
${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info |
513 |
|
fi |
514 |
} |
} |
515 |
|
|
516 |
sminclude() |
sminclude() |
552 |
fi |
fi |
553 |
} |
} |
554 |
|
|
|
|
|
555 |
# fixes given dependencies to match a MAGE_TARGET |
# fixes given dependencies to match a MAGE_TARGET |
556 |
# fix_mage_deps -target s/depend # <-- note -target ! |
# fix_mage_deps -target s/depend # <-- note -target ! |
557 |
fix_mage_deps() |
fix_mage_deps() |
625 |
# special tags: |
# special tags: |
626 |
# PKGTYPE type of pkg |
# PKGTYPE type of pkg |
627 |
# INHERITS which functions get included |
# INHERITS which functions get included |
628 |
# SPECIAL_FUNCTIONS special functions wich should also be added |
# SPECIAL_FUNCTIONS special functions which should also be added |
629 |
# warning: they get killed before the build starts ! |
# warning: they get killed before the build starts ! |
630 |
|
# SPLIT_PACKAGES names of all subpackages which are splitted from parent |
631 |
|
# SPLIT_PACKAGE_BASE base package name for splitpackages |
632 |
|
# (only in the resulting magefile} |
633 |
# |
# |
634 |
# MAGE_TREE_DEST target destination of the generated tree |
# MAGE_TREE_DEST target destination of the generated tree |
635 |
# REGEN_MAGE_TREE set to 'true' to enable this |
# REGEN_MAGE_TREE set to 'true' to enable this |
640 |
local magefile |
local magefile |
641 |
local dest |
local dest |
642 |
local target |
local target |
643 |
|
local split_pkg_base |
644 |
local sym |
local sym |
645 |
local depname |
local depname |
646 |
|
|
648 |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
649 |
|
|
650 |
# determinate which suffix this mage file should get, if any |
# determinate which suffix this mage file should get, if any |
651 |
[ -n "$1" ] && target="-$1" |
[[ $1 = --target ]] && shift && target="-$1" |
652 |
|
|
653 |
|
# mark package as splitpackage |
654 |
|
[[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1" |
655 |
|
|
656 |
# name of magefile |
# name of magefile |
657 |
magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
667 |
# now build the mage file |
# now build the mage file |
668 |
> ${dest} |
> ${dest} |
669 |
|
|
|
# header |
|
|
echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.57 2007-04-23 16:41:44 niro Exp $' >> ${dest} |
|
|
echo >> ${dest} |
|
|
|
|
670 |
# pgkname and state |
# pgkname and state |
671 |
echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
672 |
echo "STATE=\"${STATE}\"" >> ${dest} |
echo "STATE=\"${STATE}\"" >> ${dest} |
|
echo >> ${dest} |
|
673 |
|
|
674 |
# description and homepage |
# description and homepage |
675 |
echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} |
echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} |
676 |
echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
|
echo >> ${dest} |
|
677 |
|
|
678 |
# special tags and vars |
# special tags and vars |
679 |
echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
680 |
|
|
681 |
# echo MAGE_TARGETS ## note -target is needed ! |
# echo MAGE_TARGETS ## note -target is needed ! |
682 |
echo "MAGE_TARGETS=\"${target}\"" >> ${dest} |
echo "MAGE_TARGETS=\"${target}\"" >> ${dest} |
683 |
echo >> ${dest} |
|
684 |
|
# split package base |
685 |
|
echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest} |
686 |
|
|
687 |
# add special vars |
# add special vars |
688 |
if [ -n "${SPECIAL_VARS}" ] |
if [ -n "${SPECIAL_VARS}" ] |
693 |
# being tricky here :) |
# being tricky here :) |
694 |
echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} |
echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} |
695 |
done |
done |
|
echo >> ${dest} |
|
696 |
fi |
fi |
697 |
|
|
698 |
# add at least all includes |
# add at least all includes |
704 |
do |
do |
705 |
echo -n " ${i}" >> ${dest} |
echo -n " ${i}" >> ${dest} |
706 |
done |
done |
707 |
echo >> ${dest} |
# a CRLF is needed here! |
708 |
|
echo >> ${dest} |
709 |
fi |
fi |
|
echo >> ${dest} |
|
710 |
|
|
711 |
# deps and provides |
# deps and provides |
712 |
echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
|
echo >> ${dest} |
|
713 |
echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
|
echo >> ${dest} |
|
714 |
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
|
echo >> ${dest} |
|
715 |
|
|
716 |
# add special functions |
# add special functions |
717 |
if [ -n "${SPECIAL_FUNCTIONS}" ] |
if [ -n "${SPECIAL_FUNCTIONS}" ] |
721 |
do |
do |
722 |
# add to mage (quotes needed !) |
# add to mage (quotes needed !) |
723 |
typeset -f "${i}" >> ${dest} |
typeset -f "${i}" >> ${dest} |
|
echo >> ${dest} |
|
724 |
# unset to be safe (quotes needed !) |
# unset to be safe (quotes needed !) |
725 |
#unset "${i}" <-- later to get every target built |
#unset "${i}" <-- later to get every target built |
726 |
done |
done |
|
echo >> ${dest} |
|
727 |
fi |
fi |
728 |
|
|
729 |
# pre|post-install|removes |
# pre|post-install|removes |
730 |
typeset -f preinstall >> ${dest} |
typeset -f preinstall >> ${dest} |
|
echo >> ${dest} |
|
731 |
typeset -f postinstall >> ${dest} |
typeset -f postinstall >> ${dest} |
|
echo >> ${dest} |
|
732 |
typeset -f preremove >> ${dest} |
typeset -f preremove >> ${dest} |
|
echo >> ${dest} |
|
733 |
typeset -f postremove >> ${dest} |
typeset -f postremove >> ${dest} |
|
echo >> ${dest} |
|
734 |
} |
} |
735 |
|
|
736 |
regen_mage_tree() |
regen_mage_tree() |
737 |
{ |
{ |
738 |
local i |
local subpackage |
739 |
|
|
740 |
# build them only if requested |
# build them only if requested |
741 |
if [[ ${REGEN_MAGE_TREE} = true ]] |
if mqueryfeature regentree |
742 |
then |
then |
743 |
# run it without targets |
# run it without targets |
744 |
if [ -z "${MAGE_TARGETS}" ] |
if [[ -n ${MAGE_TARGETS} ]] |
745 |
then |
then |
746 |
|
# build for each target a mage file |
747 |
|
# run it with several targets |
748 |
echo |
echo |
749 |
build_mage_script |
for subpackage in ${MAGE_TARGETS} |
750 |
|
do |
751 |
|
build_mage_script --target "${subpackage}" |
752 |
|
done |
753 |
echo |
echo |
|
else |
|
754 |
|
|
755 |
# build for each target an mage file |
# run it for splitpackages |
756 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
757 |
|
then |
758 |
|
local split_pkg_base="${PNAME}" |
759 |
|
# save smage environment |
760 |
|
split_save_variables |
761 |
|
# build for each subpackage a mage file |
762 |
# run it with several targets |
# run it with several targets |
763 |
for i in ${MAGE_TARGETS} |
echo |
764 |
|
for subpackage in ${SPLIT_PACKAGES} |
765 |
do |
do |
766 |
echo |
# get the right variables for the split |
767 |
build_mage_script "${i}" |
export PNAME="${subpackage}" |
768 |
echo |
split_info_${subpackage} |
769 |
|
# get the preinstall etc |
770 |
|
split_export_inherits ${subpackage} |
771 |
|
build_mage_script --split-pkg-base "${split_pkg_base}" |
772 |
|
# delete split preinstall etc |
773 |
|
split_delete_inherits ${subpackage} |
774 |
|
# restore smage environment |
775 |
|
split_restore_variables |
776 |
done |
done |
777 |
|
echo |
778 |
|
# unset all saved smage variables |
779 |
|
split_unset_variables |
780 |
|
|
781 |
|
else |
782 |
|
echo |
783 |
|
build_mage_script |
784 |
|
echo |
785 |
fi |
fi |
786 |
fi |
fi |
787 |
|
|
801 |
unset STATE |
unset STATE |
802 |
unset DESCRIPTION |
unset DESCRIPTION |
803 |
unset HOMEPAGE |
unset HOMEPAGE |
804 |
unset PKGTYPE |
# unset PKGTYPE <-- don't do that either; smage needs this var |
805 |
unset INHERITS |
unset INHERITS |
806 |
unset DEPEND |
unset DEPEND |
807 |
unset SDEPEND |
unset SDEPEND |
812 |
unset postremove |
unset postremove |
813 |
} |
} |
814 |
|
|
815 |
|
split_save_variables() |
816 |
|
{ |
817 |
|
export SAVED_PNAME="${PNAME}" |
818 |
|
export SAVED_PVER="${PVER}" |
819 |
|
export SAVED_PBUILD="${PBUILD}" |
820 |
|
export SAVED_PCATEGORIE="${PCATEGORIE}" |
821 |
|
export SAVED_DESCRIPTION="${DESCRIPTION}" |
822 |
|
export SAVED_HOMEPAGE="${HOMEPAGE}" |
823 |
|
export SAVED_SPECIAL_VARS="${SPECIAL_VARS}" |
824 |
|
export SAVED_STATE="${STATE}" |
825 |
|
export SAVED_PKGTYPE="${PKGTYPE}" |
826 |
|
export SAVED_INHERITS="${INHERITS}" |
827 |
|
export SAVED_DEPEND="${DEPEND}" |
828 |
|
export SAVED_SDEPEND="${SDEPEND}" |
829 |
|
export SAVED_PROVIDE="${PROVIDE}" |
830 |
|
export SAVED_PKGTYPE="${PKGTYPE}" |
831 |
|
|
832 |
|
# special handling needed for mage features |
833 |
|
# pkgbuild |
834 |
|
mqueryfeature "pkgbuild" && export SAVED_FEATURE_PKGBUILD="pkgbuild" |
835 |
|
mqueryfeature "!pkgbuild" && export SAVED_FEATURE_PKGBUILD="!pkgbuild" |
836 |
|
# strip |
837 |
|
mqueryfeature "strip" && export SAVED_FEATURE_STRIP="strip" |
838 |
|
mqueryfeature "!strip" && export SAVED_FEATURE_STRIP="!strip" |
839 |
|
# libtool |
840 |
|
mqueryfeature "libtool" && export SAVED_FEATURE_LIBTOOL="libtool" |
841 |
|
mqueryfeature "!libtool" && export SAVED_FEATURE_LIBTOOL="!libtool" |
842 |
|
# compressdoc |
843 |
|
mqueryfeature "compressdoc" && export SAVED_FEATURE_COMPRESSDOC="compressdoc" |
844 |
|
mqueryfeature "!compressdoc" && export SAVED_FEATURE_COMPRESSDOC="!compressdoc" |
845 |
|
|
846 |
|
# bindir too |
847 |
|
export SAVED_BINDIR="${BINDIR}" |
848 |
|
|
849 |
|
# export the SPLIT_PACKAGE_BASE |
850 |
|
export SPLIT_PACKAGE_BASE="${SAVED_PNAME}" |
851 |
|
|
852 |
|
# functions |
853 |
|
if [[ ! -z $(typeset -f preinstall) ]] |
854 |
|
then |
855 |
|
# rename the old one |
856 |
|
local saved_preinstall |
857 |
|
saved_preinstall=SAVED_$(typeset -f preinstall) |
858 |
|
eval "${saved_preinstall}" |
859 |
|
export -f SAVED_preinstall |
860 |
|
fi |
861 |
|
|
862 |
|
if [[ ! -z $(typeset -f postinstall) ]] |
863 |
|
then |
864 |
|
# rename the old one |
865 |
|
local saved_postinstall |
866 |
|
saved_postinstall=SAVED_$(typeset -f postinstall) |
867 |
|
eval "${saved_postinstall}" |
868 |
|
export -f SAVED_postinstall |
869 |
|
fi |
870 |
|
|
871 |
|
if [[ ! -z $(typeset -f preremove) ]] |
872 |
|
then |
873 |
|
# rename the old one |
874 |
|
local saved_preremove |
875 |
|
saved_preremove=SAVED_$(typeset -f preremove) |
876 |
|
eval "${saved_preremove}" |
877 |
|
export -f SAVED_preremove |
878 |
|
fi |
879 |
|
|
880 |
|
if [[ ! -z $(typeset -f postremove) ]] |
881 |
|
then |
882 |
|
# rename the old one |
883 |
|
local saved_postremove |
884 |
|
saved_postremove=SAVED_$(typeset -f postremove) |
885 |
|
eval "${saved_postremove}" |
886 |
|
export -f SAVED_postremove |
887 |
|
fi |
888 |
|
} |
889 |
|
|
890 |
|
split_restore_variables() |
891 |
|
{ |
892 |
|
export PNAME="${SAVED_PNAME}" |
893 |
|
export PVER="${SAVED_PVER}" |
894 |
|
export PBUILD="${SAVED_PBUILD}" |
895 |
|
export PCATEGORIE="${SAVED_PCATEGORIE}" |
896 |
|
export DESCRIPTION="${SAVED_DESCRIPTION}" |
897 |
|
export HOMEPAGE="${SAVED_HOMEPAGE}" |
898 |
|
export SPECIAL_VARS="${SAVED_SPECIAL_VARS}" |
899 |
|
export STATE="${SAVED_STATE}" |
900 |
|
export PKGTYPE="${SAVED_PKGTYPE}" |
901 |
|
export INHERITS="${SAVED_INHERITS}" |
902 |
|
export DEPEND="${SAVED_DEPEND}" |
903 |
|
export SDEPEND="${SAVED_SDEPEND}" |
904 |
|
export PROVIDE="${SAVED_PROVIDE}" |
905 |
|
export PKGTYPE="${SAVED_PKGTYPE}" |
906 |
|
|
907 |
|
# special handling needed for mage features |
908 |
|
# pkgbuild |
909 |
|
FVERBOSE=off msetfeature "${SAVED_FEATURE_PKGBUILD}" |
910 |
|
# strip |
911 |
|
FVERBOSE=off msetfeature "${SAVED_FEATURE_STRIP}" |
912 |
|
# libtool |
913 |
|
FVERBOSE=off msetfeature "${SAVED_FEATURE_LIBTOOL}" |
914 |
|
# compressdoc |
915 |
|
FVERBOSE=off msetfeature "${SAVED_FEATURE_COMPRESSDOC}" |
916 |
|
|
917 |
|
# bindir too |
918 |
|
export BINDIR="${SAVED_BINDIR}" |
919 |
|
|
920 |
|
# functions |
921 |
|
if [[ ! -z $(typeset -f SAVED_preinstall) ]] |
922 |
|
then |
923 |
|
# rename the old one |
924 |
|
local saved_preinstall |
925 |
|
saved_preinstall=$(typeset -f SAVED_preinstall) |
926 |
|
eval "${saved_preinstall/SAVED_/}" |
927 |
|
export -f preinstall |
928 |
|
fi |
929 |
|
|
930 |
|
if [[ ! -z $(typeset -f SAVED_postinstall) ]] |
931 |
|
then |
932 |
|
# rename the old one |
933 |
|
local saved_postinstall |
934 |
|
saved_postinstall=$(typeset -f SAVED_postinstall) |
935 |
|
eval "${saved_postinstall/SAVED_/}" |
936 |
|
export -f postinstall |
937 |
|
fi |
938 |
|
|
939 |
|
if [[ ! -z $(typeset -f SAVED_preremove) ]] |
940 |
|
then |
941 |
|
# rename the old one |
942 |
|
local saved_preremove |
943 |
|
saved_preremove=$(typeset -f SAVED_preremove) |
944 |
|
eval "${saved_preremove/SAVED_/}" |
945 |
|
export -f preremove |
946 |
|
fi |
947 |
|
|
948 |
|
if [[ ! -z $(typeset -f SAVED_postremove) ]] |
949 |
|
then |
950 |
|
# rename the old one |
951 |
|
local saved_postremove |
952 |
|
saved_postremove=$(typeset -f SAVED_postremove) |
953 |
|
eval "${saved_postremove/SAVED_/}" |
954 |
|
export -f postremove |
955 |
|
fi |
956 |
|
} |
957 |
|
|
958 |
|
split_unset_variables() |
959 |
|
{ |
960 |
|
# unset saved vars; not needed anymore |
961 |
|
unset SAVED_PNAME |
962 |
|
unset SAVED_PVER |
963 |
|
unset SAVED_PBUILD |
964 |
|
unset SAVED_PCATEGORIE |
965 |
|
unset SAVED_DESCRIPTION |
966 |
|
unset SAVED_HOMEPAGE |
967 |
|
unset SAVED_SPECIAL_VARS |
968 |
|
unset SAVED_STATE |
969 |
|
unset SAVED_PKGTYPE |
970 |
|
unset SAVED_INHERITS |
971 |
|
unset SAVED_DEPEND |
972 |
|
unset SAVED_SDEPEND |
973 |
|
unset SAVED_PROVIDE |
974 |
|
unset SAVED_BINDIR |
975 |
|
unset SAVED_PKGTYPE |
976 |
|
unset SAVED_FEATURE_PKGBUILD |
977 |
|
unset SAVED_FEATURE_STRIP |
978 |
|
unset SAVED_FEATURE_LIBTOOL |
979 |
|
unset SAVED_FEATURE_COMPRESSDOC |
980 |
|
unset SPLIT_PACKAGE_BASE |
981 |
|
unset -f SAVED_preinstall |
982 |
|
unset -f SAVED_postinstall |
983 |
|
unset -f SAVED_preremove |
984 |
|
unset -f SAVED_postremove |
985 |
|
} |
986 |
|
|
987 |
|
split_export_inherits() |
988 |
|
{ |
989 |
|
local subpackage="$1" |
990 |
|
local func |
991 |
|
local newfunc |
992 |
|
|
993 |
|
for func in preinstall postinstall preremove postremove |
994 |
|
do |
995 |
|
if [[ ! -z $(typeset -f ${func}_${subpackage}) ]] |
996 |
|
then |
997 |
|
newfunc=$(typeset -f ${func}_${subpackage}) |
998 |
|
newfunc="${newfunc/_${subpackage} (/ (}" |
999 |
|
eval "${newfunc}" |
1000 |
|
fi |
1001 |
|
done |
1002 |
|
} |
1003 |
|
|
1004 |
|
split_delete_inherits() |
1005 |
|
{ |
1006 |
|
local subpackage="$1" |
1007 |
|
local func |
1008 |
|
|
1009 |
|
for func in preinstall postinstall preremove postremove |
1010 |
|
do |
1011 |
|
if [[ ! -z $(typeset -f ${func}_${subpackage}) ]] |
1012 |
|
then |
1013 |
|
unset -f ${func} |
1014 |
|
fi |
1015 |
|
done |
1016 |
|
} |
1017 |
|
|
1018 |
export_inherits() |
export_inherits() |
1019 |
{ |
{ |
1020 |
local include="$1" |
local include="$1" |
1080 |
pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" |
pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" |
1081 |
|
|
1082 |
# build pkg-md5-sum only if requested |
# build pkg-md5-sum only if requested |
1083 |
if [[ ${REGEN_MAGE_TREE} = true ]] |
if mqueryfeature regentree |
1084 |
then |
then |
1085 |
echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}" |
echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}" |
1086 |
|
|
1095 |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
1096 |
|
|
1097 |
# setup md5 dir |
# setup md5 dir |
1098 |
dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5" |
dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5" |
1099 |
install -d ${dest} |
install -d ${dest} |
1100 |
|
|
1101 |
# gen md5sum |
# gen md5sum |
1133 |
echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}" |
echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}" |
1134 |
} |
} |
1135 |
|
|
1136 |
|
step_by_step() |
1137 |
|
{ |
1138 |
|
if mqueryfeature stepbystep |
1139 |
|
then |
1140 |
|
echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}" |
1141 |
|
echo "Press [enter] to continue" |
1142 |
|
read |
1143 |
|
fi |
1144 |
|
} |
1145 |
|
|
1146 |
|
resume_stamp() |
1147 |
|
{ |
1148 |
|
local step="$1" |
1149 |
|
touch ${BUILDDIR}/.smage-${PKGNAME}-${step} |
1150 |
|
} |
1151 |
|
|
1152 |
|
run_resume() |
1153 |
|
{ |
1154 |
|
local step="$1" |
1155 |
|
|
1156 |
|
if mqueryfeature "resume" && [[ -f ${BUILDDIR}/.smage-${PKGNAME}-${step} ]] |
1157 |
|
then |
1158 |
|
echo -e "${COLMAGENTA}${step} already processed; doing nothing${COLDEFAULT}" |
1159 |
|
return 0 |
1160 |
|
else |
1161 |
|
return 1 |
1162 |
|
fi |
1163 |
|
} |
1164 |
|
|
1165 |
# print out our version |
# print out our version |
1166 |
showversion |
showversion |
1173 |
exit 1 |
exit 1 |
1174 |
fi |
fi |
1175 |
|
|
1176 |
|
# load supported mage features |
1177 |
|
load_mage_features |
1178 |
|
|
1179 |
# updating smage2-scripts |
# updating smage2-scripts |
1180 |
if [[ $1 = update ]] |
if [[ $1 = update ]] |
1181 |
then |
then |
1190 |
# creates md5sums for smages to given dir |
# creates md5sums for smages to given dir |
1191 |
if [[ $1 = calcmd5 ]] |
if [[ $1 = calcmd5 ]] |
1192 |
then |
then |
1193 |
if [ $# -ge 3 ] |
if [ $# -ge 2 ] |
1194 |
then |
then |
1195 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1196 |
MD5DIR="$3" |
MD5DIR="$3" |
1197 |
source ${SMAGENAME} || die "download source failed" |
[[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5" |
1198 |
|
|
1199 |
|
smagesource ${SMAGENAME} || die "download source failed" |
1200 |
|
|
1201 |
# overridable sourcedir; must be declared after source of the smage2 |
# overridable sourcedir; must be declared after source of the smage2 |
1202 |
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
1248 |
echo |
echo |
1249 |
else |
else |
1250 |
echo "Usage: Calculating MD5 Sums:" |
echo "Usage: Calculating MD5 Sums:" |
1251 |
echo " $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR" |
echo " $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]" |
1252 |
echo |
echo |
1253 |
echo |
echo |
1254 |
echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." |
echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." |
1270 |
# get smage |
# get smage |
1271 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1272 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1273 |
source ${SMAGENAME} || die "download source failed" |
smagesource ${SMAGENAME} || die "download source failed" |
1274 |
|
|
1275 |
download_sources |
download_sources |
1276 |
exit 0 |
exit 0 |
1282 |
# set correct SMAGENAME |
# set correct SMAGENAME |
1283 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1284 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1285 |
source ${SMAGENAME} || die "regen: smage2 not found" |
smagesource ${SMAGENAME} || die "regen: smage2 not found" |
1286 |
|
|
1287 |
regen_mage_tree |
regen_mage_tree |
1288 |
|
|
1289 |
# build md5sum for existing packages |
# build several targets |
1290 |
generate_package_md5sum \ |
if [[ -n ${MAGE_TARGETS} ]] |
1291 |
--pcat "${PCATEGORIE}" \ |
then |
1292 |
--pname "${PNAME}" \ |
for target in ${MAGE_TARGETS} |
1293 |
--pver "${PVER}" \ |
do |
1294 |
--pbuild "${PBUILD}" \ |
# build md5sum for existing packages |
1295 |
--parch "${ARCH}" \ |
generate_package_md5sum \ |
1296 |
--target "${target}" |
--pcat "${PCATEGORIE}" \ |
1297 |
|
--pname "${PNAME}" \ |
1298 |
|
--pver "${PVER}" \ |
1299 |
|
--pbuild "${PBUILD}" \ |
1300 |
|
--parch "${ARCH}" \ |
1301 |
|
--target "${target}" |
1302 |
|
done |
1303 |
|
|
1304 |
|
# build several subpackages |
1305 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
1306 |
|
then |
1307 |
|
split_save_variables |
1308 |
|
for subpackage in ${SPLIT_PACKAGES} |
1309 |
|
do |
1310 |
|
# get the right variables for the split |
1311 |
|
export PNAME="${subpackage}" |
1312 |
|
split_info_${subpackage} |
1313 |
|
# build md5sum for existing packages |
1314 |
|
generate_package_md5sum \ |
1315 |
|
--pcat "${PCATEGORIE}" \ |
1316 |
|
--pname "${PNAME}" \ |
1317 |
|
--pver "${PVER}" \ |
1318 |
|
--pbuild "${PBUILD}" \ |
1319 |
|
--parch "${ARCH}" |
1320 |
|
# restore smage environment |
1321 |
|
split_restore_variables |
1322 |
|
done |
1323 |
|
# unset all saved smage variables |
1324 |
|
split_unset_variables |
1325 |
|
|
1326 |
|
else |
1327 |
|
# build md5sum for existing packages |
1328 |
|
generate_package_md5sum \ |
1329 |
|
--pcat "${PCATEGORIE}" \ |
1330 |
|
--pname "${PNAME}" \ |
1331 |
|
--pver "${PVER}" \ |
1332 |
|
--pbuild "${PBUILD}" \ |
1333 |
|
--parch "${ARCH}" |
1334 |
|
fi |
1335 |
|
|
1336 |
exit 0 |
exit 0 |
1337 |
fi |
fi |
1344 |
|
|
1345 |
echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}" |
echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}" |
1346 |
|
|
1347 |
source ${SMAGENAME} || die "regen: smage2 not found" |
smagesource ${SMAGENAME} || die "regen: smage2 not found" |
1348 |
|
|
1349 |
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
1350 |
then |
then |
1360 |
if [ "$1" == "--src-tarball" -a -n "$2" ] || [ "$1" == "-st" -a -n "$2" ] |
if [ "$1" == "--src-tarball" -a -n "$2" ] || [ "$1" == "-st" -a -n "$2" ] |
1361 |
then |
then |
1362 |
SRCPKGTARBALL="${2}" |
SRCPKGTARBALL="${2}" |
1363 |
USE_SRC_PKG_TARBALL=true |
msetfeature "srcpkgtarball" |
1364 |
|
|
1365 |
# abort if given file is not a source pkg |
# abort if given file is not a source pkg |
1366 |
[[ ${SRCPKGTARBALL##*.} != ${SRCPKGSUFFIX} ]] && die "${SRCPKGTARBALL} is not a valid src-pkg file." |
[[ ${SRCPKGTARBALL##*.} != ${SRCPKGSUFFIX} ]] && die "${SRCPKGTARBALL} is not a valid src-pkg file." |
1381 |
[[ ! -f ${SMAGENAME} ]] && die "Included smage2 file in src-tarball not found: ${SMAGENAME}" |
[[ ! -f ${SMAGENAME} ]] && die "Included smage2 file in src-tarball not found: ${SMAGENAME}" |
1382 |
fi |
fi |
1383 |
|
|
1384 |
|
if [ "$1" == "--resume" -a -n "$2" ] |
1385 |
|
then |
1386 |
|
msetfeature "resume" |
1387 |
|
SMAGENAME="$2" |
1388 |
|
fi |
1389 |
|
|
1390 |
[ ! -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." |
1391 |
[ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] && |
[ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] && |
1398 |
[ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}" |
[ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}" |
1399 |
[ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}" |
[ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}" |
1400 |
|
|
1401 |
source ${SMAGENAME} || die "source failed" |
smagesource ${SMAGENAME} || die "source failed" |
1402 |
PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
1403 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1404 |
|
SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log" |
1405 |
|
|
1406 |
xtitle "Compiling ${PKGNAME}" |
xtitle "Compiling ${PKGNAME}" |
1407 |
echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}" |
echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}" |
1409 |
# auto regen mage tree if requested |
# auto regen mage tree if requested |
1410 |
regen_mage_tree |
regen_mage_tree |
1411 |
|
|
1412 |
if [[ ${CREATE_SRC_PKG_TARBALL} = true ]] |
if mqueryfeature "srcpkg" |
1413 |
then |
then |
1414 |
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
1415 |
then |
then |
1419 |
fi |
fi |
1420 |
|
|
1421 |
# download sources |
# download sources |
1422 |
[[ ${USE_SRC_PKG_TARBALL} != true ]] && download_sources |
mqueryfeature "srcpkgtarball" || download_sources |
1423 |
|
|
1424 |
# fixes some issues with these functions |
# fixes some issues with these functions |
1425 |
export -f src_prepare || die "src_prepare export failed" |
export -f src_prepare || die "src_prepare export failed" |
1426 |
export -f src_compile || die "src_compile export failed" |
export -f src_compile || die "src_compile export failed" |
1427 |
|
export -f src_check || die "src_check export failed" |
1428 |
export -f src_install || die "src_install export failed" |
export -f src_install || die "src_install export failed" |
1429 |
|
|
1430 |
# fixes some compile issues |
# fixes some compile issues |
1431 |
export CHOST="${CHOST}" || die "CHOST export failed" |
export CHOST="${CHOST}" || die "CHOST export failed" |
1432 |
export CFLAGS="${CFLAGS}" || die "CFLAGS export failed" |
export CFLAGS="${CFLAGS}" || die "CFLAGS export failed" |
1433 |
export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed" |
if [[ -z ${CXXFLAGS} ]] |
1434 |
|
then |
1435 |
|
export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed" |
1436 |
|
else |
1437 |
|
export CXXFLAGS="${CXXFLAGS}" || die "CXXFLAGS export failed" |
1438 |
|
fi |
1439 |
|
export LDFLAGS="${LDFLAGS}" || die "LDFLAGS export failed" |
1440 |
export BINDIR="${BINDIR}" || die "BINDIR export failed" |
export BINDIR="${BINDIR}" || die "BINDIR export failed" |
1441 |
export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed" |
export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed" |
1442 |
|
|
|
|
|
1443 |
# setup distcc |
# setup distcc |
1444 |
# setup for distcc goes *before* ccache, so ccache comes before distcc in path |
# setup for distcc goes *before* ccache, so ccache comes before distcc in path |
1445 |
[[ ${SMAGE_USE_DISTCC} = true ]] && setup_distcc_environment |
mqueryfeature "distcc" && setup_distcc_environment |
1446 |
|
|
1447 |
# setup ccache |
# setup ccache |
1448 |
[[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment |
mqueryfeature "ccache" && setup_ccache_environment |
1449 |
|
|
1450 |
# small sleep to show our settings |
if mqueryfeature "resume" |
|
sleep 1 |
|
|
|
|
|
# cleans up build if a previously one exists |
|
|
if [ -d ${BUILDDIR} ] |
|
1451 |
then |
then |
1452 |
rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." |
echo -e "${COLMAGENTA}Resume requested; continuing previous build${COLDEFAULT}" |
|
fi |
|
|
install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." |
|
1453 |
|
|
1454 |
# cleans up srcdir if a previously unpacked one exists |
# setup build logging |
1455 |
if [ -d ${SRCDIR} ] |
[[ ! -d /var/log/smage ]] && install -d /var/log/smage |
1456 |
then |
if [[ -f /var/log/smage/${PKGNAME}.log.bz2 ]] |
1457 |
rm -rf ${SRCDIR} |
then |
1458 |
|
bunzip2 -f /var/log/smage/${PKGNAME}.log.bz2 |
1459 |
|
fi |
1460 |
|
echo -e "### Resume started on $(date) ###\n" >> /var/log/smage/${PKGNAME}.log |
1461 |
|
|
1462 |
|
else |
1463 |
|
# clean up builddir if a previously one exist |
1464 |
|
if [ -d ${BUILDDIR} ] |
1465 |
|
then |
1466 |
|
rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." |
1467 |
|
fi |
1468 |
|
install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." |
1469 |
|
|
1470 |
|
# clean up srcdir if a previously unpacked one exist |
1471 |
|
if [ -d ${SRCDIR} ] |
1472 |
|
then |
1473 |
|
rm -rf ${SRCDIR} |
1474 |
|
fi |
1475 |
|
|
1476 |
|
# clean up bindir if a previous build exist or create a new one |
1477 |
|
if [ -d ${BINDIR} ] |
1478 |
|
then |
1479 |
|
rm -rf ${BINDIR} |
1480 |
|
fi |
1481 |
|
install -d ${BINDIR} || die "couldn't create \$BINDIR." |
1482 |
|
|
1483 |
|
# clean up package temp dir if a previous build exist |
1484 |
|
if [ -d ${BUILDDIR}/${PKGNAME} ] |
1485 |
|
then |
1486 |
|
rm -rf ${BUILDDIR}/${PKGNAME} |
1487 |
|
fi |
1488 |
|
|
1489 |
|
# setup build logging |
1490 |
|
[[ ! -d /var/log/smage ]] && install -d /var/log/smage |
1491 |
|
echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log |
1492 |
fi |
fi |
1493 |
|
|
1494 |
# cleans up bindir if a previous build exists or creates a new one |
if [[ ${PKGTYPE} = virtual ]] |
|
if [ -d ${BINDIR} ] |
|
1495 |
then |
then |
1496 |
rm -rf ${BINDIR} |
echo "virtual package detected; nothing will be build ..." |
1497 |
|
# automatically set !pkgbuild here too |
1498 |
|
msetfeature "!pkgbuild" |
1499 |
|
else |
1500 |
|
( run_resume src_prepare || src_prepare ) | ${SMAGE_LOG_CMD} |
1501 |
|
die_pipestatus 0 "src_prepare failed" |
1502 |
|
resume_stamp src_prepare |
1503 |
|
step_by_step src_prepare |
1504 |
|
|
1505 |
|
( run_resume src_compile || src_compile ) | ${SMAGE_LOG_CMD} |
1506 |
|
die_pipestatus 0 "src_compile failed" |
1507 |
|
resume_stamp src_compile |
1508 |
|
step_by_step src_compile |
1509 |
|
|
1510 |
|
# only run checks if requested |
1511 |
|
if mqueryfeature "!check" |
1512 |
|
then |
1513 |
|
echo "!check detected; src_check() will not be run!" | ${SMAGE_LOG_CMD} |
1514 |
|
else |
1515 |
|
( run_resume src_check || src_check ) | ${SMAGE_LOG_CMD} |
1516 |
|
die_pipestatus 0 "src_check failed" |
1517 |
|
resume_stamp src_check |
1518 |
|
fi |
1519 |
|
step_by_step src_check |
1520 |
|
|
1521 |
|
# build several subpackages |
1522 |
|
if [[ -n ${SPLIT_PACKAGES} ]] |
1523 |
|
then |
1524 |
|
# save bindir & pname |
1525 |
|
split_save_variables |
1526 |
|
export SAVED_BINDIR="${BINDIR}" |
1527 |
|
for subpackage in ${SPLIT_PACKAGES} |
1528 |
|
do |
1529 |
|
if typeset -f src_install_${subpackage} > /dev/null |
1530 |
|
then |
1531 |
|
# export subpackage bindir |
1532 |
|
export BINDIR="${SAVED_BINDIR}_${subpackage}" |
1533 |
|
# export PNAME, several internal function and include |
1534 |
|
# rely on this variable |
1535 |
|
export PNAME="${subpackage}" |
1536 |
|
|
1537 |
|
echo |
1538 |
|
echo -en "${COLBLUE}*** ${COLDEFAULT}" |
1539 |
|
echo -en " Running ${COLGREEN}split src_install()${COLDEFAULT}" |
1540 |
|
echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}" |
1541 |
|
echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..." |
1542 |
|
|
1543 |
|
( run_resume src_install_${subpackage} || src_install_${subpackage} ) | ${SMAGE_LOG_CMD} |
1544 |
|
die_pipestatus 0 "src_install_${subpackage} failed" |
1545 |
|
resume_stamp src_install_${subpackage} |
1546 |
|
step_by_step src_install_${subpackage} |
1547 |
|
fi |
1548 |
|
done |
1549 |
|
# restore bindir & pname |
1550 |
|
split_restore_variables |
1551 |
|
# unset all saved smage variables |
1552 |
|
split_unset_variables |
1553 |
|
else |
1554 |
|
( run_resume src_install || src_install ) | ${SMAGE_LOG_CMD} |
1555 |
|
die_pipestatus 0 "src_install failed" |
1556 |
|
resume_stamp src_install |
1557 |
|
step_by_step src_install |
1558 |
|
fi |
1559 |
fi |
fi |
|
install -d ${BINDIR} || die "couldn't create \$BINDIR." |
|
1560 |
|
|
1561 |
# cleans up package temp dir if a previous build exists |
# echo for sake of good-looking |
1562 |
if [ -d ${BUILDDIR}/${PKGNAME} ] |
echo |
1563 |
|
|
1564 |
|
if mqueryfeature "!compressdoc" |
1565 |
then |
then |
1566 |
rm -rf ${BUILDDIR}/${PKGNAME} |
echo -e "!compressdoc detected; documentation will not be compressed ..." |
1567 |
|
elif mqueryfeature "!pkgbuild" |
1568 |
|
then |
1569 |
|
echo "!pkgbuild detected; skipping documentation compression..." |
1570 |
|
else |
1571 |
|
# compressing doc, info & man files |
1572 |
|
if [[ -n ${SPLIT_PACKAGES} ]] |
1573 |
|
then |
1574 |
|
for subpackage in ${SPLIT_PACKAGES} |
1575 |
|
do |
1576 |
|
run_resume mcompressdoc_${subpackage} || mcompressdocs ${BINDIR}_${subpackage} |
1577 |
|
resume_stamp mcompressdoc_${subpackage} |
1578 |
|
done |
1579 |
|
else |
1580 |
|
run_resume mcompressdoc || mcompressdocs ${BINDIR} |
1581 |
|
resume_stamp mcompressdoc |
1582 |
|
fi |
1583 |
fi |
fi |
1584 |
|
|
1585 |
# cleans up timestamp if one exists |
if mqueryfeature "!libtool" |
|
if [ -f /var/tmp/timestamp ] |
|
1586 |
then |
then |
1587 |
mage rmstamp |
if mqueryfeature "!pkgbuild" |
1588 |
|
then |
1589 |
|
echo "!pkgbuild detected; skipping libtool archive stripping ..." |
1590 |
|
else |
1591 |
|
if [[ -n ${SPLIT_PACKAGES} ]] |
1592 |
|
then |
1593 |
|
for subpackage in ${SPLIT_PACKAGES} |
1594 |
|
do |
1595 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives for '${subpackage}' ...${COLDEFAULT}" |
1596 |
|
run_resume mstriplibtoolarchive_${subpackage} || mstriplibtoolarchive ${BINDIR}_${subpackage} |
1597 |
|
resume_stamp mstriplibtoolarchive_${subpackage} |
1598 |
|
done |
1599 |
|
else |
1600 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives ...${COLDEFAULT}" |
1601 |
|
run_resume mstriplibtoolarchive || mstriplibtoolarchive ${BINDIR} |
1602 |
|
resume_stamp mstriplibtoolarchive |
1603 |
|
fi |
1604 |
|
fi |
1605 |
fi |
fi |
1606 |
|
|
1607 |
src_prepare || die "src_prepare failed" |
if mqueryfeature "purge" |
|
src_compile || die "src_compile failed" |
|
|
src_install || die "src_install failed" |
|
|
|
|
|
|
|
|
# compressing doc, info & man files |
|
|
if [ -d ${BUILDDIR}/builded/usr/share/man ] |
|
1608 |
then |
then |
1609 |
echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}" |
if mqueryfeature "!pkgbuild" |
1610 |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man |
then |
1611 |
|
echo "!pkgbuild detected; skipping file purgation..." |
1612 |
|
else |
1613 |
|
if [[ -n ${SPLIT_PACKAGES} ]] |
1614 |
|
then |
1615 |
|
for subpackage in ${SPLIT_PACKAGES} |
1616 |
|
do |
1617 |
|
echo -e "${COLBLUE}===${COLGREEN} purging all purge targets in '${subpackage}' ...${COLDEFAULT}" |
1618 |
|
run_resume mpurgetargets_${subpackage} || mpurgetargets ${BINDIR}_${subpackage} |
1619 |
|
resume_stamp mpurgetargets_${subpackage} |
1620 |
|
done |
1621 |
|
else |
1622 |
|
echo -e "${COLBLUE}===${COLGREEN} purging all purge targets ...${COLDEFAULT}" |
1623 |
|
run_resume mpurgetargets || mpurgetargets ${BINDIR} |
1624 |
|
resume_stamp mpurgetargets |
1625 |
|
fi |
1626 |
|
fi |
1627 |
fi |
fi |
1628 |
|
|
1629 |
if [ -d ${BUILDDIR}/builded/usr/share/info ] |
# stripping all bins and libs |
1630 |
|
if mqueryfeature "!strip" |
1631 |
|
then |
1632 |
|
echo -e "!strip detected; Package will not be stripped ..." |
1633 |
|
elif mqueryfeature "!pkgbuild" |
1634 |
then |
then |
1635 |
echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}" |
echo "!pkgbuild detected; skipping stripping of the package ..." |
1636 |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info |
else |
1637 |
|
if [[ -n ${SPLIT_PACKAGES} ]] |
1638 |
|
then |
1639 |
|
for subpackage in ${SPLIT_PACKAGES} |
1640 |
|
do |
1641 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" |
1642 |
|
run_resume mstripbins_${subpackage} || mstripbins ${BINDIR}_${subpackage} |
1643 |
|
resume_stamp mstripbins_${subpackage} |
1644 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}" |
1645 |
|
run_resume mstriplibs_${subpackage} || mstriplibs ${BINDIR}_${subpackage} |
1646 |
|
resume_stamp mstriplibs_${subpackage} |
1647 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}" |
1648 |
|
run_resume mstripstatic_${subpackage} || mstripstatic ${BINDIR}_${subpackage} |
1649 |
|
resume_stamp mstripstatic_${subpackage} |
1650 |
|
done |
1651 |
|
else |
1652 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" |
1653 |
|
run_resume mstripbins || mstripbins ${BINDIR} |
1654 |
|
resume_stamp mstripbins |
1655 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}" |
1656 |
|
run_resume mstriplibs || mstriplibs ${BINDIR} |
1657 |
|
resume_stamp mstriplibs |
1658 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}" |
1659 |
|
run_resume mstripstatic || mstripstatic ${BINDIR} |
1660 |
|
resume_stamp mstripstatic |
1661 |
|
fi |
1662 |
fi |
fi |
1663 |
|
|
1664 |
# stripping all bins and libs |
if mqueryfeature "!pkgbuild" |
1665 |
case ${NOSTRIP} in |
then |
1666 |
true|TRUE|yes|y) |
echo -e "!pkgbuild detected; Package will not be build ..." |
1667 |
echo -e "NOSTRIP=true detected; Package will not be stripped ..." |
else |
|
;; |
|
|
*) |
|
|
echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" |
|
|
mstripbins ${BINDIR} |
|
|
echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}" |
|
|
mstriplibs ${BINDIR} |
|
|
;; |
|
|
esac |
|
|
|
|
|
# the new buildpkg command |
|
|
case ${NOPKGBUILD} in |
|
|
true|TRUE|yes|y) |
|
|
echo -e "NOPGKBUILD=true detected; Package will not be build ..." |
|
|
;; |
|
|
*) |
|
1668 |
# build several targets |
# build several targets |
1669 |
if [ -n "${MAGE_TARGETS}" ] |
if [[ -n ${MAGE_TARGETS} ]] |
1670 |
then |
then |
1671 |
for target in ${MAGE_TARGETS} |
for target in ${MAGE_TARGETS} |
1672 |
do |
do |
1673 |
# check if an special target_pkgbuild exists |
# check if a special target_pkgbuild exists |
1674 |
if typeset -f ${target}_pkgbuild > /dev/null |
if typeset -f ${target}_pkgbuild > /dev/null |
1675 |
then |
then |
1676 |
# run it |
# run it |
1677 |
${target}_pkgbuild |
run_resume ${target}_pkgbuild || ${target}_pkgbuild |
1678 |
|
resume_stamp ${target}_pkgbuild |
1679 |
fi |
fi |
1680 |
# now create the target package |
# now create the target package |
1681 |
${MLIBDIR}/pkgbuild_dir.sh \ |
run_resume pkg_builddir_${target} || ${MLIBDIR}/pkgbuild_dir.sh \ |
1682 |
"${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD}" \ |
"${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD}" \ |
1683 |
${BINDIR} || die "target: ${target} package-build failed" |
${BINDIR} || die "target: ${target} package-build failed" |
1684 |
|
resume_stamp pkg_builddir_${target} |
1685 |
|
|
1686 |
# build pkg-md5-sum if requested |
# build pkg-md5-sum if requested |
1687 |
generate_package_md5sum \ |
run_resume md5sum_${target} || generate_package_md5sum \ |
1688 |
--pcat "${PCATEGORIE}" \ |
--pcat "${PCATEGORIE}" \ |
1689 |
--pname "${PNAME}" \ |
--pname "${PNAME}" \ |
1690 |
--pver "${PVER}" \ |
--pver "${PVER}" \ |
1691 |
--pbuild "${PBUILD}" \ |
--pbuild "${PBUILD}" \ |
1692 |
--parch "${ARCH}" \ |
--parch "${ARCH}" \ |
1693 |
--target "${target}" |
--target "${target}" |
1694 |
|
resume_stamp md5sum_${target} |
1695 |
|
|
1696 |
echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" |
echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" |
1697 |
done |
done |
1698 |
|
|
1699 |
|
# build several subpackages |
1700 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
1701 |
|
then |
1702 |
|
split_save_variables |
1703 |
|
for subpackage in ${SPLIT_PACKAGES} |
1704 |
|
do |
1705 |
|
# get the right variables for the split |
1706 |
|
export PNAME="${subpackage}" |
1707 |
|
split_info_${PNAME} |
1708 |
|
|
1709 |
|
# jump to next one if !pkgbuild is set in split_info |
1710 |
|
mqueryfeature "!pkgbuild" && continue |
1711 |
|
|
1712 |
|
# check if an special subpackage_pkgbuild exists |
1713 |
|
if typeset -f ${PNAME}_pkgbuild > /dev/null |
1714 |
|
then |
1715 |
|
# run it |
1716 |
|
run_resume ${PNAME}_pkgbuild || ${PNAME}_pkgbuild |
1717 |
|
resume_stamp ${PNAME}_pkgbuild |
1718 |
|
fi |
1719 |
|
# now create the target package |
1720 |
|
run_resume pkg_builddir_${PNAME} || ${MLIBDIR}/pkgbuild_dir.sh \ |
1721 |
|
"${PNAME}-${PVER}-${ARCH}-${PBUILD}" \ |
1722 |
|
"${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed" |
1723 |
|
resume_stamp pkg_builddir_${PNAME} |
1724 |
|
|
1725 |
|
# build pkg-md5-sum if requested |
1726 |
|
run_resume md5sum_${PNAME} || generate_package_md5sum \ |
1727 |
|
--pcat "${PCATEGORIE}" \ |
1728 |
|
--pname "${PNAME}" \ |
1729 |
|
--pver "${PVER}" \ |
1730 |
|
--pbuild "${PBUILD}" \ |
1731 |
|
--parch "${ARCH}" |
1732 |
|
resume_stamp md5sum_${PNAME} |
1733 |
|
|
1734 |
|
echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" |
1735 |
|
|
1736 |
|
# restore smage environment |
1737 |
|
split_restore_variables |
1738 |
|
done |
1739 |
|
# unset all saved smage variables |
1740 |
|
split_unset_variables |
1741 |
|
|
1742 |
else |
else |
1743 |
${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
run_resume pkg_builddir || ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
1744 |
|
resume_stamp pkg_builddir |
1745 |
|
|
1746 |
# build pkg-md5-sum if requested |
# build pkg-md5-sum if requested |
1747 |
generate_package_md5sum \ |
run_resume md5sum || generate_package_md5sum \ |
1748 |
--pcat "${PCATEGORIE}" \ |
--pcat "${PCATEGORIE}" \ |
1749 |
--pname "${PNAME}" \ |
--pname "${PNAME}" \ |
1750 |
--pver "${PVER}" \ |
--pver "${PVER}" \ |
1751 |
--pbuild "${PBUILD}" \ |
--pbuild "${PBUILD}" \ |
1752 |
--parch "${ARCH}" |
--parch "${ARCH}" |
1753 |
|
resume_stamp md5sum |
1754 |
|
|
1755 |
echo -e "${COLGREEN}\nPackage ${PKGNAME} successfully builded.\n${COLDEFAULT}" |
echo -e "${COLGREEN}\nPackage ${PKGNAME} successfully builded.\n${COLDEFAULT}" |
1756 |
fi |
fi |
1757 |
|
|
1758 |
# build src-pkg-tarball if requested |
# build src-pkg-tarball if requested |
1759 |
[[ ${CREATE_SRC_PKG_TARBALL} = true ]] && source_pkg_build ${SMAGENAME} |
if mqueryfeature "srcpkg" |
1760 |
;; |
then |
1761 |
esac |
run_resume srcpkgbuild || source_pkg_build ${SMAGENAME} |
1762 |
|
resume_stamp srcpkgbuild |
1763 |
# for sure |
fi |
1764 |
unset NOPKGBUILD |
fi |
1765 |
unset NOSTRIP |
|
1766 |
|
if mqueryfeature "buildlog" |
1767 |
|
then |
1768 |
|
bzip2 -9f /var/log/smage/${PKGNAME}.log |
1769 |
|
else |
1770 |
|
[[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log |
1771 |
|
fi |
1772 |
|
|
1773 |
xtitleclean |
xtitleclean |