1 |
#!/bin/bash |
#!/bin/bash |
2 |
# Magellan Linux Installer Functions (mage.functions.sh) |
# Magellan Linux Installer Functions (mage.functions.sh) |
3 |
# version: 0.3.6-r8 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage3.functions.sh,v 1.15 2005-07-31 18:50:19 niro Exp $ |
4 |
|
|
5 |
mage_setup() { |
mage_setup() { |
6 |
install -d $INSTALLDB |
install -d $INSTALLDB |
49 |
do |
do |
50 |
echo "${pathto}§${posix}§${user}§${group}§${M_MTIME}§${md5sum}" \ |
echo "${pathto}§${posix}§${user}§${group}§${M_MTIME}§${md5sum}" \ |
51 |
>> ${DB_ENTRY}/.files |
>> ${DB_ENTRY}/.files |
52 |
touch -m -r ${DB_ENTRY}/.mtime ${pathto} |
touch -c -m -r ${DB_ENTRY}/.mtime ${pathto} |
53 |
done < ${DB_ENTRY}/.files-old |
done < ${DB_ENTRY}/.files-old |
54 |
|
|
55 |
#remove old list |
#remove old list |
80 |
do |
do |
81 |
echo "${pathto}§${posix}§${link}§${M_MTIME}" \ |
echo "${pathto}§${posix}§${link}§${M_MTIME}" \ |
82 |
>> ${DB_ENTRY}/.symlinks |
>> ${DB_ENTRY}/.symlinks |
83 |
touch -m -r ${DB_ENTRY}/.mtime ${pathto} |
touch -c -m -r ${DB_ENTRY}/.mtime ${pathto} |
84 |
done < ${DB_ENTRY}/.symlinks-old |
done < ${DB_ENTRY}/.symlinks-old |
85 |
|
|
86 |
#remove old list |
#remove old list |
110 |
|
|
111 |
while read pathto posix user group |
while read pathto posix user group |
112 |
do |
do |
113 |
if [ ! -z $pathto ] |
if [ ! -z "$pathto" ] |
114 |
then |
then |
115 |
if [ "$VERBOSE" == "on" ] |
if [ "$VERBOSE" == "on" ] |
116 |
then |
then |
148 |
|
|
149 |
while read pathto posix user group mtime md5sum |
while read pathto posix user group mtime md5sum |
150 |
do |
do |
151 |
if [ ! -z $pathto ] |
if [ ! -z "${pathto}" ] |
152 |
then |
then |
153 |
if [ "$VERBOSE" == "on" ] |
if [ "${VERBOSE}" == "on" ] |
154 |
then |
then |
155 |
echo -e "\t>>> FILE: $pathto" |
echo -e "\t>>> FILE: ${pathto}" |
156 |
fi |
fi |
157 |
### kleiner notfall fix ### |
### kleiner notfall fix ### |
158 |
if [ ! -d `dirname $pathto` ] |
if [ ! -d "$(dirname "${pathto}")" ] |
159 |
then |
then |
160 |
install -d `dirname $pathto` |
install -d "$(dirname "${pathto}")" |
161 |
fi |
fi |
162 |
|
|
163 |
#when file exists, check if protected |
#when file exists, check if protected |
164 |
if [ -e ${pathto} ] |
if [ -e "${pathto}" ] |
165 |
then |
then |
166 |
is_config_protected "${pathto}" |
is_config_protected "${pathto}" |
167 |
RETVAL=$? |
RETVAL=$? |
186 |
#moves the cursor up |
#moves the cursor up |
187 |
echo -en \\033[A |
echo -en \\033[A |
188 |
echo -e "${COLRED}! prot ${COLDEFAULT} === FILE: $pathto" |
echo -e "${COLRED}! prot ${COLDEFAULT} === FILE: $pathto" |
189 |
FILENAME=$(basename "${pathto}") |
FILENAME="$(basename "${pathto}")" |
190 |
FILE="$pathto" |
FILE="$pathto" |
191 |
COUNTER=$(count_protected_files ${FILE}) |
COUNTER=$(count_protected_files "${FILE}") |
192 |
DESTINATION="$(dirname "$pathto")/._cfg${COUNTER}_${FILENAME}" |
DESTINATION="$(dirname "$pathto")/._cfg${COUNTER}_${FILENAME}" |
193 |
install -m ${posix} -o ${user} -g ${group} \ |
install -m ${posix} -o ${user} -g ${group} \ |
194 |
${BUILDDIR}/${PKGNAME}/binfiles/"$FILE" \ |
${BUILDDIR}/${PKGNAME}/binfiles/"$FILE" \ |
237 |
|
|
238 |
while read pathto posix link mtime |
while read pathto posix link mtime |
239 |
do |
do |
240 |
if [ ! -z $pathto ] |
if [ ! -z "$pathto" ] |
241 |
then |
then |
242 |
if [ "$VERBOSE" == "on" ] |
if [ "$VERBOSE" == "on" ] |
243 |
then |
then |
270 |
|
|
271 |
while read pathto posix |
while read pathto posix |
272 |
do |
do |
273 |
if [ ! -z $pathto ] |
if [ ! -z "$pathto" ] |
274 |
then |
then |
275 |
if [ "$VERBOSE" == "on" ] |
if [ "$VERBOSE" == "on" ] |
276 |
then |
then |
303 |
|
|
304 |
while read pathto posix |
while read pathto posix |
305 |
do |
do |
306 |
if [ ! -z $pathto ] |
if [ ! -z "$pathto" ] |
307 |
then |
then |
308 |
if [ "$VERBOSE" == "on" ] |
if [ "$VERBOSE" == "on" ] |
309 |
then |
then |
442 |
if [ -L ${pathto} ] |
if [ -L ${pathto} ] |
443 |
then |
then |
444 |
#readlink -f resolves full path of linked file |
#readlink -f resolves full path of linked file |
445 |
x=$(stat -c %Y $(readlink -f ${pathto})) |
x=$(stat -c %Y "$(readlink -f "${pathto}")") |
446 |
else |
else |
447 |
x=$(stat -c %Y ${pathto}) |
x=$(stat -c %Y "${pathto}") |
448 |
fi |
fi |
449 |
|
|
450 |
if [ "${M_MTIME}" -eq "${x}" ] |
if [ "${M_MTIME}" -eq "${x}" ] |
475 |
|
|
476 |
while read pathto posix link mtime |
while read pathto posix link mtime |
477 |
do |
do |
478 |
if [ ! -z $pathto ] |
if [ ! -z "$pathto" ] |
479 |
then |
then |
480 |
if [ -L $pathto ] |
if [ -L "$pathto" ] |
481 |
then |
then |
482 |
compare_mtime ${PKGNAME} ${pathto} |
compare_mtime ${PKGNAME} "${pathto}" |
483 |
RETVAL=$? |
RETVAL=$? |
484 |
# 0=delete me # |
# 0=delete me # |
485 |
# 1=keep me # |
# 1=keep me # |
486 |
case ${RETVAL} in |
case ${RETVAL} in |
487 |
0) |
0) |
488 |
echo -e "\t<<< LINK: $pathto" |
echo -e "\t<<< LINK: $pathto" |
489 |
rm $pathto |
rm "$pathto" |
490 |
;; |
;; |
491 |
1) |
1) |
492 |
echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: $pathto" |
echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: $pathto" |
524 |
|
|
525 |
while read pathto posix user group mtime md5sum |
while read pathto posix user group mtime md5sum |
526 |
do |
do |
527 |
if [ ! -z $pathto ] |
if [ ! -z "$pathto" ] |
528 |
then |
then |
529 |
if [ -e $pathto ] |
if [ -e "$pathto" ] |
530 |
then |
then |
531 |
compare_mtime ${PKGNAME} ${pathto} |
compare_mtime ${PKGNAME} "${pathto}" |
532 |
RETVAL=$? |
RETVAL=$? |
533 |
# 0=delete me # |
# 0=delete me # |
534 |
# 1=keep me # |
# 1=keep me # |
535 |
case ${RETVAL} in |
case ${RETVAL} in |
536 |
0) |
0) |
537 |
echo -e "\t<<< FILE: $pathto" |
echo -e "\t<<< FILE: $pathto" |
538 |
rm $pathto |
rm "$pathto" |
539 |
;; |
;; |
540 |
1) |
1) |
541 |
echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: $pathto" |
echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: $pathto" |
570 |
|
|
571 |
while read pathto posix |
while read pathto posix |
572 |
do |
do |
573 |
if [ ! -z $pathto ] |
if [ ! -z "$pathto" ] |
574 |
then |
then |
575 |
echo -e "\t<<< PIPE: $pathto" |
echo -e "\t<<< PIPE: $pathto" |
576 |
rm $pathto |
rm "$pathto" |
577 |
fi |
fi |
578 |
done < ${INSTALLDB}/${PKGNAME}/.pipes |
done < ${INSTALLDB}/${PKGNAME}/.pipes |
579 |
|
|
600 |
|
|
601 |
while read pathto posix |
while read pathto posix |
602 |
do |
do |
603 |
if [ ! -z $pathto ] |
if [ ! -z "$pathto" ] |
604 |
then |
then |
605 |
echo -e "\t<<< CHAR: $pathto" |
echo -e "\t<<< CHAR: $pathto" |
606 |
rm $pathto |
rm "$pathto" |
607 |
fi |
fi |
608 |
done < ${INSTALLDB}/${PKGNAME}/.char |
done < ${INSTALLDB}/${PKGNAME}/.char |
609 |
|
|
637 |
|
|
638 |
while read pathto posix |
while read pathto posix |
639 |
do |
do |
640 |
if [ ! -z $pathto ] |
if [ ! -z "$pathto" ] |
641 |
then |
then |
642 |
if [ -e $pathto ] |
if [ -e "$pathto" ] |
643 |
then |
then |
644 |
echo -e "\t<<< DIR: $pathto" |
echo -e "\t<<< DIR: $pathto" |
645 |
rmdir $pathto &> /dev/null |
rmdir "$pathto" &> /dev/null |
646 |
if [ "$?" -ne "0" ] |
if [ "$?" -ne "0" ] |
647 |
then |
then |
648 |
#moves the cursor up |
#moves the cursor up |
745 |
|
|
746 |
#clean up backup files (foo~) |
#clean up backup files (foo~) |
747 |
find ${MAGEDIR} -name *~ -exec rm '{}' ';' |
find ${MAGEDIR} -name *~ -exec rm '{}' ';' |
748 |
|
|
749 |
|
# check if an newer mage version is available |
750 |
|
is_newer_mage_version_available |
751 |
} |
} |
752 |
|
|
753 |
cleanpkg(){ |
cleanpkg(){ |
994 |
fi |
fi |
995 |
done |
done |
996 |
|
|
997 |
|
# stop here if HIGHEST_MAGEFILE is zero |
998 |
|
# this package must be unstable or old |
999 |
|
if [ -z "${HIGHEST_MAGEFILE}" ] |
1000 |
|
then |
1001 |
|
echo |
1002 |
|
echo -n "All packages named " |
1003 |
|
echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT} |
1004 |
|
echo -n " are marked " |
1005 |
|
echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT} |
1006 |
|
echo "." |
1007 |
|
echo "You need to declare USE_UNSTABLE=true to install this." |
1008 |
|
echo |
1009 |
|
echo "Example:" |
1010 |
|
echo " USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}" |
1011 |
|
echo |
1012 |
|
echo "Be warned that these packages are not stable and may cause serious problems." |
1013 |
|
echo "You should know what you are doing, so don't complain about any damage." |
1014 |
|
echo |
1015 |
|
return 1 |
1016 |
|
fi |
1017 |
|
|
1018 |
MAGEFILE=${HIGHEST_MAGEFILE} |
MAGEFILE=${HIGHEST_MAGEFILE} |
1019 |
return 0 |
return 0 |
1020 |
} |
} |
1047 |
do |
do |
1048 |
#ersetzen von $i nur wenn am anfang der variable |
#ersetzen von $i nur wenn am anfang der variable |
1049 |
TEST="${EXPFILE/#${i}/Protected}" |
TEST="${EXPFILE/#${i}/Protected}" |
1050 |
if [ ${TEST} != ${EXPFILE} ] |
if [ "${TEST}" != "${EXPFILE}" ] |
1051 |
then |
then |
1052 |
#setzen das es protected ist |
#setzen das es protected ist |
1053 |
PROTECTED=TRUE |
PROTECTED=TRUE |
1056 |
for x in ${CONFIG_PROTECT_MASK} |
for x in ${CONFIG_PROTECT_MASK} |
1057 |
do |
do |
1058 |
TEST="${EXPFILE/#${x}/Protect_Masked}" |
TEST="${EXPFILE/#${x}/Protect_Masked}" |
1059 |
if [ ${TEST} != ${EXPFILE} ] |
if [ "${TEST}" != "${EXPFILE}" ] |
1060 |
then |
then |
1061 |
PROTECTED=MASKED |
PROTECTED=MASKED |
1062 |
fi |
fi |
1091 |
# exp: 0012 # |
# exp: 0012 # |
1092 |
################################################### |
################################################### |
1093 |
count_protected_files() { |
count_protected_files() { |
1094 |
${MLIBDIR}/writeprotected $1 |
${MLIBDIR}/writeprotected "$1" |
1095 |
} |
} |
1096 |
|
|
1097 |
|
|
1354 |
echo "${PKG_NAME}" |
echo "${PKG_NAME}" |
1355 |
fi |
fi |
1356 |
} |
} |
1357 |
|
|
1358 |
|
minclude() { |
1359 |
|
local i |
1360 |
|
|
1361 |
|
if [ -n "$@" ] |
1362 |
|
then |
1363 |
|
for i in $@ |
1364 |
|
do |
1365 |
|
[[ ${MAGEDEBUG} = on ]] && \ |
1366 |
|
echo "--- Including ${MAGEDIR}/include/${i}.minc" |
1367 |
|
source ${MAGEDIR}/include/${i}.minc |
1368 |
|
done |
1369 |
|
[[ ${MAGEDEBUG} = on ]] && echo |
1370 |
|
fi |
1371 |
|
} |
1372 |
|
|
1373 |
|
sminclude() { |
1374 |
|
local i |
1375 |
|
|
1376 |
|
if [ -n "$@" ] |
1377 |
|
then |
1378 |
|
for i in $@ |
1379 |
|
do |
1380 |
|
echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
1381 |
|
source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
1382 |
|
done |
1383 |
|
echo |
1384 |
|
fi |
1385 |
|
} |
1386 |
|
|
1387 |
|
# checks if an newer mage version is available |
1388 |
|
is_newer_mage_version_available() { |
1389 |
|
local newest_mage |
1390 |
|
local installed_mage |
1391 |
|
|
1392 |
|
newest_mage="$( CATEGORIE=app-mage MAGENAME=mage get_highest_magefile;echo $(basename ${MAGEFILE} .mage) )" |
1393 |
|
installed_mage="$(magequery -n mage | cut -d' ' -f5)" |
1394 |
|
|
1395 |
|
if [[ ${newest_mage} > ${installed_mage} ]] |
1396 |
|
then |
1397 |
|
echo |
1398 |
|
echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT} |
1399 |
|
echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT} |
1400 |
|
echo "It is recommened to install this newer version" |
1401 |
|
echo "or your current system installation may brake." |
1402 |
|
echo |
1403 |
|
echo -en "Please update mage by running " |
1404 |
|
echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT} |
1405 |
|
echo |
1406 |
|
fi |
1407 |
|
} |
1408 |
|
|