Magellan Linux

Diff of /branches/mage-next/src/mage4.functions.sh.in

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

revision 226 by niro, Fri Sep 9 16:35:46 2005 UTC revision 1289 by niro, Thu May 12 21:29:31 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.1 2005-09-09 16:35:38 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 23  unpack_packages() Line 23  unpack_packages()
23   local pkgtype   local pkgtype
24   local count_current   local count_current
25   local count_total   local count_total
26     local tar_opts
27    
28   # get count of total packages   # get count of total packages
29   declare -i count_current=0   declare -i count_current=0
# Line 54  unpack_packages() Line 55  unpack_packages()
55   continue   continue
56   fi   fi
57    
58     # busybox?
59     if need_busybox_support tar
60     then
61     tar_opts="xjf"
62     else
63     tar_opts="xjmf"
64     fi
65    
66   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "
67   tar xjmf ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"   tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"
68   done   done
69    
70   # add a crlf for a better view   # add a crlf for a better view
# Line 198  install_files() Line 207  install_files()
207   is_config_protected "${pathto}"   is_config_protected "${pathto}"
208   retval="$?"   retval="$?"
209    
210   # 0 - not protected        #   # 0 - not protected         #
211   # 1 - error                #   # 1 - error                 #
212   # 2 - protected            #   # 2 - protected             #
213   # 3 - protected but masked #   # 3 - protected but masked  #
214     # 4 - protected but ignored #
215    
216   case ${retval} in   case ${retval} in
217   # file is not protected - (over)write it   # file is not protected - (over)write it
# Line 218  install_files() Line 228  install_files()
228   "${user}" \   "${user}" \
229   "${group}" \   "${group}" \
230   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
231   "${MROOT}${pathto}")" \   "${MROOT}${pathto}")" \
232   "${md5sum}"   "${md5sum}"
233   ;;   ;;
234    
# Line 245  install_files() Line 255  install_files()
255   "${user}" \   "${user}" \
256   "${group}" \   "${group}" \
257   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
258   "${dest_protected}")" \   "${dest_protected}")" \
259   "${md5sum}"   "${md5sum}"
260    
261   # update global MAGE_PROTECT_COUNTER   # update global MAGE_PROTECT_COUNTER
262   (( MAGE_PROTECT_COUNTER++ ))   (( MAGE_PROTECT_COUNTER++ ))
263   export MAGE_PROTECT_COUNTER   export MAGE_PROTECT_COUNTER
264   ;;   ;;
265    
266     # file is protected but ignored, delete the update/do nothing
267     4)
268     if [[ ${VERBOSE} = on ]]
269     then
270     echo -en "${COLRED}"
271     echo -n "! ignr "
272     echo -en "${COLDEFAULT}"
273     echo " === FILE: ${MROOT}${pathto}"
274     fi
275     # simply do nothing here - only fix mtime
276     fix_descriptor ${pkgname}/.files \
277     "${pathto}" \
278     "${posix}" \
279     "${user}" \
280     "${group}" \
281     "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
282     "${MROOT}${pathto}")" \
283     "${md5sum}"
284     ;;
285   esac   esac
286   done < ${BUILDDIR}/${pkgname}/.files   done < ${BUILDDIR}/${pkgname}/.files
287    
# Line 298  install_symlinks() Line 328  install_symlinks()
328    
329   ln -snf "${link}" "${MROOT}${pathto}"   ln -snf "${link}" "${MROOT}${pathto}"
330    
331   # fix mtime and db  # # fix mtime and db
332   fix_descriptor ${pkgname}/.symlinks \  # fix_descriptor ${pkgname}/.symlinks \
333   "${pathto}" \  # "${pathto}" \
334   "${posix}" \  # "${posix}" \
335   "${link}" \  # "${link}" \
336   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \  # "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
337   "${MROOT}${pathto}")"  # "${MROOT}${pathto}")"
338    
339   done < ${BUILDDIR}/${pkgname}/.symlinks   done < ${BUILDDIR}/${pkgname}/.symlinks
340    
341   # now copy the fixed file over the old one  # # now copy the fixed file over the old one
342   [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \  # [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \
343   cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,}  # cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,}
344    
345   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
346   IFS=$'\n'   IFS=$'\n'
# Line 326  install_blockdevices() Line 356  install_blockdevices()
356   local pkgname="$1"   local pkgname="$1"
357   local pathto   local pathto
358   local posix   local posix
359     local user
360     local group
361   local IFS   local IFS
362    
363   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 339  install_blockdevices() Line 371  install_blockdevices()
371   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
372   IFS=§   IFS=§
373    
374   while read pathto posix   while read pathto posix major minor user group
375   do   do
376   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
377   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"
378    
379   mkfifo -m "${posix}" "${MROOT}$pathto"   mknod -m "${posix}" "${MROOT}${pathto}"
380     # make it optional atm !!
381     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
382     then
383     chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}"
384     fi
385   done < ${BUILDDIR}/${pkgname}/.pipes   done < ${BUILDDIR}/${pkgname}/.pipes
386    
387   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
# Line 361  install_characterdevices() Line 398  install_characterdevices()
398   local pkgname="$1"   local pkgname="$1"
399   local pathto   local pathto
400   local posix   local posix
401     local major
402     local minor
403     local user
404     local group
405   local IFS   local IFS
406    
407   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 374  install_characterdevices() Line 415  install_characterdevices()
415   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
416   IFS=§   IFS=§
417    
418   while read pathto posix   while read pathto posix major minor user group
419   do   do
420   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
421   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"
422    
423   mknode -m ${posix} -c "${MROOT}${pathto}"   mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}"
424    
425     # make it optional atm !!
426     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
427     then
428     chown "${user}:${group}" "${MROOT}${pathto}"
429     fi
430   done < ${BUILDDIR}/${pkgname}/.char   done < ${BUILDDIR}/${pkgname}/.char
431    
432   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
433   IFS=$'\n'   IFS=$'\n'
434  }  }
435    
436    ###################################################
437    # function install_fifos                          #
438    # install_fifos $PKGNAME                    #
439    ###################################################
440    install_fifos()
441    {
442     local pkgname="$1"
443     local pathto
444     local posix
445     local user
446     local group
447     local IFS
448    
449     # sanity checks; abort if not given
450     [ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given."
451    
452     # check needed global vars
453     [ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set."
454    
455     # make it optional atm !!
456     #[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found"
457     [ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return
458    
459     # sets fieldseperator to "§" instead of " "
460     IFS=§
461    
462     while read pathto posix user group
463     do
464     [ -z "${pathto}" ] && continue
465     [[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}"
466    
467     mkfifo -m "${posix}" "${MROOT}${pathto}"
468     chown "${user}:${group}" "${MROOT}${pathto}"
469     done < ${BUILDDIR}/${pkgname}/.fifo
470    
471     # very important: unsetting the '§' fieldseperator
472     IFS=$'\n'
473    }
474    
475    
476  ###################################################  ###################################################
477  # function build_doinstall                        #  # function build_doinstall                        #
478  # build_doinstall $PKGNAME                  #  # build_doinstall $PKGNAME                  #
479  # NOTE: this is an wrapper do install packages    #  # NOTE: this is an wrapper to install packages    #
480  ###################################################  ###################################################
481  build_doinstall()  build_doinstall()
482  {  {
# Line 398  build_doinstall() Line 484  build_doinstall()
484    
485   # sanity checks; abort if not given   # sanity checks; abort if not given
486   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."
487    
488   # this is only a wrapper   # this is only a wrapper
489    
490   # NOTE:   # NOTE:
# Line 413  build_doinstall() Line 499  build_doinstall()
499   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"
500   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"
501   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"
502     install_fifos ${pkgname} || die "install fifos ${pkgname}"
503  }  }
504    
505    
# Line 432  install_database_entry() Line 519  install_database_entry()
519   local magefile   local magefile
520   local dbrecorddir   local dbrecorddir
521   local provide   local provide
522     local i
523    
524   # very basic getops   # very basic getops
525   for i in $*   for i in $*
# Line 473  install_database_entry() Line 561  install_database_entry()
561    
562   # create fake file descriptors   # create fake file descriptors
563   # used by virtual and source packages   # used by virtual and source packages
564   local i   for i in .dirs .symlinks .files .pipes .char .fifo
  for i in .dirs .symlinks .files .pipes .char  
565   do   do
566   touch ${dbrecorddir}/${i}   touch ${dbrecorddir}/${i}
567   done   done
# Line 492  install_database_entry() Line 579  install_database_entry()
579    
580   # normal packages needs these files   # normal packages needs these files
581   local i   local i
582   for i in .char .dirs .files .pipes .symlinks   for i in .char .dirs .files .pipes .symlinks .fifo
583   do   do
584   install -m 0644 ${BUILDDIR}/${pkgname}/${i} \   # make .fifo optional atm
585   ${dbrecorddir}/${i}   if [[ -f ${BUILDDIR}/${pkgname}/${i} ]]
586     then
587     install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i}
588     fi
589   done   done
590   ;;   ;;
591   esac   esac
# Line 504  install_database_entry() Line 594  install_database_entry()
594   provide="$(get_value_from_magefile PROVIDE ${magefile})"   provide="$(get_value_from_magefile PROVIDE ${magefile})"
595   if [ -n "${provide}" ]   if [ -n "${provide}" ]
596   then   then
597   virtuals_add "${provide}" "${pcat}/${pname}"   for i in ${provide}
598     do
599     virtuals_add "${i}" "${pcat}/${pname}"
600     done
601   fi   fi
602  }  }
603    
# Line 523  remove_database_entry() Line 616  remove_database_entry()
616   local magefile   local magefile
617   local dbrecorddir   local dbrecorddir
618   local provide   local provide
619     local i
620    
621   # very basic getops   # very basic getops
622   for i in $*   for i in $*
# Line 552  remove_database_entry() Line 646  remove_database_entry()
646   # abort if mage file not exists   # abort if mage file not exists
647   [ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist."   [ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist."
648    
649   # first unregister virtuals   # remove virtuals only if no other exist
650   provide="$(get_value_from_magefile PROVIDE ${magefile})"   if [[ $(count_installed_pkgs --pcat ${pcat} --pname ${pname}) -le 1 ]]
  if [ -n "${provide}" ]  
651   then   then
652   virtuals_del "${provide}" "${pcat}/${pname}"   # first unregister virtuals
653     provide="$(get_value_from_magefile PROVIDE ${magefile})"
654     if [ -n "${provide}" ]
655     then
656     for i in ${provide}
657     do
658     virtuals_del "${i}" "${pcat}/${pname}"
659     done
660     fi
661   fi   fi
662    
663   # removes database entry   # removes database entry
# Line 566  remove_database_entry() Line 667  remove_database_entry()
667   fi   fi
668  }  }
669    
670    # get the number of installed packages
671    count_installed_pkgs()
672    {
673     local pcat
674     local pname
675     local pkg
676     local i
677    
678     # very basic getops
679     for i in $*
680     do
681     case $1 in
682     --pcat|-c) shift; pcat="$1" ;;
683     --pname|-n) shift; pname="$1" ;;
684     esac
685     shift
686     done
687    
688     # sanity checks; abort if not given
689     [ -z "${pcat}" ] && die "pkg_count() \$pcat not given."
690     [ -z "${pname}" ] && die "pkg_count() \$pname not given."
691    
692     declare -i i=0
693     for pkg in $(get_uninstall_candidates --pcat ${pcat} --pname ${pname})
694     do
695     (( i++ ))
696     #echo "$i ${pkg}"
697     done
698    
699     # return the value
700     echo "${i}"
701    }
702    
703    
704  ###################################################  ###################################################
705  # function compare_mtime                          #  # function compare_mtime                          #
# Line 726  remove_files() Line 860  remove_files()
860   done   done
861    
862   # sanity checks; abort if not given   # sanity checks; abort if not given
863   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_files() \$pcat not given."
864   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_files() \$pname not given."
865   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_files() \$pver not given."
866   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_files() \$pbuild not given."
867   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
868    
869   # check needed global vars   # check needed global vars
# Line 744  remove_files() Line 878  remove_files()
878   do   do
879   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
880    
881   if [ -e "${MROOT}${pathto}" ]   if [ ! -e "${MROOT}${pathto}" ]
882   then   then
883   [[ ${VERBOSE} = on ]] && \   [[ ${VERBOSE} = on ]] && \
884   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"
# Line 758  remove_files() Line 892  remove_files()
892   # 1=keep me   #   # 1=keep me   #
893   case ${retval} in   case ${retval} in
894   0)   0)
895   [[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}"   # check if the file is config_protected
896   rm "${MROOT}${pathto}"   # ${MROOT} will automatically added if set !!
897   ;;   is_config_protected "${pathto}"
898     retval="$?"
899    
900     # 0 - not protected         #
901     # 1 - error                 #
902     # 2 - protected             #
903     # 3 - protected but masked  #
904     # 4 - protected but ignored #
905    
906     case ${retval} in
907     # file is not protected - delete it
908     0|3)
909     [[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}"
910     rm "${MROOT}${pathto}"
911     ;;
912    
913     # file is protected, do not delete
914     2)
915     if [[ ${VERBOSE} = on ]]
916     then
917     echo -en "${COLRED}"
918     echo -n "! prot "
919     echo -en "${COLDEFAULT}"
920     echo " === FILE: ${MROOT}${pathto}"
921     fi
922     ;;
923    
924     # file is protected but ignored, delete the update/do nothing
925     4)
926     if [[ ${VERBOSE} = on ]]
927     then
928     echo -en "${COLRED}"
929     echo -n "! ignr "
930     echo -en "${COLDEFAULT}"
931     echo " === FILE: ${MROOT}${pathto}"
932     fi
933     # simply do nothing here
934     ;;
935     esac
936     ;;
937   1)   1)
938   [[ ${VERBOSE} = on ]] && \   [[ ${VERBOSE} = on ]] && \
939   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"
# Line 782  remove_blockdevices() Line 954  remove_blockdevices()
954  {  {
955   local pathto   local pathto
956   local posix   local posix
957     local user
958     local group
959   local IFS   local IFS
960   local pcat   local pcat
961   local pname   local pname
# Line 805  remove_blockdevices() Line 979  remove_blockdevices()
979   done   done
980    
981   # sanity checks; abort if not given   # sanity checks; abort if not given
982   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given."
983   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_blockdevices() \$pname not given."
984   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_blockdevices() \$pver not given."
985   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given."
986   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
987    
988   # check needed global vars   # check needed global vars
# Line 819  remove_blockdevices() Line 993  remove_blockdevices()
993   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
994   IFS=§   IFS=§
995    
996   while read pathto posix   while read pathto posix user group
997   do   do
998   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
999    
# Line 840  remove_characterdevices() Line 1014  remove_characterdevices()
1014  {  {
1015   local pathto   local pathto
1016   local posix   local posix
1017     local user
1018     local group
1019   local IFS   local IFS
1020   local pcat   local pcat
1021   local pname   local pname
# Line 863  remove_characterdevices() Line 1039  remove_characterdevices()
1039   done   done
1040    
1041   # sanity checks; abort if not given   # sanity checks; abort if not given
1042   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given."
1043   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_characterdevices() \$pname not given."
1044   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_characterdevices() \$pver not given."
1045   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given."
1046   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1047    
1048   # check needed global vars   # check needed global vars
# Line 877  remove_characterdevices() Line 1053  remove_characterdevices()
1053   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1054   IFS=§   IFS=§
1055    
1056   while read pathto posix   while read pathto posix user group
1057   do   do
1058   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1059    
# Line 891  remove_characterdevices() Line 1067  remove_characterdevices()
1067    
1068    
1069  ###################################################  ###################################################
1070    # function remove_fifos                           #
1071    # remove_fifos $PKGNAME                     #
1072    ###################################################
1073    remove_fifos()
1074    {
1075     local pathto
1076     local posix
1077     local user
1078     local group
1079     local IFS
1080     local pcat
1081     local pname
1082     local pver
1083     local pbuild
1084     local i
1085     local pfull
1086    
1087     IFS=$'\n'
1088    
1089     # very basic getops
1090     for i in $*
1091     do
1092     case $1 in
1093     --pcat|-c) shift; pcat="$1" ;;
1094     --pname|-n) shift; pname="$1" ;;
1095     --pver|-v) shift; pver="$1" ;;
1096     --pbuild|-b) shift; pbuild="$1" ;;
1097     esac
1098     shift
1099     done
1100    
1101     # sanity checks; abort if not given
1102     [ -z "${pcat}" ] && die "remove_fifos() \$pcat not given."
1103     [ -z "${pname}" ] && die "remove_fifos() \$pname not given."
1104     [ -z "${pver}" ] && die "remove_fifos() \$pver not given."
1105     [ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given."
1106     pfull="${pcat}/${pname}-${pver}-${pbuild}"
1107    
1108     # check needed global vars
1109     [ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set."
1110    
1111     # make it optional atm !!
1112     #[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found"
1113     [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return
1114    
1115     # sets fieldseperator to "§" instead of " "
1116     IFS=§
1117    
1118     while read pathto posix user group
1119     do
1120     [ -z "${pathto}" ] && continue
1121    
1122     [[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}"
1123     rm "${MROOT}${pathto}"
1124     done < ${MROOT}${INSTALLDB}/${pfull}/.fifo
1125    
1126     # very important: unsetting the '§' fieldseperator
1127     IFS=$'\n'
1128    }
1129    
1130    
1131    ###################################################
1132  # function remove_direcories                      #  # function remove_direcories                      #
1133  # remove_direcories $PKGNAME                #  # remove_direcories $PKGNAME                #
1134  ###################################################  ###################################################
# Line 921  remove_directories() Line 1159  remove_directories()
1159   done   done
1160    
1161   # sanity checks; abort if not given   # sanity checks; abort if not given
1162   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_directories() \$pcat not given."
1163   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_directories() \$pname not given."
1164   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_directories() \$pver not given."
1165   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given."
1166   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1167    
1168   # check needed global vars   # check needed global vars
# Line 932  remove_directories() Line 1170  remove_directories()
1170    
1171   [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.char ] && die "remove_directories() .dirs not found"   [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.char ] && die "remove_directories() .dirs not found"
1172    
  # uninstall of dirs ## added small hack to fix dirs  
  # must be reverse -> smage2 doesn't sort them  
  # -> using tac  
   
1173   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1174   IFS=§   IFS=§
1175    
1176   while read pathto posix   # reversed order is mandatory !
1177     tac ${MROOT}${INSTALLDB}/${pfull}/.dirs | while read pathto posix
1178   do   do
1179   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1180    
# Line 954  remove_directories() Line 1189  remove_directories()
1189   if [ -f "${MROOT}${pathto}/.keep" ]   if [ -f "${MROOT}${pathto}/.keep" ]
1190   then   then
1191   [[ ${VERBOSE} = on ]] && \   [[ ${VERBOSE} = on ]] && \
1192   echo -e "${COLRED}  .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1193   continue   continue
1194   fi   fi
1195    
# Line 971  remove_directories() Line 1206  remove_directories()
1206   [[ ${VERBOSE} = on ]] && \   [[ ${VERBOSE} = on ]] && \
1207   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1208   fi   fi
1209   done < ${MROOT}${INSTALLDB}/${pfull}/.dirs   done
1210    
1211   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
1212   IFS=$'\n'   IFS=$'\n'
# Line 981  remove_directories() Line 1216  remove_directories()
1216  ###################################################  ###################################################
1217  # function build_douninstall                      #  # function build_douninstall                      #
1218  # build_douninstall $PKGNAME                #  # build_douninstall $PKGNAME                #
1219  # NOTE: this is an wrapper do remove packages     #  # NOTE: this is an wrapper to remove packages     #
1220  ###################################################  ###################################################
1221  build_douninstall()  build_douninstall()
1222  {  {
# Line 1015  build_douninstall() Line 1250  build_douninstall()
1250   # !! we use § as field seperator !!   # !! we use § as field seperator !!
1251   # doing so prevent us to get errors by filenames with spaces   # doing so prevent us to get errors by filenames with spaces
1252    
1253   for i in symlinks files blockdevices characterdevices directories   for i in symlinks files blockdevices characterdevices directories fifos
1254   do   do
1255   remove_${i} \   remove_${i} \
1256   --pcat "${pcat}" \   --pcat "${pcat}" \
# Line 1037  fetch_packages() Line 1272  fetch_packages()
1272   local opt   local opt
1273   local count_current   local count_current
1274   local count_total   local count_total
1275     local wget_opts
1276    
1277   [ -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}."
1278    
1279     # filter wget command if busybox was found
1280     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1281    
1282   # get count of total packages   # get count of total packages
1283   declare -i count_current=0   declare -i count_current=0
# Line 1085  fetch_packages() Line 1324  fetch_packages()
1324   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1325   [[ ${VERBOSE} = off ]] && opt="--quiet"   [[ ${VERBOSE} = off ]] && opt="--quiet"
1326   wget \   wget \
1327   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
1328   --directory-prefix=${PKGDIR} \   --directory-prefix=${PKGDIR} \
1329   ${opt} ${mirr}/packages/${pkg}   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}
1330   if [[ $? = 0 ]]   if [[ $? = 0 ]]
1331   then   then
1332   break   break
# Line 1113  syncmage() Line 1349  syncmage()
1349  {  {
1350   if [ -z "${RSYNC}" ]   if [ -z "${RSYNC}" ]
1351   then   then
1352   die "You have no rsync-mirrors defined. Please edit your /etc/mage.rc."   die "You have no rsync-mirrors defined. Please edit your ${MAGERC}."
1353   fi   fi
1354    
1355   local i   local i
1356   for i in ${RSYNC}   for i in ${RSYNC}
1357   do   do
1358   rsync \   rsync ${RSYNC_FETCH_OPTIONS} ${i} ${MAGEDIR}
  --recursive \  
  --links \  
  --perms \  
  --times \  
  --devices \  
  --timeout=600 \  
  --verbose \  
  --compress \  
  --progress \  
  --stats \  
  --delete \  
  --delete-after \  
  ${i} ${MAGEDIR}  
1359   if [[ $? = 0 ]]   if [[ $? = 0 ]]
1360   then   then
1361   break   break
# Line 1144  syncmage() Line 1367  syncmage()
1367   # clean up backup files (foo~)   # clean up backup files (foo~)
1368   find ${MAGEDIR} -name *~ -exec rm '{}' ';'   find ${MAGEDIR} -name *~ -exec rm '{}' ';'
1369    
1370   # check if an newer mage version is available   # check if a newer mage version is available
1371   is_newer_mage_version_available   is_newer_mage_version_available
1372  }  }
1373    
1374    syncmage_tarball()
1375    {
1376     local latest_tarball
1377     local latest_md5
1378     local temp="$(mktemp -d)"
1379     local mirr mymirr
1380     local opt
1381     local tar_opts
1382    
1383     # try to get the md5 marked as latest on the server
1384     latest_md5="mage-latest.md5"
1385    
1386     # try to get the tarball marked as latest on the server
1387     latest_tarball="mage-latest.tar.bz2"
1388    
1389     for mirr in ${MIRRORS}
1390     do
1391     # path without distribution
1392     mymirr="${mirr%/*}"
1393    
1394     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1395     echo "fetching latest md5 from ${mymirr} ..."
1396     [[ ${VERBOSE} = off ]] && opt="--quiet"
1397     wget \
1398     ${WGET_FETCH_OPTIONS} \
1399     --directory-prefix=${temp} \
1400     ${opt} ${mymirr}/rsync/tarballs/${latest_md5}
1401    
1402     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1403     echo "fetching latest tarball from ${mymirr} ..."
1404     wget \
1405     ${WGET_FETCH_OPTIONS} \
1406     --directory-prefix=${temp} \
1407     ${opt} ${mymirr}/rsync/tarballs/${latest_tarball}
1408     if [[ $? = 0 ]]
1409     then
1410     break
1411     else
1412     continue
1413     fi
1414     done
1415    
1416     if [[ -f ${temp}/${latest_tarball} ]]
1417     then
1418     # check md5
1419     if [[ ! -f ${temp}/${latest_md5} ]]
1420     then
1421     die "md5 is missing ... aborting"
1422     else
1423     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1424     echo -n "checking md5sum... "
1425     ( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed"
1426     fi
1427    
1428     if [[ -d ${MAGEDIR} ]]
1429     then
1430     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1431     echo "cleaning old mage-tree ${MAGEDIR}..."
1432     rm -rf ${MAGEDIR}
1433     fi
1434    
1435     if need_busybox_support tar
1436     then
1437     tar_opts="xjf"
1438     else
1439     tar_opts="xjmf"
1440     fi
1441    
1442     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1443     echo "updating mage-tree from tarball ..."
1444     # unpack in dirname of MAGEDIR, as the tarball has already the mage
1445     tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1446    
1447     if [[ -d ${temp} ]]
1448     then
1449     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1450     echo "cleaning temp-files ..."
1451     rm -rf ${temp}
1452     fi
1453    
1454     # check if a newer mage version is available
1455     is_newer_mage_version_available
1456     else
1457     die "Could not fetch the latest tarball ... aborting"
1458     fi
1459    }
1460    
1461  cleanpkg()  cleanpkg()
1462  {  {
1463   if [ -d "${PKGDIR}" ]   if [ -d "${PKGDIR}" ]
# Line 1185  choppkgname() Line 1495  choppkgname()
1495   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]
1496   then   then
1497   #cuts ARCH and PBUILD   #cuts ARCH and PBUILD
1498   #ARCH comes from /etc/mage.rc   #ARCH comes from ${MAGERC}
1499   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")
1500    
1501   #cuts version number   #cuts version number
# Line 1218  pname2pcat() Line 1528  pname2pcat()
1528  # returns 0=stable 1=unstable  # returns 0=stable 1=unstable
1529  check_stable_package()  check_stable_package()
1530  {  {
1531     # first check if this magefile is not blacklisted
1532     blacklisted "$1" || return 1
1533    
1534   local STATE   local STATE
1535   STATE="$(get_value_from_magefile STATE "$1")"   STATE="$(get_value_from_magefile STATE "$1")"
1536    
1537   # state testing   # state testing
1538   if [[ ${USE_TESTING} = true ]]   if [[ ${USE_TESTING} = true ]] || [[ ${MAGE_DISTRIBUTION} = testing ]]
1539   then   then
1540   case ${STATE} in   case ${STATE} in
1541   testing|stable) return 0 ;;   testing|stable) return 0 ;;
# Line 1231  check_stable_package() Line 1544  check_stable_package()
1544   fi   fi
1545    
1546   # state unstable   # state unstable
1547   if [[ ${USE_UNSTABLE} = true ]]   if [[ ${USE_UNSTABLE} = true ]] || [[ ${MAGE_DISTRIBUTION} = unstable ]]
1548   then   then
1549   case ${STATE} in   case ${STATE} in
1550   unstable|testing|stable) return 0 ;;   unstable|testing|stable) return 0 ;;
# Line 1257  get_highest_magefile() Line 1570  get_highest_magefile()
1570   local PNAME="$2"   local PNAME="$2"
1571   local magefile   local magefile
1572    
1573   for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*)   # do not list the content of a directory, only the name (-d)
1574     for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*)
1575   do   do
1576     [[ -z ${magefile} ]] && continue
1577   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
1578   [ -d ${magefile} ] && continue   [[ -d ${magefile} ]] && continue
1579   if check_stable_package ${magefile}   if check_stable_package ${magefile}
1580   then   then
1581   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
# Line 1269  get_highest_magefile() Line 1584  get_highest_magefile()
1584   fi   fi
1585   done   done
1586    
1587   # stop here if HIGHEST_MAGEFILE is zero  # do not so anything
1588   # this package must be unstable or old  # # stop here if HIGHEST_MAGEFILE is zero
1589   if [ -z "${HIGHEST_MAGEFILE}" ]  # # this package must be unstable or old
1590   then  # if [ -z "${HIGHEST_MAGEFILE}" ]
1591   echo  # then
1592   echo -n "All packages named "  # echo
1593   echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT}  # echo -n "All packages named "
1594   echo -n " are marked "  # echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT}
1595   echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT}  # echo -n " are marked "
1596   echo "."  # echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT}
1597   echo "You need to declare USE_UNSTABLE=true to install this."  # echo "."
1598   echo  # echo "You need to declare USE_UNSTABLE=true to install this."
1599   echo "Example:"  # echo
1600   echo "         USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}"  # echo "Example:"
1601   echo  # echo "         USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}"
1602   echo "Be warned that these packages are not stable and may cause serious problems."  # echo
1603   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."
1604   echo  # echo "You should know what you are doing, so don't complain about any damage."
1605   return 1  # echo
1606   fi  # return 1
1607    # fi
1608    
1609   echo "${HIGHEST_MAGEFILE}"   echo "${HIGHEST_MAGEFILE}"
1610   return 0   return 0
# Line 1304  get_highest_magefile() Line 1620  get_highest_magefile()
1620  #        1 - error                                #  #        1 - error                                #
1621  #        2 - protected                            #  #        2 - protected                            #
1622  #        3 - protected but masked                 #  #        3 - protected but masked                 #
1623    #        4 - protected but ignored                #
1624  #                                                 #  #                                                 #
1625  ###################################################  ###################################################
1626  is_config_protected()  is_config_protected()
# Line 1312  is_config_protected() Line 1629  is_config_protected()
1629   local TEST   local TEST
1630   local PROTECTED   local PROTECTED
1631   local IFS   local IFS
1632     local i
1633     local x
1634    
1635   EXPFILE="${MROOT}$1"   EXPFILE="${MROOT}$1"
1636    
1637   # file does not exist; it can be written   # file does not exist; it can be written
1638   [ ! -e ${EXPFILE} ] && return 0   [[ ! -e ${EXPFILE} ]] && return 0
1639    
1640   # to be safe; it may be '§'   # to be safe; it may be '§'
1641   IFS=' '   IFS=' '
1642    
1643   # check ob in config protect   # check if config protected
1644   for i in ${CONFIG_PROTECT}   for i in ${CONFIG_PROTECT}
1645   do   do
1646   # ersetzen von $i nur wenn am anfang der variable   # only replace $i in the beginning of the variable
1647   TEST="${EXPFILE/#${MROOT}${i}/Protected}"   TEST="${EXPFILE/#${MROOT}${i}/Protected}"
1648   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1649   then   then
1650   # setzen das es protected ist   # file is config proteced
1651   PROTECTED=TRUE   PROTECTED=TRUE
1652    
1653   # check ob nicht doch maskiert   # check if not masked
1654   for x in ${CONFIG_PROTECT_MASK}   for x in ${CONFIG_PROTECT_MASK}
1655   do   do
1656   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"
1657   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1658   then   then
1659   PROTECTED=MASKED   PROTECTED=MASKED
1660   fi   fi
1661   done   done
1662    
1663     # check if not ignored
1664     for x in ${CONFIG_PROTECT_IGNORE}
1665     do
1666     TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}"
1667     if [[ ${TEST} != ${EXPFILE} ]]
1668     then
1669     PROTECTED=IGNORED
1670     fi
1671     done
1672   fi   fi
1673   done   done
1674    
# Line 1354  is_config_protected() Line 1683  is_config_protected()
1683   #echo "I'm protected, but masked - delete me"   #echo "I'm protected, but masked - delete me"
1684   return 3   return 3
1685   ;;   ;;
1686     IGNORED)
1687     #echo "I'm protected, but ignored - keep me, del update"
1688     return 4
1689     ;;
1690   *)   *)
1691   #echo "delete me"   #echo "delete me"
1692   return 0   return 0
# Line 1371  is_config_protected() Line 1704  is_config_protected()
1704  ###################################################  ###################################################
1705  count_protected_files()  count_protected_files()
1706  {  {
1707   ${MLIBDIR}/writeprotected "$1"   local file="$1"
1708     local dirname="${file%/*}"
1709     local filename="${file##*/}"
1710     local count
1711     local output
1712     local i
1713    
1714     declare -i count=0
1715    
1716     # check if there are already protected files
1717     for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" |
1718     sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
1719     sort -t'%' -k3 -k2 | cut -f1 -d'%')
1720     do
1721     count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::")
1722     done
1723     (( count ++ ))
1724    
1725     # fill output up with zeros
1726     for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
1727     output="${output}${count}"
1728    
1729     echo "${output}"
1730  }  }
1731    
1732  # call with  # call with
# Line 1388  get_uninstall_candidates() Line 1743  get_uninstall_candidates()
1743   local list   local list
1744   local pcatdir   local pcatdir
1745   local protected   local protected
1746     local i
1747    
1748   # very basic getops   # very basic getops
1749   for i in $*   for i in $*
# Line 1400  get_uninstall_candidates() Line 1756  get_uninstall_candidates()
1756   shift   shift
1757   done   done
1758    
1759   # sanity checks; abort if not given  # it's not good to complain here about empty pnames; better to continue later anyway
1760   [ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given."  # # sanity checks; abort if not given
1761    # [ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given."
1762    
1763    
1764   # check needed global vars   # check needed global vars
1765   [ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set."   [ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set."
1766    
1767   # set pcatdir to '*' if empty   # set pcatdir to '*' if empty
1768   [ -z "${pcatdir}" ] && pcatdir=*   [ -z "${pcatdir}" ] && pcatdir='*'
1769    
1770   for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/*   for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/*
1771   do   do
# Line 1493  virtuals_add() Line 1850  virtuals_add()
1850   local oldline   local oldline
1851   local line i   local line i
1852   local installed_file   local installed_file
1853     local OLDIFS
1854    
1855   if virtuals_read ${virtualname}   if virtuals_read ${virtualname}
1856   then   then
1857   # make shure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already   # make sure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already
1858   for i in $(virtuals_read ${virtualname} showpkgs)   for i in $(virtuals_read ${virtualname} showpkgs)
1859   do   do
1860   if [[ ${i} = ${pkgname} ]]   if [[ ${i} = ${pkgname} ]]
# Line 1515  virtuals_add() Line 1873  virtuals_add()
1873   # make a backup   # make a backup
1874   mv ${MROOT}${VIRTUALDB_FILE} ${MROOT}${VIRTUALDB_FILE}.old   mv ${MROOT}${VIRTUALDB_FILE} ${MROOT}${VIRTUALDB_FILE}.old
1875    
1876     OLDIFS="${IFS}"
1877   IFS=$'\n'   IFS=$'\n'
1878   for line in $(< ${MROOT}${VIRTUALDB_FILE}.old)   for line in $(< ${MROOT}${VIRTUALDB_FILE}.old)
1879   do   do
# Line 1526  virtuals_add() Line 1885  virtuals_add()
1885   echo "${line}" >> ${MROOT}${VIRTUALDB_FILE}   echo "${line}" >> ${MROOT}${VIRTUALDB_FILE}
1886   fi   fi
1887   done   done
1888     # unset IFS
1889   #unset IFS   IFS="${OLDIFS}"
1890   else   else
1891   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} >>> ${COLDEFAULT}"
1892   echo "register ${pkgname} as ${virtualname} ..."   echo "register ${pkgname} as ${virtualname} ..."
1893   echo "${virtualname} ${pkgname}" >> ${MROOT}${VIRTUALDB_FILE}   echo "${virtualname} ${pkgname}" >> ${MROOT}${VIRTUALDB_FILE}
1894   fi   fi
# Line 1539  virtuals_add() Line 1898  virtuals_add()
1898    
1899  #deletes pakages from virtual database  #deletes pakages from virtual database
1900  #$1 virtualname; $2 pkgname  #$1 virtualname; $2 pkgname
1901  virtuals_del() {  virtuals_del()
1902    {
1903    
1904   local VIRTUAL_NAME PKG_NAME OLD_LINE METHOD line i x PKG_INSTALLED   local virtualname="$1"
1905     local pkgname="$2"
1906   VIRTUAL_NAME=$1   local oldline
1907   PKG_NAME=$2   local method
1908     local line i x
1909   #first check if exists   local pkg_installed
1910   if virtuals_read ${VIRTUAL_NAME}   local OLDIFS
1911    
1912     # first check if exists
1913     if virtuals_read ${virtualname}
1914   then   then
1915   #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}
1916   declare -i x=0   declare -i x=0
1917   for i in $(virtuals_read ${VIRTUAL_NAME} showpkgs)   for i in $(virtuals_read ${virtualname} showpkgs)
1918   do   do
1919   if [ "${i}" == "${PKG_NAME}" ]   if [[ ${i} = ${pkgname} ]]
1920   then   then
1921   PKG_INSTALLED=true   pkg_installed=true
1922   fi   fi
1923   ((x++))   ((x++))
1924   done   done
1925    
1926   #abort if not installed   # abort if not installed
1927   if [ "${PKG_INSTALLED}" != "true" ]   if [[ ${pkg_installed} != true ]]
1928   then   then
1929   echo "!!!! ${PKG_NAME} does not exists in ${VIRTUAL_NAME}."   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1930     echo "${pkgname} does not exists in ${virtualname}."
1931   return 0   return 0
1932   fi   fi
1933    
1934   if [ ${x} -ge 2 ]   if [ ${x} -ge 2 ]
1935   then   then
1936   METHOD=update   method=update
1937   else   else
1938   METHOD=delall   method=delall
1939   fi   fi
1940    
1941   #get the complete line   # get the complete line
1942   OLD_LINE="$(virtuals_read ${VIRTUAL_NAME} showline)"   oldline="$(virtuals_read ${virtualname} showline)"
1943    
1944   #make a backup   # make a backup of the db
1945   mv ${VIRTUALDB_FILE} ${VIRTUALDB_FILE}.old   mv ${VIRTUALDB_FILE} ${VIRTUALDB_FILE}.old
1946    
1947   #parse virtualdb   # parse virtualdb
1948     OLDIFS="${IFS}"
1949   IFS=$'\n'   IFS=$'\n'
1950   for line in $(< ${VIRTUALDB_FILE}.old)   for line in $(< ${VIRTUALDB_FILE}.old)
1951   do   do
1952   if [ "${line}" == "${OLD_LINE}" ]   if [[ ${line} = ${oldline} ]]
1953   then   then
1954   #delall or update?   #delall or update?
1955   case ${METHOD} in   case ${method} in
1956   update)   update)
1957   echo "<<<< Unlinking ${PKG_NAME} from ${VIRTUAL_NAME} in virtual database ..."   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
1958   #del PKG_NAME from line   echo "Unlinking ${pkgname} from ${virtualname} in virtual database ..."
1959   echo "${line/ ${PKG_NAME}/}" >> ${VIRTUALDB_FILE}   # del PKG_NAME from line
1960     echo "${line/ ${pkgname}/}" >> ${VIRTUALDB_FILE}
1961   ;;   ;;
1962   delall)   delall)
1963   echo "<<<< Deleting ${VIRTUAL_NAME} in virtual database ..."   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"
1964   #continue; do not write anything   echo "Deleting ${virtualname} in virtual database ..."
1965     # continue; do not write anything
1966   continue   continue
1967   ;;   ;;
1968   esac   esac
# Line 1603  virtuals_del() { Line 1970  virtuals_del() {
1970   echo "${line}" >> ${VIRTUALDB_FILE}   echo "${line}" >> ${VIRTUALDB_FILE}
1971   fi   fi
1972   done   done
1973   unset IFS   # unset IFS
1974     IFS="${OLDIFS}"
1975   else   else
1976   echo "!!!! ${VIRTUAL_NAME} does not exists in virtual database."   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1977     echo "${virtualname} does not exists in virtual database."
1978   fi   fi
1979  }  }
1980    
# Line 1637  minclude() Line 2006  minclude()
2006  {  {
2007   local i   local i
2008    
2009   if [ -n "$@" ]   if [[ -n $* ]]
2010   then   then
2011   for i in $@   for i in $*
2012   do   do
2013   [[ ${MAGEDEBUG} = on ]] && \   [[ ${MAGEDEBUG} = on ]] && \
2014   echo "--- Including ${MAGEDIR}/include/${i}.minc"   echo "--- Including ${MAGEDIR}/include/${i}.minc"
# Line 1653  sminclude() Line 2022  sminclude()
2022  {  {
2023   local i   local i
2024    
2025   if [ -n "$@" ]   if [[ -n $* ]]
2026   then   then
2027   for i in $@   for i in $*
2028   do   do
2029   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
2030   source ${SMAGESCRIPTSDIR}/include/${i}.sminc   source ${SMAGESCRIPTSDIR}/include/${i}.sminc
# Line 1670  is_newer_mage_version_available() Line 2039  is_newer_mage_version_available()
2039   local newest_mage   local newest_mage
2040   local installed_mage   local installed_mage
2041    
2042   newest_mage="$( CATEGORIE=app-mage MAGENAME=mage get_highest_magefile;echo $(basename ${MAGEFILE} .mage) )"   newest_mage="$(basename $(get_highest_magefile app-mage mage) .mage)"
2043   installed_mage="$(magequery -n mage | cut -d' ' -f5)"   installed_mage="$(magequery -n mage | cut -d' ' -f5)"
2044    
2045   if [[ ${newest_mage} > ${installed_mage} ]]   if [[ ${newest_mage} > ${installed_mage} ]]
# Line 1679  is_newer_mage_version_available() Line 2048  is_newer_mage_version_available()
2048   echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT}   echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT}
2049   echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT}   echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT}
2050   echo "It is recommened to install this newer version"   echo "It is recommened to install this newer version"
2051   echo "or your current system installation may brake."   echo "or your current system installation may break."
2052   echo   echo
2053   echo -en "Please update mage by running "   echo -en "Please update mage by running "
2054   echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT}   echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT}
# Line 1951  get_value_from_magefile() Line 2320  get_value_from_magefile()
2320   local magefile="$2"   local magefile="$2"
2321   local value   local value
2322    
2323     [[ -z ${var} ]] && return 1
2324     [[ -z ${magefile} ]] && return 1
2325    
2326   # local all possible vars of a mage file   # local all possible vars of a mage file
2327   # to prevent bad issues   # to prevent bad issues
2328   local PKGNAME   local PKGNAME
# Line 1961  get_value_from_magefile() Line 2333  get_value_from_magefile()
2333   local SDEPEND   local SDEPEND
2334   local PROVIDE   local PROVIDE
2335   local PKGTYPE   local PKGTYPE
2336     local MAGE_TARGETS
2337     local SPLIT_PACKAGE_BASE
2338   local preinstall   local preinstall
2339   local postinstall   local postinstall
2340     local preremove
2341     local postremove
2342    
2343   # sanity checks   # sanity checks
2344   [ -f ${magefile} ] && source ${magefile} || \   [ -f ${magefile} ] && source ${magefile} || \
# Line 1972  get_value_from_magefile() Line 2348  get_value_from_magefile()
2348   source ${magefile}   source ${magefile}
2349   eval value=\$$(echo ${var})   eval value=\$$(echo ${var})
2350   echo "${value}"   echo "${value}"
2351    
2352     # unset these functions
2353     unset -f preinstall
2354     unset -f postinstall
2355     unset -f preremove
2356     unset -f postremove
2357  }  }
2358    
2359  mage_install()  mage_install()
# Line 1988  mage_install() Line 2370  mage_install()
2370   local PKGTYPE   local PKGTYPE
2371   local preinstall   local preinstall
2372   local postinstall   local postinstall
2373     local preremove
2374     local postremove
2375    
2376   local pcat   local pcat
2377   local pname   local pname
# Line 1997  mage_install() Line 2381  mage_install()
2381   local count_current   local count_current
2382   local magefile   local magefile
2383   local src_install   local src_install
2384     local i
2385    
2386   # very basic getops   # very basic getops
2387   for i in $*   for i in $*
# Line 2070  mage_install() Line 2455  mage_install()
2455   echo B:${pbuild}   echo B:${pbuild}
2456   fi   fi
2457    
2458   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2   if [[ -n ${MAGE_TARGETS} ]]
2459     then
2460     # basic svn compat
2461     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2462     then
2463     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2464     do
2465     smage2file="${i}"
2466     done
2467     else
2468     smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2469     fi
2470    
2471     elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2472     then
2473     # basic svn compat
2474     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2475     then
2476     for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2477     do
2478     smage2file="${i}"
2479     done
2480     else
2481     smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2482     fi
2483    
2484     else
2485     # basic svn compat
2486     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2487     then
2488     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2489     do
2490     smage2file="${i}"
2491     done
2492     else
2493     smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2
2494     fi
2495     fi
2496    
2497   if [ -f "${smage2file}" ]   if [ -f "${smage2file}" ]
2498   then   then
2499     echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "
2500   smage2 ${smage2file} || die "compile failed"   smage2 ${smage2file} || die "compile failed"
2501   else   else
2502   echo   echo
# Line 2086  mage_install() Line 2510  mage_install()
2510   if [[ ${PKGTYPE} != virtual ]] && \   if [[ ${PKGTYPE} != virtual ]] && \
2511   [[ ${PKGTYPE} != sources ]]   [[ ${PKGTYPE} != sources ]]
2512   then   then
2513   # 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  
2514   build_doinstall ${PKGNAME}   build_doinstall ${PKGNAME}
2515   fi   fi
2516    
# Line 2149  mage_install() Line 2566  mage_install()
2566  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2567  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "
2568   echo "successfully installed."   echo "successfully installed."
2569    
2570     # unset these functions
2571     unset -f preinstall
2572     unset -f postinstall
2573     unset -f preremove
2574     unset -f postremove
2575  }  }
2576    
2577  md5sum_packages()  md5sum_packages()
# Line 2201  md5sum_packages() Line 2624  md5sum_packages()
2624   then   then
2625   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2626   echo -ne "checking md5sum (${count_current}/${count_total}): "   echo -ne "checking md5sum (${count_current}/${count_total}): "
2627   ( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed"   ( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed"
2628   else   else
2629   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2630   echo -e "!! no md5sum file found for ${pkgfile} :("   echo -e "!! no md5sum file found for ${pkgfile} :("
# Line 2253  uninstall_packages() Line 2676  uninstall_packages()
2676   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2677   echo "following candidate(s) will be removed:"   echo "following candidate(s) will be removed:"
2678   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2679   echo -ne "\033[1m${can_pcat}/${can_pname}:${COLDEFAULT}"   echo -ne "${COLBOLD}${can_pcat}/${can_pname}:${COLDEFAULT}"
2680   echo -e "${COLRED} ${can_ver_list} ${COLDEFAULT}"   echo -e "${COLRED} ${can_ver_list} ${COLDEFAULT}"
2681   echo   echo
2682   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   if [ ${MAGE_UNINSTALL_TIMEOUT} -gt 0 ]
2683   echo "( Press [CTRL+C] to abort )"   then
2684   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2685   echo -n "Waiting ${MAGE_UNINSTALL_TIMEOUT} seconds ..."   echo "( Press [CTRL+C] to abort )"
2686   for ((i=MAGE_UNINSTALL_TIMEOUT; i >= 0; i--))   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2687   do   echo -n "Waiting ${MAGE_UNINSTALL_TIMEOUT} seconds ..."
2688   echo -ne "${COLRED} ${i}${COLDEFAULT}"   for ((i=MAGE_UNINSTALL_TIMEOUT; i >= 0; i--))
2689   sleep 1   do
2690   done   echo -ne "${COLRED} ${i}${COLDEFAULT}"
2691   echo   sleep 1
2692   echo   done
2693     echo
2694     echo
2695     fi
2696    
2697   for pkg in ${list}   for pkg in ${list}
2698   do   do
# Line 2304  mage_uninstall() Line 2730  mage_uninstall()
2730   local PKGTYPE   local PKGTYPE
2731   local preinstall   local preinstall
2732   local postinstall   local postinstall
2733     local preremove
2734     local postremove
2735    
2736   local pcat   local pcat
2737   local pname   local pname
# Line 2339  mage_uninstall() Line 2767  mage_uninstall()
2767   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"
2768   echo -n "removing: "   echo -n "removing: "
2769   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2770   echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"   echo -e "${COLRED}${pname}-${pver}-${pbuild}${COLDEFAULT}"
2771    
2772   magefile="${MAGEDIR}/${pcat}/${pname}/${pname}-${pver}-${pbuild}.mage"   magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
2773   source ${magefile}   source ${magefile}
2774    
2775   ## preremove scripts   ## preremove scripts
# Line 2401  mage_uninstall() Line 2829  mage_uninstall()
2829  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2830  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "
2831   echo "successfully removed."   echo "successfully removed."
2832    
2833     # unset these functions
2834     unset -f preinstall
2835     unset -f postinstall
2836     unset -f preremove
2837     unset -f postremove
2838  }  }
2839    
2840  show_etc_update_mesg() {  show_etc_update_mesg()
2841    {
2842   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0
2843    
2844   echo   echo
# Line 2415  show_etc_update_mesg() { Line 2850  show_etc_update_mesg() {
2850   echo "Please run 'etc-update' to update your configuration files."   echo "Please run 'etc-update' to update your configuration files."
2851   echo   echo
2852  }  }
2853    
2854    pkgsearch()
2855    {
2856     local string="$1"
2857     local result
2858     local pkg
2859     local pcat
2860     local pname
2861     local magefile
2862     local pver
2863     local pbuild
2864     local state
2865     local descriptiom
2866     local homepage
2867     local i
2868     local all_installed
2869     local ipver
2870     local ipbuild
2871     local latest_available
2872     local depsfull
2873     local sdepsfull
2874     local deps
2875     local sdeps
2876     local dep
2877     local sign
2878    
2879     # only names no versions
2880     result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name '*'${string}'*'| sed '/profiles/d' | sed '/includes/d')"
2881     #result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)"
2882    
2883     # nothing found
2884     [[ -z ${result} ]] && die "No package found containing '${string}' in the name."
2885    
2886     for pkg in ${result}
2887     do
2888     # dirty, but does the job
2889     pcat="$(magename2pcat ${pkg}/foo)"
2890     pname="$(magename2pname ${pkg}-foo-foo)"
2891    
2892     # get highest version available
2893     magefile=$(get_highest_magefile ${pcat} ${pname})
2894    
2895     if [[ ! -z ${magefile} ]]
2896     then
2897     # now get all needed infos to print a nice output
2898     pver="$(magename2pver ${magefile})"
2899     pbuild="$(magename2pbuild ${magefile})"
2900     state="$(get_value_from_magefile STATE ${magefile})"
2901     description="$(get_value_from_magefile DESCRIPTION ${magefile})"
2902     homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
2903    
2904     # all installed
2905     for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
2906     do
2907     ipver="$(magename2pver ${i})"
2908     ipbuild="$(magename2pbuild ${i})"
2909    
2910     if [[ -z ${all_installed} ]]
2911     then
2912     all_installed="${ipver}-${ipbuild}"
2913     else
2914     all_installed="${all_installed} ${ipver}-${ipbuild}"
2915     fi
2916     done
2917     [[ -z ${all_installed} ]] && all_installed="none"
2918    
2919     case ${state} in
2920     stable) state=${COLGREEN}"[s] ";;
2921     testing) state=${COLYELLOW}"[t] ";;
2922     unstable) state=${COLRED}"[u] ";;
2923     old) state=${COLGRAY}"[o] ";;
2924     esac
2925    
2926     latest_available="${pver}-${pbuild}"
2927     else
2928     # package is masked
2929     state="${COLRED}[m] "
2930     latest_available="${COLRED}masked for this distribution.${COLDEFAULT}"
2931     fi
2932    
2933     depsfull="$(get_value_from_magefile DEPEND ${magefile})"
2934     sdepsfull="$(get_value_from_magefile SDEPEND ${magefile})"
2935    
2936     while read sign dep
2937     do
2938     case ${dep} in
2939     "") continue;;
2940     esac
2941    
2942     deps="${deps} $(basename ${dep%-*})"
2943     done << EOF
2944    ${depsfull}
2945    EOF
2946    
2947     while read sign dep
2948     do
2949     case ${dep} in
2950     "") continue;;
2951     esac
2952    
2953     sdeps="${sdeps} $(basename ${dep%-*})"
2954     done << EOF
2955    ${sdepsfull}
2956    EOF
2957    
2958     echo -e "${state}${pcat}/${pname}"${COLDEFAULT}
2959     echo -e "      Latest available:   ${latest_available}"
2960     echo "      Installed versions: ${all_installed}"
2961     echo "      Description: ${description}"
2962     echo "      Homepage: ${homepage}"
2963     echo "      Depends: ${deps}"
2964     echo "      SDepends: ${sdeps}"
2965     echo
2966    
2967     unset pcat
2968     unset pname
2969     unset magefile
2970     unset pver
2971     unset pbuild
2972     unset state
2973     unset descriptiom
2974     unset homepage
2975     unset all_installed
2976     unset ipver
2977     unset ipbuild
2978     unset depsfull
2979     unset sdepsfull
2980     unset deps
2981     unset sdeps
2982     unset dep
2983     unset sign
2984     done
2985    }
2986    
2987    export_inherits()
2988    {
2989     local include="$1"
2990     shift
2991    
2992     while [ "$1" ]
2993     do
2994     local functions="$1"
2995    
2996     # sanity checks
2997     [ -z "${include}" ] && die "export_inherits(): \$include not given."
2998     [ -z "${functions}" ] && die "export_inherits(): \$functions not given."
2999    
3000     eval "${functions}() { ${include}_${functions} ; }"
3001    
3002     # debug
3003     [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"
3004    
3005     shift
3006     done
3007    }
3008    
3009    mlibdir()
3010    {
3011     local libdir=lib
3012     [[ ${ARCH} = x86_64 ]] && libdir=lib64
3013    
3014     echo "${libdir}"
3015    }
3016    
3017    ## blacklisted ${magefile}
3018    blacklisted()
3019    {
3020     [[ -z ${MAGE_DISTRIBUTION} ]] && local MAGE_DISTRIBUTION=stable
3021    
3022     # compat
3023     [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable
3024     [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing
3025    
3026     # support both types for the moment
3027     if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]]
3028     then
3029     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"
3030     else
3031     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}"
3032     fi
3033    
3034     # return 0 if the list not exist; nothin is masked
3035     [[ ! -f ${EXCLUDED} ]] && return 0
3036    
3037     local MAGEFILE="$1"
3038    
3039     local PCAT="$(magename2pcat ${MAGEFILE})"
3040     local PNAME="$(magename2pname ${MAGEFILE})"
3041     local PVER="$(magename2pver ${MAGEFILE})"
3042     local PBUILD="$(magename2pbuild ${MAGEFILE})"
3043    
3044     local EXPCAT EXPNAME EXPVER EXPBUILD
3045     while read EXPCAT EXPNAME EXPVER EXPBUILD
3046     do
3047     # ignore spaces and comments
3048             case "${EXPCAT}" in
3049                     \#*|"") continue ;;
3050             esac
3051    
3052     # exclude full pver
3053     if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] &&
3054     [[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] &&
3055     [[ -n ${PVER} ]] && [[ -n ${PBUILD} ]] &&
3056     [[ -n ${EXPVER} ]] && [[ -n ${EXPBUILD} ]]
3057     then
3058     [[ ${EXPCAT}/${EXPNAME}-${EXPVER}-${EXPBUILD} = ${PCAT}/${PNAME}-${PVER}-${PBUILD} ]] && return 1
3059     fi
3060    
3061     # exclude pcat/pname only
3062     if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] &&
3063     [[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] &&
3064     [[ -z ${EXPVER} ]] && [[ -z ${EXPBUILD} ]]
3065     then
3066     [[ ${EXPCAT}/${EXPNAME} = ${PCAT}/${PNAME} ]] && return 1
3067     fi
3068     done << EOF
3069    $( cat ${EXCLUDED}; echo)
3070    EOF
3071    
3072     return 0
3073    }
3074    
3075    # need_busybox_support ${cmd}
3076    # return 0 (no error = needs busybox support) or return 1 (error = no busybox support required)
3077    need_busybox_support()
3078    {
3079     local cmd
3080     cmd="$1"
3081    
3082     if [[ -x /bin/busybox ]]
3083     then
3084     if [[ $(readlink $(which ${cmd})) = /bin/busybox ]]
3085     then
3086     # needs busybox support
3087     return 0
3088     else
3089     # no busybox
3090     return 1
3091     fi
3092     fi
3093    }
3094    
3095    # busybox_filter_wget_options ${wget_opts}
3096    busybox_filter_wget_options()
3097    {
3098     local opts="$@"
3099     local i
3100     local fixed_opts
3101    
3102     if need_busybox_support wget
3103     then
3104     for i in ${opts}
3105     do
3106     # show only the allowed ones
3107     case ${i} in
3108     -c|--continue) fixed_opts+=" -c" ;;
3109     -s|--spider) fixed_opts+=" -s" ;;
3110     -q|--quiet) fixed_opts+=" -q" ;;
3111     -O|--output-document) shift; fixed_opts+=" -O $1" ;;
3112     --header) shift; fixed_opts+=" --header $1" ;;
3113     -Y|--proxy) shift; fixed_opts+=" -Y $1" ;;
3114     -P) shift; fixed_opts+=" -P $1" ;;
3115     --no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;;
3116     -U|--user-agent) shift; fixed_opts+=" -U ${i}" ;;
3117     # simply drop all other opts
3118     *) continue ;;
3119     esac
3120     done
3121    
3122     echo "${fixed_opts}"
3123     else
3124     echo "${opts}"
3125     fi
3126    }

Legend:
Removed from v.226  
changed lines
  Added in v.1289