2 |
# Magellan Linux Installer Functions (mage.functions.sh) |
# Magellan Linux Installer Functions (mage.functions.sh) |
3 |
# $Id$ |
# $Id$ |
4 |
|
|
|
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 |
|
|
|
|
5 |
mage_setup() |
mage_setup() |
6 |
{ |
{ |
7 |
[ ! -d ${MROOT}${INSTALLDB} ] && \ |
[ ! -d ${MROOT}${INSTALLDB} ] && \ |
162 |
if [ ${count_total} -gt 1 ]; then echo; fi |
if [ ${count_total} -gt 1 ]; then echo; fi |
163 |
} |
} |
164 |
|
|
|
|
|
165 |
# fix_mtime path/to/$mtime/reffile $pathto/file |
# fix_mtime path/to/$mtime/reffile $pathto/file |
166 |
# creates a given reference file and fixes given file |
# creates a given reference file and fixes given file |
167 |
# returns new mtime |
# returns new mtime |
737 |
[ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist." |
[ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist." |
738 |
|
|
739 |
# remove virtuals only if no other exist |
# remove virtuals only if no other exist |
740 |
if [[ $(count_installed_pkgs --pcat ${pcat} --pname ${pname}) -le 1 ]] |
if [[ $(count_installed_pkgs --pcat=${pcat} --pname=${pname}) -le 1 ]] |
741 |
then |
then |
742 |
# first unregister virtuals |
# first unregister virtuals |
743 |
provide="$(get_value_from_magefile PROVIDE ${magefile})" |
provide="$(get_value_from_magefile PROVIDE ${magefile})" |
766 |
local i |
local i |
767 |
|
|
768 |
# very basic getops |
# very basic getops |
769 |
for i in $* |
for i in $@ |
770 |
do |
do |
771 |
case $1 in |
case ${i} in |
772 |
--pcat|-c) shift; pcat="$1" ;; |
--pcat*) pcat="${i#*=}" ;; |
773 |
--pname|-n) shift; pname="$1" ;; |
--pname*) pname="${i#*=}" ;; |
774 |
esac |
esac |
|
shift |
|
775 |
done |
done |
776 |
|
|
777 |
# sanity checks; abort if not given |
# sanity checks; abort if not given |
1359 |
|
|
1360 |
# check known uri schemes |
# check known uri schemes |
1361 |
case ${uri} in |
case ${uri} in |
1362 |
http://*|https://*|ftp://*|ftps://*) mirrors="" ;; |
http://*|https://*|ftp://*|ftps://*|file://*) mirrors="" ;; |
1363 |
mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;; |
mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;; |
1364 |
package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;; |
package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;; |
1365 |
gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;; |
gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;; |
1426 |
# get the name of the output file |
# get the name of the output file |
1427 |
outputfile="${mirror##*/}" |
outputfile="${mirror##*/}" |
1428 |
|
|
1429 |
wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}" |
case ${mirror} in |
1430 |
retval="$?" |
file://*) |
1431 |
|
cp -v "${mirror//file:\/\/}" "${outputdir}/${outputfile}" |
1432 |
|
retval="$?" |
1433 |
|
;; |
1434 |
|
*) |
1435 |
|
wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}" |
1436 |
|
retval="$?" |
1437 |
|
;; |
1438 |
|
esac |
1439 |
|
|
1440 |
if [[ ${retval} = 0 ]] |
if [[ ${retval} = 0 ]] |
1441 |
then |
then |
1442 |
break |
break |
1683 |
fi |
fi |
1684 |
} |
} |
1685 |
|
|
|
xtitle() |
|
|
{ |
|
|
if [[ ${TERM} = xterm ]] |
|
|
then |
|
|
echo -ne "\033]0;Mage: $1\007" |
|
|
fi |
|
|
return 0 |
|
|
} |
|
|
|
|
|
|
|
|
xtitleclean() |
|
|
{ |
|
|
if [[ ${TERM} = xterm ]] |
|
|
then |
|
|
echo -ne "\033]0;\007" |
|
|
fi |
|
|
return 0 |
|
|
} |
|
|
|
|
|
|
|
1686 |
# unused? |
# unused? |
1687 |
# |
# |
1688 |
# # cuts full pathnames or versionized names down to basename |
# # cuts full pathnames or versionized names down to basename |
1722 |
echo "${categorie}" |
echo "${categorie}" |
1723 |
} |
} |
1724 |
|
|
|
# check_stable_package /path/to/foo.mage |
|
|
# returns 0=stable 1=unstable |
|
|
check_stable_package() |
|
|
{ |
|
|
# first check if this magefile is not blacklisted |
|
|
blacklisted "$1" || return 1 |
|
|
|
|
|
local STATE |
|
|
STATE="$(get_value_from_magefile STATE "$1")" |
|
|
|
|
|
# state testing |
|
|
if [[ ${USE_TESTING} = true ]] || [[ ${MAGE_DISTRIBUTION} = testing ]] |
|
|
then |
|
|
case ${STATE} in |
|
|
testing|stable) return 0 ;; |
|
|
*) return 1 ;; |
|
|
esac |
|
|
fi |
|
|
|
|
|
# state unstable |
|
|
if [[ ${USE_UNSTABLE} = true ]] || [[ ${MAGE_DISTRIBUTION} = unstable ]] |
|
|
then |
|
|
case ${STATE} in |
|
|
unstable|testing|stable) return 0 ;; |
|
|
*) return 1 ;; |
|
|
esac |
|
|
fi |
|
|
|
|
|
# no use_state given = stable |
|
|
case ${STATE} in |
|
|
stable) return 0 ;; |
|
|
*) return 1 ;; |
|
|
esac |
|
|
} |
|
|
|
|
|
|
|
1725 |
# get_highest_magefile ${PCAT} ${PNAME} |
# get_highest_magefile ${PCAT} ${PNAME} |
1726 |
# fake at moment returns only stable pkgs (must set to be one) |
# returns $HIGHEST_MAGEFILE |
|
# return $HIGHEST_MAGEFILE |
|
1727 |
get_highest_magefile() |
get_highest_magefile() |
1728 |
{ |
{ |
1729 |
local HIGHEST_MAGEFILE |
local pcat="$1" |
1730 |
local PCAT="$1" |
local pname="$2" |
|
local PNAME="$2" |
|
|
local magefile |
|
1731 |
|
|
1732 |
# do not list the content of a directory, only the name (-d) |
${MLIBDIR}/highest_magefile ${MAGEDIR}/${pcat}/${pname} |
|
for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/* 2> /dev/null) |
|
|
do |
|
|
[[ -z ${magefile} ]] && continue |
|
|
# we exclude subdirs (for stuff like a md5sum dir) |
|
|
[[ -d ${magefile} ]] && continue |
|
|
if check_stable_package ${magefile} |
|
|
then |
|
|
HIGHEST_MAGEFILE=${magefile} |
|
|
#for debug only |
|
|
mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" >&2 |
|
|
fi |
|
|
done |
|
|
|
|
|
echo "${HIGHEST_MAGEFILE}" |
|
1733 |
return 0 |
return 0 |
1734 |
} |
} |
1735 |
|
|
|
|
|
1736 |
################################################### |
################################################### |
1737 |
# function is_config_protected # |
# function is_config_protected # |
1738 |
# is_config_protected /path/to/file # |
# is_config_protected /path/to/file # |
2196 |
fi |
fi |
2197 |
} |
} |
2198 |
|
|
|
|
|
2199 |
# returns pname from pkgname |
# returns pname from pkgname |
2200 |
# pkgname2pname $PKGNAME |
# pkgname2pname $PKGNAME |
2201 |
pkgname2pname() |
pkgname2pname() |
2680 |
then |
then |
2681 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
2682 |
echo -n "rebuilding environment ... " |
echo -n "rebuilding environment ... " |
2683 |
${MLIBDIR}/env-rebuild.sh > /dev/null && \ |
${MLIBDIR}/env-rebuild > /dev/null && \ |
2684 |
echo "done." || echo "failure." |
echo "done." || echo "failure." |
2685 |
unset MAGE_ENV_REBUILD |
unset MAGE_ENV_REBUILD |
2686 |
fi |
fi |
2945 |
then |
then |
2946 |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
echo -ne "${COLBLUE} *** ${COLDEFAULT}" |
2947 |
echo -n "rebuilding environment ... " |
echo -n "rebuilding environment ... " |
2948 |
${MLIBDIR}/env-rebuild.sh > /dev/null && \ |
${MLIBDIR}/env-rebuild > /dev/null && \ |
2949 |
echo "done." || echo "failure." |
echo "done." || echo "failure." |
2950 |
unset MAGE_ENV_REBUILD |
unset MAGE_ENV_REBUILD |
2951 |
fi |
fi |
2963 |
unset -f postremove |
unset -f postremove |
2964 |
} |
} |
2965 |
|
|
2966 |
|
# rerun_pkgfunctions [method] pkg1 pkg2 pkg3 |
2967 |
|
rerun_pkgfunctions() |
2968 |
|
{ |
2969 |
|
local method |
2970 |
|
local list |
2971 |
|
local pcat |
2972 |
|
local pname |
2973 |
|
local pver |
2974 |
|
local pbuild |
2975 |
|
local magefile |
2976 |
|
local i |
2977 |
|
|
2978 |
|
# very basic getops |
2979 |
|
case $1 in |
2980 |
|
--method) shift; method="$1" ;; |
2981 |
|
esac |
2982 |
|
shift |
2983 |
|
local list="$@" |
2984 |
|
|
2985 |
|
# sanity check |
2986 |
|
case ${method} in |
2987 |
|
preinstall|postinstall) ;; |
2988 |
|
preremove|postremove) ;; |
2989 |
|
*) die "rerun_pkgfunctions(): Unknown method '${method}'." ;; |
2990 |
|
esac |
2991 |
|
|
2992 |
|
if [[ -n ${MROOT} ]] |
2993 |
|
then |
2994 |
|
echo -ne ${COLRED} |
2995 |
|
echo "!! running in MROOT=${MROOT}" |
2996 |
|
echo -ne ${COLDEFAULT} |
2997 |
|
echo |
2998 |
|
fi |
2999 |
|
|
3000 |
|
for pkg in ${list} |
3001 |
|
do |
3002 |
|
pcat=$(dep2pcat ${pkg}) |
3003 |
|
pname=$(magename2pname ${pkg}) |
3004 |
|
pver=$(magename2pver ${pkg}) |
3005 |
|
pbuild=$(magename2pbuild ${pkg}) |
3006 |
|
magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage" |
3007 |
|
|
3008 |
|
if [ -e ${magefile} ] |
3009 |
|
then |
3010 |
|
source ${magefile} |
3011 |
|
if [ -n "$(typeset -f ${method})" ] |
3012 |
|
then |
3013 |
|
echo -e " ${COLBLUE}***${COLDEFAULT} running ${method} for ${pkg} ... " |
3014 |
|
${method} |
3015 |
|
else |
3016 |
|
echo "No ${method}() for pkg '${pkg}' defined. Doing nothing." |
3017 |
|
fi |
3018 |
|
unset -f preinstall postinstall preremove postremove |
3019 |
|
else |
3020 |
|
die "Magefile '${magefile}' does not exist." |
3021 |
|
fi |
3022 |
|
done |
3023 |
|
} |
3024 |
|
|
3025 |
show_etc_update_mesg() |
show_etc_update_mesg() |
3026 |
{ |
{ |
3027 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
[ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0 |
3361 |
kernelsrcunpack|!kernelsrcunpack) retval=0 ;; |
kernelsrcunpack|!kernelsrcunpack) retval=0 ;; |
3362 |
libtool|!libtool) retval=0 ;; |
libtool|!libtool) retval=0 ;; |
3363 |
linuxsymlink|!linuxsymlink) retval=0 ;; |
linuxsymlink|!linuxsymlink) retval=0 ;; |
3364 |
|
multilib|!multilib) reval=0 ;; |
3365 |
pkgbuild|!pkgbuild) retval=0 ;; |
pkgbuild|!pkgbuild) retval=0 ;; |
3366 |
pkgdistrotag|!pkgdistrotag) retval=0 ;; |
pkgdistrotag|!pkgdistrotag) retval=0 ;; |
3367 |
|
pkgmetadata|!pkgmetadata) retval=0 ;; |
3368 |
purge|!purge) retval=0 ;; |
purge|!purge) retval=0 ;; |
3369 |
qalint|!qalint) retval=0 ;; |
qalint|!qalint) retval=0 ;; |
3370 |
regentree|!regentree) retval=0 ;; |
regentree|!regentree) retval=0 ;; |
3435 |
MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" ) |
MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" ) |
3436 |
fi |
fi |
3437 |
|
|
3438 |
export MAGE_FEATURE_CURRENT |
export MAGE_FEATURES_CURRENT |
3439 |
done |
done |
3440 |
} |
} |
3441 |
|
|