Magellan Linux

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

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

revision 501 by niro, Sat Jun 30 15:38:50 2007 UTC revision 2225 by niro, Wed Oct 16 07:49:19 2013 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.33 2007-06-30 15:38:50 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     local sum
50     local dest
51    
52     # very basic getops
53     for i in $*
54     do
55     case $1 in
56     --rundir|-r) shift; rundir="$1" ;;
57     --file|-f) shift; file="$1" ;;
58     --method|-m) shift; method="$1" ;;
59     esac
60     shift
61     done
62    
63     # sanity checks
64     [[ -z ${rundir} ]] && die "mchecksum(): rundir missing"
65     [[ -z ${file} ]] && die "mchecksum(): file missing"
66     [[ -z ${method} ]] && die "mchecksum(): method missing"
67    
68     case ${method} in
69     md5) cmd="md5sum" ;;
70     sha256) cmd="sha256sum" ;;
71     *) die "mchecksum(): unknown method '${method}'" ;;
72     esac
73    
74     if [[ -d ${rundir} ]]
75     then
76     pushd ${rundir} &> /dev/null
77    
78     # all file must be non-zero
79     retval=0
80     while read sum dest
81     do
82     if [ -s ${dest} ]
83     then
84     echo "${dest}: file-size OK"
85     else
86     echo "${dest}: file is empty ;("
87     retval=127
88     fi
89     done < ${file}
90     if [[ ${retval} != 127 ]]
91     then
92     # insert an empty line for cosmetic
93     echo
94    
95     # be verbose here
96     ${cmd} -c ${file} #&> /dev/null
97     retval="$?"
98     fi
99    
100     popd &> /dev/null
101     else
102     retval=1
103     fi
104    
105     return "${retval}"
106    }
107    
108    mcheckemptydir()
109    {
110     local dir="$1"
111     local retval=1
112    
113     if [[ ! -d ${dir} ]]
114     then
115     echo "mcheckemptydir(): '${dir}' is not a directory!"
116     retval=3
117     else
118     shopt -s nullglob dotglob
119     files=( ${dir}/* )
120     (( ${#files[*]} )) || retval=0
121     shopt -u nullglob dotglob
122     fi
123    
124     return ${retval}
125    }
126    
127    unpack_package()
128    {
129     local magefile="$1"
130     local pkg
131     local pkgtype
132     local tar_opts
133    
134     pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}"
135     pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"
136    
137     xtitle "[ Unpacking ${pkg} ]"
138    
139     # abort on virtual pkg
140     if [[ ${pkgtype} = virtual ]]
141     then
142     echo -ne " ${COLBLUE}---${COLDEFAULT}"
143     echo " !unpack virtual ${pkg/.${PKGSUFFIX}/} ... "
144     continue
145     fi
146    
147     # abort on sources pkg
148     if [[ ${pkgtype} = sources ]]
149     then
150     echo -ne " ${COLBLUE}---${COLDEFAULT}"
151     echo " !unpack sources ${pkg/.${PKGSUFFIX}/} ... "
152     continue
153     fi
154    
155     # busybox?
156     if need_busybox_support tar
157     then
158     tar_opts="xjf"
159     else
160     tar_opts="xjmf"
161     fi
162    
163     echo -e " ${COLBLUE}***${COLDEFAULT} unpacking ${pkg} ... "
164     tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"
165    }
166    
167  unpack_packages()  unpack_packages()
168  {  {
169   local list="$@"   local list="$@"
170   local magefile   local magefile
  local pkg  
  local pkgtype  
171   local count_current   local count_current
172   local count_total   local count_total
173     local tar_opts
174    
175   # get count of total packages   # get count of total packages
176   declare -i count_current=0   declare -i count_current=0
# Line 32  unpack_packages() Line 180  unpack_packages()
180    
181   for magefile in ${list}   for magefile in ${list}
182   do   do
183   pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}"   unpack_package "${magefile}"
  pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"  
   
184   (( count_current++ ))   (( count_current++ ))
  xtitle "[ (${count_current}/${count_total}) Unpacking ${pkg} ]"  
   
  # abort on virtual pkg  
  if [[ ${pkgtype} = virtual ]]  
  then  
  echo -ne " ${COLBLUE}---${COLDEFAULT}"  
  echo " !unpack virtual (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... "  
  continue  
  fi  
   
  # abort on sources pkg  
  if [[ ${pkgtype} = sources ]]  
  then  
  echo -ne " ${COLBLUE}---${COLDEFAULT}"  
  echo " !unpack sources (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... "  
  continue  
  fi  
   
  echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "  
  tar xjmf ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"  
185   done   done
186    
187   # add a crlf for a better view   # add a crlf for a better view
# Line 75  fix_mtime() Line 201  fix_mtime()
201   mtime=$(stat -c %Y "${reference}")   mtime=$(stat -c %Y "${reference}")
202   touch \   touch \
203   --no-create \   --no-create \
204     --no-dereference \
205   --time=mtime \   --time=mtime \
206   --reference "${reference}" \   --reference="${reference}" \
207   "${pathto}"   "${pathto}"
208    
209   echo "${mtime}"   echo "${mtime}"
# Line 130  install_directories() Line 257  install_directories()
257   while read pathto posix user group   while read pathto posix user group
258   do   do
259   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
260   [[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR:  ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> DIR:  ${MROOT}${pathto}"
   
261    
262   # monitors /etc/env.d -> env-rebuild   # monitors /etc/env.d -> env-rebuild
263   [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true   [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true
# Line 198  install_files() Line 324  install_files()
324   is_config_protected "${pathto}"   is_config_protected "${pathto}"
325   retval="$?"   retval="$?"
326    
327   # 0 - not protected        #   # 0 - not protected         #
328   # 1 - error                #   # 1 - error                 #
329   # 2 - protected            #   # 2 - protected             #
330   # 3 - protected but masked #   # 3 - protected but masked  #
331     # 4 - protected but ignored #
332    
333   case ${retval} in   case ${retval} in
334   # file is not protected - (over)write it   # file is not protected - (over)write it
335   0|3)   0|3)
336   [[ ${VERBOSE} = on ]] && echo -e "\t>>> FILE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> FILE: ${MROOT}${pathto}"
337   install -m "${posix}" -o "${user}" -g "${group}" \   install -m "${posix}" -o "${user}" -g "${group}" \
338   ${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \   ${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \
339   "${MROOT}${pathto}"   "${MROOT}${pathto}"
# Line 218  install_files() Line 345  install_files()
345   "${user}" \   "${user}" \
346   "${group}" \   "${group}" \
347   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
348   "${MROOT}${pathto}")" \   "${MROOT}${pathto}")" \
349   "${md5sum}"   "${md5sum}"
350   ;;   ;;
351    
352   # file is protected, write backup file   # file is protected, write backup file
353   2)   2)
354   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
355   then   then
356   echo -en "${COLRED}"   echo -en "${COLRED}"
357   echo -n "! prot "   echo -n "! prot "
# Line 245  install_files() Line 372  install_files()
372   "${user}" \   "${user}" \
373   "${group}" \   "${group}" \
374   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
375   "${dest_protected}")" \   "${dest_protected}")" \
376   "${md5sum}"   "${md5sum}"
377    
378   # update global MAGE_PROTECT_COUNTER   # update global MAGE_PROTECT_COUNTER
379   (( MAGE_PROTECT_COUNTER++ ))   (( MAGE_PROTECT_COUNTER++ ))
380   export MAGE_PROTECT_COUNTER   export MAGE_PROTECT_COUNTER
381   ;;   ;;
382    
383     # file is protected but ignored, delete the update/do nothing
384     4)
385     if mqueryfeature "verbose"
386     then
387     echo -en "${COLRED}"
388     echo -n "! ignr "
389     echo -en "${COLDEFAULT}"
390     echo " === FILE: ${MROOT}${pathto}"
391     fi
392     # simply do nothing here - only fix mtime
393     fix_descriptor ${pkgname}/.files \
394     "${pathto}" \
395     "${posix}" \
396     "${user}" \
397     "${group}" \
398     "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
399     "${MROOT}${pathto}")" \
400     "${md5sum}"
401     ;;
402   esac   esac
403   done < ${BUILDDIR}/${pkgname}/.files   done < ${BUILDDIR}/${pkgname}/.files
404    
# Line 294  install_symlinks() Line 441  install_symlinks()
441   while read pathto posix link mtime   while read pathto posix link mtime
442   do   do
443   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
444   [[ ${VERBOSE} = on ]] && echo -e "\t>>> LINK: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> LINK: ${MROOT}${pathto}"
445    
446   ln -snf "${link}" "${MROOT}${pathto}"   ln -snf "${link}" "${MROOT}${pathto}"
447    
448   # fix mtime and db   # fix mtime and db
449   fix_descriptor ${pkgname}/.symlinks \   fix_descriptor ${pkgname}/.symlinks \
450   "${pathto}" \   "${pathto}" \
451   "${posix}" \   "${posix}" \
452   "${link}" \   "${link}" \
453   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
454   "${MROOT}${pathto}")"   "${MROOT}${pathto}")"
455    
456   done < ${BUILDDIR}/${pkgname}/.symlinks   done < ${BUILDDIR}/${pkgname}/.symlinks
457    
458   # now copy the fixed file over the old one  # # now copy the fixed file over the old one
459   [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \  # [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \
460   cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,}  # cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,}
461    
462   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
463   IFS=$'\n'   IFS=$'\n'
# Line 326  install_blockdevices() Line 473  install_blockdevices()
473   local pkgname="$1"   local pkgname="$1"
474   local pathto   local pathto
475   local posix   local posix
476     local user
477     local group
478   local IFS   local IFS
479    
480   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 339  install_blockdevices() Line 488  install_blockdevices()
488   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
489   IFS=§   IFS=§
490    
491   while read pathto posix   while read pathto posix major minor user group
492   do   do
493   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
494   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> PIPE: ${MROOT}${pathto}"
495    
496   mkfifo -m "${posix}" "${MROOT}$pathto"   mknod -m "${posix}" "${MROOT}${pathto}"
497     # make it optional atm !!
498     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
499     then
500     chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}"
501     fi
502   done < ${BUILDDIR}/${pkgname}/.pipes   done < ${BUILDDIR}/${pkgname}/.pipes
503    
504   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
# Line 363  install_characterdevices() Line 517  install_characterdevices()
517   local posix   local posix
518   local major   local major
519   local minor   local minor
520     local user
521     local group
522   local IFS   local IFS
523    
524   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 376  install_characterdevices() Line 532  install_characterdevices()
532   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
533   IFS=§   IFS=§
534    
535   while read pathto posix major minor   while read pathto posix major minor user group
536   do   do
537   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
538   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> CHAR: ${MROOT}${pathto}"
539    
540     mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}"
541    
542   mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor}   # make it optional atm !!
543     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
544     then
545     chown "${user}:${group}" "${MROOT}${pathto}"
546     fi
547   done < ${BUILDDIR}/${pkgname}/.char   done < ${BUILDDIR}/${pkgname}/.char
548    
549   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
550   IFS=$'\n'   IFS=$'\n'
551  }  }
552    
553    ###################################################
554    # function install_fifos                          #
555    # install_fifos $PKGNAME                    #
556    ###################################################
557    install_fifos()
558    {
559     local pkgname="$1"
560     local pathto
561     local posix
562     local user
563     local group
564     local IFS
565    
566     # sanity checks; abort if not given
567     [ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given."
568    
569     # check needed global vars
570     [ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set."
571    
572     # make it optional atm !!
573     #[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found"
574     [ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return
575    
576     # sets fieldseperator to "§" instead of " "
577     IFS=§
578    
579     while read pathto posix user group
580     do
581     [ -z "${pathto}" ] && continue
582     mqueryfeature "verbose" && echo -e "\t>>> FIFO: ${MROOT}${pathto}"
583    
584     mkfifo -m "${posix}" "${MROOT}${pathto}"
585     chown "${user}:${group}" "${MROOT}${pathto}"
586     done < ${BUILDDIR}/${pkgname}/.fifo
587    
588     # very important: unsetting the '§' fieldseperator
589     IFS=$'\n'
590    }
591    
592    
593  ###################################################  ###################################################
594  # function build_doinstall                        #  # function build_doinstall                        #
595  # build_doinstall $PKGNAME                  #  # build_doinstall $PKGNAME                  #
596  # NOTE: this is an wrapper do install packages    #  # NOTE: this is an wrapper to install packages    #
597  ###################################################  ###################################################
598  build_doinstall()  build_doinstall()
599  {  {
# Line 400  build_doinstall() Line 601  build_doinstall()
601    
602   # sanity checks; abort if not given   # sanity checks; abort if not given
603   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."
604    
605   # this is only a wrapper   # this is only a wrapper
606    
607   # NOTE:   # NOTE:
# Line 415  build_doinstall() Line 616  build_doinstall()
616   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"
617   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"
618   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"
619     install_fifos ${pkgname} || die "install fifos ${pkgname}"
620  }  }
621    
622    
# Line 476  install_database_entry() Line 678  install_database_entry()
678    
679   # create fake file descriptors   # create fake file descriptors
680   # used by virtual and source packages   # used by virtual and source packages
681   for i in .dirs .symlinks .files .pipes .char   for i in .dirs .symlinks .files .pipes .char .fifo
682   do   do
683   touch ${dbrecorddir}/${i}   touch ${dbrecorddir}/${i}
684   done   done
# Line 494  install_database_entry() Line 696  install_database_entry()
696    
697   # normal packages needs these files   # normal packages needs these files
698   local i   local i
699   for i in .char .dirs .files .pipes .symlinks   for i in .char .dirs .files .pipes .symlinks .fifo
700   do   do
701   install -m 0644 ${BUILDDIR}/${pkgname}/${i} \   # make .fifo optional atm
702   ${dbrecorddir}/${i}   if [[ -f ${BUILDDIR}/${pkgname}/${i} ]]
703     then
704     install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i}
705     fi
706   done   done
707   ;;   ;;
708   esac   esac
# Line 633  compare_mtime() Line 838  compare_mtime()
838    
839   mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)"   mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)"
840    
841   # if $pathto is a symlink than compare linked binary   # no extra handlink for symlinks anymore as fix_mtime
842   if [ -L "${MROOT}${pathto}" ]   # uses --no-dereference, compare directly
843   then   x=$(stat -c %Y "${MROOT}${pathto}")
  # readlink -f resolves full path of linked file  
  x="$(readlink -f "${MROOT}${pathto}")"  
   
  # abort if target does not exists  
  # we keep safe here, theoretically the link can removed  
  [ ! -e "${x}" ] && return 1  
   
  x=$(stat -c %Y "${x}")  
  else  
  x=$(stat -c %Y "${MROOT}${pathto}")  
  fi  
844    
845   [[ ${mtime} = ${x} ]] && return 0   [[ ${mtime} = ${x} ]] && return 0
846    
# Line 708  remove_symlinks() Line 902  remove_symlinks()
902   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
903   if [ ! -L "${MROOT}${pathto}" ]   if [ ! -L "${MROOT}${pathto}" ]
904   then   then
905   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
906   echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}"
907   continue   continue
908   fi   fi
# Line 720  remove_symlinks() Line 914  remove_symlinks()
914   # 1=keep me   #   # 1=keep me   #
915   case ${retval} in   case ${retval} in
916   0)   0)
917   [[ ${VERBOSE} = on ]] && echo -e "\t<<< LINK: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< LINK: ${MROOT}${pathto}"
918   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
919   ;;   ;;
920    
921   1)   1)
922   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
923   echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}"
924   ;;   ;;
925   esac   esac
# Line 772  remove_files() Line 966  remove_files()
966   done   done
967    
968   # sanity checks; abort if not given   # sanity checks; abort if not given
969   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_files() \$pcat not given."
970   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_files() \$pname not given."
971   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_files() \$pver not given."
972   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_files() \$pbuild not given."
973   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
974    
975   # check needed global vars   # check needed global vars
# Line 792  remove_files() Line 986  remove_files()
986    
987   if [ ! -e "${MROOT}${pathto}" ]   if [ ! -e "${MROOT}${pathto}" ]
988   then   then
989   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
990   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"
991   continue   continue
992   fi   fi
# Line 809  remove_files() Line 1003  remove_files()
1003   is_config_protected "${pathto}"   is_config_protected "${pathto}"
1004   retval="$?"   retval="$?"
1005    
1006   # 0 - not protected        #   # 0 - not protected         #
1007   # 1 - error                #   # 1 - error                 #
1008   # 2 - protected            #   # 2 - protected             #
1009   # 3 - protected but masked #   # 3 - protected but masked  #
1010     # 4 - protected but ignored #
1011    
1012   case ${retval} in   case ${retval} in
1013   # file is not protected - delete it   # file is not protected - delete it
1014   0|3)   0|3)
1015   [[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< FILE: ${MROOT}${pathto}"
1016   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1017   ;;   ;;
1018    
1019   # file is protected, do not delete   # file is protected, do not delete
1020   2)   2)
1021   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
1022   then   then
1023   echo -en "${COLRED}"   echo -en "${COLRED}"
1024   echo -n "! prot "   echo -n "! prot "
# Line 831  remove_files() Line 1026  remove_files()
1026   echo " === FILE: ${MROOT}${pathto}"   echo " === FILE: ${MROOT}${pathto}"
1027   fi   fi
1028   ;;   ;;
1029    
1030     # file is protected but ignored, delete the update/do nothing
1031     4)
1032     if mqueryfeature "verbose"
1033     then
1034     echo -en "${COLRED}"
1035     echo -n "! ignr "
1036     echo -en "${COLDEFAULT}"
1037     echo " === FILE: ${MROOT}${pathto}"
1038     fi
1039     # simply do nothing here
1040     ;;
1041   esac   esac
1042   ;;   ;;
1043   1)   1)
1044   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1045   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"
1046   ;;   ;;
1047   esac   esac
# Line 853  remove_blockdevices() Line 1060  remove_blockdevices()
1060  {  {
1061   local pathto   local pathto
1062   local posix   local posix
1063     local user
1064     local group
1065   local IFS   local IFS
1066   local pcat   local pcat
1067   local pname   local pname
# Line 876  remove_blockdevices() Line 1085  remove_blockdevices()
1085   done   done
1086    
1087   # sanity checks; abort if not given   # sanity checks; abort if not given
1088   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given."
1089   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_blockdevices() \$pname not given."
1090   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_blockdevices() \$pver not given."
1091   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given."
1092   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1093    
1094   # check needed global vars   # check needed global vars
# Line 890  remove_blockdevices() Line 1099  remove_blockdevices()
1099   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1100   IFS=§   IFS=§
1101    
1102   while read pathto posix   while read pathto posix user group
1103   do   do
1104   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1105    
1106   [[ ${VERBOSE} = on ]] && echo -e "\t<<< PIPE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< PIPE: ${MROOT}${pathto}"
1107   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1108   done < ${MROOT}${INSTALLDB}/${pfull}/.pipes   done < ${MROOT}${INSTALLDB}/${pfull}/.pipes
1109    
# Line 911  remove_characterdevices() Line 1120  remove_characterdevices()
1120  {  {
1121   local pathto   local pathto
1122   local posix   local posix
1123     local user
1124     local group
1125   local IFS   local IFS
1126   local pcat   local pcat
1127   local pname   local pname
# Line 934  remove_characterdevices() Line 1145  remove_characterdevices()
1145   done   done
1146    
1147   # sanity checks; abort if not given   # sanity checks; abort if not given
1148   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given."
1149   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_characterdevices() \$pname not given."
1150   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_characterdevices() \$pver not given."
1151   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given."
1152   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1153    
1154   # check needed global vars   # check needed global vars
# Line 948  remove_characterdevices() Line 1159  remove_characterdevices()
1159   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1160   IFS=§   IFS=§
1161    
1162   while read pathto posix   while read pathto posix user group
1163   do   do
1164   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1165    
1166   [[ ${VERBOSE} = on ]] && echo -e "\t<<< CHAR: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< CHAR: ${MROOT}${pathto}"
1167   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1168   done < ${MROOT}${INSTALLDB}/${pfull}/.char   done < ${MROOT}${INSTALLDB}/${pfull}/.char
1169    
# Line 962  remove_characterdevices() Line 1173  remove_characterdevices()
1173    
1174    
1175  ###################################################  ###################################################
1176    # function remove_fifos                           #
1177    # remove_fifos $PKGNAME                     #
1178    ###################################################
1179    remove_fifos()
1180    {
1181     local pathto
1182     local posix
1183     local user
1184     local group
1185     local IFS
1186     local pcat
1187     local pname
1188     local pver
1189     local pbuild
1190     local i
1191     local pfull
1192    
1193     IFS=$'\n'
1194    
1195     # very basic getops
1196     for i in $*
1197     do
1198     case $1 in
1199     --pcat|-c) shift; pcat="$1" ;;
1200     --pname|-n) shift; pname="$1" ;;
1201     --pver|-v) shift; pver="$1" ;;
1202     --pbuild|-b) shift; pbuild="$1" ;;
1203     esac
1204     shift
1205     done
1206    
1207     # sanity checks; abort if not given
1208     [ -z "${pcat}" ] && die "remove_fifos() \$pcat not given."
1209     [ -z "${pname}" ] && die "remove_fifos() \$pname not given."
1210     [ -z "${pver}" ] && die "remove_fifos() \$pver not given."
1211     [ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given."
1212     pfull="${pcat}/${pname}-${pver}-${pbuild}"
1213    
1214     # check needed global vars
1215     [ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set."
1216    
1217     # make it optional atm !!
1218     #[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found"
1219     [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return
1220    
1221     # sets fieldseperator to "§" instead of " "
1222     IFS=§
1223    
1224     while read pathto posix user group
1225     do
1226     [ -z "${pathto}" ] && continue
1227    
1228     mqueryfeature "verbose" && echo -e "\t<<< FIFO: ${MROOT}${pathto}"
1229     rm "${MROOT}${pathto}"
1230     done < ${MROOT}${INSTALLDB}/${pfull}/.fifo
1231    
1232     # very important: unsetting the '§' fieldseperator
1233     IFS=$'\n'
1234    }
1235    
1236    
1237    ###################################################
1238  # function remove_direcories                      #  # function remove_direcories                      #
1239  # remove_direcories $PKGNAME                #  # remove_direcories $PKGNAME                #
1240  ###################################################  ###################################################
# Line 992  remove_directories() Line 1265  remove_directories()
1265   done   done
1266    
1267   # sanity checks; abort if not given   # sanity checks; abort if not given
1268   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_directories() \$pcat not given."
1269   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_directories() \$pname not given."
1270   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_directories() \$pver not given."
1271   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given."
1272   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1273    
1274   # check needed global vars   # check needed global vars
# Line 1013  remove_directories() Line 1286  remove_directories()
1286    
1287   if [ ! -d "${MROOT}${pathto}" ]   if [ ! -d "${MROOT}${pathto}" ]
1288   then   then
1289   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1290   echo -e "${COLRED}! exist${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1291   continue   continue
1292   fi   fi
# Line 1021  remove_directories() Line 1294  remove_directories()
1294   # exclude .keep directories   # exclude .keep directories
1295   if [ -f "${MROOT}${pathto}/.keep" ]   if [ -f "${MROOT}${pathto}/.keep" ]
1296   then   then
1297   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1298   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1299   continue   continue
1300   fi   fi
# Line 1034  remove_directories() Line 1307  remove_directories()
1307    
1308   if rmdir "${MROOT}${pathto}" &> /dev/null   if rmdir "${MROOT}${pathto}" &> /dev/null
1309   then   then
1310   [[ ${VERBOSE} = on ]] && echo -e "\t<<< DIR:  ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< DIR:  ${MROOT}${pathto}"
1311   else   else
1312   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1313   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1314   fi   fi
1315   done   done
# Line 1049  remove_directories() Line 1322  remove_directories()
1322  ###################################################  ###################################################
1323  # function build_douninstall                      #  # function build_douninstall                      #
1324  # build_douninstall $PKGNAME                #  # build_douninstall $PKGNAME                #
1325  # NOTE: this is an wrapper do remove packages     #  # NOTE: this is an wrapper to remove packages     #
1326  ###################################################  ###################################################
1327  build_douninstall()  build_douninstall()
1328  {  {
# Line 1083  build_douninstall() Line 1356  build_douninstall()
1356   # !! we use § as field seperator !!   # !! we use § as field seperator !!
1357   # doing so prevent us to get errors by filenames with spaces   # doing so prevent us to get errors by filenames with spaces
1358    
1359   for i in symlinks files blockdevices characterdevices directories   for i in symlinks files blockdevices characterdevices directories fifos
1360   do   do
1361   remove_${i} \   remove_${i} \
1362   --pcat "${pcat}" \   --pcat "${pcat}" \
# Line 1094  build_douninstall() Line 1367  build_douninstall()
1367   done   done
1368  }  }
1369    
1370    # convertmirrors [uri]
1371    convertmirrors()
1372    {
1373     local uri="$1"
1374     local scheme
1375     local mirror
1376     local mirrors
1377     local addon
1378     local real_uri
1379     local output
1380    
1381     # needs
1382     [[ -z ${MIRRORS} ]] && die "convertmirrors(): no mirrors defined!"
1383     [[ -z ${SOURCEFORGE_MIRRORS} ]] && die "convertmirrors(): no sourceforge mirrors defined!"
1384     [[ -z ${GNU_MIRRORS} ]] && die "convertmirrors(): no gnu mirrors defined!"
1385     [[ -z ${GNOME_MIRRORS} ]] && die "convertmirrors(): no gnome mirrors defined!"
1386     [[ -z ${KDE_MIRRORS} ]] && die "convertmirrors(): no kde mirrors defined!"
1387    
1388     # check known uri schemes
1389     case ${uri} in
1390     http://*|https://*|ftp://*|ftps://*) mirrors="" ;;
1391     mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;;
1392     package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;;
1393     gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;;
1394     sourceforge://*) mirrors="${SOURCEFORGE_MIRRORS}"; scheme="sourceforge://" ;;
1395     gnome://*) mirrors="${GNOME_MIRRORS}"; scheme="gnome://" ;;
1396     kde://*) mirrors="${KDE_MIRRORS}"; scheme="kde://" ;;
1397     *) die "convertmirror(): unsupported uri scheme in '${uri}'!" ;;
1398     esac
1399    
1400     if [[ ! -z ${mirrors} ]]
1401     then
1402     for mirror in ${mirrors}
1403     do
1404     # add a whitespace to the output
1405     [[ -z ${output} ]] || output+=" "
1406     output+="${mirror}${addon}/${uri/${scheme}/}"
1407     done
1408     else
1409     output="${uri}"
1410     fi
1411    
1412     echo "${output}"
1413    }
1414    
1415    mdownload()
1416    {
1417     local i
1418     local uri
1419     local real_uris
1420     local mirror
1421     local outputfile
1422     local outputdir
1423     local retval
1424     local wget_opts
1425    
1426     # very basic getops
1427     for i in $*
1428     do
1429     case $1 in
1430     --uri|-u) shift; uri="$1" ;;
1431     --dir|-d) shift; outputdir="$1" ;;
1432     esac
1433     shift
1434     done
1435    
1436     # sanity checks; abort if not given
1437     [[ -z ${uri} ]] && die "mdownload(): no uri given!"
1438     [[ -z ${outputdir} ]] && die "mdownload(): no dir given!"
1439    
1440     # convert mirrored uris to the real ones
1441     real_uris="$(convertmirrors ${uri})"
1442    
1443     # verbose or not
1444     mqueryfeature "!verbose" && wget_opts+=" --quiet"
1445    
1446     # filter wget options if busybox was found
1447     wget_opts+=" $(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1448    
1449     # create outputdir
1450     [[ ! -d ${outputdir} ]] && install -d "${outputdir}"
1451    
1452     for mirror in ${real_uris}
1453     do
1454     # get the name of the output file
1455     outputfile="${mirror##*/}"
1456    
1457     wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}"
1458     retval="$?"
1459     if [[ ${retval} = 0 ]]
1460     then
1461     break
1462     else
1463     continue
1464     fi
1465     done
1466    
1467     # return wget retval
1468     return "${retval}"
1469    }
1470    
1471  # fetch_packages /path/to/mage/file1 /path/to/mage/file2  # fetch_packages /path/to/mage/file1 /path/to/mage/file2
1472  fetch_packages()  fetch_packages()
1473  {  {
1474     local i
1475   local list="$@"   local list="$@"
1476   local pkg   local pkg
1477   local mirr   local mirr
# Line 1105  fetch_packages() Line 1480  fetch_packages()
1480   local opt   local opt
1481   local count_current   local count_current
1482   local count_total   local count_total
1483     local wget_opts
1484    
1485   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."
1486    
1487     # filter wget command if busybox was found
1488     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1489    
1490   # get count of total packages   # get count of total packages
1491   declare -i count_current=0   declare -i count_current=0
1492   declare -i count_total=0   declare -i count_total=0
# Line 1146  fetch_packages() Line 1525  fetch_packages()
1525   continue   continue
1526   fi   fi
1527    
1528   for mirr in ${MIRRORS}   echo -ne " ${COLBLUE}***${COLDEFAULT}"
1529   do   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1530   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  
   
1531   if [ ! -f ${PKGDIR}/${pkg} ]   if [ ! -f ${PKGDIR}/${pkg} ]
1532   then   then
1533   die "Could not download ${pkg}"   die "Package '${pkg}' after download not found in '${PKGDIR}'"
1534   fi   fi
1535   done   done
1536    
# Line 1197  syncmage() Line 1558  syncmage()
1558   done   done
1559    
1560   # clean up backup files (foo~)   # clean up backup files (foo~)
1561   find ${MAGEDIR} -name *~ -exec rm '{}' ';'   find ${MAGEDIR} -name \*~ -exec rm '{}' ';'
1562    
1563   # check if an newer mage version is available   # check if a newer mage version is available
1564   is_newer_mage_version_available   is_newer_mage_version_available
1565  }  }
1566    
1567    syncmage_tarball()
1568    {
1569     local latest_tarball
1570     local latest_md5
1571     local temp="$(mktemp -d)"
1572     local mirr mymirr
1573     local opt
1574     local tar_opts
1575     local wget_opts
1576    
1577     # try to get the md5 marked as latest on the server
1578     latest_md5="mage-latest.md5"
1579    
1580     # try to get the tarball marked as latest on the server
1581     latest_tarball="mage-latest.tar.bz2"
1582    
1583     # filter wget command if busybox was found
1584     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1585    
1586     for mirr in ${MIRRORS}
1587     do
1588     # path without distribution
1589     # (only for stable|testing|unstable and not DISTROTAG)
1590     case ${mirr##*/} in
1591     stable|testing|unstable) mymirr="${mirr%/*}";;
1592     *) mymirr="${mirr}";;
1593     esac
1594    
1595     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1596     echo "fetching latest md5 from ${mymirr} ..."
1597     mqueryfeature "!verbose" && opt="--quiet"
1598     wget \
1599     ${wget_opts} \
1600     --directory-prefix=${temp} \
1601     ${opt} ${mymirr}/rsync/tarballs/${latest_md5}
1602    
1603     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1604     echo "fetching latest tarball from ${mymirr} ..."
1605     wget \
1606     ${wget_opts} \
1607     --directory-prefix=${temp} \
1608     ${opt} ${mymirr}/rsync/tarballs/${latest_tarball}
1609     if [[ $? = 0 ]]
1610     then
1611     break
1612     else
1613     continue
1614     fi
1615     done
1616    
1617     if [[ -f ${temp}/${latest_tarball} ]]
1618     then
1619     # check md5
1620     if [[ ! -f ${temp}/${latest_md5} ]]
1621     then
1622     die "md5 is missing ... aborting"
1623     else
1624     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1625     echo -n "checking md5sum... "
1626     mchecksum --rundir "${temp}" --file "${latest_md5}" --method md5 || die "md5 for ${latest_tarball} failed"
1627     fi
1628    
1629     if [[ -d ${MAGEDIR} ]]
1630     then
1631     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1632     echo "cleaning old mage-tree ${MAGEDIR}..."
1633     # honor mountpoints and empty dirs
1634     if mountpoint -q ${MAGEDIR}
1635     then
1636     if ! mcheckemptydir ${MAGEDIR}
1637     then
1638     find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xargs --no-run-if-empty rm -r
1639     fi
1640     else
1641     rm -rf ${MAGEDIR}
1642     fi
1643     fi
1644    
1645     if need_busybox_support tar
1646     then
1647     tar_opts="xjf"
1648     else
1649     tar_opts="xjmf"
1650     fi
1651    
1652     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1653     echo "updating mage-tree from tarball ..."
1654     # unpack in dirname of MAGEDIR, as the tarball has already the mage
1655     tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1656    
1657     if [[ -d ${temp} ]]
1658     then
1659     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1660     echo "cleaning temp-files ..."
1661     rm -rf ${temp}
1662     fi
1663    
1664     # check if a newer mage version is available
1665     is_newer_mage_version_available
1666     else
1667     die "Could not fetch the latest tarball ... aborting"
1668     fi
1669    }
1670    
1671  cleanpkg()  cleanpkg()
1672  {  {
1673   if [ -d "${PKGDIR}" ]   if [ -d "${PKGDIR}" ]
# Line 1233  xtitleclean() Line 1698  xtitleclean()
1698  }  }
1699    
1700    
1701  # cuts full pathnames or versioniezed names down to basename  # unused?
1702  choppkgname()  #
1703  {  # # cuts full pathnames or versionized names down to basename
1704   #we want this only if full name was used  # choppkgname()
1705   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]  # {
1706   then  # #we want this only if full name was used
1707   #cuts ARCH and PBUILD  # if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]
1708   #ARCH comes from ${MAGERC}  # then
1709   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")  # #cuts ARCH and PBUILD
1710    # #ARCH comes from ${MAGERC}
1711    # MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}$(print_distrotag)-r*.::g")
1712    #
1713    # #cuts version number
1714    # MAGENAME=$(basename ${MAGENAME%-*} .mage)
1715    # fi
1716    # }
1717    
  #cuts version number  
  MAGENAME=$(basename ${MAGENAME%-*} .mage)  
  fi  
 }  
1718    
1719  # get_categorie $PNAME, returns CATEGORIE  # get_categorie $PNAME, returns CATEGORIE
1720  # $1=pname  # $1=pname
# Line 1315  get_highest_magefile() Line 1783  get_highest_magefile()
1783   local PNAME="$2"   local PNAME="$2"
1784   local magefile   local magefile
1785    
1786   for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*)   # do not list the content of a directory, only the name (-d)
1787     for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/* 2> /dev/null)
1788   do   do
1789     [[ -z ${magefile} ]] && continue
1790   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
1791   [ -d ${magefile} ] && continue   [[ -d ${magefile} ]] && continue
1792   if check_stable_package ${magefile}   if check_stable_package ${magefile}
1793   then   then
1794   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
1795   #for debug only   #for debug only
1796   [[ ${MAGEDEBUG} = on ]] && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"   mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" >&2
1797   fi   fi
1798   done   done
1799    
 # 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  
   
1800   echo "${HIGHEST_MAGEFILE}"   echo "${HIGHEST_MAGEFILE}"
1801   return 0   return 0
1802  }  }
# Line 1363  get_highest_magefile() Line 1811  get_highest_magefile()
1811  #        1 - error                                #  #        1 - error                                #
1812  #        2 - protected                            #  #        2 - protected                            #
1813  #        3 - protected but masked                 #  #        3 - protected but masked                 #
1814    #        4 - protected but ignored                #
1815  #                                                 #  #                                                 #
1816  ###################################################  ###################################################
1817  is_config_protected()  is_config_protected()
# Line 1371  is_config_protected() Line 1820  is_config_protected()
1820   local TEST   local TEST
1821   local PROTECTED   local PROTECTED
1822   local IFS   local IFS
1823     local i
1824     local x
1825    
1826   EXPFILE="${MROOT}$1"   EXPFILE="${MROOT}$1"
1827    
# Line 1380  is_config_protected() Line 1831  is_config_protected()
1831   # to be safe; it may be '§'   # to be safe; it may be '§'
1832   IFS=' '   IFS=' '
1833    
1834   # check ob in config protect   # check if config protected
1835   for i in ${CONFIG_PROTECT}   for i in ${CONFIG_PROTECT}
1836   do   do
1837   # ersetzen von $i nur wenn am anfang der variable   # only replace $i in the beginning of the variable
1838   TEST="${EXPFILE/#${MROOT}${i}/Protected}"   TEST="${EXPFILE/#${MROOT}${i}/Protected}"
1839   if [[ ${TEST} != ${EXPFILE} ]]   if [[ ${TEST} != ${EXPFILE} ]]
1840   then   then
1841   # setzen das es protected ist   # file is config proteced
1842   PROTECTED=TRUE   PROTECTED=TRUE
1843    
1844   # check ob nicht doch maskiert   # check if not masked
1845   for x in ${CONFIG_PROTECT_MASK}   for x in ${CONFIG_PROTECT_MASK}
1846   do   do
1847   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"
# Line 1399  is_config_protected() Line 1850  is_config_protected()
1850   PROTECTED=MASKED   PROTECTED=MASKED
1851   fi   fi
1852   done   done
1853    
1854     # check if not ignored
1855     for x in ${CONFIG_PROTECT_IGNORE}
1856     do
1857     TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}"
1858     if [[ ${TEST} != ${EXPFILE} ]]
1859     then
1860     PROTECTED=IGNORED
1861     fi
1862     done
1863   fi   fi
1864   done   done
1865    
# Line 1413  is_config_protected() Line 1874  is_config_protected()
1874   #echo "I'm protected, but masked - delete me"   #echo "I'm protected, but masked - delete me"
1875   return 3   return 3
1876   ;;   ;;
1877     IGNORED)
1878     #echo "I'm protected, but ignored - keep me, del update"
1879     return 4
1880     ;;
1881   *)   *)
1882   #echo "delete me"   #echo "delete me"
1883   return 0   return 0
# Line 1430  is_config_protected() Line 1895  is_config_protected()
1895  ###################################################  ###################################################
1896  count_protected_files()  count_protected_files()
1897  {  {
1898   ${MLIBDIR}/writeprotected "$1"   local file="$1"
1899     local dirname="${file%/*}"
1900     local filename="${file##*/}"
1901     local count
1902     local output
1903     local oldprotected
1904     local i
1905     local x
1906    
1907     # hack; do not honor a global set IFS like '§'
1908     local IFS
1909    
1910     count=0
1911    
1912     # check if there are already protected files
1913     for oldprotected in $(find ${dirname} -iname "._cfg????_${filename}" |
1914     sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
1915     sort -t'%' -k3 -k2 | cut -f1 -d'%')
1916     do
1917     count="$(echo ${oldprotected} | sed 's:.*\/._cfg\(.*\)_.*:\1:')"
1918     done
1919    
1920     # convert 0001 -> 1; 0120 -> 120 etc
1921     # use bash internal base functions to this task
1922     x="$((10#${count}))"
1923     for (( i=0; i<x; i++ ))
1924     do
1925     if [[ ${count:${i}:1} != 0 ]]
1926     then
1927     count="${count:${i}}"
1928     break
1929     fi
1930     done
1931    
1932     count="$(( ${count}+1 ))"
1933    
1934     # fill output up with zeros
1935     for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
1936     output="${output}${count}"
1937    
1938     echo "${output}"
1939  }  }
1940    
1941  # call with  # call with
# Line 1602  virtuals_add() Line 2107  virtuals_add()
2107    
2108  #deletes pakages from virtual database  #deletes pakages from virtual database
2109  #$1 virtualname; $2 pkgname  #$1 virtualname; $2 pkgname
2110  virtuals_del() {  virtuals_del()
2111    {
2112    
2113   local virtualname="$1"   local virtualname="$1"
2114   local pkgname="$2"   local pkgname="$2"
# Line 1713  minclude() Line 2219  minclude()
2219   then   then
2220   for i in $*   for i in $*
2221   do   do
2222   [[ ${MAGEDEBUG} = on ]] && \   mqueryfeature "debug" && \
2223   echo "--- Including ${MAGEDIR}/include/${i}.minc"   echo "--- Including ${MAGEDIR}/include/${i}.minc"
2224   source ${MAGEDIR}/include/${i}.minc   source ${MAGEDIR}/include/${i}.minc
2225   done   done
2226   [[ ${MAGEDEBUG} = on ]] && echo   mqueryfeature "debug" && echo
2227   fi   fi
2228  }  }
2229    
# Line 2036  get_value_from_magefile() Line 2542  get_value_from_magefile()
2542   local SDEPEND   local SDEPEND
2543   local PROVIDE   local PROVIDE
2544   local PKGTYPE   local PKGTYPE
2545     local MAGE_TARGETS
2546     local SPLIT_PACKAGE_BASE
2547   local preinstall   local preinstall
2548   local postinstall   local postinstall
2549   local preremove   local preremove
# Line 2082  mage_install() Line 2590  mage_install()
2590   local count_current   local count_current
2591   local magefile   local magefile
2592   local src_install   local src_install
2593     local i
2594    
2595   # very basic getops   # very basic getops
2596   for i in $*   for i in $*
# Line 2155  mage_install() Line 2664  mage_install()
2664   echo B:${pbuild}   echo B:${pbuild}
2665   fi   fi
2666    
2667   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2   if [[ -n ${MAGE_TARGETS} ]]
2668     then
2669     # basic svn compat
2670     if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2671     then
2672     for i in ${SMAGESCRIPTSDIR}/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2673     do
2674     smage2file="${i}"
2675     done
2676     else
2677     smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2678     fi
2679    
2680     elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2681     then
2682     # basic svn compat
2683     if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2684     then
2685     for i in ${SMAGESCRIPTSDIR}/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2686     do
2687     smage2file="${i}"
2688     done
2689     else
2690     smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2691     fi
2692    
2693     else
2694     # basic svn compat
2695     if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2696     then
2697     for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2698     do
2699     smage2file="${i}"
2700     done
2701     else
2702     smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2
2703     fi
2704     fi
2705    
2706   if [ -f "${smage2file}" ]   if [ -f "${smage2file}" ]
2707   then   then
2708   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "
# Line 2172  mage_install() Line 2719  mage_install()
2719   if [[ ${PKGTYPE} != virtual ]] && \   if [[ ${PKGTYPE} != virtual ]] && \
2720   [[ ${PKGTYPE} != sources ]]   [[ ${PKGTYPE} != sources ]]
2721   then   then
2722     unpack_package "${magefile}"
2723   echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... "   echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... "
2724   build_doinstall ${PKGNAME}   build_doinstall ${PKGNAME}
2725   fi   fi
# Line 2286  md5sum_packages() Line 2834  md5sum_packages()
2834   then   then
2835   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2836   echo -ne "checking md5sum (${count_current}/${count_total}): "   echo -ne "checking md5sum (${count_current}/${count_total}): "
2837   ( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed"   mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 || die "md5 for ${pkgfile} failed"
2838   else   else
2839   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2840   echo -e "!! no md5sum file found for ${pkgfile} :("   echo -e "!! no md5sum file found for ${pkgfile} :("
# Line 2499  mage_uninstall() Line 3047  mage_uninstall()
3047   unset -f postremove   unset -f postremove
3048  }  }
3049    
3050  show_etc_update_mesg() {  show_etc_update_mesg()
3051    {
3052   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0
3053    
3054   echo   echo
# Line 2525  pkgsearch() Line 3074  pkgsearch()
3074   local state   local state
3075   local descriptiom   local descriptiom
3076   local homepage   local homepage
3077     local license
3078   local i   local i
3079   local all_installed   local all_installed
3080   local ipver   local ipver
# Line 2561  pkgsearch() Line 3111  pkgsearch()
3111   state="$(get_value_from_magefile STATE ${magefile})"   state="$(get_value_from_magefile STATE ${magefile})"
3112   description="$(get_value_from_magefile DESCRIPTION ${magefile})"   description="$(get_value_from_magefile DESCRIPTION ${magefile})"
3113   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
3114     license="$(get_value_from_magefile LICENSE ${magefile})"
3115    
3116   # all installed   # all installed
3117   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
3118   do   do
3119   ipver="$(magename2pver ${i})"   ipver="$(magename2pver ${i})"
3120   ipbuild="$(magename2pbuild ${i})"   ipbuild="$(magename2pbuild ${i})"
3121    
3122   if [[ -z ${all_installed} ]]   if [[ -z ${all_installed} ]]
3123   then   then
3124   all_installed="${ipver}-${ipbuild}"   all_installed="${ipver}-${ipbuild}"
# Line 2576  pkgsearch() Line 3127  pkgsearch()
3127   fi   fi
3128   done   done
3129   [[ -z ${all_installed} ]] && all_installed="none"   [[ -z ${all_installed} ]] && all_installed="none"
3130    
3131   case ${state} in   case ${state} in
3132   stable) state=${COLGREEN}"[s] ";;   stable) state=${COLGREEN}"[s] ";;
3133   testing) state=${COLYELLOW}"[t] ";;   testing) state=${COLYELLOW}"[t] ";;
# Line 2600  pkgsearch() Line 3151  pkgsearch()
3151   "") continue;;   "") continue;;
3152   esac   esac
3153    
3154   deps="${deps} $(basename ${dep%-*})"   if [[ -z ${deps} ]]
3155     then
3156     deps="$(basename ${dep%-*})"
3157     else
3158     deps="${deps} $(basename ${dep%-*})"
3159     fi
3160   done << EOF   done << EOF
3161  ${depsfull}  ${depsfull}
3162  EOF  EOF
# Line 2611  EOF Line 3167  EOF
3167   "") continue;;   "") continue;;
3168   esac   esac
3169    
3170   sdeps="${sdeps} $(basename ${dep%-*})"   if [[ -z ${sdeps} ]]
3171     then
3172     sdeps="$(basename ${dep%-*})"
3173     else
3174     sdeps="${sdeps} $(basename ${dep%-*})"
3175     fi
3176   done << EOF   done << EOF
3177  ${sdepsfull}  ${sdepsfull}
3178  EOF  EOF
# Line 2621  EOF Line 3182  EOF
3182   echo "      Installed versions: ${all_installed}"   echo "      Installed versions: ${all_installed}"
3183   echo "      Description: ${description}"   echo "      Description: ${description}"
3184   echo "      Homepage: ${homepage}"   echo "      Homepage: ${homepage}"
3185   echo "      Depends: ${deps}"   if [[ ! -z ${license} ]]
3186     then
3187     echo "      License:  ${license}"
3188     fi
3189     echo "      Depends:  ${deps}"
3190   echo "      SDepends: ${sdeps}"   echo "      SDepends: ${sdeps}"
3191   echo   echo
3192    
# Line 2661  export_inherits() Line 3226  export_inherits()
3226   eval "${functions}() { ${include}_${functions} ; }"   eval "${functions}() { ${include}_${functions} ; }"
3227    
3228   # debug   # debug
3229   [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"   mqueryfeature "debug" && typeset -f "${functions}"
3230    
3231   shift   shift
3232   done   done
# Line 2684  blacklisted() Line 3249  blacklisted()
3249   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable
3250   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing
3251    
3252   local EXCLUDED="${MROOT}/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"   # support both types for the moment
3253     if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]]
3254     then
3255     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"
3256     else
3257     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}"
3258     fi
3259    
3260   # return 0 if the list not exist; nothin is masked   # return 0 if the list not exist; nothin is masked
3261   [[ ! -f ${EXCLUDED} ]] && return 0   [[ ! -f ${EXCLUDED} ]] && return 0
# Line 2727  EOF Line 3298  EOF
3298   return 0   return 0
3299  }  }
3300    
3301    # need_busybox_support ${cmd}
3302    # return 0 (no error = needs busybox support) or return 1 (error = no busybox support required)
3303    need_busybox_support()
3304    {
3305     local cmd
3306     local busybox
3307     cmd="$1"
3308    
3309     for busybox in {,/usr}/bin/busybox
3310     do
3311     if [[ -x ${busybox} ]]
3312     then
3313     if [[ $(readlink $(type -P ${cmd})) = ${busybox} ]]
3314     then
3315     # needs busybox support
3316     return 0
3317     fi
3318     fi
3319     done
3320    
3321     # no busybox
3322     return 1
3323    }
3324    
3325    # busybox_filter_wget_options ${wget_opts}
3326    busybox_filter_wget_options()
3327    {
3328     local opts="$@"
3329     local i
3330     local fixed_opts
3331    
3332     if need_busybox_support wget
3333     then
3334     for i in ${opts}
3335     do
3336     # show only the allowed ones
3337     case ${i} in
3338     -c|--continue) fixed_opts+=" -c" ;;
3339     -s|--spider) fixed_opts+=" -s" ;;
3340     -q|--quiet) fixed_opts+=" -q" ;;
3341     -O|--output-document) shift; fixed_opts+=" -O $1" ;;
3342     --header) shift; fixed_opts+=" --header $1" ;;
3343     -Y|--proxy) shift; fixed_opts+=" -Y $1" ;;
3344     -P) shift; fixed_opts+=" -P $1" ;;
3345     --no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;;
3346     -U|--user-agent) shift; fixed_opts+=" -U ${i}" ;;
3347     # simply drop all other opts
3348     *) continue ;;
3349     esac
3350     done
3351    
3352     echo "${fixed_opts}"
3353     else
3354     echo "${opts}"
3355     fi
3356    }
3357    
3358    have_root_privileges()
3359    {
3360     local retval
3361    
3362     if [[ $(id -u) = 0 ]]
3363     then
3364     retval=0
3365     else
3366     retval=1
3367     fi
3368    
3369     return ${retval}
3370    }
3371    
3372    known_mage_feature()
3373    {
3374     local feature="$1"
3375     local retval
3376    
3377     case "${feature}" in
3378     autosvc|!autosvc) retval=0 ;;
3379     buildlog|!buildlog) retval=0 ;;
3380     ccache|!ccache) retval=0 ;;
3381     check|!check) retval=0 ;;
3382     compressdoc|!compressdoc) retval=0 ;;
3383     debug|!debug) retval=0 ;;
3384     distcc|!distcc) retval=0 ;;
3385     icecc|!icecc) retval=0 ;;
3386     kernelsrcunpack|!kernelsrcunpack) retval=0 ;;
3387     libtool|!libtool) retval=0 ;;
3388     linuxsymlink|!linuxsymlink) retval=0 ;;
3389     pkgbuild|!pkgbuild) retval=0 ;;
3390     pkgdistrotag|!pkgdistrotag) retval=0 ;;
3391     purge|!purge) retval=0 ;;
3392     qalint|!qalint) retval=0 ;;
3393     regentree|!regentree) retval=0 ;;
3394     resume|!resume) retval=0 ;;
3395     srcpkgbuild|!srcpkgbuild) retval=0 ;;
3396     srcpkgtarball|!srcpkgtarball) retval=0 ;;
3397     static|!static) retval=0 ;;
3398     stepbystep|!stepbystep) retval=0 ;;
3399     strip|!strip) retval=0 ;;
3400     verbose|!verbose) retval=0 ;;
3401     *) retval=1 ;;
3402     esac
3403    
3404     return "${retval}"
3405    }
3406    
3407    load_mage_features()
3408    {
3409     for i in ${MAGE_FEATURES_GLOBAL[*]} ${MAGE_FEATURES[*]}
3410     do
3411     FVERBOSE=off msetfeature ${i}
3412     done
3413    }
3414    
3415    msetfeature()
3416    {
3417     local feature
3418     local count
3419     local i
3420     local found
3421    
3422     for feature in $@
3423     do
3424     found=0
3425     count="${#MAGE_FEATURES_CURRENT[*]}"
3426    
3427     if ! known_mage_feature "${feature}"
3428     then
3429     [[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}"
3430     return 3
3431     fi
3432    
3433     for ((i=0; i<count; i++))
3434     do
3435     if [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature} ]]
3436     then
3437     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' already enabled${COLDEFAULT}"
3438     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3439     found=1
3440     elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = !${feature} ]]
3441     then
3442     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' currently disabled, enabling it!${COLDEFAULT}"
3443     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3444     found=1
3445     elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature//!} ]]
3446     then
3447     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature//!}' currently enabled, disabling it!${COLDEFAULT}"
3448     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3449     found=1
3450     fi
3451     done
3452    
3453     # if the feature was not found after proccessing the whole array
3454     # it was not declared. in this case enable it
3455     if [[ ${found} = 0 ]]
3456     then
3457     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' was not declared, enabling it!${COLDEFAULT}"
3458     MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )
3459     fi
3460    
3461     export MAGE_FEATURE_CURRENT
3462     done
3463    }
3464    
3465    mqueryfeature()
3466    {
3467     local feature="$1"
3468     local retval=1
3469     local i
3470    
3471     if known_mage_feature "${feature}"
3472     then
3473     for i in ${MAGE_FEATURES_CURRENT[*]}
3474     do
3475     if [[ ${i} = ${feature} ]]
3476     then
3477     retval=0
3478     break # found break here
3479     fi
3480     done
3481     else
3482     [[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}"
3483     retval=3
3484     fi
3485    
3486     return ${retval}
3487    }
3488    
3489    mprintfeatures()
3490    {
3491     echo -e "${COLRED}Global features:${COLDEFAULT} ${MAGE_FEATURES_GLOBAL[*]}"
3492     echo -e "${COLYELLOW}Local features:${COLDEFAULT} ${MAGE_FEATURES[*]}"
3493     echo -e "${COLGREEN}Current features:${COLDEFAULT} ${MAGE_FEATURES_CURRENT[*]}"
3494    }

Legend:
Removed from v.501  
changed lines
  Added in v.2225