Magellan Linux

Diff of /trunk/mage/usr/lib/mage/mage4.functions.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 415 by niro, Sun Jan 21 23:22:15 2007 UTC revision 1271 by niro, Wed Apr 27 08:42:24 2011 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
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.24 2007-01-21 23:22:15 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  mage_setup()  mage_setup()
6  {  {
# Line 198  install_files() Line 198  install_files()
198   is_config_protected "${pathto}"   is_config_protected "${pathto}"
199   retval="$?"   retval="$?"
200    
201   # 0 - not protected        #   # 0 - not protected         #
202   # 1 - error                #   # 1 - error                 #
203   # 2 - protected            #   # 2 - protected             #
204   # 3 - protected but masked #   # 3 - protected but masked  #
205     # 4 - protected but ignored #
206    
207   case ${retval} in   case ${retval} in
208   # file is not protected - (over)write it   # file is not protected - (over)write it
# Line 252  install_files() Line 253  install_files()
253   (( MAGE_PROTECT_COUNTER++ ))   (( MAGE_PROTECT_COUNTER++ ))
254   export MAGE_PROTECT_COUNTER   export MAGE_PROTECT_COUNTER
255   ;;   ;;
256    
257     # file is protected but ignored, delete the update/do nothing
258     4)
259     if [[ ${VERBOSE} = on ]]
260     then
261     echo -en "${COLRED}"
262     echo -n "! ignr "
263     echo -en "${COLDEFAULT}"
264     echo " === FILE: ${MROOT}${pathto}"
265     fi
266     # simply do nothing here
267     ;;
268   esac   esac
269   done < ${BUILDDIR}/${pkgname}/.files   done < ${BUILDDIR}/${pkgname}/.files
270    
# Line 298  install_symlinks() Line 311  install_symlinks()
311    
312   ln -snf "${link}" "${MROOT}${pathto}"   ln -snf "${link}" "${MROOT}${pathto}"
313    
314   # fix mtime and db  # # fix mtime and db
315   fix_descriptor ${pkgname}/.symlinks \  # fix_descriptor ${pkgname}/.symlinks \
316   "${pathto}" \  # "${pathto}" \
317   "${posix}" \  # "${posix}" \
318   "${link}" \  # "${link}" \
319   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \  # "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
320   "${MROOT}${pathto}")"  # "${MROOT}${pathto}")"
321    
322   done < ${BUILDDIR}/${pkgname}/.symlinks   done < ${BUILDDIR}/${pkgname}/.symlinks
323    
324   # now copy the fixed file over the old one  # # now copy the fixed file over the old one
325   [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \  # [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \
326   cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,}  # cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,}
327    
328   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
329   IFS=$'\n'   IFS=$'\n'
# Line 326  install_blockdevices() Line 339  install_blockdevices()
339   local pkgname="$1"   local pkgname="$1"
340   local pathto   local pathto
341   local posix   local posix
342     local user
343     local group
344   local IFS   local IFS
345    
346   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 339  install_blockdevices() Line 354  install_blockdevices()
354   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
355   IFS=§   IFS=§
356    
357   while read pathto posix   while read pathto posix major minor user group
358   do   do
359   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
360   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"
361    
362   mkfifo -m "${posix}" "${MROOT}$pathto"   mknod -m "${posix}" "${MROOT}${pathto}"
363     # make it optional atm !!
364     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
365     then
366     chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}"
367     fi
368   done < ${BUILDDIR}/${pkgname}/.pipes   done < ${BUILDDIR}/${pkgname}/.pipes
369    
370   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
# Line 363  install_characterdevices() Line 383  install_characterdevices()
383   local posix   local posix
384   local major   local major
385   local minor   local minor
386     local user
387     local group
388   local IFS   local IFS
389    
390   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 376  install_characterdevices() Line 398  install_characterdevices()
398   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
399   IFS=§   IFS=§
400    
401   while read pathto posix major minor   while read pathto posix major minor user group
402   do   do
403   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
404   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"
405    
406   mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor}   mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}"
407    
408     # make it optional atm !!
409     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
410     then
411     chown "${user}:${group}" "${MROOT}${pathto}"
412     fi
413   done < ${BUILDDIR}/${pkgname}/.char   done < ${BUILDDIR}/${pkgname}/.char
414    
415   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
416   IFS=$'\n'   IFS=$'\n'
417  }  }
418    
419    ###################################################
420    # function install_fifos                          #
421    # install_fifos $PKGNAME                    #
422    ###################################################
423    install_fifos()
424    {
425     local pkgname="$1"
426     local pathto
427     local posix
428     local user
429     local group
430     local IFS
431    
432     # sanity checks; abort if not given
433     [ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given."
434    
435     # check needed global vars
436     [ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set."
437    
438     # make it optional atm !!
439     #[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found"
440     [ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return
441    
442     # sets fieldseperator to "§" instead of " "
443     IFS=§
444    
445     while read pathto posix user group
446     do
447     [ -z "${pathto}" ] && continue
448     [[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}"
449    
450     mkfifo -m "${posix}" "${MROOT}${pathto}"
451     chown "${user}:${group}" "${MROOT}${pathto}"
452     done < ${BUILDDIR}/${pkgname}/.fifo
453    
454     # very important: unsetting the '§' fieldseperator
455     IFS=$'\n'
456    }
457    
458    
459  ###################################################  ###################################################
460  # function build_doinstall                        #  # function build_doinstall                        #
461  # build_doinstall $PKGNAME                  #  # build_doinstall $PKGNAME                  #
462  # NOTE: this is an wrapper do install packages    #  # NOTE: this is an wrapper to install packages    #
463  ###################################################  ###################################################
464  build_doinstall()  build_doinstall()
465  {  {
# Line 415  build_doinstall() Line 482  build_doinstall()
482   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"
483   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"
484   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"
485     install_fifos ${pkgname} || die "install fifos ${pkgname}"
486  }  }
487    
488    
# Line 476  install_database_entry() Line 544  install_database_entry()
544    
545   # create fake file descriptors   # create fake file descriptors
546   # used by virtual and source packages   # used by virtual and source packages
547   for i in .dirs .symlinks .files .pipes .char   for i in .dirs .symlinks .files .pipes .char .fifo
548   do   do
549   touch ${dbrecorddir}/${i}   touch ${dbrecorddir}/${i}
550   done   done
# Line 494  install_database_entry() Line 562  install_database_entry()
562    
563   # normal packages needs these files   # normal packages needs these files
564   local i   local i
565   for i in .char .dirs .files .pipes .symlinks   for i in .char .dirs .files .pipes .symlinks .fifo
566   do   do
567   install -m 0644 ${BUILDDIR}/${pkgname}/${i} \   # make .fifo optional atm
568   ${dbrecorddir}/${i}   if [[ -f ${BUILDDIR}/${pkgname}/${i} ]]
569     then
570     install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i}
571     fi
572   done   done
573   ;;   ;;
574   esac   esac
# Line 772  remove_files() Line 843  remove_files()
843   done   done
844    
845   # sanity checks; abort if not given   # sanity checks; abort if not given
846   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_files() \$pcat not given."
847   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_files() \$pname not given."
848   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_files() \$pver not given."
849   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_files() \$pbuild not given."
850   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
851    
852   # check needed global vars   # check needed global vars
# Line 809  remove_files() Line 880  remove_files()
880   is_config_protected "${pathto}"   is_config_protected "${pathto}"
881   retval="$?"   retval="$?"
882    
883   # 0 - not protected        #   # 0 - not protected         #
884   # 1 - error                #   # 1 - error                 #
885   # 2 - protected            #   # 2 - protected             #
886   # 3 - protected but masked #   # 3 - protected but masked  #
887     # 4 - protected but ignored #
888    
889   case ${retval} in   case ${retval} in
890   # file is not protected - delete it   # file is not protected - delete it
# Line 831  remove_files() Line 903  remove_files()
903   echo " === FILE: ${MROOT}${pathto}"   echo " === FILE: ${MROOT}${pathto}"
904   fi   fi
905   ;;   ;;
906    
907     # file is protected but ignored, delete the update/do nothing
908     4)
909     if [[ ${VERBOSE} = on ]]
910     then
911     echo -en "${COLRED}"
912     echo -n "! ignr "
913     echo -en "${COLDEFAULT}"
914     echo " === FILE: ${MROOT}${pathto}"
915     fi
916     # simply do nothing here
917     ;;
918   esac   esac
919   ;;   ;;
920   1)   1)
# Line 853  remove_blockdevices() Line 937  remove_blockdevices()
937  {  {
938   local pathto   local pathto
939   local posix   local posix
940     local user
941     local group
942   local IFS   local IFS
943   local pcat   local pcat
944   local pname   local pname
# Line 876  remove_blockdevices() Line 962  remove_blockdevices()
962   done   done
963    
964   # sanity checks; abort if not given   # sanity checks; abort if not given
965   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given."
966   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_blockdevices() \$pname not given."
967   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_blockdevices() \$pver not given."
968   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given."
969   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
970    
971   # check needed global vars   # check needed global vars
# Line 890  remove_blockdevices() Line 976  remove_blockdevices()
976   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
977   IFS=§   IFS=§
978    
979   while read pathto posix   while read pathto posix user group
980   do   do
981   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
982    
# Line 911  remove_characterdevices() Line 997  remove_characterdevices()
997  {  {
998   local pathto   local pathto
999   local posix   local posix
1000     local user
1001     local group
1002   local IFS   local IFS
1003   local pcat   local pcat
1004   local pname   local pname
# Line 934  remove_characterdevices() Line 1022  remove_characterdevices()
1022   done   done
1023    
1024   # sanity checks; abort if not given   # sanity checks; abort if not given
1025   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given."
1026   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_characterdevices() \$pname not given."
1027   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_characterdevices() \$pver not given."
1028   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given."
1029   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1030    
1031   # check needed global vars   # check needed global vars
# Line 948  remove_characterdevices() Line 1036  remove_characterdevices()
1036   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1037   IFS=§   IFS=§
1038    
1039   while read pathto posix   while read pathto posix user group
1040   do   do
1041   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1042    
# Line 962  remove_characterdevices() Line 1050  remove_characterdevices()
1050    
1051    
1052  ###################################################  ###################################################
1053    # function remove_fifos                           #
1054    # remove_fifos $PKGNAME                     #
1055    ###################################################
1056    remove_fifos()
1057    {
1058     local pathto
1059     local posix
1060     local user
1061     local group
1062     local IFS
1063     local pcat
1064     local pname
1065     local pver
1066     local pbuild
1067     local i
1068     local pfull
1069    
1070     IFS=$'\n'
1071    
1072     # very basic getops
1073     for i in $*
1074     do
1075     case $1 in
1076     --pcat|-c) shift; pcat="$1" ;;
1077     --pname|-n) shift; pname="$1" ;;
1078     --pver|-v) shift; pver="$1" ;;
1079     --pbuild|-b) shift; pbuild="$1" ;;
1080     esac
1081     shift
1082     done
1083    
1084     # sanity checks; abort if not given
1085     [ -z "${pcat}" ] && die "remove_fifos() \$pcat not given."
1086     [ -z "${pname}" ] && die "remove_fifos() \$pname not given."
1087     [ -z "${pver}" ] && die "remove_fifos() \$pver not given."
1088     [ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given."
1089     pfull="${pcat}/${pname}-${pver}-${pbuild}"
1090    
1091     # check needed global vars
1092     [ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set."
1093    
1094     # make it optional atm !!
1095     #[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found"
1096     [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return
1097    
1098     # sets fieldseperator to "§" instead of " "
1099     IFS=§
1100    
1101     while read pathto posix user group
1102     do
1103     [ -z "${pathto}" ] && continue
1104    
1105     [[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}"
1106     rm "${MROOT}${pathto}"
1107     done < ${MROOT}${INSTALLDB}/${pfull}/.fifo
1108    
1109     # very important: unsetting the '§' fieldseperator
1110     IFS=$'\n'
1111    }
1112    
1113    
1114    ###################################################
1115  # function remove_direcories                      #  # function remove_direcories                      #
1116  # remove_direcories $PKGNAME                #  # remove_direcories $PKGNAME                #
1117  ###################################################  ###################################################
# Line 992  remove_directories() Line 1142  remove_directories()
1142   done   done
1143    
1144   # sanity checks; abort if not given   # sanity checks; abort if not given
1145   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_directories() \$pcat not given."
1146   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_directories() \$pname not given."
1147   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_directories() \$pver not given."
1148   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given."
1149   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1150    
1151   # check needed global vars   # check needed global vars
# Line 1049  remove_directories() Line 1199  remove_directories()
1199  ###################################################  ###################################################
1200  # function build_douninstall                      #  # function build_douninstall                      #
1201  # build_douninstall $PKGNAME                #  # build_douninstall $PKGNAME                #
1202  # NOTE: this is an wrapper do remove packages     #  # NOTE: this is an wrapper to remove packages     #
1203  ###################################################  ###################################################
1204  build_douninstall()  build_douninstall()
1205  {  {
# Line 1083  build_douninstall() Line 1233  build_douninstall()
1233   # !! we use § as field seperator !!   # !! we use § as field seperator !!
1234   # doing so prevent us to get errors by filenames with spaces   # doing so prevent us to get errors by filenames with spaces
1235    
1236   for i in symlinks files blockdevices characterdevices directories   for i in symlinks files blockdevices characterdevices directories fifos
1237   do   do
1238   remove_${i} \   remove_${i} \
1239   --pcat "${pcat}" \   --pcat "${pcat}" \
# Line 1106  fetch_packages() Line 1256  fetch_packages()
1256   local count_current   local count_current
1257   local count_total   local count_total
1258    
1259   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your /etc/mage.rc."   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."
1260    
1261   # get count of total packages   # get count of total packages
1262   declare -i count_current=0   declare -i count_current=0
# Line 1153  fetch_packages() Line 1303  fetch_packages()
1303   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1304   [[ ${VERBOSE} = off ]] && opt="--quiet"   [[ ${VERBOSE} = off ]] && opt="--quiet"
1305   wget \   wget \
1306   --passive-ftp \   ${WGET_FETCH_OPTIONS} \
  --tries 3 \  
  --continue \  
  --progress bar \  
1307   --directory-prefix=${PKGDIR} \   --directory-prefix=${PKGDIR} \
1308   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}
1309   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 1181  syncmage() Line 1328  syncmage()
1328  {  {
1329   if [ -z "${RSYNC}" ]   if [ -z "${RSYNC}" ]
1330   then   then
1331   die "You have no rsync-mirrors defined. Please edit your /etc/mage.rc."   die "You have no rsync-mirrors defined. Please edit your ${MAGERC}."
1332   fi   fi
1333    
1334   local i   local i
# Line 1199  syncmage() Line 1346  syncmage()
1346   # clean up backup files (foo~)   # clean up backup files (foo~)
1347   find ${MAGEDIR} -name *~ -exec rm '{}' ';'   find ${MAGEDIR} -name *~ -exec rm '{}' ';'
1348    
1349   # check if an newer mage version is available   # check if a newer mage version is available
1350   is_newer_mage_version_available   is_newer_mage_version_available
1351  }  }
1352    
1353    syncmage_tarball()
1354    {
1355     local latest_tarball
1356     local latest_md5
1357     local temp="$(mktemp -d)"
1358     local mirr mymirr
1359     local opt
1360    
1361     # try to get the md5 marked as latest on the server
1362     latest_md5="mage-latest.md5"
1363    
1364     # try to get the tarball marked as latest on the server
1365     latest_tarball="mage-latest.tar.bz2"
1366    
1367     for mirr in ${MIRRORS}
1368     do
1369     # path without distribution
1370     mymirr="${mirr%/*}"
1371    
1372     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1373     echo "fetching latest md5 from ${mymirr} ..."
1374     [[ ${VERBOSE} = off ]] && opt="--quiet"
1375     wget \
1376     ${WGET_FETCH_OPTIONS} \
1377     --directory-prefix=${temp} \
1378     ${opt} ${mymirr}/rsync/tarballs/${latest_md5}
1379    
1380     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1381     echo "fetching latest tarball from ${mymirr} ..."
1382     wget \
1383     ${WGET_FETCH_OPTIONS} \
1384     --directory-prefix=${temp} \
1385     ${opt} ${mymirr}/rsync/tarballs/${latest_tarball}
1386     if [[ $? = 0 ]]
1387     then
1388     break
1389     else
1390     continue
1391     fi
1392     done
1393    
1394     if [[ -f ${temp}/${latest_tarball} ]]
1395     then
1396     # check md5
1397     if [[ ! -f ${temp}/${latest_md5} ]]
1398     then
1399     die "md5 is missing ... aborting"
1400     else
1401     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1402     echo -n "checking md5sum... "
1403     ( cd ${temp}; md5sum --check ${latest_md5} ) || die "md5 for ${latest_tarball} failed"
1404     fi
1405    
1406     if [[ -d ${MAGEDIR} ]]
1407     then
1408     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1409     echo "cleaning old mage-tree ${MAGEDIR}..."
1410     rm -rf ${MAGEDIR}
1411     fi
1412    
1413     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1414     echo "updating mage-tree from tarball ..."
1415     # unpack in dirname of MAGEDIR, as the tarball has already the mage
1416     tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1417    
1418     if [[ -d ${temp} ]]
1419     then
1420     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1421     echo "cleaning temp-files ..."
1422     rm -rf ${temp}
1423     fi
1424    
1425     # check if a newer mage version is available
1426     is_newer_mage_version_available
1427     else
1428     die "Could not fetch the latest tarball ... aborting"
1429     fi
1430    }
1431    
1432  cleanpkg()  cleanpkg()
1433  {  {
1434   if [ -d "${PKGDIR}" ]   if [ -d "${PKGDIR}" ]
# Line 1240  choppkgname() Line 1466  choppkgname()
1466   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]
1467   then   then
1468   #cuts ARCH and PBUILD   #cuts ARCH and PBUILD
1469   #ARCH comes from /etc/mage.rc   #ARCH comes from ${MAGERC}
1470   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")
1471    
1472   #cuts version number   #cuts version number
# Line 1315  get_highest_magefile() Line 1541  get_highest_magefile()
1541   local PNAME="$2"   local PNAME="$2"
1542   local magefile   local magefile
1543    
1544   for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*)   # do not list the content of a directory, only the name (-d)
1545     for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*)
1546   do   do
1547     [[ -z ${magefile} ]] && continue
1548   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
1549   [ -d ${magefile} ] && continue   [[ -d ${magefile} ]] && continue
1550   if check_stable_package ${magefile}   if check_stable_package ${magefile}
1551   then   then
1552   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
# Line 1363  get_highest_magefile() Line 1591  get_highest_magefile()
1591  #        1 - error                                #  #        1 - error                                #
1592  #        2 - protected                            #  #        2 - protected                            #
1593  #        3 - protected but masked                 #  #        3 - protected but masked                 #
1594    #        4 - protected but ignored                #
1595  #                                                 #  #                                                 #
1596  ###################################################  ###################################################
1597  is_config_protected()  is_config_protected()
# Line 1371  is_config_protected() Line 1600  is_config_protected()
1600   local TEST   local TEST
1601   local PROTECTED   local PROTECTED
1602   local IFS   local IFS
1603     local i
1604     local x
1605    
1606   EXPFILE="${MROOT}$1"   EXPFILE="${MROOT}$1"
1607    
1608   # file does not exist; it can be written   # file does not exist; it can be written
1609   [ ! -e ${EXPFILE} ] && return 0   [[ ! -e ${EXPFILE} ]] && return 0
1610    
1611   # to be safe; it may be '§'   # to be safe; it may be '§'
1612   IFS=' '   IFS=' '
1613    
1614   # check ob in config protect   # check if config protected
1615   for i in ${CONFIG_PROTECT}   for i in ${CONFIG_PROTECT}
1616   do   do
1617   # ersetzen von $i nur wenn am anfang der variable   # only replace $i in the beginning of the variable
1618   TEST="${EXPFILE/#${MROOT}${i}/Protected}"   TEST="${EXPFILE/#${MROOT}${i}/Protected}"
1619   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1620   then   then
1621   # setzen das es protected ist   # file is config proteced
1622   PROTECTED=TRUE   PROTECTED=TRUE
1623    
1624   # check ob nicht doch maskiert   # check if not masked
1625   for x in ${CONFIG_PROTECT_MASK}   for x in ${CONFIG_PROTECT_MASK}
1626   do   do
1627   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"
1628   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1629   then   then
1630   PROTECTED=MASKED   PROTECTED=MASKED
1631   fi   fi
1632   done   done
1633    
1634     # check if not ignored
1635     for x in ${CONFIG_PROTECT_IGNORE}
1636     do
1637     TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}"
1638     if [[ ${TEST} != ${EXPFILE} ]]
1639     then
1640     PROTECTED=IGNORED
1641     fi
1642     done
1643   fi   fi
1644   done   done
1645    
# Line 1413  is_config_protected() Line 1654  is_config_protected()
1654   #echo "I'm protected, but masked - delete me"   #echo "I'm protected, but masked - delete me"
1655   return 3   return 3
1656   ;;   ;;
1657     IGNORED)
1658     #echo "I'm protected, but ignored - keep me, del update"
1659     return 4
1660     ;;
1661   *)   *)
1662   #echo "delete me"   #echo "delete me"
1663   return 0   return 0
# Line 1430  is_config_protected() Line 1675  is_config_protected()
1675  ###################################################  ###################################################
1676  count_protected_files()  count_protected_files()
1677  {  {
1678   ${MLIBDIR}/writeprotected "$1"   local file="$1"
1679     local dirname="${file%/*}"
1680     local filename="${file##*/}"
1681     local count
1682     local output
1683     local i
1684    
1685     declare -i count=0
1686    
1687     # check if there are already protected files
1688     for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" |
1689     sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
1690     sort -t'%' -k3 -k2 | cut -f1 -d'%')
1691     do
1692     count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::")
1693     done
1694     (( count ++ ))
1695    
1696     # fill output up with zeros
1697     for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
1698     output="${output}${count}"
1699    
1700     echo "${output}"
1701  }  }
1702    
1703  # call with  # call with
# Line 1447  get_uninstall_candidates() Line 1714  get_uninstall_candidates()
1714   local list   local list
1715   local pcatdir   local pcatdir
1716   local protected   local protected
1717     local i
1718    
1719   # very basic getops   # very basic getops
1720   for i in $*   for i in $*
# Line 1601  virtuals_add() Line 1869  virtuals_add()
1869    
1870  #deletes pakages from virtual database  #deletes pakages from virtual database
1871  #$1 virtualname; $2 pkgname  #$1 virtualname; $2 pkgname
1872  virtuals_del() {  virtuals_del()
1873    {
1874    
1875   local virtualname="$1"   local virtualname="$1"
1876   local pkgname="$2"   local pkgname="$2"
# Line 1708  minclude() Line 1977  minclude()
1977  {  {
1978   local i   local i
1979    
1980   if [[ -n $@ ]]   if [[ -n $* ]]
1981   then   then
1982   for i in $@   for i in $*
1983   do   do
1984   [[ ${MAGEDEBUG} = on ]] && \   [[ ${MAGEDEBUG} = on ]] && \
1985   echo "--- Including ${MAGEDIR}/include/${i}.minc"   echo "--- Including ${MAGEDIR}/include/${i}.minc"
# Line 1724  sminclude() Line 1993  sminclude()
1993  {  {
1994   local i   local i
1995    
1996   if [ -n "$@" ]   if [[ -n $* ]]
1997   then   then
1998   for i in $@   for i in $*
1999   do   do
2000   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
2001   source ${SMAGESCRIPTSDIR}/include/${i}.sminc   source ${SMAGESCRIPTSDIR}/include/${i}.sminc
# Line 2035  get_value_from_magefile() Line 2304  get_value_from_magefile()
2304   local SDEPEND   local SDEPEND
2305   local PROVIDE   local PROVIDE
2306   local PKGTYPE   local PKGTYPE
2307     local MAGE_TARGETS
2308     local SPLIT_PACKAGE_BASE
2309   local preinstall   local preinstall
2310   local postinstall   local postinstall
2311   local preremove   local preremove
# Line 2081  mage_install() Line 2352  mage_install()
2352   local count_current   local count_current
2353   local magefile   local magefile
2354   local src_install   local src_install
2355     local i
2356    
2357   # very basic getops   # very basic getops
2358   for i in $*   for i in $*
# Line 2154  mage_install() Line 2426  mage_install()
2426   echo B:${pbuild}   echo B:${pbuild}
2427   fi   fi
2428    
2429   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2   if [[ -n ${MAGE_TARGETS} ]]
2430     then
2431     # basic svn compat
2432     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2433     then
2434     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2435     do
2436     smage2file="${i}"
2437     done
2438     else
2439     smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2440     fi
2441    
2442     elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2443     then
2444     # basic svn compat
2445     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2446     then
2447     for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2448     do
2449     smage2file="${i}"
2450     done
2451     else
2452     smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2453     fi
2454    
2455     else
2456     # basic svn compat
2457     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2458     then
2459     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2460     do
2461     smage2file="${i}"
2462     done
2463     else
2464     smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2
2465     fi
2466     fi
2467    
2468   if [ -f "${smage2file}" ]   if [ -f "${smage2file}" ]
2469   then   then
2470   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "
# Line 2428  mage_uninstall() Line 2738  mage_uninstall()
2738   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"
2739   echo -n "removing: "   echo -n "removing: "
2740   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2741   echo -e "${COLGRED}${pname}-${pver}-${pbuild}${COLDEFAULT}"   echo -e "${COLRED}${pname}-${pver}-${pbuild}${COLDEFAULT}"
2742    
2743   magefile="${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"   magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
2744   source ${magefile}   source ${magefile}
2745    
2746   ## preremove scripts   ## preremove scripts
# Line 2498  mage_uninstall() Line 2808  mage_uninstall()
2808   unset -f postremove   unset -f postremove
2809  }  }
2810    
2811  show_etc_update_mesg() {  show_etc_update_mesg()
2812    {
2813   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0
2814    
2815   echo   echo
# Line 2528  pkgsearch() Line 2839  pkgsearch()
2839   local all_installed   local all_installed
2840   local ipver   local ipver
2841   local ipbuild   local ipbuild
2842     local latest_available
2843     local depsfull
2844     local sdepsfull
2845     local deps
2846     local sdeps
2847     local dep
2848     local sign
2849    
2850   # only names no versions   # only names no versions
2851   result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name '*'${string}'*'| sed '/profiles/d' | sed '/includes/d')"   result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name '*'${string}'*'| sed '/profiles/d' | sed '/includes/d')"
# Line 2545  pkgsearch() Line 2863  pkgsearch()
2863   # get highest version available   # get highest version available
2864   magefile=$(get_highest_magefile ${pcat} ${pname})   magefile=$(get_highest_magefile ${pcat} ${pname})
2865    
2866   # now get all needed infos to print a nice output   if [[ ! -z ${magefile} ]]
2867   pver="$(magename2pver ${magefile})"   then
2868   pbuild="$(magename2pbuild ${magefile})"   # now get all needed infos to print a nice output
2869   state="$(get_value_from_magefile STATE ${magefile})"   pver="$(magename2pver ${magefile})"
2870   description="$(get_value_from_magefile DESCRIPTION ${magefile})"   pbuild="$(magename2pbuild ${magefile})"
2871   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"   state="$(get_value_from_magefile STATE ${magefile})"
2872     description="$(get_value_from_magefile DESCRIPTION ${magefile})"
2873     homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
2874    
2875     # all installed
2876     for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
2877     do
2878     ipver="$(magename2pver ${i})"
2879     ipbuild="$(magename2pbuild ${i})"
2880    
2881     if [[ -z ${all_installed} ]]
2882     then
2883     all_installed="${ipver}-${ipbuild}"
2884     else
2885     all_installed="${all_installed} ${ipver}-${ipbuild}"
2886     fi
2887     done
2888     [[ -z ${all_installed} ]] && all_installed="none"
2889    
2890     case ${state} in
2891     stable) state=${COLGREEN}"[s] ";;
2892     testing) state=${COLYELLOW}"[t] ";;
2893     unstable) state=${COLRED}"[u] ";;
2894     old) state=${COLGRAY}"[o] ";;
2895     esac
2896    
2897   # all installed   latest_available="${pver}-${pbuild}"
2898   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})   else
2899   do   # package is masked
2900   ipver="$(magename2pver ${i})"   state="${COLRED}[m] "
2901   ipbuild="$(magename2pbuild ${i})"   latest_available="${COLRED}masked for this distribution.${COLDEFAULT}"
2902     fi
2903    
2904   if [[ -z ${all_installed} ]]   depsfull="$(get_value_from_magefile DEPEND ${magefile})"
2905   then   sdepsfull="$(get_value_from_magefile SDEPEND ${magefile})"
  all_installed="${ipver}-${ipbuild}"  
  else  
  all_installed="${all_installed} ${ipver}-${ipbuild}"  
  fi  
  done  
  [[ -z ${all_installed} ]] && all_installed="none"  
2906    
2907   case ${state} in   while read sign dep
2908   stable) state=${COLGREEN}"[s] ";;   do
2909   testing) state=${COLYELLOW}"[t] ";;   case ${dep} in
2910   unstable) state=${COLRED}"[u] ";;   "") continue;;
2911   old) state=${COLGRAY}"[o] ";;   esac
2912   esac  
2913     deps="${deps} $(basename ${dep%-*})"
2914     done << EOF
2915    ${depsfull}
2916    EOF
2917    
2918     while read sign dep
2919     do
2920     case ${dep} in
2921     "") continue;;
2922     esac
2923    
2924     sdeps="${sdeps} $(basename ${dep%-*})"
2925     done << EOF
2926    ${sdepsfull}
2927    EOF
2928    
2929   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}
2930   echo "      Latest available:   ${pver}-${pbuild}"   echo -e "      Latest available:   ${latest_available}"
2931   echo "      Installed versions: ${all_installed}"   echo "      Installed versions: ${all_installed}"
2932   echo "      Description: ${description}"   echo "      Description: ${description}"
2933   echo "      Homepage: ${homepage}"   echo "      Homepage: ${homepage}"
2934     echo "      Depends: ${deps}"
2935     echo "      SDepends: ${sdeps}"
2936   echo   echo
2937    
2938   unset pcat   unset pcat
# Line 2592  pkgsearch() Line 2946  pkgsearch()
2946   unset all_installed   unset all_installed
2947   unset ipver   unset ipver
2948   unset ipbuild   unset ipbuild
2949     unset depsfull
2950     unset sdepsfull
2951     unset deps
2952     unset sdeps
2953     unset dep
2954     unset sign
2955   done   done
2956  }  }
2957    
# Line 2634  blacklisted() Line 2994  blacklisted()
2994   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable
2995   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing
2996    
2997   local EXCLUDED="${MROOT}/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"   # support both types for the moment
2998     if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]]
2999     then
3000     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"
3001     else
3002     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}"
3003     fi
3004    
3005   # return 0 if the list not exist; nothin is masked   # return 0 if the list not exist; nothin is masked
3006   [[ ! -f ${EXCLUDED} ]] && return 0   [[ ! -f ${EXCLUDED} ]] && return 0

Legend:
Removed from v.415  
changed lines
  Added in v.1271