Magellan Linux

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

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

revision 258 by niro, Tue Oct 4 14:35:21 2005 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.7 2005-10-04 14:35:21 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 361  install_characterdevices() Line 381  install_characterdevices()
381   local pkgname="$1"   local pkgname="$1"
382   local pathto   local pathto
383   local posix   local posix
384     local major
385     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 374  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   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   mknode -m ${posix} -c "${MROOT}${pathto}"   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 413  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 432  install_database_entry() Line 502  install_database_entry()
502   local magefile   local magefile
503   local dbrecorddir   local dbrecorddir
504   local provide   local provide
505     local i
506    
507   # very basic getops   # very basic getops
508   for i in $*   for i in $*
# Line 473  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   local i   for i in .dirs .symlinks .files .pipes .char .fifo
  for i in .dirs .symlinks .files .pipes .char  
548   do   do
549   touch ${dbrecorddir}/${i}   touch ${dbrecorddir}/${i}
550   done   done
# Line 492  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 504  install_database_entry() Line 577  install_database_entry()
577   provide="$(get_value_from_magefile PROVIDE ${magefile})"   provide="$(get_value_from_magefile PROVIDE ${magefile})"
578   if [ -n "${provide}" ]   if [ -n "${provide}" ]
579   then   then
580   virtuals_add "${provide}" "${pcat}/${pname}"   for i in ${provide}
581     do
582     virtuals_add "${i}" "${pcat}/${pname}"
583     done
584   fi   fi
585  }  }
586    
# Line 523  remove_database_entry() Line 599  remove_database_entry()
599   local magefile   local magefile
600   local dbrecorddir   local dbrecorddir
601   local provide   local provide
602     local i
603    
604   # very basic getops   # very basic getops
605   for i in $*   for i in $*
# Line 552  remove_database_entry() Line 629  remove_database_entry()
629   # abort if mage file not exists   # abort if mage file not exists
630   [ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist."   [ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist."
631    
632   # first unregister virtuals   # remove virtuals only if no other exist
633   provide="$(get_value_from_magefile PROVIDE ${magefile})"   if [[ $(count_installed_pkgs --pcat ${pcat} --pname ${pname}) -le 1 ]]
  if [ -n "${provide}" ]  
634   then   then
635   virtuals_del "${provide}" "${pcat}/${pname}"   # first unregister virtuals
636     provide="$(get_value_from_magefile PROVIDE ${magefile})"
637     if [ -n "${provide}" ]
638     then
639     for i in ${provide}
640     do
641     virtuals_del "${i}" "${pcat}/${pname}"
642     done
643     fi
644   fi   fi
645    
646   # removes database entry   # removes database entry
# Line 566  remove_database_entry() Line 650  remove_database_entry()
650   fi   fi
651  }  }
652    
653    # get the number of installed packages
654    count_installed_pkgs()
655    {
656     local pcat
657     local pname
658     local pkg
659     local i
660    
661     # very basic getops
662     for i in $*
663     do
664     case $1 in
665     --pcat|-c) shift; pcat="$1" ;;
666     --pname|-n) shift; pname="$1" ;;
667     esac
668     shift
669     done
670    
671     # sanity checks; abort if not given
672     [ -z "${pcat}" ] && die "pkg_count() \$pcat not given."
673     [ -z "${pname}" ] && die "pkg_count() \$pname not given."
674    
675     declare -i i=0
676     for pkg in $(get_uninstall_candidates --pcat ${pcat} --pname ${pname})
677     do
678     (( i++ ))
679     #echo "$i ${pkg}"
680     done
681    
682     # return the value
683     echo "${i}"
684    }
685    
686    
687  ###################################################  ###################################################
688  # function compare_mtime                          #  # function compare_mtime                          #
# Line 726  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 758  remove_files() Line 875  remove_files()
875   # 1=keep me   #   # 1=keep me   #
876   case ${retval} in   case ${retval} in
877   0)   0)
878   [[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}"   # check if the file is config_protected
879   rm "${MROOT}${pathto}"   # ${MROOT} will automatically added if set !!
880   ;;   is_config_protected "${pathto}"
881     retval="$?"
882    
883     # 0 - not protected         #
884     # 1 - error                 #
885     # 2 - protected             #
886     # 3 - protected but masked  #
887     # 4 - protected but ignored #
888    
889     case ${retval} in
890     # file is not protected - delete it
891     0|3)
892     [[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}"
893     rm "${MROOT}${pathto}"
894     ;;
895    
896     # file is protected, do not delete
897     2)
898     if [[ ${VERBOSE} = on ]]
899     then
900     echo -en "${COLRED}"
901     echo -n "! prot "
902     echo -en "${COLDEFAULT}"
903     echo " === FILE: ${MROOT}${pathto}"
904     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
919     ;;
920   1)   1)
921   [[ ${VERBOSE} = on ]] && \   [[ ${VERBOSE} = on ]] && \
922   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"
# Line 782  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 805  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 819  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 840  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 863  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 877  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 891  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 921  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 978  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 1012  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 1035  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 1082  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/${pkg}   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}
1309   if [[ $? = 0 ]]   if [[ $? = 0 ]]
1310   then   then
1311   break   break
# Line 1110  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
1335   for i in ${RSYNC}   for i in ${RSYNC}
1336   do   do
1337   rsync \   rsync ${RSYNC_FETCH_OPTIONS} ${i} ${MAGEDIR}
  --recursive \  
  --links \  
  --perms \  
  --times \  
  --devices \  
  --timeout=600 \  
  --verbose \  
  --compress \  
  --progress \  
  --stats \  
  --delete \  
  --delete-after \  
  ${i} ${MAGEDIR}  
1338   if [[ $? = 0 ]]   if [[ $? = 0 ]]
1339   then   then
1340   break   break
# Line 1141  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 1182  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 1215  pname2pcat() Line 1499  pname2pcat()
1499  # returns 0=stable 1=unstable  # returns 0=stable 1=unstable
1500  check_stable_package()  check_stable_package()
1501  {  {
1502     # first check if this magefile is not blacklisted
1503     blacklisted "$1" || return 1
1504    
1505   local STATE   local STATE
1506   STATE="$(get_value_from_magefile STATE "$1")"   STATE="$(get_value_from_magefile STATE "$1")"
1507    
1508   # state testing   # state testing
1509   if [[ ${USE_TESTING} = true ]]   if [[ ${USE_TESTING} = true ]] || [[ ${MAGE_DISTRIBUTION} = testing ]]
1510   then   then
1511   case ${STATE} in   case ${STATE} in
1512   testing|stable) return 0 ;;   testing|stable) return 0 ;;
# Line 1228  check_stable_package() Line 1515  check_stable_package()
1515   fi   fi
1516    
1517   # state unstable   # state unstable
1518   if [[ ${USE_UNSTABLE} = true ]]   if [[ ${USE_UNSTABLE} = true ]] || [[ ${MAGE_DISTRIBUTION} = unstable ]]
1519   then   then
1520   case ${STATE} in   case ${STATE} in
1521   unstable|testing|stable) return 0 ;;   unstable|testing|stable) return 0 ;;
# Line 1254  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 1266  get_highest_magefile() Line 1555  get_highest_magefile()
1555   fi   fi
1556   done   done
1557    
1558   # stop here if HIGHEST_MAGEFILE is zero  # do not so anything
1559   # this package must be unstable or old  # # stop here if HIGHEST_MAGEFILE is zero
1560   if [ -z "${HIGHEST_MAGEFILE}" ]  # # this package must be unstable or old
1561   then  # if [ -z "${HIGHEST_MAGEFILE}" ]
1562   echo  # then
1563   echo -n "All packages named "  # echo
1564   echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT}  # echo -n "All packages named "
1565   echo -n " are marked "  # echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT}
1566   echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT}  # echo -n " are marked "
1567   echo "."  # echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT}
1568   echo "You need to declare USE_UNSTABLE=true to install this."  # echo "."
1569   echo  # echo "You need to declare USE_UNSTABLE=true to install this."
1570   echo "Example:"  # echo
1571   echo "         USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}"  # echo "Example:"
1572   echo  # echo "         USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}"
1573   echo "Be warned that these packages are not stable and may cause serious problems."  # echo
1574   echo "You should know what you are doing, so don't complain about any damage."  # echo "Be warned that these packages are not stable and may cause serious problems."
1575   echo  # echo "You should know what you are doing, so don't complain about any damage."
1576   return 1  # echo
1577   fi  # return 1
1578    # fi
1579    
1580   echo "${HIGHEST_MAGEFILE}"   echo "${HIGHEST_MAGEFILE}"
1581   return 0   return 0
# Line 1301  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 1309  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 1351  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 1368  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 1385  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 1397  get_uninstall_candidates() Line 1727  get_uninstall_candidates()
1727   shift   shift
1728   done   done
1729    
1730   # sanity checks; abort if not given  # it's not good to complain here about empty pnames; better to continue later anyway
1731   [ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given."  # # sanity checks; abort if not given
1732    # [ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given."
1733    
1734    
1735   # check needed global vars   # check needed global vars
1736   [ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set."   [ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set."
1737    
1738   # set pcatdir to '*' if empty   # set pcatdir to '*' if empty
1739   [ -z "${pcatdir}" ] && pcatdir=*   [ -z "${pcatdir}" ] && pcatdir='*'
1740    
1741   for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/*   for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/*
1742   do   do
# Line 1490  virtuals_add() Line 1821  virtuals_add()
1821   local oldline   local oldline
1822   local line i   local line i
1823   local installed_file   local installed_file
1824     local OLDIFS
1825    
1826   if virtuals_read ${virtualname}   if virtuals_read ${virtualname}
1827   then   then
1828   # make shure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already   # make sure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already
1829   for i in $(virtuals_read ${virtualname} showpkgs)   for i in $(virtuals_read ${virtualname} showpkgs)
1830   do   do
1831   if [[ ${i} = ${pkgname} ]]   if [[ ${i} = ${pkgname} ]]
# Line 1512  virtuals_add() Line 1844  virtuals_add()
1844   # make a backup   # make a backup
1845   mv ${MROOT}${VIRTUALDB_FILE} ${MROOT}${VIRTUALDB_FILE}.old   mv ${MROOT}${VIRTUALDB_FILE} ${MROOT}${VIRTUALDB_FILE}.old
1846    
1847     OLDIFS="${IFS}"
1848   IFS=$'\n'   IFS=$'\n'
1849   for line in $(< ${MROOT}${VIRTUALDB_FILE}.old)   for line in $(< ${MROOT}${VIRTUALDB_FILE}.old)
1850   do   do
# Line 1523  virtuals_add() Line 1856  virtuals_add()
1856   echo "${line}" >> ${MROOT}${VIRTUALDB_FILE}   echo "${line}" >> ${MROOT}${VIRTUALDB_FILE}
1857   fi   fi
1858   done   done
1859     # unset IFS
1860   #unset IFS   IFS="${OLDIFS}"
1861   else   else
1862   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} >>> ${COLDEFAULT}"
1863   echo "register ${pkgname} as ${virtualname} ..."   echo "register ${pkgname} as ${virtualname} ..."
1864   echo "${virtualname} ${pkgname}" >> ${MROOT}${VIRTUALDB_FILE}   echo "${virtualname} ${pkgname}" >> ${MROOT}${VIRTUALDB_FILE}
1865   fi   fi
# Line 1536  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 VIRTUAL_NAME PKG_NAME OLD_LINE METHOD line i x PKG_INSTALLED   local virtualname="$1"
1876     local pkgname="$2"
1877   VIRTUAL_NAME=$1   local oldline
1878   PKG_NAME=$2   local method
1879     local line i x
1880   #first check if exists   local pkg_installed
1881   if virtuals_read ${VIRTUAL_NAME}   local OLDIFS
1882    
1883     # first check if exists
1884     if virtuals_read ${virtualname}
1885   then   then
1886   #get method -> delall or update and check if ${PKG_NAME} exists in ${VIRTUAL_NAME}   # get method -> delall or update and check if ${PKG_NAME} exists in ${VIRTUAL_NAME}
1887   declare -i x=0   declare -i x=0
1888   for i in $(virtuals_read ${VIRTUAL_NAME} showpkgs)   for i in $(virtuals_read ${virtualname} showpkgs)
1889   do   do
1890   if [ "${i}" == "${PKG_NAME}" ]   if [[ ${i} = ${pkgname} ]]
1891   then   then
1892   PKG_INSTALLED=true   pkg_installed=true
1893   fi   fi
1894   ((x++))   ((x++))
1895   done   done
1896    
1897   #abort if not installed   # abort if not installed
1898   if [ "${PKG_INSTALLED}" != "true" ]   if [[ ${pkg_installed} != true ]]
1899   then   then
1900   echo "!!!! ${PKG_NAME} does not exists in ${VIRTUAL_NAME}."   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1901     echo "${pkgname} does not exists in ${virtualname}."
1902   return 0   return 0
1903   fi   fi
1904    
1905   if [ ${x} -ge 2 ]   if [ ${x} -ge 2 ]
1906   then   then
1907   METHOD=update   method=update
1908   else   else
1909   METHOD=delall   method=delall
1910   fi   fi
1911    
1912   #get the complete line   # get the complete line
1913   OLD_LINE="$(virtuals_read ${VIRTUAL_NAME} showline)"   oldline="$(virtuals_read ${virtualname} showline)"
1914    
1915   #make a backup   # make a backup of the db
1916   mv ${VIRTUALDB_FILE} ${VIRTUALDB_FILE}.old   mv ${VIRTUALDB_FILE} ${VIRTUALDB_FILE}.old
1917    
1918   #parse virtualdb   # parse virtualdb
1919     OLDIFS="${IFS}"
1920   IFS=$'\n'   IFS=$'\n'
1921   for line in $(< ${VIRTUALDB_FILE}.old)   for line in $(< ${VIRTUALDB_FILE}.old)
1922   do   do
1923   if [ "${line}" == "${OLD_LINE}" ]   if [[ ${line} = ${oldline} ]]
1924   then   then
1925   #delall or update?   #delall or update?
1926   case ${METHOD} in   case ${method} in
1927   update)   update)
1928   echo "<<<< Unlinking ${PKG_NAME} from ${VIRTUAL_NAME} in virtual database ..."   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
1929   #del PKG_NAME from line   echo "Unlinking ${pkgname} from ${virtualname} in virtual database ..."
1930   echo "${line/ ${PKG_NAME}/}" >> ${VIRTUALDB_FILE}   # del PKG_NAME from line
1931     echo "${line/ ${pkgname}/}" >> ${VIRTUALDB_FILE}
1932   ;;   ;;
1933   delall)   delall)
1934   echo "<<<< Deleting ${VIRTUAL_NAME} in virtual database ..."   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"
1935   #continue; do not write anything   echo "Deleting ${virtualname} in virtual database ..."
1936     # continue; do not write anything
1937   continue   continue
1938   ;;   ;;
1939   esac   esac
# Line 1600  virtuals_del() { Line 1941  virtuals_del() {
1941   echo "${line}" >> ${VIRTUALDB_FILE}   echo "${line}" >> ${VIRTUALDB_FILE}
1942   fi   fi
1943   done   done
1944   unset IFS   # unset IFS
1945     IFS="${OLDIFS}"
1946   else   else
1947   echo "!!!! ${VIRTUAL_NAME} does not exists in virtual database."   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1948     echo "${virtualname} does not exists in virtual database."
1949   fi   fi
1950  }  }
1951    
# Line 1634  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 1650  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 1676  is_newer_mage_version_available() Line 2019  is_newer_mage_version_available()
2019   echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT}   echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT}
2020   echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT}   echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT}
2021   echo "It is recommened to install this newer version"   echo "It is recommened to install this newer version"
2022   echo "or your current system installation may brake."   echo "or your current system installation may break."
2023   echo   echo
2024   echo -en "Please update mage by running "   echo -en "Please update mage by running "
2025   echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT}   echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT}
# Line 1948  get_value_from_magefile() Line 2291  get_value_from_magefile()
2291   local magefile="$2"   local magefile="$2"
2292   local value   local value
2293    
2294     [[ -z ${var} ]] && return 1
2295     [[ -z ${magefile} ]] && return 1
2296    
2297   # local all possible vars of a mage file   # local all possible vars of a mage file
2298   # to prevent bad issues   # to prevent bad issues
2299   local PKGNAME   local PKGNAME
# Line 1958  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 2004  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 2077  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 ... "
2471   smage2 ${smage2file} || die "compile failed"   smage2 ${smage2file} || die "compile failed"
2472   else   else
2473   echo   echo
# Line 2093  mage_install() Line 2481  mage_install()
2481   if [[ ${PKGTYPE} != virtual ]] && \   if [[ ${PKGTYPE} != virtual ]] && \
2482   [[ ${PKGTYPE} != sources ]]   [[ ${PKGTYPE} != sources ]]
2483   then   then
2484   # show a verbose message on src-install   echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... "
  if [[ ${src_install} = true ]]  
  then  
  echo -ne "${COLBLUE} *** ${COLDEFAULT}"  
  echo -ne "merging files: "  
  echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"  
  echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"  
  fi  
2485   build_doinstall ${PKGNAME}   build_doinstall ${PKGNAME}
2486   fi   fi
2487    
# Line 2357  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 "${COLGREEN}${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 2427  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 2457  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}*)"   result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name '*'${string}'*'| sed '/profiles/d' | sed '/includes/d')"
2852   #result="$(find ${MAGEDIR} -type f -name *${string}*.mage | sort)"   #result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)"
2853    
2854   # nothing found   # nothing found
2855   [[ -z ${result} ]] && die "No package found containing '${string}' in the name."   [[ -z ${result} ]] && die "No package found containing '${string}' in the name."
# Line 2474  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 2521  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 2545  export_inherits() Line 2976  export_inherits()
2976   shift   shift
2977   done   done
2978  }  }
2979    
2980    mlibdir()
2981    {
2982     local libdir=lib
2983     [[ ${ARCH} = x86_64 ]] && libdir=lib64
2984    
2985     echo "${libdir}"
2986    }
2987    
2988    ## blacklisted ${magefile}
2989    blacklisted()
2990    {
2991     [[ -z ${MAGE_DISTRIBUTION} ]] && local MAGE_DISTRIBUTION=stable
2992    
2993     # compat
2994     [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable
2995     [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing
2996    
2997     # 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
3006     [[ ! -f ${EXCLUDED} ]] && return 0
3007    
3008     local MAGEFILE="$1"
3009    
3010     local PCAT="$(magename2pcat ${MAGEFILE})"
3011     local PNAME="$(magename2pname ${MAGEFILE})"
3012     local PVER="$(magename2pver ${MAGEFILE})"
3013     local PBUILD="$(magename2pbuild ${MAGEFILE})"
3014    
3015     local EXPCAT EXPNAME EXPVER EXPBUILD
3016     while read EXPCAT EXPNAME EXPVER EXPBUILD
3017     do
3018     # ignore spaces and comments
3019             case "${EXPCAT}" in
3020                     \#*|"") continue ;;
3021             esac
3022    
3023     # exclude full pver
3024     if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] &&
3025     [[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] &&
3026     [[ -n ${PVER} ]] && [[ -n ${PBUILD} ]] &&
3027     [[ -n ${EXPVER} ]] && [[ -n ${EXPBUILD} ]]
3028     then
3029     [[ ${EXPCAT}/${EXPNAME}-${EXPVER}-${EXPBUILD} = ${PCAT}/${PNAME}-${PVER}-${PBUILD} ]] && return 1
3030     fi
3031    
3032     # exclude pcat/pname only
3033     if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] &&
3034     [[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] &&
3035     [[ -z ${EXPVER} ]] && [[ -z ${EXPBUILD} ]]
3036     then
3037     [[ ${EXPCAT}/${EXPNAME} = ${PCAT}/${PNAME} ]] && return 1
3038     fi
3039     done << EOF
3040    $( cat ${EXCLUDED}; echo)
3041    EOF
3042    
3043     return 0
3044    }
3045    

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