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} ] && \ |
164 |
[ -z "${pathto}" ] && continue |
[ -z "${pathto}" ] && continue |
165 |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR: ${MROOT}${pathto}" |
[[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR: ${MROOT}${pathto}" |
166 |
|
|
|
|
|
167 |
# monitors /etc/env.d -> env-rebuild |
# monitors /etc/env.d -> env-rebuild |
168 |
[[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true |
[[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true |
169 |
|
|
1387 |
done |
done |
1388 |
|
|
1389 |
# clean up backup files (foo~) |
# clean up backup files (foo~) |
1390 |
find ${MAGEDIR} -name *~ -exec rm '{}' ';' |
find ${MAGEDIR} -name \*~ -exec rm '{}' ';' |
1391 |
|
|
1392 |
# check if a newer mage version is available |
# check if a newer mage version is available |
1393 |
is_newer_mage_version_available |
is_newer_mage_version_available |
1401 |
local mirr mymirr |
local mirr mymirr |
1402 |
local opt |
local opt |
1403 |
local tar_opts |
local tar_opts |
1404 |
|
local wget_opts |
1405 |
|
|
1406 |
# try to get the md5 marked as latest on the server |
# try to get the md5 marked as latest on the server |
1407 |
latest_md5="mage-latest.md5" |
latest_md5="mage-latest.md5" |
1409 |
# try to get the tarball marked as latest on the server |
# try to get the tarball marked as latest on the server |
1410 |
latest_tarball="mage-latest.tar.bz2" |
latest_tarball="mage-latest.tar.bz2" |
1411 |
|
|
1412 |
|
# filter wget command if busybox was found |
1413 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
1414 |
|
|
1415 |
for mirr in ${MIRRORS} |
for mirr in ${MIRRORS} |
1416 |
do |
do |
1417 |
# path without distribution |
# path without distribution |
1421 |
echo "fetching latest md5 from ${mymirr} ..." |
echo "fetching latest md5 from ${mymirr} ..." |
1422 |
[[ ${VERBOSE} = off ]] && opt="--quiet" |
[[ ${VERBOSE} = off ]] && opt="--quiet" |
1423 |
wget \ |
wget \ |
1424 |
${WGET_FETCH_OPTIONS} \ |
${wget_opts} \ |
1425 |
--directory-prefix=${temp} \ |
--directory-prefix=${temp} \ |
1426 |
${opt} ${mymirr}/rsync/tarballs/${latest_md5} |
${opt} ${mymirr}/rsync/tarballs/${latest_md5} |
1427 |
|
|
1428 |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
echo -ne "${COLBLUE} --- ${COLDEFAULT}" |
1429 |
echo "fetching latest tarball from ${mymirr} ..." |
echo "fetching latest tarball from ${mymirr} ..." |
1430 |
wget \ |
wget \ |
1431 |
${WGET_FETCH_OPTIONS} \ |
${wget_opts} \ |
1432 |
--directory-prefix=${temp} \ |
--directory-prefix=${temp} \ |
1433 |
${opt} ${mymirr}/rsync/tarballs/${latest_tarball} |
${opt} ${mymirr}/rsync/tarballs/${latest_tarball} |
1434 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
1514 |
} |
} |
1515 |
|
|
1516 |
|
|
1517 |
# cuts full pathnames or versioniezed names down to basename |
# cuts full pathnames or versionized names down to basename |
1518 |
choppkgname() |
choppkgname() |
1519 |
{ |
{ |
1520 |
#we want this only if full name was used |
#we want this only if full name was used |
1597 |
local magefile |
local magefile |
1598 |
|
|
1599 |
# do not list the content of a directory, only the name (-d) |
# do not list the content of a directory, only the name (-d) |
1600 |
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) |
1601 |
do |
do |
1602 |
[[ -z ${magefile} ]] && continue |
[[ -z ${magefile} ]] && continue |
1603 |
# we exclude subdirs (for stuff like a md5sum dir) |
# we exclude subdirs (for stuff like a md5sum dir) |
1610 |
fi |
fi |
1611 |
done |
done |
1612 |
|
|
|
# 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 |
|
|
|
|
1613 |
echo "${HIGHEST_MAGEFILE}" |
echo "${HIGHEST_MAGEFILE}" |
1614 |
return 0 |
return 0 |
1615 |
} |
} |
2462 |
if [[ -n ${MAGE_TARGETS} ]] |
if [[ -n ${MAGE_TARGETS} ]] |
2463 |
then |
then |
2464 |
# basic svn compat |
# basic svn compat |
2465 |
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2466 |
then |
then |
2467 |
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 |
2468 |
do |
do |
2469 |
smage2file="${i}" |
smage2file="${i}" |
2470 |
done |
done |
2475 |
elif [[ -n ${SPLIT_PACKAGE_BASE} ]] |
elif [[ -n ${SPLIT_PACKAGE_BASE} ]] |
2476 |
then |
then |
2477 |
# basic svn compat |
# basic svn compat |
2478 |
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2479 |
then |
then |
2480 |
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 |
2481 |
do |
do |
2482 |
smage2file="${i}" |
smage2file="${i}" |
2483 |
done |
done |
2487 |
|
|
2488 |
else |
else |
2489 |
# basic svn compat |
# basic svn compat |
2490 |
if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] |
if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] |
2491 |
then |
then |
2492 |
for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2 |
2493 |
do |
do |
2494 |
smage2file="${i}" |
smage2file="${i}" |
2495 |
done |
done |
3089 |
then |
then |
3090 |
# needs busybox support |
# needs busybox support |
3091 |
return 0 |
return 0 |
|
else |
|
|
# no busybox |
|
|
return 1 |
|
3092 |
fi |
fi |
3093 |
fi |
fi |
3094 |
|
|
3095 |
|
# no busybox |
3096 |
|
return 1 |
3097 |
} |
} |
3098 |
|
|
3099 |
# busybox_filter_wget_options ${wget_opts} |
# busybox_filter_wget_options ${wget_opts} |
3128 |
echo "${opts}" |
echo "${opts}" |
3129 |
fi |
fi |
3130 |
} |
} |
3131 |
|
|
3132 |
|
have_root_privileges() |
3133 |
|
{ |
3134 |
|
local retval |
3135 |
|
|
3136 |
|
if [[ $(id -u) = 0 ]] |
3137 |
|
then |
3138 |
|
retval=0 |
3139 |
|
else |
3140 |
|
retval=1 |
3141 |
|
fi |
3142 |
|
|
3143 |
|
return ${retval} |
3144 |
|
} |