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} ] && \ |
1388 |
done |
done |
1389 |
|
|
1390 |
# clean up backup files (foo~) |
# clean up backup files (foo~) |
1391 |
find ${MAGEDIR} -name *~ -exec rm '{}' ';' |
find ${MAGEDIR} -name \*~ -exec rm '{}' ';' |
1392 |
|
|
1393 |
# check if a newer mage version is available |
# check if a newer mage version is available |
1394 |
is_newer_mage_version_available |
is_newer_mage_version_available |
1402 |
local mirr mymirr |
local mirr mymirr |
1403 |
local opt |
local opt |
1404 |
local tar_opts |
local tar_opts |
1405 |
|
local wget_opts |
1406 |
|
|
1407 |
# try to get the md5 marked as latest on the server |
# try to get the md5 marked as latest on the server |
1408 |
latest_md5="mage-latest.md5" |
latest_md5="mage-latest.md5" |
1410 |
# try to get the tarball marked as latest on the server |
# try to get the tarball marked as latest on the server |
1411 |
latest_tarball="mage-latest.tar.bz2" |
latest_tarball="mage-latest.tar.bz2" |
1412 |
|
|
1413 |
|
# filter wget command if busybox was found |
1414 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1415 |
|
|
1416 |
for mirr in ${MIRRORS} |
for mirr in ${MIRRORS} |
1417 |
do |
do |
1418 |
# path without distribution |
# path without distribution |
1422 |
echo "fetching latest md5 from ${mymirr} ..." |
echo "fetching latest md5 from ${mymirr} ..." |
1423 |
[[ ${VERBOSE} = off ]] && opt="--quiet" |
[[ ${VERBOSE} = off ]] && opt="--quiet" |
1424 |
wget \ |
wget \ |
1425 |
${WGET_FETCH_OPTIONS} \ |
${wget_opts} \ |
1426 |
--directory-prefix=${temp} \ |
--directory-prefix=${temp} \ |
1427 |
${opt} ${mymirr}/rsync/tarballs/${latest_md5} |
${opt} ${mymirr}/rsync/tarballs/${latest_md5} |
1428 |
|
|
1429 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1430 |
echo "fetching latest tarball from ${mymirr} ..." |
echo "fetching latest tarball from ${mymirr} ..." |
1431 |
wget \ |
wget \ |
1432 |
${WGET_FETCH_OPTIONS} \ |
${wget_opts} \ |
1433 |
--directory-prefix=${temp} \ |
--directory-prefix=${temp} \ |
1434 |
${opt} ${mymirr}/rsync/tarballs/${latest_tarball} |
${opt} ${mymirr}/rsync/tarballs/${latest_tarball} |
1435 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
1598 |
local magefile |
local magefile |
1599 |
|
|
1600 |
# do not list the content of a directory, only the name (-d) |
# do not list the content of a directory, only the name (-d) |
1601 |
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) |
1602 |
do |
do |
1603 |
[[ -z ${magefile} ]] && continue |
[[ -z ${magefile} ]] && continue |
1604 |
# we exclude subdirs (for stuff like a md5sum dir) |
# we exclude subdirs (for stuff like a md5sum dir) |
2485 |
if [[ -n ${MAGE_TARGETS} ]] |
if [[ -n ${MAGE_TARGETS} ]] |
2486 |
then |
then |
2487 |
# basic svn compat |
# basic svn compat |
2488 |
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2489 |
then |
then |
2490 |
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 |
2491 |
do |
do |
2492 |
smage2file="${i}" |
smage2file="${i}" |
2493 |
done |
done |
2498 |
elif [[ -n ${SPLIT_PACKAGE_BASE} ]] |
elif [[ -n ${SPLIT_PACKAGE_BASE} ]] |
2499 |
then |
then |
2500 |
# basic svn compat |
# basic svn compat |
2501 |
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2502 |
then |
then |
2503 |
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 |
2504 |
do |
do |
2505 |
smage2file="${i}" |
smage2file="${i}" |
2506 |
done |
done |
2510 |
|
|
2511 |
else |
else |
2512 |
# basic svn compat |
# basic svn compat |
2513 |
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2514 |
then |
then |
2515 |
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2516 |
do |
do |
2517 |
smage2file="${i}" |
smage2file="${i}" |
2518 |
done |
done |
3112 |
then |
then |
3113 |
# needs busybox support |
# needs busybox support |
3114 |
return 0 |
return 0 |
|
else |
|
|
# no busybox |
|
|
return 1 |
|
3115 |
fi |
fi |
3116 |
fi |
fi |
3117 |
|
|
3118 |
|
# no busybox |
3119 |
|
return 1 |
3120 |
} |
} |
3121 |
|
|
3122 |
# busybox_filter_wget_options ${wget_opts} |
# busybox_filter_wget_options ${wget_opts} |
3151 |
echo "${opts}" |
echo "${opts}" |
3152 |
fi |
fi |
3153 |
} |
} |
3154 |
|
|
3155 |
|
have_root_privileges() |
3156 |
|
{ |
3157 |
|
local retval |
3158 |
|
|
3159 |
|
if [[ $(id -u) = 0 ]] |
3160 |
|
then |
3161 |
|
retval=0 |
3162 |
|
else |
3163 |
|
retval=1 |
3164 |
|
fi |
3165 |
|
|
3166 |
|
return ${retval} |
3167 |
|
} |