2 |
# Magellan Linux Installer Functions (mage.functions.sh) |
# Magellan Linux Installer Functions (mage.functions.sh) |
3 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.38 2008-10-05 10:32:24 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.38 2008-10-05 10:32:24 niro Exp $ |
4 |
|
|
5 |
|
COLRED="\033[1;6m\033[31m" |
6 |
|
COLGREEN="\033[1;6m\033[32m" |
7 |
|
COLYELLOW="\033[1;6m\033[33m" |
8 |
|
COLBLUE="\033[1;6m\033[34m" |
9 |
|
COLMAGENTA="\033[1;6m\033[35m" |
10 |
|
COLWHITE="\033[1;6m\033[37m" |
11 |
|
COLGRAY="\033[0;6m\033[37m" |
12 |
|
COLBOLD="\033[1m" |
13 |
|
COLDEFAULT="\033[0m" |
14 |
|
|
15 |
|
if [[ ${NOCOLORS} = true ]] |
16 |
|
then |
17 |
|
COLRED="" |
18 |
|
COLGREEN="" |
19 |
|
COLYELLOW="" |
20 |
|
COLBLUE="" |
21 |
|
COLMAGENTA="" |
22 |
|
COLWHITE="" |
23 |
|
COLGRAY="" |
24 |
|
COLBOLD="" |
25 |
|
COLDEFAULT="" |
26 |
|
fi |
27 |
|
|
28 |
mage_setup() |
mage_setup() |
29 |
{ |
{ |
30 |
[ ! -d ${MROOT}${INSTALLDB} ] && \ |
[ ! -d ${MROOT}${INSTALLDB} ] && \ |
38 |
return 0 |
return 0 |
39 |
} |
} |
40 |
|
|
41 |
|
mchecksum() |
42 |
|
{ |
43 |
|
local i |
44 |
|
local rundir |
45 |
|
local file |
46 |
|
local method |
47 |
|
local cmd |
48 |
|
local retval |
49 |
|
|
50 |
|
# very basic getops |
51 |
|
for i in $* |
52 |
|
do |
53 |
|
case $1 in |
54 |
|
--rundir|-r) shift; rundir="$1" ;; |
55 |
|
--file|-f) shift; file="$1" ;; |
56 |
|
--method|-m) shift; method="$1" ;; |
57 |
|
esac |
58 |
|
shift |
59 |
|
done |
60 |
|
|
61 |
|
# sanity checks |
62 |
|
[[ -z ${rundir} ]] && die "mchecksum(): rundir missing" |
63 |
|
[[ -z ${file} ]] && die "mchecksum(): file missing" |
64 |
|
[[ -z ${method} ]] && die "mchecksum(): method missing" |
65 |
|
|
66 |
|
case ${method} in |
67 |
|
md5) cmd="md5sum" ;; |
68 |
|
sha256) cmd="sha256sum" ;; |
69 |
|
*) die "mchecksum(): unknown method '${method}'" ;; |
70 |
|
esac |
71 |
|
|
72 |
|
if [[ -d ${rundir} ]] |
73 |
|
then |
74 |
|
pushd ${rundir} &> /dev/null |
75 |
|
# be verbose here |
76 |
|
${cmd} -c ${file} #&> /dev/null |
77 |
|
retval="$?" |
78 |
|
popd &> /dev/null |
79 |
|
else |
80 |
|
retval=1 |
81 |
|
fi |
82 |
|
|
83 |
|
return "${retval}" |
84 |
|
} |
85 |
|
|
86 |
|
mcheckemptydir() |
87 |
|
{ |
88 |
|
local dir="$1" |
89 |
|
local retval=1 |
90 |
|
|
91 |
|
if [[ ! -d ${dir} ]] |
92 |
|
then |
93 |
|
echo "mcheckemptydir(): '${dir}' is not a directory!" |
94 |
|
retval=3 |
95 |
|
else |
96 |
|
shopt -s nullglob dotglob |
97 |
|
files=( ${dir}/* ) |
98 |
|
(( ${#files[*]} )) || retval=0 |
99 |
|
shopt -u nullglob dotglob |
100 |
|
fi |
101 |
|
|
102 |
|
return ${retval} |
103 |
|
} |
104 |
|
|
105 |
unpack_packages() |
unpack_packages() |
106 |
{ |
{ |
107 |
local list="$@" |
local list="$@" |
226 |
while read pathto posix user group |
while read pathto posix user group |
227 |
do |
do |
228 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
229 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> DIR: ${MROOT}${pathto}" |
|
|
|
230 |
|
|
231 |
# monitors /etc/env.d -> env-rebuild |
# monitors /etc/env.d -> env-rebuild |
232 |
[[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true |
[[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true |
302 |
case ${retval} in |
case ${retval} in |
303 |
# file is not protected - (over)write it |
# file is not protected - (over)write it |
304 |
0|3) |
0|3) |
305 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> FILE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> FILE: ${MROOT}${pathto}" |
306 |
install -m "${posix}" -o "${user}" -g "${group}" \ |
install -m "${posix}" -o "${user}" -g "${group}" \ |
307 |
${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \ |
${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \ |
308 |
"${MROOT}${pathto}" |
"${MROOT}${pathto}" |
314 |
"${user}" \ |
"${user}" \ |
315 |
"${group}" \ |
"${group}" \ |
316 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
317 |
"${MROOT}${pathto}")" \ |
"${MROOT}${pathto}")" \ |
318 |
"${md5sum}" |
"${md5sum}" |
319 |
;; |
;; |
320 |
|
|
321 |
# file is protected, write backup file |
# file is protected, write backup file |
322 |
2) |
2) |
323 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
324 |
then |
then |
325 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
326 |
echo -n "! prot " |
echo -n "! prot " |
341 |
"${user}" \ |
"${user}" \ |
342 |
"${group}" \ |
"${group}" \ |
343 |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
344 |
"${dest_protected}")" \ |
"${dest_protected}")" \ |
345 |
"${md5sum}" |
"${md5sum}" |
346 |
|
|
347 |
# update global MAGE_PROTECT_COUNTER |
# update global MAGE_PROTECT_COUNTER |
351 |
|
|
352 |
# file is protected but ignored, delete the update/do nothing |
# file is protected but ignored, delete the update/do nothing |
353 |
4) |
4) |
354 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
355 |
then |
then |
356 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
357 |
echo -n "! ignr " |
echo -n "! ignr " |
358 |
echo -en "${COLDEFAULT}" |
echo -en "${COLDEFAULT}" |
359 |
echo " === FILE: ${MROOT}${pathto}" |
echo " === FILE: ${MROOT}${pathto}" |
360 |
fi |
fi |
361 |
# simply do nothing here |
# simply do nothing here - only fix mtime |
362 |
|
fix_descriptor ${pkgname}/.files \ |
363 |
|
"${pathto}" \ |
364 |
|
"${posix}" \ |
365 |
|
"${user}" \ |
366 |
|
"${group}" \ |
367 |
|
"$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ |
368 |
|
"${MROOT}${pathto}")" \ |
369 |
|
"${md5sum}" |
370 |
;; |
;; |
371 |
esac |
esac |
372 |
done < ${BUILDDIR}/${pkgname}/.files |
done < ${BUILDDIR}/${pkgname}/.files |
410 |
while read pathto posix link mtime |
while read pathto posix link mtime |
411 |
do |
do |
412 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
413 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> LINK: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> LINK: ${MROOT}${pathto}" |
414 |
|
|
415 |
ln -snf "${link}" "${MROOT}${pathto}" |
ln -snf "${link}" "${MROOT}${pathto}" |
416 |
|
|
460 |
while read pathto posix major minor user group |
while read pathto posix major minor user group |
461 |
do |
do |
462 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
463 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> PIPE: ${MROOT}${pathto}" |
464 |
|
|
465 |
mknod -m "${posix}" "${MROOT}${pathto}" |
mknod -m "${posix}" "${MROOT}${pathto}" |
466 |
# make it optional atm !! |
# make it optional atm !! |
504 |
while read pathto posix major minor user group |
while read pathto posix major minor user group |
505 |
do |
do |
506 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
507 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> CHAR: ${MROOT}${pathto}" |
508 |
|
|
509 |
mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}" |
mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}" |
510 |
|
|
548 |
while read pathto posix user group |
while read pathto posix user group |
549 |
do |
do |
550 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
551 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t>>> FIFO: ${MROOT}${pathto}" |
552 |
|
|
553 |
mkfifo -m "${posix}" "${MROOT}${pathto}" |
mkfifo -m "${posix}" "${MROOT}${pathto}" |
554 |
chown "${user}:${group}" "${MROOT}${pathto}" |
chown "${user}:${group}" "${MROOT}${pathto}" |
570 |
|
|
571 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
572 |
[ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." |
[ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." |
573 |
|
|
574 |
# this is only a wrapper |
# this is only a wrapper |
575 |
|
|
576 |
# NOTE: |
# NOTE: |
882 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
883 |
if [ ! -L "${MROOT}${pathto}" ] |
if [ ! -L "${MROOT}${pathto}" ] |
884 |
then |
then |
885 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
886 |
echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
887 |
continue |
continue |
888 |
fi |
fi |
894 |
# 1=keep me # |
# 1=keep me # |
895 |
case ${retval} in |
case ${retval} in |
896 |
0) |
0) |
897 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< LINK: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< LINK: ${MROOT}${pathto}" |
898 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
899 |
;; |
;; |
900 |
|
|
901 |
1) |
1) |
902 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
903 |
echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}" |
904 |
;; |
;; |
905 |
esac |
esac |
966 |
|
|
967 |
if [ ! -e "${MROOT}${pathto}" ] |
if [ ! -e "${MROOT}${pathto}" ] |
968 |
then |
then |
969 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
970 |
echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
971 |
continue |
continue |
972 |
fi |
fi |
992 |
case ${retval} in |
case ${retval} in |
993 |
# file is not protected - delete it |
# file is not protected - delete it |
994 |
0|3) |
0|3) |
995 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< FILE: ${MROOT}${pathto}" |
996 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
997 |
;; |
;; |
998 |
|
|
999 |
# file is protected, do not delete |
# file is protected, do not delete |
1000 |
2) |
2) |
1001 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
1002 |
then |
then |
1003 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
1004 |
echo -n "! prot " |
echo -n "! prot " |
1009 |
|
|
1010 |
# file is protected but ignored, delete the update/do nothing |
# file is protected but ignored, delete the update/do nothing |
1011 |
4) |
4) |
1012 |
if [[ ${VERBOSE} = on ]] |
if mqueryfeature "verbose" |
1013 |
then |
then |
1014 |
echo -en "${COLRED}" |
echo -en "${COLRED}" |
1015 |
echo -n "! ignr " |
echo -n "! ignr " |
1021 |
esac |
esac |
1022 |
;; |
;; |
1023 |
1) |
1) |
1024 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1025 |
echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}" |
1026 |
;; |
;; |
1027 |
esac |
esac |
1083 |
do |
do |
1084 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1085 |
|
|
1086 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< PIPE: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< PIPE: ${MROOT}${pathto}" |
1087 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
1088 |
done < ${MROOT}${INSTALLDB}/${pfull}/.pipes |
done < ${MROOT}${INSTALLDB}/${pfull}/.pipes |
1089 |
|
|
1143 |
do |
do |
1144 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1145 |
|
|
1146 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< CHAR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< CHAR: ${MROOT}${pathto}" |
1147 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
1148 |
done < ${MROOT}${INSTALLDB}/${pfull}/.char |
done < ${MROOT}${INSTALLDB}/${pfull}/.char |
1149 |
|
|
1205 |
do |
do |
1206 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
1207 |
|
|
1208 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< FIFO: ${MROOT}${pathto}" |
1209 |
rm "${MROOT}${pathto}" |
rm "${MROOT}${pathto}" |
1210 |
done < ${MROOT}${INSTALLDB}/${pfull}/.fifo |
done < ${MROOT}${INSTALLDB}/${pfull}/.fifo |
1211 |
|
|
1266 |
|
|
1267 |
if [ ! -d "${MROOT}${pathto}" ] |
if [ ! -d "${MROOT}${pathto}" ] |
1268 |
then |
then |
1269 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1270 |
echo -e "${COLRED}! exist${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! exist${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1271 |
continue |
continue |
1272 |
fi |
fi |
1274 |
# exclude .keep directories |
# exclude .keep directories |
1275 |
if [ -f "${MROOT}${pathto}/.keep" ] |
if [ -f "${MROOT}${pathto}/.keep" ] |
1276 |
then |
then |
1277 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1278 |
echo -e "${COLRED}! .keep${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! .keep${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1279 |
continue |
continue |
1280 |
fi |
fi |
1287 |
|
|
1288 |
if rmdir "${MROOT}${pathto}" &> /dev/null |
if rmdir "${MROOT}${pathto}" &> /dev/null |
1289 |
then |
then |
1290 |
[[ ${VERBOSE} = on ]] && echo -e "\t<<< DIR: ${MROOT}${pathto}" |
mqueryfeature "verbose" && echo -e "\t<<< DIR: ${MROOT}${pathto}" |
1291 |
else |
else |
1292 |
[[ ${VERBOSE} = on ]] && \ |
mqueryfeature "verbose" && \ |
1293 |
echo -e "${COLRED}! empty${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
echo -e "${COLRED}! empty${COLDEFAULT} === DIR: ${MROOT}${pathto}" |
1294 |
fi |
fi |
1295 |
done |
done |
1347 |
done |
done |
1348 |
} |
} |
1349 |
|
|
1350 |
|
# convertmirrors [uri] |
1351 |
|
convertmirrors() |
1352 |
|
{ |
1353 |
|
local uri="$1" |
1354 |
|
local scheme |
1355 |
|
local mirror |
1356 |
|
local mirrors |
1357 |
|
local addon |
1358 |
|
local real_uri |
1359 |
|
local output |
1360 |
|
|
1361 |
|
# needs |
1362 |
|
[[ -z ${MIRRORS} ]] && die "convertmirrors(): no mirrors defined!" |
1363 |
|
[[ -z ${SOURCEFORGE_MIRRORS} ]] && die "convertmirrors(): no sourceforge mirrors defined!" |
1364 |
|
[[ -z ${GNU_MIRRORS} ]] && die "convertmirrors(): no gnu mirrors defined!" |
1365 |
|
[[ -z ${GNOME_MIRRORS} ]] && die "convertmirrors(): no gnome mirrors defined!" |
1366 |
|
[[ -z ${KDE_MIRRORS} ]] && die "convertmirrors(): no kde mirrors defined!" |
1367 |
|
|
1368 |
|
# check known uri schemes |
1369 |
|
case ${uri} in |
1370 |
|
http://*|https://*|ftp://*|ftps://*) mirrors="" ;; |
1371 |
|
mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;; |
1372 |
|
package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;; |
1373 |
|
gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;; |
1374 |
|
sourceforge://*) mirrors="${SOURCEFORGE_MIRRORS}"; scheme="sourceforge://" ;; |
1375 |
|
gnome://*) mirrors="${GNOME_MIRRORS}"; scheme="gnome://" ;; |
1376 |
|
kde://*) mirrors="${KDE_MIRRORS}"; scheme="kde://" ;; |
1377 |
|
*) die "convertmirror(): unsupported uri scheme in '${uri}'!" ;; |
1378 |
|
esac |
1379 |
|
|
1380 |
|
if [[ ! -z ${mirrors} ]] |
1381 |
|
then |
1382 |
|
for mirror in ${mirrors} |
1383 |
|
do |
1384 |
|
# add a whitespace to the output |
1385 |
|
[[ -z ${output} ]] || output+=" " |
1386 |
|
output+="${mirror}${addon}/${uri/${scheme}/}" |
1387 |
|
done |
1388 |
|
else |
1389 |
|
output="${uri}" |
1390 |
|
fi |
1391 |
|
|
1392 |
|
echo "${output}" |
1393 |
|
} |
1394 |
|
|
1395 |
|
mdownload() |
1396 |
|
{ |
1397 |
|
local i |
1398 |
|
local uri |
1399 |
|
local real_uris |
1400 |
|
local mirror |
1401 |
|
local outputfile |
1402 |
|
local outputdir |
1403 |
|
local retval |
1404 |
|
local wget_opts |
1405 |
|
|
1406 |
|
# very basic getops |
1407 |
|
for i in $* |
1408 |
|
do |
1409 |
|
case $1 in |
1410 |
|
--uri|-u) shift; uri="$1" ;; |
1411 |
|
--dir|-d) shift; outputdir="$1" ;; |
1412 |
|
esac |
1413 |
|
shift |
1414 |
|
done |
1415 |
|
|
1416 |
|
# sanity checks; abort if not given |
1417 |
|
[[ -z ${uri} ]] && die "mdownload(): no uri given!" |
1418 |
|
[[ -z ${outputdir} ]] && die "mdownload(): no dir given!" |
1419 |
|
|
1420 |
|
# convert mirrored uris to the real ones |
1421 |
|
real_uris="$(convertmirrors ${uri})" |
1422 |
|
|
1423 |
|
# verbose or not |
1424 |
|
mqueryfeature "!verbose" && wget_opts+=" --quiet" |
1425 |
|
|
1426 |
|
# filter wget options if busybox was found |
1427 |
|
wget_opts+=" $(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1428 |
|
|
1429 |
|
# create outputdir |
1430 |
|
[[ ! -d ${outputdir} ]] && install -d "${outputdir}" |
1431 |
|
|
1432 |
|
for mirror in ${real_uris} |
1433 |
|
do |
1434 |
|
# get the name of the output file |
1435 |
|
outputfile="${mirror##*/}" |
1436 |
|
|
1437 |
|
wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}" |
1438 |
|
retval="$?" |
1439 |
|
if [[ ${retval} = 0 ]] |
1440 |
|
then |
1441 |
|
break |
1442 |
|
else |
1443 |
|
continue |
1444 |
|
fi |
1445 |
|
done |
1446 |
|
|
1447 |
|
# return wget retval |
1448 |
|
return "${retval}" |
1449 |
|
} |
1450 |
|
|
1451 |
# fetch_packages /path/to/mage/file1 /path/to/mage/file2 |
# fetch_packages /path/to/mage/file1 /path/to/mage/file2 |
1452 |
fetch_packages() |
fetch_packages() |
1453 |
{ |
{ |
1454 |
|
local i |
1455 |
local list="$@" |
local list="$@" |
1456 |
local pkg |
local pkg |
1457 |
local mirr |
local mirr |
1505 |
continue |
continue |
1506 |
fi |
fi |
1507 |
|
|
1508 |
for mirr in ${MIRRORS} |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
1509 |
do |
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
1510 |
echo -ne " ${COLBLUE}***${COLDEFAULT}" |
mdownload --uri "package://${pkg}" --dir "${PKGDIR}" || die "Could not download ${pkg}" |
|
#echo -e " fetching (${count_current}/${count_total}): ${mirr}/${pkg} ... " |
|
|
echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " |
|
|
[[ ${VERBOSE} = off ]] && opt="--quiet" |
|
|
wget \ |
|
|
${wget_opts} \ |
|
|
--directory-prefix=${PKGDIR} \ |
|
|
${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg} |
|
|
if [[ $? = 0 ]] |
|
|
then |
|
|
break |
|
|
else |
|
|
continue |
|
|
fi |
|
|
done |
|
|
|
|
1511 |
if [ ! -f ${PKGDIR}/${pkg} ] |
if [ ! -f ${PKGDIR}/${pkg} ] |
1512 |
then |
then |
1513 |
die "Could not download ${pkg}" |
die "Package '${pkg}' after download not found in '${PKGDIR}'" |
1514 |
fi |
fi |
1515 |
done |
done |
1516 |
|
|
1538 |
done |
done |
1539 |
|
|
1540 |
# clean up backup files (foo~) |
# clean up backup files (foo~) |
1541 |
find ${MAGEDIR} -name *~ -exec rm '{}' ';' |
find ${MAGEDIR} -name \*~ -exec rm '{}' ';' |
1542 |
|
|
1543 |
# check if a newer mage version is available |
# check if a newer mage version is available |
1544 |
is_newer_mage_version_available |
is_newer_mage_version_available |
1552 |
local mirr mymirr |
local mirr mymirr |
1553 |
local opt |
local opt |
1554 |
local tar_opts |
local tar_opts |
1555 |
|
local wget_opts |
1556 |
|
|
1557 |
# try to get the md5 marked as latest on the server |
# try to get the md5 marked as latest on the server |
1558 |
latest_md5="mage-latest.md5" |
latest_md5="mage-latest.md5" |
1560 |
# try to get the tarball marked as latest on the server |
# try to get the tarball marked as latest on the server |
1561 |
latest_tarball="mage-latest.tar.bz2" |
latest_tarball="mage-latest.tar.bz2" |
1562 |
|
|
1563 |
|
# filter wget command if busybox was found |
1564 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1565 |
|
|
1566 |
for mirr in ${MIRRORS} |
for mirr in ${MIRRORS} |
1567 |
do |
do |
1568 |
# path without distribution |
# path without distribution |
1569 |
mymirr="${mirr%/*}" |
# (only for stable|testing|unstable and not DISTROTAG) |
1570 |
|
case ${mirr##*/} in |
1571 |
|
stable|testing|unstable) mymirr="${mirr%/*}";; |
1572 |
|
*) mymirr="${mirr}";; |
1573 |
|
esac |
1574 |
|
|
1575 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1576 |
echo "fetching latest md5 from ${mymirr} ..." |
echo "fetching latest md5 from ${mymirr} ..." |
1577 |
[[ ${VERBOSE} = off ]] && opt="--quiet" |
mqueryfeature "!verbose" && opt="--quiet" |
1578 |
wget \ |
wget \ |
1579 |
${WGET_FETCH_OPTIONS} \ |
${wget_opts} \ |
1580 |
--directory-prefix=${temp} \ |
--directory-prefix=${temp} \ |
1581 |
${opt} ${mymirr}/rsync/tarballs/${latest_md5} |
${opt} ${mymirr}/rsync/tarballs/${latest_md5} |
1582 |
|
|
1583 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1584 |
echo "fetching latest tarball from ${mymirr} ..." |
echo "fetching latest tarball from ${mymirr} ..." |
1585 |
wget \ |
wget \ |
1586 |
${WGET_FETCH_OPTIONS} \ |
${wget_opts} \ |
1587 |
--directory-prefix=${temp} \ |
--directory-prefix=${temp} \ |
1588 |
${opt} ${mymirr}/rsync/tarballs/${latest_tarball} |
${opt} ${mymirr}/rsync/tarballs/${latest_tarball} |
1589 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
1603 |
else |
else |
1604 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1605 |
echo -n "checking md5sum... " |
echo -n "checking md5sum... " |
1606 |
( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed" |
mchecksum --rundir "${temp}" --file "${latest_md5}" --method md5 || die "md5 for ${latest_tarball} failed" |
1607 |
fi |
fi |
1608 |
|
|
1609 |
if [[ -d ${MAGEDIR} ]] |
if [[ -d ${MAGEDIR} ]] |
1610 |
then |
then |
1611 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1612 |
echo "cleaning old mage-tree ${MAGEDIR}..." |
echo "cleaning old mage-tree ${MAGEDIR}..." |
1613 |
rm -rf ${MAGEDIR} |
# honor mountpoints and empty dirs |
1614 |
|
if mountpoint -q ${MAGEDIR} |
1615 |
|
then |
1616 |
|
if ! mcheckemptydir ${MAGEDIR} |
1617 |
|
then |
1618 |
|
find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xarg --no-run-if-empty rm -r |
1619 |
|
fi |
1620 |
|
else |
1621 |
|
rm -rf ${MAGEDIR} |
1622 |
|
fi |
1623 |
fi |
fi |
1624 |
|
|
1625 |
if need_busybox_support tar |
if need_busybox_support tar |
1678 |
} |
} |
1679 |
|
|
1680 |
|
|
1681 |
# cuts full pathnames or versioniezed names down to basename |
# unused? |
1682 |
choppkgname() |
# |
1683 |
{ |
# # cuts full pathnames or versionized names down to basename |
1684 |
#we want this only if full name was used |
# choppkgname() |
1685 |
if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
# { |
1686 |
then |
# #we want this only if full name was used |
1687 |
#cuts ARCH and PBUILD |
# if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ] |
1688 |
#ARCH comes from ${MAGERC} |
# then |
1689 |
MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g") |
# #cuts ARCH and PBUILD |
1690 |
|
# #ARCH comes from ${MAGERC} |
1691 |
|
# MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}$(print_distrotag)-r*.::g") |
1692 |
|
# |
1693 |
|
# #cuts version number |
1694 |
|
# MAGENAME=$(basename ${MAGENAME%-*} .mage) |
1695 |
|
# fi |
1696 |
|
# } |
1697 |
|
|
|
#cuts version number |
|
|
MAGENAME=$(basename ${MAGENAME%-*} .mage) |
|
|
fi |
|
|
} |
|
1698 |
|
|
1699 |
# get_categorie $PNAME, returns CATEGORIE |
# get_categorie $PNAME, returns CATEGORIE |
1700 |
# $1=pname |
# $1=pname |
1764 |
local magefile |
local magefile |
1765 |
|
|
1766 |
# do not list the content of a directory, only the name (-d) |
# do not list the content of a directory, only the name (-d) |
1767 |
for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*) |
for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/* 2> /dev/null) |
1768 |
do |
do |
1769 |
[[ -z ${magefile} ]] && continue |
[[ -z ${magefile} ]] && continue |
1770 |
# we exclude subdirs (for stuff like a md5sum dir) |
# we exclude subdirs (for stuff like a md5sum dir) |
1773 |
then |
then |
1774 |
HIGHEST_MAGEFILE=${magefile} |
HIGHEST_MAGEFILE=${magefile} |
1775 |
#for debug only |
#for debug only |
1776 |
[[ ${MAGEDEBUG} = on ]] && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" |
mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" |
1777 |
fi |
fi |
1778 |
done |
done |
1779 |
|
|
|
# do not so anything |
|
|
# # stop here if HIGHEST_MAGEFILE is zero |
|
|
# # this package must be unstable or old |
|
|
# if [ -z "${HIGHEST_MAGEFILE}" ] |
|
|
# then |
|
|
# echo |
|
|
# echo -n "All packages named " |
|
|
# echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT} |
|
|
# echo -n " are marked " |
|
|
# echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT} |
|
|
# echo "." |
|
|
# echo "You need to declare USE_UNSTABLE=true to install this." |
|
|
# echo |
|
|
# echo "Example:" |
|
|
# echo " USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}" |
|
|
# echo |
|
|
# echo "Be warned that these packages are not stable and may cause serious problems." |
|
|
# echo "You should know what you are doing, so don't complain about any damage." |
|
|
# echo |
|
|
# return 1 |
|
|
# fi |
|
|
|
|
1780 |
echo "${HIGHEST_MAGEFILE}" |
echo "${HIGHEST_MAGEFILE}" |
1781 |
return 0 |
return 0 |
1782 |
} |
} |
2181 |
then |
then |
2182 |
for i in $* |
for i in $* |
2183 |
do |
do |
2184 |
[[ ${MAGEDEBUG} = on ]] && \ |
mqueryfeature "debug" && \ |
2185 |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
2186 |
source ${MAGEDIR}/include/${i}.minc |
source ${MAGEDIR}/include/${i}.minc |
2187 |
done |
done |
2188 |
[[ ${MAGEDEBUG} = on ]] && echo |
mqueryfeature "debug" && echo |
2189 |
fi |
fi |
2190 |
} |
} |
2191 |
|
|
2629 |
if [[ -n ${MAGE_TARGETS} ]] |
if [[ -n ${MAGE_TARGETS} ]] |
2630 |
then |
then |
2631 |
# basic svn compat |
# basic svn compat |
2632 |
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2633 |
then |
then |
2634 |
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
for i in ${SMAGESCRIPTSDIR}/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2 |
2635 |
do |
do |
2636 |
smage2file="${i}" |
smage2file="${i}" |
2637 |
done |
done |
2642 |
elif [[ -n ${SPLIT_PACKAGE_BASE} ]] |
elif [[ -n ${SPLIT_PACKAGE_BASE} ]] |
2643 |
then |
then |
2644 |
# basic svn compat |
# basic svn compat |
2645 |
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2646 |
then |
then |
2647 |
for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
for i in ${SMAGESCRIPTSDIR}/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2 |
2648 |
do |
do |
2649 |
smage2file="${i}" |
smage2file="${i}" |
2650 |
done |
done |
2654 |
|
|
2655 |
else |
else |
2656 |
# basic svn compat |
# basic svn compat |
2657 |
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2658 |
then |
then |
2659 |
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2660 |
do |
do |
2661 |
smage2file="${i}" |
smage2file="${i}" |
2662 |
done |
done |
2795 |
then |
then |
2796 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
2797 |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
echo -ne "checking md5sum (${count_current}/${count_total}): " |
2798 |
( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed" |
mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 || die "md5 for ${pkgfile} failed" |
2799 |
else |
else |
2800 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
2801 |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
echo -e "!! no md5sum file found for ${pkgfile} :(" |
3035 |
local state |
local state |
3036 |
local descriptiom |
local descriptiom |
3037 |
local homepage |
local homepage |
3038 |
|
local license |
3039 |
local i |
local i |
3040 |
local all_installed |
local all_installed |
3041 |
local ipver |
local ipver |
3072 |
state="$(get_value_from_magefile STATE ${magefile})" |
state="$(get_value_from_magefile STATE ${magefile})" |
3073 |
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
description="$(get_value_from_magefile DESCRIPTION ${magefile})" |
3074 |
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" |
3075 |
|
license="$(get_value_from_magefile LICENSE ${magefile})" |
3076 |
|
|
3077 |
# all installed |
# all installed |
3078 |
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) |
3079 |
do |
do |
3080 |
ipver="$(magename2pver ${i})" |
ipver="$(magename2pver ${i})" |
3081 |
ipbuild="$(magename2pbuild ${i})" |
ipbuild="$(magename2pbuild ${i})" |
3082 |
|
|
3083 |
if [[ -z ${all_installed} ]] |
if [[ -z ${all_installed} ]] |
3084 |
then |
then |
3085 |
all_installed="${ipver}-${ipbuild}" |
all_installed="${ipver}-${ipbuild}" |
3088 |
fi |
fi |
3089 |
done |
done |
3090 |
[[ -z ${all_installed} ]] && all_installed="none" |
[[ -z ${all_installed} ]] && all_installed="none" |
3091 |
|
|
3092 |
case ${state} in |
case ${state} in |
3093 |
stable) state=${COLGREEN}"[s] ";; |
stable) state=${COLGREEN}"[s] ";; |
3094 |
testing) state=${COLYELLOW}"[t] ";; |
testing) state=${COLYELLOW}"[t] ";; |
3133 |
echo " Installed versions: ${all_installed}" |
echo " Installed versions: ${all_installed}" |
3134 |
echo " Description: ${description}" |
echo " Description: ${description}" |
3135 |
echo " Homepage: ${homepage}" |
echo " Homepage: ${homepage}" |
3136 |
|
if [[ ! -z ${license} ]] |
3137 |
|
then |
3138 |
|
echo " License: ${license}" |
3139 |
|
fi |
3140 |
echo " Depends: ${deps}" |
echo " Depends: ${deps}" |
3141 |
echo " SDepends: ${sdeps}" |
echo " SDepends: ${sdeps}" |
3142 |
echo |
echo |
3177 |
eval "${functions}() { ${include}_${functions} ; }" |
eval "${functions}() { ${include}_${functions} ; }" |
3178 |
|
|
3179 |
# debug |
# debug |
3180 |
[[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}" |
mqueryfeature "debug" && typeset -f "${functions}" |
3181 |
|
|
3182 |
shift |
shift |
3183 |
done |
done |
3262 |
then |
then |
3263 |
# needs busybox support |
# needs busybox support |
3264 |
return 0 |
return 0 |
|
else |
|
|
# no busybox |
|
|
return 1 |
|
3265 |
fi |
fi |
3266 |
fi |
fi |
3267 |
|
|
3268 |
|
# no busybox |
3269 |
|
return 1 |
3270 |
} |
} |
3271 |
|
|
3272 |
# busybox_filter_wget_options ${wget_opts} |
# busybox_filter_wget_options ${wget_opts} |
3301 |
echo "${opts}" |
echo "${opts}" |
3302 |
fi |
fi |
3303 |
} |
} |
3304 |
|
|
3305 |
|
have_root_privileges() |
3306 |
|
{ |
3307 |
|
local retval |
3308 |
|
|
3309 |
|
if [[ $(id -u) = 0 ]] |
3310 |
|
then |
3311 |
|
retval=0 |
3312 |
|
else |
3313 |
|
retval=1 |
3314 |
|
fi |
3315 |
|
|
3316 |
|
return ${retval} |
3317 |
|
} |
3318 |
|
|
3319 |
|
known_mage_feature() |
3320 |
|
{ |
3321 |
|
local feature="$1" |
3322 |
|
local retval |
3323 |
|
|
3324 |
|
case "${feature}" in |
3325 |
|
autosvc|!autosvc) retval=0 ;; |
3326 |
|
buildlog|!buildlog) retval=0 ;; |
3327 |
|
ccache|!ccache) retval=0 ;; |
3328 |
|
check|!check) retval=0 ;; |
3329 |
|
compressdoc|!compressdoc) retval=0 ;; |
3330 |
|
debug|!debug) retval=0 ;; |
3331 |
|
distcc|!distcc) retval=0 ;; |
3332 |
|
kernelsrcunpack|!kernelsrcunpack) retval=0 ;; |
3333 |
|
libtool|!libtool) retval=0 ;; |
3334 |
|
linuxsymlink|!linuxsymlink) retval=0 ;; |
3335 |
|
pkgbuild|!pkgbuild) retval=0 ;; |
3336 |
|
pkgdistrotag|!pkgdistrotag) retval=0 ;; |
3337 |
|
purge|!purge) retval=0 ;; |
3338 |
|
qalint|!qalint) retval=0 ;; |
3339 |
|
regentree|!regentree) retval=0 ;; |
3340 |
|
resume|!resume) retval=0 ;; |
3341 |
|
srcpkgbuild|!srcpkgbuild) retval=0 ;; |
3342 |
|
srcpkgtarball|!srcpkgtarball) retval=0 ;; |
3343 |
|
static|!static) retval=0 ;; |
3344 |
|
stepbystep|!stepbystep) retval=0 ;; |
3345 |
|
strip|!strip) retval=0 ;; |
3346 |
|
verbose|!verbose) retval=0 ;; |
3347 |
|
*) retval=1 ;; |
3348 |
|
esac |
3349 |
|
|
3350 |
|
return "${retval}" |
3351 |
|
} |
3352 |
|
|
3353 |
|
load_mage_features() |
3354 |
|
{ |
3355 |
|
for i in ${MAGE_FEATURES_GLOBAL[*]} ${MAGE_FEATURES[*]} |
3356 |
|
do |
3357 |
|
FVERBOSE=off msetfeature ${i} |
3358 |
|
done |
3359 |
|
} |
3360 |
|
|
3361 |
|
msetfeature() |
3362 |
|
{ |
3363 |
|
local feature |
3364 |
|
local count |
3365 |
|
local i |
3366 |
|
local found |
3367 |
|
|
3368 |
|
for feature in $@ |
3369 |
|
do |
3370 |
|
found=0 |
3371 |
|
count="${#MAGE_FEATURES_CURRENT[*]}" |
3372 |
|
|
3373 |
|
if ! known_mage_feature "${feature}" |
3374 |
|
then |
3375 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}" |
3376 |
|
return 3 |
3377 |
|
fi |
3378 |
|
|
3379 |
|
for ((i=0; i<count; i++)) |
3380 |
|
do |
3381 |
|
if [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature} ]] |
3382 |
|
then |
3383 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' already enabled${COLDEFAULT}" |
3384 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3385 |
|
found=1 |
3386 |
|
elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = !${feature} ]] |
3387 |
|
then |
3388 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' currently disabled, enabling it!${COLDEFAULT}" |
3389 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3390 |
|
found=1 |
3391 |
|
elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature//!} ]] |
3392 |
|
then |
3393 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature//!}' currently enabled, disabling it!${COLDEFAULT}" |
3394 |
|
MAGE_FEATURES_CURRENT[${i}]="${feature}" |
3395 |
|
found=1 |
3396 |
|
fi |
3397 |
|
done |
3398 |
|
|
3399 |
|
# if the feature was not found after proccessing the whole array |
3400 |
|
# it was not declared. in this case enable it |
3401 |
|
if [[ ${found} = 0 ]] |
3402 |
|
then |
3403 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' was not declared, enabling it!${COLDEFAULT}" |
3404 |
|
MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" ) |
3405 |
|
fi |
3406 |
|
|
3407 |
|
export MAGE_FEATURE_CURRENT |
3408 |
|
done |
3409 |
|
} |
3410 |
|
|
3411 |
|
mqueryfeature() |
3412 |
|
{ |
3413 |
|
local feature="$1" |
3414 |
|
local retval=1 |
3415 |
|
local i |
3416 |
|
|
3417 |
|
if known_mage_feature "${feature}" |
3418 |
|
then |
3419 |
|
for i in ${MAGE_FEATURES_CURRENT[*]} |
3420 |
|
do |
3421 |
|
if [[ ${i} = ${feature} ]] |
3422 |
|
then |
3423 |
|
retval=0 |
3424 |
|
break # found break here |
3425 |
|
fi |
3426 |
|
done |
3427 |
|
else |
3428 |
|
[[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}" |
3429 |
|
retval=3 |
3430 |
|
fi |
3431 |
|
|
3432 |
|
return ${retval} |
3433 |
|
} |
3434 |
|
|
3435 |
|
mprintfeatures() |
3436 |
|
{ |
3437 |
|
echo "Global features: ${MAGE_FEATURES_GLOBAL[*]}" |
3438 |
|
echo "Local features: ${MAGE_FEATURES[*]}" |
3439 |
|
echo "Current features: ${MAGE_FEATURES_CURRENT[*]}" |
3440 |
|
} |