Magellan Linux

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

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

revision 373 by niro, Thu Apr 27 17:15:23 2006 UTC revision 1675 by niro, Mon Feb 6 09:45:23 2012 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.19 2006-04-27 17:15:23 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    COLRED="\033[1;6m\033[31m"
6    COLGREEN="\033[1;6m\033[32m"
7    COLYELLOW="\033[1;6m\033[33m"
8    COLBLUE="\033[1;6m\033[34m"
9    COLMAGENTA="\033[1;6m\033[35m"
10    COLWHITE="\033[1;6m\033[37m"
11    COLGRAY="\033[0;6m\033[37m"
12    COLBOLD="\033[1m"
13    COLDEFAULT="\033[0m"
14    
15    if [[ ${NOCOLORS} = true ]]
16    then
17     COLRED=""
18     COLGREEN=""
19     COLYELLOW=""
20     COLBLUE=""
21     COLMAGENTA=""
22     COLWHITE=""
23     COLGRAY=""
24     COLBOLD=""
25     COLDEFAULT=""
26    fi
27    
28  mage_setup()  mage_setup()
29  {  {
# Line 15  mage_setup() Line 38  mage_setup()
38   return 0   return 0
39  }  }
40    
41    mchecksum()
42    {
43     local i
44     local rundir
45     local file
46     local method
47     local cmd
48     local retval
49    
50     # very basic getops
51     for i in $*
52     do
53     case $1 in
54     --rundir|-r) shift; rundir="$1" ;;
55     --file|-f) shift; file="$1" ;;
56     --method|-m) shift; method="$1" ;;
57     esac
58     shift
59     done
60    
61     # sanity checks
62     [[ -z ${rundir} ]] && die "mchecksum(): rundir missing"
63     [[ -z ${file} ]] && die "mchecksum(): file missing"
64     [[ -z ${method} ]] && die "mchecksum(): method missing"
65    
66     case ${method} in
67     md5) cmd="md5sum" ;;
68     sha256) cmd="sha256sum" ;;
69     *) die "mchecksum(): unknown method '${method}'" ;;
70     esac
71    
72     if [[ -d ${rundir} ]]
73     then
74     pushd ${rundir} &> /dev/null
75     # be verbose here
76     ${cmd} -c ${file} #&> /dev/null
77     retval="$?"
78     popd &> /dev/null
79     else
80     retval=1
81     fi
82    
83     return "${retval}"
84    }
85    
86    mcheckemptydir()
87    {
88     local dir="$1"
89     local retval=1
90    
91     if [[ ! -d ${dir} ]]
92     then
93     echo "mcheckemptydir(): '${dir}' is not a directory!"
94     retval=3
95     else
96     shopt -s nullglob dotglob
97     files=( ${dir}/* )
98     (( ${#files[*]} )) || retval=0
99     shopt -u nullglob dotglob
100     fi
101    
102     return ${retval}
103    }
104    
105  unpack_packages()  unpack_packages()
106  {  {
107   local list="$@"   local list="$@"
# Line 23  unpack_packages() Line 110  unpack_packages()
110   local pkgtype   local pkgtype
111   local count_current   local count_current
112   local count_total   local count_total
113     local tar_opts
114    
115   # get count of total packages   # get count of total packages
116   declare -i count_current=0   declare -i count_current=0
# Line 54  unpack_packages() Line 142  unpack_packages()
142   continue   continue
143   fi   fi
144    
145     # busybox?
146     if need_busybox_support tar
147     then
148     tar_opts="xjf"
149     else
150     tar_opts="xjmf"
151     fi
152    
153   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "
154   tar xjmf ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"   tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"
155   done   done
156    
157   # add a crlf for a better view   # add a crlf for a better view
# Line 130  install_directories() Line 226  install_directories()
226   while read pathto posix user group   while read pathto posix user group
227   do   do
228   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
229   [[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR:  ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> DIR:  ${MROOT}${pathto}"
   
230    
231   # monitors /etc/env.d -> env-rebuild   # monitors /etc/env.d -> env-rebuild
232   [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true   [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true
# Line 198  install_files() Line 293  install_files()
293   is_config_protected "${pathto}"   is_config_protected "${pathto}"
294   retval="$?"   retval="$?"
295    
296   # 0 - not protected        #   # 0 - not protected         #
297   # 1 - error                #   # 1 - error                 #
298   # 2 - protected            #   # 2 - protected             #
299   # 3 - protected but masked #   # 3 - protected but masked  #
300     # 4 - protected but ignored #
301    
302   case ${retval} in   case ${retval} in
303   # file is not protected - (over)write it   # file is not protected - (over)write it
304   0|3)   0|3)
305   [[ ${VERBOSE} = on ]] && echo -e "\t>>> FILE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> FILE: ${MROOT}${pathto}"
306   install -m "${posix}" -o "${user}" -g "${group}" \   install -m "${posix}" -o "${user}" -g "${group}" \
307   ${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \   ${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \
308   "${MROOT}${pathto}"   "${MROOT}${pathto}"
# Line 218  install_files() Line 314  install_files()
314   "${user}" \   "${user}" \
315   "${group}" \   "${group}" \
316   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
317   "${MROOT}${pathto}")" \   "${MROOT}${pathto}")" \
318   "${md5sum}"   "${md5sum}"
319   ;;   ;;
320    
321   # file is protected, write backup file   # file is protected, write backup file
322   2)   2)
323   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
324   then   then
325   echo -en "${COLRED}"   echo -en "${COLRED}"
326   echo -n "! prot "   echo -n "! prot "
# Line 245  install_files() Line 341  install_files()
341   "${user}" \   "${user}" \
342   "${group}" \   "${group}" \
343   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
344   "${dest_protected}")" \   "${dest_protected}")" \
345   "${md5sum}"   "${md5sum}"
346    
347   # update global MAGE_PROTECT_COUNTER   # update global MAGE_PROTECT_COUNTER
348   (( MAGE_PROTECT_COUNTER++ ))   (( MAGE_PROTECT_COUNTER++ ))
349   export MAGE_PROTECT_COUNTER   export MAGE_PROTECT_COUNTER
350   ;;   ;;
351    
352     # file is protected but ignored, delete the update/do nothing
353     4)
354     if mqueryfeature "verbose"
355     then
356     echo -en "${COLRED}"
357     echo -n "! ignr "
358     echo -en "${COLDEFAULT}"
359     echo " === FILE: ${MROOT}${pathto}"
360     fi
361     # simply do nothing here - only fix mtime
362     fix_descriptor ${pkgname}/.files \
363     "${pathto}" \
364     "${posix}" \
365     "${user}" \
366     "${group}" \
367     "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
368     "${MROOT}${pathto}")" \
369     "${md5sum}"
370     ;;
371   esac   esac
372   done < ${BUILDDIR}/${pkgname}/.files   done < ${BUILDDIR}/${pkgname}/.files
373    
# Line 294  install_symlinks() Line 410  install_symlinks()
410   while read pathto posix link mtime   while read pathto posix link mtime
411   do   do
412   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
413   [[ ${VERBOSE} = on ]] && echo -e "\t>>> LINK: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> LINK: ${MROOT}${pathto}"
414    
415   ln -snf "${link}" "${MROOT}${pathto}"   ln -snf "${link}" "${MROOT}${pathto}"
416    
417   # fix mtime and db  # # fix mtime and db
418   fix_descriptor ${pkgname}/.symlinks \  # fix_descriptor ${pkgname}/.symlinks \
419   "${pathto}" \  # "${pathto}" \
420   "${posix}" \  # "${posix}" \
421   "${link}" \  # "${link}" \
422   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \  # "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
423   "${MROOT}${pathto}")"  # "${MROOT}${pathto}")"
424    
425   done < ${BUILDDIR}/${pkgname}/.symlinks   done < ${BUILDDIR}/${pkgname}/.symlinks
426    
427   # now copy the fixed file over the old one  # # now copy the fixed file over the old one
428   [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \  # [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \
429   cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,}  # cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,}
430    
431   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
432   IFS=$'\n'   IFS=$'\n'
# Line 326  install_blockdevices() Line 442  install_blockdevices()
442   local pkgname="$1"   local pkgname="$1"
443   local pathto   local pathto
444   local posix   local posix
445     local user
446     local group
447   local IFS   local IFS
448    
449   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 339  install_blockdevices() Line 457  install_blockdevices()
457   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
458   IFS=§   IFS=§
459    
460   while read pathto posix   while read pathto posix major minor user group
461   do   do
462   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
463   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> PIPE: ${MROOT}${pathto}"
464    
465   mkfifo -m "${posix}" "${MROOT}$pathto"   mknod -m "${posix}" "${MROOT}${pathto}"
466     # make it optional atm !!
467     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
468     then
469     chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}"
470     fi
471   done < ${BUILDDIR}/${pkgname}/.pipes   done < ${BUILDDIR}/${pkgname}/.pipes
472    
473   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
# Line 363  install_characterdevices() Line 486  install_characterdevices()
486   local posix   local posix
487   local major   local major
488   local minor   local minor
489     local user
490     local group
491   local IFS   local IFS
492    
493   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 376  install_characterdevices() Line 501  install_characterdevices()
501   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
502   IFS=§   IFS=§
503    
504   while read pathto posix major minor   while read pathto posix major minor user group
505   do   do
506   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
507   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> CHAR: ${MROOT}${pathto}"
508    
509   mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor}   mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}"
510    
511     # make it optional atm !!
512     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
513     then
514     chown "${user}:${group}" "${MROOT}${pathto}"
515     fi
516   done < ${BUILDDIR}/${pkgname}/.char   done < ${BUILDDIR}/${pkgname}/.char
517    
518   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
519   IFS=$'\n'   IFS=$'\n'
520  }  }
521    
522    ###################################################
523    # function install_fifos                          #
524    # install_fifos $PKGNAME                    #
525    ###################################################
526    install_fifos()
527    {
528     local pkgname="$1"
529     local pathto
530     local posix
531     local user
532     local group
533     local IFS
534    
535     # sanity checks; abort if not given
536     [ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given."
537    
538     # check needed global vars
539     [ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set."
540    
541     # make it optional atm !!
542     #[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found"
543     [ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return
544    
545     # sets fieldseperator to "§" instead of " "
546     IFS=§
547    
548     while read pathto posix user group
549     do
550     [ -z "${pathto}" ] && continue
551     mqueryfeature "verbose" && echo -e "\t>>> FIFO: ${MROOT}${pathto}"
552    
553     mkfifo -m "${posix}" "${MROOT}${pathto}"
554     chown "${user}:${group}" "${MROOT}${pathto}"
555     done < ${BUILDDIR}/${pkgname}/.fifo
556    
557     # very important: unsetting the '§' fieldseperator
558     IFS=$'\n'
559    }
560    
561    
562  ###################################################  ###################################################
563  # function build_doinstall                        #  # function build_doinstall                        #
564  # build_doinstall $PKGNAME                  #  # build_doinstall $PKGNAME                  #
565  # NOTE: this is an wrapper do install packages    #  # NOTE: this is an wrapper to install packages    #
566  ###################################################  ###################################################
567  build_doinstall()  build_doinstall()
568  {  {
# Line 400  build_doinstall() Line 570  build_doinstall()
570    
571   # sanity checks; abort if not given   # sanity checks; abort if not given
572   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."
573    
574   # this is only a wrapper   # this is only a wrapper
575    
576   # NOTE:   # NOTE:
# Line 415  build_doinstall() Line 585  build_doinstall()
585   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"
586   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"
587   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"
588     install_fifos ${pkgname} || die "install fifos ${pkgname}"
589  }  }
590    
591    
# Line 476  install_database_entry() Line 647  install_database_entry()
647    
648   # create fake file descriptors   # create fake file descriptors
649   # used by virtual and source packages   # used by virtual and source packages
650   for i in .dirs .symlinks .files .pipes .char   for i in .dirs .symlinks .files .pipes .char .fifo
651   do   do
652   touch ${dbrecorddir}/${i}   touch ${dbrecorddir}/${i}
653   done   done
# Line 494  install_database_entry() Line 665  install_database_entry()
665    
666   # normal packages needs these files   # normal packages needs these files
667   local i   local i
668   for i in .char .dirs .files .pipes .symlinks   for i in .char .dirs .files .pipes .symlinks .fifo
669   do   do
670   install -m 0644 ${BUILDDIR}/${pkgname}/${i} \   # make .fifo optional atm
671   ${dbrecorddir}/${i}   if [[ -f ${BUILDDIR}/${pkgname}/${i} ]]
672     then
673     install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i}
674     fi
675   done   done
676   ;;   ;;
677   esac   esac
# Line 708  remove_symlinks() Line 882  remove_symlinks()
882   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
883   if [ ! -L "${MROOT}${pathto}" ]   if [ ! -L "${MROOT}${pathto}" ]
884   then   then
885   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
886   echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}"
887   continue   continue
888   fi   fi
# Line 720  remove_symlinks() Line 894  remove_symlinks()
894   # 1=keep me   #   # 1=keep me   #
895   case ${retval} in   case ${retval} in
896   0)   0)
897   [[ ${VERBOSE} = on ]] && echo -e "\t<<< LINK: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< LINK: ${MROOT}${pathto}"
898   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
899   ;;   ;;
900    
901   1)   1)
902   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
903   echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}"
904   ;;   ;;
905   esac   esac
# Line 772  remove_files() Line 946  remove_files()
946   done   done
947    
948   # sanity checks; abort if not given   # sanity checks; abort if not given
949   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_files() \$pcat not given."
950   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_files() \$pname not given."
951   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_files() \$pver not given."
952   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_files() \$pbuild not given."
953   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
954    
955   # check needed global vars   # check needed global vars
# Line 792  remove_files() Line 966  remove_files()
966    
967   if [ ! -e "${MROOT}${pathto}" ]   if [ ! -e "${MROOT}${pathto}" ]
968   then   then
969   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
970   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"
971   continue   continue
972   fi   fi
# Line 809  remove_files() Line 983  remove_files()
983   is_config_protected "${pathto}"   is_config_protected "${pathto}"
984   retval="$?"   retval="$?"
985    
986   # 0 - not protected        #   # 0 - not protected         #
987   # 1 - error                #   # 1 - error                 #
988   # 2 - protected            #   # 2 - protected             #
989   # 3 - protected but masked #   # 3 - protected but masked  #
990     # 4 - protected but ignored #
991    
992   case ${retval} in   case ${retval} in
993   # file is not protected - delete it   # file is not protected - delete it
994   0|3)   0|3)
995   [[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< FILE: ${MROOT}${pathto}"
996   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
997   ;;   ;;
998    
999   # file is protected, do not delete   # file is protected, do not delete
1000   2)   2)
1001   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
1002   then   then
1003   echo -en "${COLRED}"   echo -en "${COLRED}"
1004   echo -n "! prot "   echo -n "! prot "
# Line 831  remove_files() Line 1006  remove_files()
1006   echo " === FILE: ${MROOT}${pathto}"   echo " === FILE: ${MROOT}${pathto}"
1007   fi   fi
1008   ;;   ;;
1009    
1010     # file is protected but ignored, delete the update/do nothing
1011     4)
1012     if mqueryfeature "verbose"
1013     then
1014     echo -en "${COLRED}"
1015     echo -n "! ignr "
1016     echo -en "${COLDEFAULT}"
1017     echo " === FILE: ${MROOT}${pathto}"
1018     fi
1019     # simply do nothing here
1020     ;;
1021   esac   esac
1022   ;;   ;;
1023   1)   1)
1024   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1025   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"
1026   ;;   ;;
1027   esac   esac
# Line 853  remove_blockdevices() Line 1040  remove_blockdevices()
1040  {  {
1041   local pathto   local pathto
1042   local posix   local posix
1043     local user
1044     local group
1045   local IFS   local IFS
1046   local pcat   local pcat
1047   local pname   local pname
# Line 876  remove_blockdevices() Line 1065  remove_blockdevices()
1065   done   done
1066    
1067   # sanity checks; abort if not given   # sanity checks; abort if not given
1068   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given."
1069   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_blockdevices() \$pname not given."
1070   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_blockdevices() \$pver not given."
1071   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given."
1072   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1073    
1074   # check needed global vars   # check needed global vars
# Line 890  remove_blockdevices() Line 1079  remove_blockdevices()
1079   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1080   IFS=§   IFS=§
1081    
1082   while read pathto posix   while read pathto posix user group
1083   do   do
1084   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1085    
1086   [[ ${VERBOSE} = on ]] && echo -e "\t<<< PIPE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< PIPE: ${MROOT}${pathto}"
1087   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1088   done < ${MROOT}${INSTALLDB}/${pfull}/.pipes   done < ${MROOT}${INSTALLDB}/${pfull}/.pipes
1089    
# Line 911  remove_characterdevices() Line 1100  remove_characterdevices()
1100  {  {
1101   local pathto   local pathto
1102   local posix   local posix
1103     local user
1104     local group
1105   local IFS   local IFS
1106   local pcat   local pcat
1107   local pname   local pname
# Line 934  remove_characterdevices() Line 1125  remove_characterdevices()
1125   done   done
1126    
1127   # sanity checks; abort if not given   # sanity checks; abort if not given
1128   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given."
1129   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_characterdevices() \$pname not given."
1130   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_characterdevices() \$pver not given."
1131   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given."
1132   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1133    
1134   # check needed global vars   # check needed global vars
# Line 948  remove_characterdevices() Line 1139  remove_characterdevices()
1139   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1140   IFS=§   IFS=§
1141    
1142   while read pathto posix   while read pathto posix user group
1143   do   do
1144   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1145    
1146   [[ ${VERBOSE} = on ]] && echo -e "\t<<< CHAR: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< CHAR: ${MROOT}${pathto}"
1147   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1148   done < ${MROOT}${INSTALLDB}/${pfull}/.char   done < ${MROOT}${INSTALLDB}/${pfull}/.char
1149    
# Line 962  remove_characterdevices() Line 1153  remove_characterdevices()
1153    
1154    
1155  ###################################################  ###################################################
1156    # function remove_fifos                           #
1157    # remove_fifos $PKGNAME                     #
1158    ###################################################
1159    remove_fifos()
1160    {
1161     local pathto
1162     local posix
1163     local user
1164     local group
1165     local IFS
1166     local pcat
1167     local pname
1168     local pver
1169     local pbuild
1170     local i
1171     local pfull
1172    
1173     IFS=$'\n'
1174    
1175     # very basic getops
1176     for i in $*
1177     do
1178     case $1 in
1179     --pcat|-c) shift; pcat="$1" ;;
1180     --pname|-n) shift; pname="$1" ;;
1181     --pver|-v) shift; pver="$1" ;;
1182     --pbuild|-b) shift; pbuild="$1" ;;
1183     esac
1184     shift
1185     done
1186    
1187     # sanity checks; abort if not given
1188     [ -z "${pcat}" ] && die "remove_fifos() \$pcat not given."
1189     [ -z "${pname}" ] && die "remove_fifos() \$pname not given."
1190     [ -z "${pver}" ] && die "remove_fifos() \$pver not given."
1191     [ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given."
1192     pfull="${pcat}/${pname}-${pver}-${pbuild}"
1193    
1194     # check needed global vars
1195     [ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set."
1196    
1197     # make it optional atm !!
1198     #[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found"
1199     [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return
1200    
1201     # sets fieldseperator to "§" instead of " "
1202     IFS=§
1203    
1204     while read pathto posix user group
1205     do
1206     [ -z "${pathto}" ] && continue
1207    
1208     mqueryfeature "verbose" && echo -e "\t<<< FIFO: ${MROOT}${pathto}"
1209     rm "${MROOT}${pathto}"
1210     done < ${MROOT}${INSTALLDB}/${pfull}/.fifo
1211    
1212     # very important: unsetting the '§' fieldseperator
1213     IFS=$'\n'
1214    }
1215    
1216    
1217    ###################################################
1218  # function remove_direcories                      #  # function remove_direcories                      #
1219  # remove_direcories $PKGNAME                #  # remove_direcories $PKGNAME                #
1220  ###################################################  ###################################################
# Line 992  remove_directories() Line 1245  remove_directories()
1245   done   done
1246    
1247   # sanity checks; abort if not given   # sanity checks; abort if not given
1248   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_directories() \$pcat not given."
1249   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_directories() \$pname not given."
1250   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_directories() \$pver not given."
1251   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given."
1252   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1253    
1254   # check needed global vars   # check needed global vars
# Line 1013  remove_directories() Line 1266  remove_directories()
1266    
1267   if [ ! -d "${MROOT}${pathto}" ]   if [ ! -d "${MROOT}${pathto}" ]
1268   then   then
1269   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1270   echo -e "${COLRED}! exist${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1271   continue   continue
1272   fi   fi
# Line 1021  remove_directories() Line 1274  remove_directories()
1274   # exclude .keep directories   # exclude .keep directories
1275   if [ -f "${MROOT}${pathto}/.keep" ]   if [ -f "${MROOT}${pathto}/.keep" ]
1276   then   then
1277   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1278   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1279   continue   continue
1280   fi   fi
# Line 1034  remove_directories() Line 1287  remove_directories()
1287    
1288   if rmdir "${MROOT}${pathto}" &> /dev/null   if rmdir "${MROOT}${pathto}" &> /dev/null
1289   then   then
1290   [[ ${VERBOSE} = on ]] && echo -e "\t<<< DIR:  ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< DIR:  ${MROOT}${pathto}"
1291   else   else
1292   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1293   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1294   fi   fi
1295   done   done
# Line 1049  remove_directories() Line 1302  remove_directories()
1302  ###################################################  ###################################################
1303  # function build_douninstall                      #  # function build_douninstall                      #
1304  # build_douninstall $PKGNAME                #  # build_douninstall $PKGNAME                #
1305  # NOTE: this is an wrapper do remove packages     #  # NOTE: this is an wrapper to remove packages     #
1306  ###################################################  ###################################################
1307  build_douninstall()  build_douninstall()
1308  {  {
# Line 1083  build_douninstall() Line 1336  build_douninstall()
1336   # !! we use § as field seperator !!   # !! we use § as field seperator !!
1337   # doing so prevent us to get errors by filenames with spaces   # doing so prevent us to get errors by filenames with spaces
1338    
1339   for i in symlinks files blockdevices characterdevices directories   for i in symlinks files blockdevices characterdevices directories fifos
1340   do   do
1341   remove_${i} \   remove_${i} \
1342   --pcat "${pcat}" \   --pcat "${pcat}" \
# Line 1094  build_douninstall() Line 1347  build_douninstall()
1347   done   done
1348  }  }
1349    
1350    # convertmirrors [uri]
1351    convertmirrors()
1352    {
1353     local uri="$1"
1354     local scheme
1355     local mirror
1356     local mirrors
1357     local addon
1358     local real_uri
1359     local output
1360    
1361     # needs
1362     [[ -z ${MIRRORS} ]] && die "convertmirrors(): no mirrors defined!"
1363     [[ -z ${SOURCEFORGE_MIRRORS} ]] && die "convertmirrors(): no sourceforge mirrors defined!"
1364     [[ -z ${GNU_MIRRORS} ]] && die "convertmirrors(): no gnu mirrors defined!"
1365     [[ -z ${GNOME_MIRRORS} ]] && die "convertmirrors(): no gnome mirrors defined!"
1366     [[ -z ${KDE_MIRRORS} ]] && die "convertmirrors(): no kde mirrors defined!"
1367    
1368     # check known uri schemes
1369     case ${uri} in
1370     http://*|https://*|ftp://*|ftps://*) mirrors="" ;;
1371     mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;;
1372     package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;;
1373     gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;;
1374     sourceforge://*) mirrors="${SOURCEFORGE_MIRRORS}"; scheme="sourceforge://" ;;
1375     gnome://*) mirrors="${GNOME_MIRRORS}"; scheme="gnome://" ;;
1376     kde://*) mirrors="${KDE_MIRRORS}"; scheme="kde://" ;;
1377     *) die "convertmirror(): unsupported uri scheme in '${uri}'!" ;;
1378     esac
1379    
1380     if [[ ! -z ${mirrors} ]]
1381     then
1382     for mirror in ${mirrors}
1383     do
1384     # add a whitespace to the output
1385     [[ -z ${output} ]] || output+=" "
1386     output+="${mirror}${addon}/${uri/${scheme}/}"
1387     done
1388     else
1389     output="${uri}"
1390     fi
1391    
1392     echo "${output}"
1393    }
1394    
1395    mdownload()
1396    {
1397     local i
1398     local uri
1399     local real_uris
1400     local mirror
1401     local outputfile
1402     local outputdir
1403     local retval
1404     local wget_opts
1405    
1406     # very basic getops
1407     for i in $*
1408     do
1409     case $1 in
1410     --uri|-u) shift; uri="$1" ;;
1411     --dir|-d) shift; outputdir="$1" ;;
1412     esac
1413     shift
1414     done
1415    
1416     # sanity checks; abort if not given
1417     [[ -z ${uri} ]] && die "mdownload(): no uri given!"
1418     [[ -z ${outputdir} ]] && die "mdownload(): no dir given!"
1419    
1420     # convert mirrored uris to the real ones
1421     real_uris="$(convertmirrors ${uri})"
1422    
1423     # verbose or not
1424     mqueryfeature "!verbose" && wget_opts+=" --quiet"
1425    
1426     # filter wget options if busybox was found
1427     wget_opts+=" $(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1428    
1429     # create outputdir
1430     [[ ! -d ${outputdir} ]] && install -d "${outputdir}"
1431    
1432     for mirror in ${real_uris}
1433     do
1434     # get the name of the output file
1435     outputfile="${mirror##*/}"
1436    
1437     wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}"
1438     retval="$?"
1439     if [[ ${retval} = 0 ]]
1440     then
1441     break
1442     else
1443     continue
1444     fi
1445     done
1446    
1447     # return wget retval
1448     return "${retval}"
1449    }
1450    
1451  # fetch_packages /path/to/mage/file1 /path/to/mage/file2  # fetch_packages /path/to/mage/file1 /path/to/mage/file2
1452  fetch_packages()  fetch_packages()
1453  {  {
1454     local i
1455   local list="$@"   local list="$@"
1456   local pkg   local pkg
1457   local mirr   local mirr
# Line 1105  fetch_packages() Line 1460  fetch_packages()
1460   local opt   local opt
1461   local count_current   local count_current
1462   local count_total   local count_total
1463     local wget_opts
1464    
1465   [ -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}."
1466    
1467     # filter wget command if busybox was found
1468     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1469    
1470   # get count of total packages   # get count of total packages
1471   declare -i count_current=0   declare -i count_current=0
# Line 1146  fetch_packages() Line 1505  fetch_packages()
1505   continue   continue
1506   fi   fi
1507    
1508   for mirr in ${MIRRORS}   echo -ne " ${COLBLUE}***${COLDEFAULT}"
1509   do   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1510   echo -ne " ${COLBLUE}***${COLDEFAULT}"   mdownload --uri "package://${pkg}" --dir "${PKGDIR}" || die "Could not download ${pkg}"
  #echo -e " fetching (${count_current}/${count_total}): ${mirr}/${pkg} ... "  
  echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "  
  [[ ${VERBOSE} = off ]] && opt="--quiet"  
  wget \  
  --passive-ftp \  
  --tries 3 \  
  --continue \  
  --progress bar \  
  --directory-prefix=${PKGDIR} \  
  ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}  
  if [[ $? = 0 ]]  
  then  
  break  
  else  
  continue  
  fi  
  done  
   
1511   if [ ! -f ${PKGDIR}/${pkg} ]   if [ ! -f ${PKGDIR}/${pkg} ]
1512   then   then
1513   die "Could not download ${pkg}"   die "Package '${pkg}' after download not found in '${PKGDIR}'"
1514   fi   fi
1515   done   done
1516    
# Line 1181  syncmage() Line 1522  syncmage()
1522  {  {
1523   if [ -z "${RSYNC}" ]   if [ -z "${RSYNC}" ]
1524   then   then
1525   die "You have no rsync-mirrors defined. Please edit your /etc/mage.rc."   die "You have no rsync-mirrors defined. Please edit your ${MAGERC}."
1526   fi   fi
1527    
1528   local i   local i
1529   for i in ${RSYNC}   for i in ${RSYNC}
1530   do   do
1531   rsync \   rsync ${RSYNC_FETCH_OPTIONS} ${i} ${MAGEDIR}
  --recursive \  
  --links \  
  --perms \  
  --times \  
  --devices \  
  --timeout=600 \  
  --verbose \  
  --compress \  
  --progress \  
  --stats \  
  --delete \  
  --delete-after \  
  ${i} ${MAGEDIR}  
1532   if [[ $? = 0 ]]   if [[ $? = 0 ]]
1533   then   then
1534   break   break
# Line 1210  syncmage() Line 1538  syncmage()
1538   done   done
1539    
1540   # clean up backup files (foo~)   # clean up backup files (foo~)
1541   find ${MAGEDIR} -name *~ -exec rm '{}' ';'   find ${MAGEDIR} -name \*~ -exec rm '{}' ';'
1542    
1543   # check if an newer mage version is available   # check if a newer mage version is available
1544   is_newer_mage_version_available   is_newer_mage_version_available
1545  }  }
1546    
1547    syncmage_tarball()
1548    {
1549     local latest_tarball
1550     local latest_md5
1551     local temp="$(mktemp -d)"
1552     local mirr mymirr
1553     local opt
1554     local tar_opts
1555     local wget_opts
1556    
1557     # try to get the md5 marked as latest on the server
1558     latest_md5="mage-latest.md5"
1559    
1560     # try to get the tarball marked as latest on the server
1561     latest_tarball="mage-latest.tar.bz2"
1562    
1563     # filter wget command if busybox was found
1564     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1565    
1566     for mirr in ${MIRRORS}
1567     do
1568     # path without distribution
1569     # (only for stable|testing|unstable and not DISTROTAG)
1570     case ${mirr##*/} in
1571     stable|testing|unstable) mymirr="${mirr%/*}";;
1572     *) mymirr="${mirr}";;
1573     esac
1574    
1575     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1576     echo "fetching latest md5 from ${mymirr} ..."
1577     mqueryfeature "!verbose" && opt="--quiet"
1578     wget \
1579     ${wget_opts} \
1580     --directory-prefix=${temp} \
1581     ${opt} ${mymirr}/rsync/tarballs/${latest_md5}
1582    
1583     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1584     echo "fetching latest tarball from ${mymirr} ..."
1585     wget \
1586     ${wget_opts} \
1587     --directory-prefix=${temp} \
1588     ${opt} ${mymirr}/rsync/tarballs/${latest_tarball}
1589     if [[ $? = 0 ]]
1590     then
1591     break
1592     else
1593     continue
1594     fi
1595     done
1596    
1597     if [[ -f ${temp}/${latest_tarball} ]]
1598     then
1599     # check md5
1600     if [[ ! -f ${temp}/${latest_md5} ]]
1601     then
1602     die "md5 is missing ... aborting"
1603     else
1604     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1605     echo -n "checking md5sum... "
1606     mchecksum --rundir "${temp}" --file "${latest_md5}" --method md5 || die "md5 for ${latest_tarball} failed"
1607     fi
1608    
1609     if [[ -d ${MAGEDIR} ]]
1610     then
1611     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1612     echo "cleaning old mage-tree ${MAGEDIR}..."
1613     # honor mountpoints and empty dirs
1614     if mountpoint -q ${MAGEDIR}
1615     then
1616     if ! mcheckemptydir ${MAGEDIR}
1617     then
1618     find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xarg --no-run-if-empty rm -r
1619     fi
1620     else
1621     rm -rf ${MAGEDIR}
1622     fi
1623     fi
1624    
1625     if need_busybox_support tar
1626     then
1627     tar_opts="xjf"
1628     else
1629     tar_opts="xjmf"
1630     fi
1631    
1632     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1633     echo "updating mage-tree from tarball ..."
1634     # unpack in dirname of MAGEDIR, as the tarball has already the mage
1635     tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1636    
1637     if [[ -d ${temp} ]]
1638     then
1639     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1640     echo "cleaning temp-files ..."
1641     rm -rf ${temp}
1642     fi
1643    
1644     # check if a newer mage version is available
1645     is_newer_mage_version_available
1646     else
1647     die "Could not fetch the latest tarball ... aborting"
1648     fi
1649    }
1650    
1651  cleanpkg()  cleanpkg()
1652  {  {
1653   if [ -d "${PKGDIR}" ]   if [ -d "${PKGDIR}" ]
# Line 1246  xtitleclean() Line 1678  xtitleclean()
1678  }  }
1679    
1680    
1681  # cuts full pathnames or versioniezed names down to basename  # unused?
1682  choppkgname()  #
1683  {  # # cuts full pathnames or versionized names down to basename
1684   #we want this only if full name was used  # choppkgname()
1685   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]  # {
1686   then  # #we want this only if full name was used
1687   #cuts ARCH and PBUILD  # if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]
1688   #ARCH comes from /etc/mage.rc  # then
1689   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")  # #cuts ARCH and PBUILD
1690    # #ARCH comes from ${MAGERC}
1691    # MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}$(print_distrotag)-r*.::g")
1692    #
1693    # #cuts version number
1694    # MAGENAME=$(basename ${MAGENAME%-*} .mage)
1695    # fi
1696    # }
1697    
  #cuts version number  
  MAGENAME=$(basename ${MAGENAME%-*} .mage)  
  fi  
 }  
1698    
1699  # get_categorie $PNAME, returns CATEGORIE  # get_categorie $PNAME, returns CATEGORIE
1700  # $1=pname  # $1=pname
# Line 1328  get_highest_magefile() Line 1763  get_highest_magefile()
1763   local PNAME="$2"   local PNAME="$2"
1764   local magefile   local magefile
1765    
1766   for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*)   # do not list the content of a directory, only the name (-d)
1767     for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/* 2> /dev/null)
1768   do   do
1769     [[ -z ${magefile} ]] && continue
1770   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
1771   [ -d ${magefile} ] && continue   [[ -d ${magefile} ]] && continue
1772   if check_stable_package ${magefile}   if check_stable_package ${magefile}
1773   then   then
1774   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
1775   #for debug only   #for debug only
1776   [[ ${MAGEDEBUG} = on ]] && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"   mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"
1777   fi   fi
1778   done   done
1779    
 # do not so anything  
 # # stop here if HIGHEST_MAGEFILE is zero  
 # # this package must be unstable or old  
 # if [ -z "${HIGHEST_MAGEFILE}" ]  
 # then  
 # echo  
 # echo -n "All packages named "  
 # echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT}  
 # echo -n " are marked "  
 # echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT}  
 # echo "."  
 # echo "You need to declare USE_UNSTABLE=true to install this."  
 # echo  
 # echo "Example:"  
 # echo "         USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}"  
 # echo  
 # echo "Be warned that these packages are not stable and may cause serious problems."  
 # echo "You should know what you are doing, so don't complain about any damage."  
 # echo  
 # return 1  
 # fi  
   
1780   echo "${HIGHEST_MAGEFILE}"   echo "${HIGHEST_MAGEFILE}"
1781   return 0   return 0
1782  }  }
# Line 1376  get_highest_magefile() Line 1791  get_highest_magefile()
1791  #        1 - error                                #  #        1 - error                                #
1792  #        2 - protected                            #  #        2 - protected                            #
1793  #        3 - protected but masked                 #  #        3 - protected but masked                 #
1794    #        4 - protected but ignored                #
1795  #                                                 #  #                                                 #
1796  ###################################################  ###################################################
1797  is_config_protected()  is_config_protected()
# Line 1384  is_config_protected() Line 1800  is_config_protected()
1800   local TEST   local TEST
1801   local PROTECTED   local PROTECTED
1802   local IFS   local IFS
1803     local i
1804     local x
1805    
1806   EXPFILE="${MROOT}$1"   EXPFILE="${MROOT}$1"
1807    
1808   # file does not exist; it can be written   # file does not exist; it can be written
1809   [ ! -e ${EXPFILE} ] && return 0   [[ ! -e ${EXPFILE} ]] && return 0
1810    
1811   # to be safe; it may be '§'   # to be safe; it may be '§'
1812   IFS=' '   IFS=' '
1813    
1814   # check ob in config protect   # check if config protected
1815   for i in ${CONFIG_PROTECT}   for i in ${CONFIG_PROTECT}
1816   do   do
1817   # ersetzen von $i nur wenn am anfang der variable   # only replace $i in the beginning of the variable
1818   TEST="${EXPFILE/#${MROOT}${i}/Protected}"   TEST="${EXPFILE/#${MROOT}${i}/Protected}"
1819   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1820   then   then
1821   # setzen das es protected ist   # file is config proteced
1822   PROTECTED=TRUE   PROTECTED=TRUE
1823    
1824   # check ob nicht doch maskiert   # check if not masked
1825   for x in ${CONFIG_PROTECT_MASK}   for x in ${CONFIG_PROTECT_MASK}
1826   do   do
1827   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"
1828   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1829   then   then
1830   PROTECTED=MASKED   PROTECTED=MASKED
1831   fi   fi
1832   done   done
1833    
1834     # check if not ignored
1835     for x in ${CONFIG_PROTECT_IGNORE}
1836     do
1837     TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}"
1838     if [[ ${TEST} != ${EXPFILE} ]]
1839     then
1840     PROTECTED=IGNORED
1841     fi
1842     done
1843   fi   fi
1844   done   done
1845    
# Line 1426  is_config_protected() Line 1854  is_config_protected()
1854   #echo "I'm protected, but masked - delete me"   #echo "I'm protected, but masked - delete me"
1855   return 3   return 3
1856   ;;   ;;
1857     IGNORED)
1858     #echo "I'm protected, but ignored - keep me, del update"
1859     return 4
1860     ;;
1861   *)   *)
1862   #echo "delete me"   #echo "delete me"
1863   return 0   return 0
# Line 1443  is_config_protected() Line 1875  is_config_protected()
1875  ###################################################  ###################################################
1876  count_protected_files()  count_protected_files()
1877  {  {
1878   ${MLIBDIR}/writeprotected "$1"   local file="$1"
1879     local dirname="${file%/*}"
1880     local filename="${file##*/}"
1881     local count
1882     local output
1883     local i
1884    
1885     declare -i count=0
1886    
1887     # check if there are already protected files
1888     for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" |
1889     sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
1890     sort -t'%' -k3 -k2 | cut -f1 -d'%')
1891     do
1892     count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::")
1893     done
1894     (( count ++ ))
1895    
1896     # fill output up with zeros
1897     for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
1898     output="${output}${count}"
1899    
1900     echo "${output}"
1901  }  }
1902    
1903  # call with  # call with
# Line 1460  get_uninstall_candidates() Line 1914  get_uninstall_candidates()
1914   local list   local list
1915   local pcatdir   local pcatdir
1916   local protected   local protected
1917     local i
1918    
1919   # very basic getops   # very basic getops
1920   for i in $*   for i in $*
# Line 1614  virtuals_add() Line 2069  virtuals_add()
2069    
2070  #deletes pakages from virtual database  #deletes pakages from virtual database
2071  #$1 virtualname; $2 pkgname  #$1 virtualname; $2 pkgname
2072  virtuals_del() {  virtuals_del()
2073    {
2074    
2075   local virtualname="$1"   local virtualname="$1"
2076   local pkgname="$2"   local pkgname="$2"
# Line 1721  minclude() Line 2177  minclude()
2177  {  {
2178   local i   local i
2179    
2180   if [ -n "$@" ]   if [[ -n $* ]]
2181   then   then
2182   for i in $@   for i in $*
2183   do   do
2184   [[ ${MAGEDEBUG} = on ]] && \   mqueryfeature "debug" && \
2185   echo "--- Including ${MAGEDIR}/include/${i}.minc"   echo "--- Including ${MAGEDIR}/include/${i}.minc"
2186   source ${MAGEDIR}/include/${i}.minc   source ${MAGEDIR}/include/${i}.minc
2187   done   done
2188   [[ ${MAGEDEBUG} = on ]] && echo   mqueryfeature "debug" && echo
2189   fi   fi
2190  }  }
2191    
# Line 1737  sminclude() Line 2193  sminclude()
2193  {  {
2194   local i   local i
2195    
2196   if [ -n "$@" ]   if [[ -n $* ]]
2197   then   then
2198   for i in $@   for i in $*
2199   do   do
2200   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
2201   source ${SMAGESCRIPTSDIR}/include/${i}.sminc   source ${SMAGESCRIPTSDIR}/include/${i}.sminc
# Line 2048  get_value_from_magefile() Line 2504  get_value_from_magefile()
2504   local SDEPEND   local SDEPEND
2505   local PROVIDE   local PROVIDE
2506   local PKGTYPE   local PKGTYPE
2507     local MAGE_TARGETS
2508     local SPLIT_PACKAGE_BASE
2509   local preinstall   local preinstall
2510   local postinstall   local postinstall
2511   local preremove   local preremove
# Line 2094  mage_install() Line 2552  mage_install()
2552   local count_current   local count_current
2553   local magefile   local magefile
2554   local src_install   local src_install
2555     local i
2556    
2557   # very basic getops   # very basic getops
2558   for i in $*   for i in $*
# Line 2167  mage_install() Line 2626  mage_install()
2626   echo B:${pbuild}   echo B:${pbuild}
2627   fi   fi
2628    
2629   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2   if [[ -n ${MAGE_TARGETS} ]]
2630     then
2631     # basic svn compat
2632     if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2633     then
2634     for i in ${SMAGESCRIPTSDIR}/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2635     do
2636     smage2file="${i}"
2637     done
2638     else
2639     smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2640     fi
2641    
2642     elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2643     then
2644     # basic svn compat
2645     if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2646     then
2647     for i in ${SMAGESCRIPTSDIR}/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2648     do
2649     smage2file="${i}"
2650     done
2651     else
2652     smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2653     fi
2654    
2655     else
2656     # basic svn compat
2657     if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2658     then
2659     for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2660     do
2661     smage2file="${i}"
2662     done
2663     else
2664     smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2
2665     fi
2666     fi
2667    
2668   if [ -f "${smage2file}" ]   if [ -f "${smage2file}" ]
2669   then   then
2670     echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "
2671   smage2 ${smage2file} || die "compile failed"   smage2 ${smage2file} || die "compile failed"
2672   else   else
2673   echo   echo
# Line 2183  mage_install() Line 2681  mage_install()
2681   if [[ ${PKGTYPE} != virtual ]] && \   if [[ ${PKGTYPE} != virtual ]] && \
2682   [[ ${PKGTYPE} != sources ]]   [[ ${PKGTYPE} != sources ]]
2683   then   then
2684   # 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  
2685   build_doinstall ${PKGNAME}   build_doinstall ${PKGNAME}
2686   fi   fi
2687    
# Line 2304  md5sum_packages() Line 2795  md5sum_packages()
2795   then   then
2796   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2797   echo -ne "checking md5sum (${count_current}/${count_total}): "   echo -ne "checking md5sum (${count_current}/${count_total}): "
2798   ( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed"   mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 || die "md5 for ${pkgfile} failed"
2799   else   else
2800   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2801   echo -e "!! no md5sum file found for ${pkgfile} :("   echo -e "!! no md5sum file found for ${pkgfile} :("
# Line 2447  mage_uninstall() Line 2938  mage_uninstall()
2938   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"
2939   echo -n "removing: "   echo -n "removing: "
2940   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2941   echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"   echo -e "${COLRED}${pname}-${pver}-${pbuild}${COLDEFAULT}"
2942    
2943   magefile="${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"   magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
2944   source ${magefile}   source ${magefile}
2945    
2946   ## preremove scripts   ## preremove scripts
# Line 2517  mage_uninstall() Line 3008  mage_uninstall()
3008   unset -f postremove   unset -f postremove
3009  }  }
3010    
3011  show_etc_update_mesg() {  show_etc_update_mesg()
3012    {
3013   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0
3014    
3015   echo   echo
# Line 2543  pkgsearch() Line 3035  pkgsearch()
3035   local state   local state
3036   local descriptiom   local descriptiom
3037   local homepage   local homepage
3038     local license
3039   local i   local i
3040   local all_installed   local all_installed
3041   local ipver   local ipver
3042   local ipbuild   local ipbuild
3043     local latest_available
3044     local depsfull
3045     local sdepsfull
3046     local deps
3047     local sdeps
3048     local dep
3049     local sign
3050    
3051   # only names no versions   # only names no versions
3052   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')"
3053   #result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)"   #result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)"
3054    
3055   # nothing found   # nothing found
# Line 2564  pkgsearch() Line 3064  pkgsearch()
3064   # get highest version available   # get highest version available
3065   magefile=$(get_highest_magefile ${pcat} ${pname})   magefile=$(get_highest_magefile ${pcat} ${pname})
3066    
3067   # now get all needed infos to print a nice output   if [[ ! -z ${magefile} ]]
3068   pver="$(magename2pver ${magefile})"   then
3069   pbuild="$(magename2pbuild ${magefile})"   # now get all needed infos to print a nice output
3070   state="$(get_value_from_magefile STATE ${magefile})"   pver="$(magename2pver ${magefile})"
3071   description="$(get_value_from_magefile DESCRIPTION ${magefile})"   pbuild="$(magename2pbuild ${magefile})"
3072   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"   state="$(get_value_from_magefile STATE ${magefile})"
3073     description="$(get_value_from_magefile DESCRIPTION ${magefile})"
3074     homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
3075     license="$(get_value_from_magefile LICENSE ${magefile})"
3076    
3077   # all installed   # all installed
3078   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
3079   do   do
3080   ipver="$(magename2pver ${i})"   ipver="$(magename2pver ${i})"
3081   ipbuild="$(magename2pbuild ${i})"   ipbuild="$(magename2pbuild ${i})"
3082    
3083   if [[ -z ${all_installed} ]]   if [[ -z ${all_installed} ]]
3084   then   then
3085   all_installed="${ipver}-${ipbuild}"   all_installed="${ipver}-${ipbuild}"
3086   else   else
3087   all_installed="${all_installed} ${ipver}-${ipbuild}"   all_installed="${all_installed} ${ipver}-${ipbuild}"
3088   fi   fi
3089   done   done
3090   [[ -z ${all_installed} ]] && all_installed="none"   [[ -z ${all_installed} ]] && all_installed="none"
3091    
3092   case ${state} in   case ${state} in
3093   stable) state=${COLGREEN}"[s] ";;   stable) state=${COLGREEN}"[s] ";;
3094   testing) state=${COLYELLOW}"[t] ";;   testing) state=${COLYELLOW}"[t] ";;
3095   unstable) state=${COLRED}"[u] ";;   unstable) state=${COLRED}"[u] ";;
3096   old) state=${COLGRAY}"[o] ";;   old) state=${COLGRAY}"[o] ";;
3097   esac   esac
3098    
3099     latest_available="${pver}-${pbuild}"
3100     else
3101     # package is masked
3102     state="${COLRED}[m] "
3103     latest_available="${COLRED}masked for this distribution.${COLDEFAULT}"
3104     fi
3105    
3106     depsfull="$(get_value_from_magefile DEPEND ${magefile})"
3107     sdepsfull="$(get_value_from_magefile SDEPEND ${magefile})"
3108    
3109     while read sign dep
3110     do
3111     case ${dep} in
3112     "") continue;;
3113     esac
3114    
3115     deps="${deps} $(basename ${dep%-*})"
3116     done << EOF
3117    ${depsfull}
3118    EOF
3119    
3120     while read sign dep
3121     do
3122     case ${dep} in
3123     "") continue;;
3124     esac
3125    
3126     sdeps="${sdeps} $(basename ${dep%-*})"
3127     done << EOF
3128    ${sdepsfull}
3129    EOF
3130    
3131   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}
3132   echo "      Latest available:   ${pver}-${pbuild}"   echo -e "      Latest available:   ${latest_available}"
3133   echo "      Installed versions: ${all_installed}"   echo "      Installed versions: ${all_installed}"
3134   echo "      Description: ${description}"   echo "      Description: ${description}"
3135   echo "      Homepage: ${homepage}"   echo "      Homepage: ${homepage}"
3136     if [[ ! -z ${license} ]]
3137     then
3138     echo "      License:  ${license}"
3139     fi
3140     echo "      Depends: ${deps}"
3141     echo "      SDepends: ${sdeps}"
3142   echo   echo
3143    
3144   unset pcat   unset pcat
# Line 2611  pkgsearch() Line 3152  pkgsearch()
3152   unset all_installed   unset all_installed
3153   unset ipver   unset ipver
3154   unset ipbuild   unset ipbuild
3155     unset depsfull
3156     unset sdepsfull
3157     unset deps
3158     unset sdeps
3159     unset dep
3160     unset sign
3161   done   done
3162  }  }
3163    
# Line 2630  export_inherits() Line 3177  export_inherits()
3177   eval "${functions}() { ${include}_${functions} ; }"   eval "${functions}() { ${include}_${functions} ; }"
3178    
3179   # debug   # debug
3180   [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"   mqueryfeature "debug" && typeset -f "${functions}"
3181    
3182   shift   shift
3183   done   done
# Line 2653  blacklisted() Line 3200  blacklisted()
3200   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable
3201   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing
3202    
3203   local EXCLUDED="${MROOT}/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"   # support both types for the moment
3204     if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]]
3205     then
3206     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"
3207     else
3208     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}"
3209     fi
3210    
3211   # return 0 if the list not exist; nothin is masked   # return 0 if the list not exist; nothin is masked
3212   [[ ! -f ${EXCLUDED} ]] && return 0   [[ ! -f ${EXCLUDED} ]] && return 0
# Line 2696  EOF Line 3249  EOF
3249   return 0   return 0
3250  }  }
3251    
3252    # need_busybox_support ${cmd}
3253    # return 0 (no error = needs busybox support) or return 1 (error = no busybox support required)
3254    need_busybox_support()
3255    {
3256     local cmd
3257     cmd="$1"
3258    
3259     if [[ -x /bin/busybox ]]
3260     then
3261     if [[ $(readlink $(which ${cmd})) = /bin/busybox ]]
3262     then
3263     # needs busybox support
3264     return 0
3265     fi
3266     fi
3267    
3268     # no busybox
3269     return 1
3270    }
3271    
3272    # busybox_filter_wget_options ${wget_opts}
3273    busybox_filter_wget_options()
3274    {
3275     local opts="$@"
3276     local i
3277     local fixed_opts
3278    
3279     if need_busybox_support wget
3280     then
3281     for i in ${opts}
3282     do
3283     # show only the allowed ones
3284     case ${i} in
3285     -c|--continue) fixed_opts+=" -c" ;;
3286     -s|--spider) fixed_opts+=" -s" ;;
3287     -q|--quiet) fixed_opts+=" -q" ;;
3288     -O|--output-document) shift; fixed_opts+=" -O $1" ;;
3289     --header) shift; fixed_opts+=" --header $1" ;;
3290     -Y|--proxy) shift; fixed_opts+=" -Y $1" ;;
3291     -P) shift; fixed_opts+=" -P $1" ;;
3292     --no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;;
3293     -U|--user-agent) shift; fixed_opts+=" -U ${i}" ;;
3294     # simply drop all other opts
3295     *) continue ;;
3296     esac
3297     done
3298    
3299     echo "${fixed_opts}"
3300     else
3301     echo "${opts}"
3302     fi
3303    }
3304    
3305    have_root_privileges()
3306    {
3307     local retval
3308    
3309     if [[ $(id -u) = 0 ]]
3310     then
3311     retval=0
3312     else
3313     retval=1
3314     fi
3315    
3316     return ${retval}
3317    }
3318    
3319    known_mage_feature()
3320    {
3321     local feature="$1"
3322     local retval
3323    
3324     case "${feature}" in
3325     autosvc|!autosvc) retval=0 ;;
3326     buildlog|!buildlog) retval=0 ;;
3327     ccache|!ccache) retval=0 ;;
3328     check|!check) retval=0 ;;
3329     compressdoc|!compressdoc) retval=0 ;;
3330     debug|!debug) retval=0 ;;
3331     distcc|!distcc) retval=0 ;;
3332     kernelsrcunpack|!kernelsrcunpack) retval=0 ;;
3333     libtool|!libtool) retval=0 ;;
3334     linuxsymlink|!linuxsymlink) retval=0 ;;
3335     pkgbuild|!pkgbuild) retval=0 ;;
3336     pkgdistrotag|!pkgdistrotag) retval=0 ;;
3337     purge|!purge) retval=0 ;;
3338     qalint|!qalint) retval=0 ;;
3339     regentree|!regentree) retval=0 ;;
3340     resume|!resume) retval=0 ;;
3341     srcpkgbuild|!srcpkgbuild) retval=0 ;;
3342     srcpkgtarball|!srcpkgtarball) retval=0 ;;
3343     static|!static) retval=0 ;;
3344     stepbystep|!stepbystep) retval=0 ;;
3345     strip|!strip) retval=0 ;;
3346     verbose|!verbose) retval=0 ;;
3347     *) retval=1 ;;
3348     esac
3349    
3350     return "${retval}"
3351    }
3352    
3353    load_mage_features()
3354    {
3355     for i in ${MAGE_FEATURES_GLOBAL[*]} ${MAGE_FEATURES[*]}
3356     do
3357     FVERBOSE=off msetfeature ${i}
3358     done
3359    }
3360    
3361    msetfeature()
3362    {
3363     local feature
3364     local count
3365     local i
3366     local found
3367    
3368     for feature in $@
3369     do
3370     found=0
3371     count="${#MAGE_FEATURES_CURRENT[*]}"
3372    
3373     if ! known_mage_feature "${feature}"
3374     then
3375     [[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}"
3376     return 3
3377     fi
3378    
3379     for ((i=0; i<count; i++))
3380     do
3381     if [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature} ]]
3382     then
3383     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' already enabled${COLDEFAULT}"
3384     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3385     found=1
3386     elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = !${feature} ]]
3387     then
3388     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' currently disabled, enabling it!${COLDEFAULT}"
3389     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3390     found=1
3391     elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature//!} ]]
3392     then
3393     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature//!}' currently enabled, disabling it!${COLDEFAULT}"
3394     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3395     found=1
3396     fi
3397     done
3398    
3399     # if the feature was not found after proccessing the whole array
3400     # it was not declared. in this case enable it
3401     if [[ ${found} = 0 ]]
3402     then
3403     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' was not declared, enabling it!${COLDEFAULT}"
3404     MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )
3405     fi
3406    
3407     export MAGE_FEATURE_CURRENT
3408     done
3409    }
3410    
3411    mqueryfeature()
3412    {
3413     local feature="$1"
3414     local retval=1
3415     local i
3416    
3417     if known_mage_feature "${feature}"
3418     then
3419     for i in ${MAGE_FEATURES_CURRENT[*]}
3420     do
3421     if [[ ${i} = ${feature} ]]
3422     then
3423     retval=0
3424     break # found break here
3425     fi
3426     done
3427     else
3428     [[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}"
3429     retval=3
3430     fi
3431    
3432     return ${retval}
3433    }
3434    
3435    mprintfeatures()
3436    {
3437     echo "Global features:  ${MAGE_FEATURES_GLOBAL[*]}"
3438     echo "Local features:   ${MAGE_FEATURES[*]}"
3439     echo "Current features: ${MAGE_FEATURES_CURRENT[*]}"
3440    }

Legend:
Removed from v.373  
changed lines
  Added in v.1675