Magellan Linux

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

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

revision 1083 by niro, Mon Jun 28 18:07:29 2010 UTC revision 1625 by niro, Fri Jan 13 13:06:13 2012 UTC
# Line 2  Line 2 
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.38 2008-10-05 10:32:24 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  {  {
30   [ ! -d ${MROOT}${INSTALLDB} ] && \   [ ! -d ${MROOT}${INSTALLDB} ] && \
# 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     ${cmd} -c ${file} &> /dev/null
76     retval="$?"
77     popd &> /dev/null
78     else
79     retval=1
80     fi
81    
82     return "${retval}"
83    }
84    
85  unpack_packages()  unpack_packages()
86  {  {
87   local list="$@"   local list="$@"
# Line 23  unpack_packages() Line 90  unpack_packages()
90   local pkgtype   local pkgtype
91   local count_current   local count_current
92   local count_total   local count_total
93     local tar_opts
94    
95   # get count of total packages   # get count of total packages
96   declare -i count_current=0   declare -i count_current=0
# Line 54  unpack_packages() Line 122  unpack_packages()
122   continue   continue
123   fi   fi
124    
125     # busybox?
126     if need_busybox_support tar
127     then
128     tar_opts="xjf"
129     else
130     tar_opts="xjmf"
131     fi
132    
133   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "
134   tar xjmf ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"   tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"
135   done   done
136    
137   # add a crlf for a better view   # add a crlf for a better view
# Line 130  install_directories() Line 206  install_directories()
206   while read pathto posix user group   while read pathto posix user group
207   do   do
208   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
209   [[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR:  ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> DIR:  ${MROOT}${pathto}"
   
210    
211   # monitors /etc/env.d -> env-rebuild   # monitors /etc/env.d -> env-rebuild
212   [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true   [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true
# Line 207  install_files() Line 282  install_files()
282   case ${retval} in   case ${retval} in
283   # file is not protected - (over)write it   # file is not protected - (over)write it
284   0|3)   0|3)
285   [[ ${VERBOSE} = on ]] && echo -e "\t>>> FILE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> FILE: ${MROOT}${pathto}"
286   install -m "${posix}" -o "${user}" -g "${group}" \   install -m "${posix}" -o "${user}" -g "${group}" \
287   ${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \   ${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \
288   "${MROOT}${pathto}"   "${MROOT}${pathto}"
# Line 219  install_files() Line 294  install_files()
294   "${user}" \   "${user}" \
295   "${group}" \   "${group}" \
296   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
297   "${MROOT}${pathto}")" \   "${MROOT}${pathto}")" \
298   "${md5sum}"   "${md5sum}"
299   ;;   ;;
300    
301   # file is protected, write backup file   # file is protected, write backup file
302   2)   2)
303   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
304   then   then
305   echo -en "${COLRED}"   echo -en "${COLRED}"
306   echo -n "! prot "   echo -n "! prot "
# Line 246  install_files() Line 321  install_files()
321   "${user}" \   "${user}" \
322   "${group}" \   "${group}" \
323   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
324   "${dest_protected}")" \   "${dest_protected}")" \
325   "${md5sum}"   "${md5sum}"
326    
327   # update global MAGE_PROTECT_COUNTER   # update global MAGE_PROTECT_COUNTER
# Line 256  install_files() Line 331  install_files()
331    
332   # file is protected but ignored, delete the update/do nothing   # file is protected but ignored, delete the update/do nothing
333   4)   4)
334   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
335   then   then
336   echo -en "${COLRED}"   echo -en "${COLRED}"
337   echo -n "! ignr "   echo -n "! ignr "
338   echo -en "${COLDEFAULT}"   echo -en "${COLDEFAULT}"
339   echo " === FILE: ${MROOT}${pathto}"   echo " === FILE: ${MROOT}${pathto}"
340   fi   fi
341   # simply do nothing here   # simply do nothing here - only fix mtime
342     fix_descriptor ${pkgname}/.files \
343     "${pathto}" \
344     "${posix}" \
345     "${user}" \
346     "${group}" \
347     "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
348     "${MROOT}${pathto}")" \
349     "${md5sum}"
350   ;;   ;;
351   esac   esac
352   done < ${BUILDDIR}/${pkgname}/.files   done < ${BUILDDIR}/${pkgname}/.files
# Line 307  install_symlinks() Line 390  install_symlinks()
390   while read pathto posix link mtime   while read pathto posix link mtime
391   do   do
392   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
393   [[ ${VERBOSE} = on ]] && echo -e "\t>>> LINK: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> LINK: ${MROOT}${pathto}"
394    
395   ln -snf "${link}" "${MROOT}${pathto}"   ln -snf "${link}" "${MROOT}${pathto}"
396    
# Line 339  install_blockdevices() Line 422  install_blockdevices()
422   local pkgname="$1"   local pkgname="$1"
423   local pathto   local pathto
424   local posix   local posix
425     local user
426     local group
427   local IFS   local IFS
428    
429   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 352  install_blockdevices() Line 437  install_blockdevices()
437   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
438   IFS=§   IFS=§
439    
440   while read pathto posix   while read pathto posix major minor user group
441   do   do
442   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
443   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> PIPE: ${MROOT}${pathto}"
444    
445   mkfifo -m "${posix}" "${MROOT}$pathto"   mknod -m "${posix}" "${MROOT}${pathto}"
446     # make it optional atm !!
447     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
448     then
449     chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}"
450     fi
451   done < ${BUILDDIR}/${pkgname}/.pipes   done < ${BUILDDIR}/${pkgname}/.pipes
452    
453   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
# Line 376  install_characterdevices() Line 466  install_characterdevices()
466   local posix   local posix
467   local major   local major
468   local minor   local minor
469     local user
470     local group
471   local IFS   local IFS
472    
473   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 389  install_characterdevices() Line 481  install_characterdevices()
481   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
482   IFS=§   IFS=§
483    
484   while read pathto posix major minor   while read pathto posix major minor user group
485   do   do
486   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
487   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> CHAR: ${MROOT}${pathto}"
488    
489   mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor}   mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}"
490    
491     # make it optional atm !!
492     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
493     then
494     chown "${user}:${group}" "${MROOT}${pathto}"
495     fi
496   done < ${BUILDDIR}/${pkgname}/.char   done < ${BUILDDIR}/${pkgname}/.char
497    
498   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
499   IFS=$'\n'   IFS=$'\n'
500  }  }
501    
502    ###################################################
503    # function install_fifos                          #
504    # install_fifos $PKGNAME                    #
505    ###################################################
506    install_fifos()
507    {
508     local pkgname="$1"
509     local pathto
510     local posix
511     local user
512     local group
513     local IFS
514    
515     # sanity checks; abort if not given
516     [ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given."
517    
518     # check needed global vars
519     [ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set."
520    
521     # make it optional atm !!
522     #[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found"
523     [ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return
524    
525     # sets fieldseperator to "§" instead of " "
526     IFS=§
527    
528     while read pathto posix user group
529     do
530     [ -z "${pathto}" ] && continue
531     mqueryfeature "verbose" && echo -e "\t>>> FIFO: ${MROOT}${pathto}"
532    
533     mkfifo -m "${posix}" "${MROOT}${pathto}"
534     chown "${user}:${group}" "${MROOT}${pathto}"
535     done < ${BUILDDIR}/${pkgname}/.fifo
536    
537     # very important: unsetting the '§' fieldseperator
538     IFS=$'\n'
539    }
540    
541    
542  ###################################################  ###################################################
543  # function build_doinstall                        #  # function build_doinstall                        #
544  # build_doinstall $PKGNAME                  #  # build_doinstall $PKGNAME                  #
545  # NOTE: this is an wrapper do install packages    #  # NOTE: this is an wrapper to install packages    #
546  ###################################################  ###################################################
547  build_doinstall()  build_doinstall()
548  {  {
# Line 413  build_doinstall() Line 550  build_doinstall()
550    
551   # sanity checks; abort if not given   # sanity checks; abort if not given
552   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."
553    
554   # this is only a wrapper   # this is only a wrapper
555    
556   # NOTE:   # NOTE:
# Line 428  build_doinstall() Line 565  build_doinstall()
565   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"
566   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"
567   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"
568     install_fifos ${pkgname} || die "install fifos ${pkgname}"
569  }  }
570    
571    
# Line 489  install_database_entry() Line 627  install_database_entry()
627    
628   # create fake file descriptors   # create fake file descriptors
629   # used by virtual and source packages   # used by virtual and source packages
630   for i in .dirs .symlinks .files .pipes .char   for i in .dirs .symlinks .files .pipes .char .fifo
631   do   do
632   touch ${dbrecorddir}/${i}   touch ${dbrecorddir}/${i}
633   done   done
# Line 507  install_database_entry() Line 645  install_database_entry()
645    
646   # normal packages needs these files   # normal packages needs these files
647   local i   local i
648   for i in .char .dirs .files .pipes .symlinks   for i in .char .dirs .files .pipes .symlinks .fifo
649   do   do
650   install -m 0644 ${BUILDDIR}/${pkgname}/${i} \   # make .fifo optional atm
651   ${dbrecorddir}/${i}   if [[ -f ${BUILDDIR}/${pkgname}/${i} ]]
652     then
653     install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i}
654     fi
655   done   done
656   ;;   ;;
657   esac   esac
# Line 721  remove_symlinks() Line 862  remove_symlinks()
862   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
863   if [ ! -L "${MROOT}${pathto}" ]   if [ ! -L "${MROOT}${pathto}" ]
864   then   then
865   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
866   echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}"
867   continue   continue
868   fi   fi
# Line 733  remove_symlinks() Line 874  remove_symlinks()
874   # 1=keep me   #   # 1=keep me   #
875   case ${retval} in   case ${retval} in
876   0)   0)
877   [[ ${VERBOSE} = on ]] && echo -e "\t<<< LINK: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< LINK: ${MROOT}${pathto}"
878   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
879   ;;   ;;
880    
881   1)   1)
882   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
883   echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}"
884   ;;   ;;
885   esac   esac
# Line 785  remove_files() Line 926  remove_files()
926   done   done
927    
928   # sanity checks; abort if not given   # sanity checks; abort if not given
929   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_files() \$pcat not given."
930   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_files() \$pname not given."
931   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_files() \$pver not given."
932   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_files() \$pbuild not given."
933   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
934    
935   # check needed global vars   # check needed global vars
# Line 805  remove_files() Line 946  remove_files()
946    
947   if [ ! -e "${MROOT}${pathto}" ]   if [ ! -e "${MROOT}${pathto}" ]
948   then   then
949   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
950   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"
951   continue   continue
952   fi   fi
# Line 831  remove_files() Line 972  remove_files()
972   case ${retval} in   case ${retval} in
973   # file is not protected - delete it   # file is not protected - delete it
974   0|3)   0|3)
975   [[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< FILE: ${MROOT}${pathto}"
976   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
977   ;;   ;;
978    
979   # file is protected, do not delete   # file is protected, do not delete
980   2)   2)
981   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
982   then   then
983   echo -en "${COLRED}"   echo -en "${COLRED}"
984   echo -n "! prot "   echo -n "! prot "
# Line 848  remove_files() Line 989  remove_files()
989    
990   # file is protected but ignored, delete the update/do nothing   # file is protected but ignored, delete the update/do nothing
991   4)   4)
992   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
993   then   then
994   echo -en "${COLRED}"   echo -en "${COLRED}"
995   echo -n "! ignr "   echo -n "! ignr "
# Line 860  remove_files() Line 1001  remove_files()
1001   esac   esac
1002   ;;   ;;
1003   1)   1)
1004   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1005   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"
1006   ;;   ;;
1007   esac   esac
# Line 879  remove_blockdevices() Line 1020  remove_blockdevices()
1020  {  {
1021   local pathto   local pathto
1022   local posix   local posix
1023     local user
1024     local group
1025   local IFS   local IFS
1026   local pcat   local pcat
1027   local pname   local pname
# Line 902  remove_blockdevices() Line 1045  remove_blockdevices()
1045   done   done
1046    
1047   # sanity checks; abort if not given   # sanity checks; abort if not given
1048   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given."
1049   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_blockdevices() \$pname not given."
1050   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_blockdevices() \$pver not given."
1051   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given."
1052   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1053    
1054   # check needed global vars   # check needed global vars
# Line 916  remove_blockdevices() Line 1059  remove_blockdevices()
1059   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1060   IFS=§   IFS=§
1061    
1062   while read pathto posix   while read pathto posix user group
1063   do   do
1064   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1065    
1066   [[ ${VERBOSE} = on ]] && echo -e "\t<<< PIPE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< PIPE: ${MROOT}${pathto}"
1067   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1068   done < ${MROOT}${INSTALLDB}/${pfull}/.pipes   done < ${MROOT}${INSTALLDB}/${pfull}/.pipes
1069    
# Line 937  remove_characterdevices() Line 1080  remove_characterdevices()
1080  {  {
1081   local pathto   local pathto
1082   local posix   local posix
1083     local user
1084     local group
1085   local IFS   local IFS
1086   local pcat   local pcat
1087   local pname   local pname
# Line 960  remove_characterdevices() Line 1105  remove_characterdevices()
1105   done   done
1106    
1107   # sanity checks; abort if not given   # sanity checks; abort if not given
1108   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given."
1109   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_characterdevices() \$pname not given."
1110   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_characterdevices() \$pver not given."
1111   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given."
1112   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1113    
1114   # check needed global vars   # check needed global vars
# Line 974  remove_characterdevices() Line 1119  remove_characterdevices()
1119   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1120   IFS=§   IFS=§
1121    
1122   while read pathto posix   while read pathto posix user group
1123   do   do
1124   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1125    
1126   [[ ${VERBOSE} = on ]] && echo -e "\t<<< CHAR: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< CHAR: ${MROOT}${pathto}"
1127   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1128   done < ${MROOT}${INSTALLDB}/${pfull}/.char   done < ${MROOT}${INSTALLDB}/${pfull}/.char
1129    
# Line 988  remove_characterdevices() Line 1133  remove_characterdevices()
1133    
1134    
1135  ###################################################  ###################################################
1136    # function remove_fifos                           #
1137    # remove_fifos $PKGNAME                     #
1138    ###################################################
1139    remove_fifos()
1140    {
1141     local pathto
1142     local posix
1143     local user
1144     local group
1145     local IFS
1146     local pcat
1147     local pname
1148     local pver
1149     local pbuild
1150     local i
1151     local pfull
1152    
1153     IFS=$'\n'
1154    
1155     # very basic getops
1156     for i in $*
1157     do
1158     case $1 in
1159     --pcat|-c) shift; pcat="$1" ;;
1160     --pname|-n) shift; pname="$1" ;;
1161     --pver|-v) shift; pver="$1" ;;
1162     --pbuild|-b) shift; pbuild="$1" ;;
1163     esac
1164     shift
1165     done
1166    
1167     # sanity checks; abort if not given
1168     [ -z "${pcat}" ] && die "remove_fifos() \$pcat not given."
1169     [ -z "${pname}" ] && die "remove_fifos() \$pname not given."
1170     [ -z "${pver}" ] && die "remove_fifos() \$pver not given."
1171     [ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given."
1172     pfull="${pcat}/${pname}-${pver}-${pbuild}"
1173    
1174     # check needed global vars
1175     [ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set."
1176    
1177     # make it optional atm !!
1178     #[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found"
1179     [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return
1180    
1181     # sets fieldseperator to "§" instead of " "
1182     IFS=§
1183    
1184     while read pathto posix user group
1185     do
1186     [ -z "${pathto}" ] && continue
1187    
1188     mqueryfeature "verbose" && echo -e "\t<<< FIFO: ${MROOT}${pathto}"
1189     rm "${MROOT}${pathto}"
1190     done < ${MROOT}${INSTALLDB}/${pfull}/.fifo
1191    
1192     # very important: unsetting the '§' fieldseperator
1193     IFS=$'\n'
1194    }
1195    
1196    
1197    ###################################################
1198  # function remove_direcories                      #  # function remove_direcories                      #
1199  # remove_direcories $PKGNAME                #  # remove_direcories $PKGNAME                #
1200  ###################################################  ###################################################
# Line 1018  remove_directories() Line 1225  remove_directories()
1225   done   done
1226    
1227   # sanity checks; abort if not given   # sanity checks; abort if not given
1228   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_directories() \$pcat not given."
1229   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_directories() \$pname not given."
1230   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_directories() \$pver not given."
1231   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given."
1232   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1233    
1234   # check needed global vars   # check needed global vars
# Line 1039  remove_directories() Line 1246  remove_directories()
1246    
1247   if [ ! -d "${MROOT}${pathto}" ]   if [ ! -d "${MROOT}${pathto}" ]
1248   then   then
1249   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1250   echo -e "${COLRED}! exist${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1251   continue   continue
1252   fi   fi
# Line 1047  remove_directories() Line 1254  remove_directories()
1254   # exclude .keep directories   # exclude .keep directories
1255   if [ -f "${MROOT}${pathto}/.keep" ]   if [ -f "${MROOT}${pathto}/.keep" ]
1256   then   then
1257   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1258   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1259   continue   continue
1260   fi   fi
# Line 1060  remove_directories() Line 1267  remove_directories()
1267    
1268   if rmdir "${MROOT}${pathto}" &> /dev/null   if rmdir "${MROOT}${pathto}" &> /dev/null
1269   then   then
1270   [[ ${VERBOSE} = on ]] && echo -e "\t<<< DIR:  ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< DIR:  ${MROOT}${pathto}"
1271   else   else
1272   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1273   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1274   fi   fi
1275   done   done
# Line 1075  remove_directories() Line 1282  remove_directories()
1282  ###################################################  ###################################################
1283  # function build_douninstall                      #  # function build_douninstall                      #
1284  # build_douninstall $PKGNAME                #  # build_douninstall $PKGNAME                #
1285  # NOTE: this is an wrapper do remove packages     #  # NOTE: this is an wrapper to remove packages     #
1286  ###################################################  ###################################################
1287  build_douninstall()  build_douninstall()
1288  {  {
# Line 1109  build_douninstall() Line 1316  build_douninstall()
1316   # !! we use § as field seperator !!   # !! we use § as field seperator !!
1317   # doing so prevent us to get errors by filenames with spaces   # doing so prevent us to get errors by filenames with spaces
1318    
1319   for i in symlinks files blockdevices characterdevices directories   for i in symlinks files blockdevices characterdevices directories fifos
1320   do   do
1321   remove_${i} \   remove_${i} \
1322   --pcat "${pcat}" \   --pcat "${pcat}" \
# Line 1120  build_douninstall() Line 1327  build_douninstall()
1327   done   done
1328  }  }
1329    
1330    # convertmirrors [uri]
1331    convertmirrors()
1332    {
1333     local uri="$1"
1334     local scheme
1335     local mirror
1336     local mirrors
1337     local addon
1338     local real_uri
1339     local output
1340    
1341     # needs
1342     [[ -z ${MIRRORS} ]] && die "convertmirrors(): no mirrors defined!"
1343     [[ -z ${SOURCEFORGE_MIRRORS} ]] && die "convertmirrors(): no sourceforge mirrors defined!"
1344     [[ -z ${GNU_MIRRORS} ]] && die "convertmirrors(): no gnu mirrors defined!"
1345     [[ -z ${GNOME_MIRRORS} ]] && die "convertmirrors(): no gnome mirrors defined!"
1346     [[ -z ${KDE_MIRRORS} ]] && die "convertmirrors(): no kde mirrors defined!"
1347    
1348     # check known uri schemes
1349     case ${uri} in
1350     http://*|https://*|ftp://*|ftps://*) mirrors="" ;;
1351     mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;;
1352     package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;;
1353     gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;;
1354     sourceforge://*) mirrors="${SOURCEFORGE_MIRRORS}"; scheme="sourceforge://" ;;
1355     gnome://*) mirrors="${GNOME_MIRRORS}"; scheme="gnome://" ;;
1356     kde://*) mirrors="${KDE_MIRRORS}"; scheme="kde://" ;;
1357     *) die "convertmirror(): unsupported uri scheme in '${uri}'!" ;;
1358     esac
1359    
1360     if [[ ! -z ${mirrors} ]]
1361     then
1362     for mirror in ${mirrors}
1363     do
1364     # add a whitespace to the output
1365     [[ -z ${output} ]] || output+=" "
1366     output+="${mirror}${addon}/${uri/${scheme}/}"
1367     done
1368     else
1369     output="${uri}"
1370     fi
1371    
1372     echo "${output}"
1373    }
1374    
1375    mdownload()
1376    {
1377     local i
1378     local uri
1379     local real_uris
1380     local mirror
1381     local outputfile
1382     local outputdir
1383     local retval
1384     local wget_opts
1385    
1386     # very basic getops
1387     for i in $*
1388     do
1389     case $1 in
1390     --uri|-u) shift; uri="$1" ;;
1391     --dir|-d) shift; outputdir="$1" ;;
1392     esac
1393     shift
1394     done
1395    
1396     # sanity checks; abort if not given
1397     [[ -z ${uri} ]] && die "mdownload(): no uri given!"
1398     [[ -z ${outputdir} ]] && die "mdownload(): no dir given!"
1399    
1400     # convert mirrored uris to the real ones
1401     real_uris="$(convertmirrors ${uri})"
1402    
1403     # verbose or not
1404     mqueryfeature "!verbose" && wget_opts="--quiet"
1405    
1406     # filter wget options if busybox was found
1407     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1408    
1409     # create outputdir
1410     [[ ! -d ${outputdir} ]] && install -d "${outputdir}"
1411    
1412     for mirror in ${real_uris}
1413     do
1414     # get the name of the output file
1415     outputfile="${mirror##*/}"
1416    
1417     wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}"
1418     retval="$?"
1419     if [[ ${retval} = 0 ]]
1420     then
1421     break
1422     else
1423     continue
1424     fi
1425     done
1426    
1427     # return wget retval
1428     return "${retval}"
1429    }
1430    
1431  # fetch_packages /path/to/mage/file1 /path/to/mage/file2  # fetch_packages /path/to/mage/file1 /path/to/mage/file2
1432  fetch_packages()  fetch_packages()
1433  {  {
1434     local i
1435   local list="$@"   local list="$@"
1436   local pkg   local pkg
1437   local mirr   local mirr
# Line 1131  fetch_packages() Line 1440  fetch_packages()
1440   local opt   local opt
1441   local count_current   local count_current
1442   local count_total   local count_total
1443     local wget_opts
1444    
1445   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."
1446    
1447     # filter wget command if busybox was found
1448     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1449    
1450   # get count of total packages   # get count of total packages
1451   declare -i count_current=0   declare -i count_current=0
1452   declare -i count_total=0   declare -i count_total=0
# Line 1172  fetch_packages() Line 1485  fetch_packages()
1485   continue   continue
1486   fi   fi
1487    
1488   for mirr in ${MIRRORS}   echo -ne " ${COLBLUE}***${COLDEFAULT}"
1489   do   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1490   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  
   
1491   if [ ! -f ${PKGDIR}/${pkg} ]   if [ ! -f ${PKGDIR}/${pkg} ]
1492   then   then
1493   die "Could not download ${pkg}"   die "Package '${pkg}' after download not found in '${PKGDIR}'"
1494   fi   fi
1495   done   done
1496    
# Line 1223  syncmage() Line 1518  syncmage()
1518   done   done
1519    
1520   # clean up backup files (foo~)   # clean up backup files (foo~)
1521   find ${MAGEDIR} -name *~ -exec rm '{}' ';'   find ${MAGEDIR} -name \*~ -exec rm '{}' ';'
1522    
1523   # check if a newer mage version is available   # check if a newer mage version is available
1524   is_newer_mage_version_available   is_newer_mage_version_available
# Line 1235  syncmage_tarball() Line 1530  syncmage_tarball()
1530   local latest_md5   local latest_md5
1531   local temp="$(mktemp -d)"   local temp="$(mktemp -d)"
1532   local mirr mymirr   local mirr mymirr
1533     local opt
1534     local tar_opts
1535     local wget_opts
1536    
1537   # try to get the md5 marked as latest on the server   # try to get the md5 marked as latest on the server
1538   latest_md5="mage-latest.md5"   latest_md5="mage-latest.md5"
# Line 1242  syncmage_tarball() Line 1540  syncmage_tarball()
1540   # try to get the tarball marked as latest on the server   # try to get the tarball marked as latest on the server
1541   latest_tarball="mage-latest.tar.bz2"   latest_tarball="mage-latest.tar.bz2"
1542    
1543     # filter wget command if busybox was found
1544     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1545    
1546   for mirr in ${MIRRORS}   for mirr in ${MIRRORS}
1547   do   do
1548   # path without distribution   # path without distribution
# Line 1249  syncmage_tarball() Line 1550  syncmage_tarball()
1550    
1551   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1552   echo "fetching latest md5 from ${mymirr} ..."   echo "fetching latest md5 from ${mymirr} ..."
1553     mqueryfeature "!verbose" && opt="--quiet"
1554   wget \   wget \
1555   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
1556   --directory-prefix=${temp} \   --directory-prefix=${temp} \
1557   ${mymirr}/rsync/tarballs/${latest_md5}   ${opt} ${mymirr}/rsync/tarballs/${latest_md5}
1558    
1559   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1560   echo "fetching latest tarball from ${mymirr} ..."   echo "fetching latest tarball from ${mymirr} ..."
   
1561   wget \   wget \
1562   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
1563   --directory-prefix=${temp} \   --directory-prefix=${temp} \
1564   ${mymirr}/rsync/tarballs/${latest_tarball}   ${opt} ${mymirr}/rsync/tarballs/${latest_tarball}
1565   if [[ $? = 0 ]]   if [[ $? = 0 ]]
1566   then   then
1567   break   break
# Line 1282  syncmage_tarball() Line 1577  syncmage_tarball()
1577   then   then
1578   die "md5 is missing ... aborting"   die "md5 is missing ... aborting"
1579   else   else
1580   ( cd ${temp}; md5sum --check ${lastest_md5} ) || die "md5 for ${lastest_tarball} failed"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1581     echo -n "checking md5sum... "
1582     ( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed"
1583   fi   fi
1584    
1585   if [[ -d ${MAGEDIR} ]]   if [[ -d ${MAGEDIR} ]]
# Line 1292  syncmage_tarball() Line 1589  syncmage_tarball()
1589   rm -rf ${MAGEDIR}   rm -rf ${MAGEDIR}
1590   fi   fi
1591    
1592     if need_busybox_support tar
1593     then
1594     tar_opts="xjf"
1595     else
1596     tar_opts="xjmf"
1597     fi
1598    
1599   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1600   echo "updating mage-tree from tarball ..."   echo "updating mage-tree from tarball ..."
1601   # unpack in dirname of MAGEDIR, as the tarball has already the mage   # unpack in dirname of MAGEDIR, as the tarball has already the mage
1602   tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"   tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1603    
1604   if [[ -d ${temp} ]]   if [[ -d ${temp} ]]
1605   then   then
# Line 1341  xtitleclean() Line 1645  xtitleclean()
1645  }  }
1646    
1647    
1648  # cuts full pathnames or versioniezed names down to basename  # cuts full pathnames or versionized names down to basename
1649  choppkgname()  choppkgname()
1650  {  {
1651   #we want this only if full name was used   #we want this only if full name was used
# Line 1424  get_highest_magefile() Line 1728  get_highest_magefile()
1728   local magefile   local magefile
1729    
1730   # do not list the content of a directory, only the name (-d)   # do not list the content of a directory, only the name (-d)
1731   for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*)   for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/* 2> /dev/null)
1732   do   do
1733   [[ -z ${magefile} ]] && continue   [[ -z ${magefile} ]] && continue
1734   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
# Line 1433  get_highest_magefile() Line 1737  get_highest_magefile()
1737   then   then
1738   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
1739   #for debug only   #for debug only
1740   [[ ${MAGEDEBUG} = on ]] && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"   mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"
1741   fi   fi
1742   done   done
1743    
 # 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  
   
1744   echo "${HIGHEST_MAGEFILE}"   echo "${HIGHEST_MAGEFILE}"
1745   return 0   return 0
1746  }  }
# Line 1751  virtuals_add() Line 2033  virtuals_add()
2033    
2034  #deletes pakages from virtual database  #deletes pakages from virtual database
2035  #$1 virtualname; $2 pkgname  #$1 virtualname; $2 pkgname
2036  virtuals_del() {  virtuals_del()
2037    {
2038    
2039   local virtualname="$1"   local virtualname="$1"
2040   local pkgname="$2"   local pkgname="$2"
# Line 1862  minclude() Line 2145  minclude()
2145   then   then
2146   for i in $*   for i in $*
2147   do   do
2148   [[ ${MAGEDEBUG} = on ]] && \   mqueryfeature "debug" && \
2149   echo "--- Including ${MAGEDIR}/include/${i}.minc"   echo "--- Including ${MAGEDIR}/include/${i}.minc"
2150   source ${MAGEDIR}/include/${i}.minc   source ${MAGEDIR}/include/${i}.minc
2151   done   done
2152   [[ ${MAGEDEBUG} = on ]] && echo   mqueryfeature "debug" && echo
2153   fi   fi
2154  }  }
2155    
# Line 2310  mage_install() Line 2593  mage_install()
2593   if [[ -n ${MAGE_TARGETS} ]]   if [[ -n ${MAGE_TARGETS} ]]
2594   then   then
2595   # basic svn compat   # basic svn compat
2596   if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2597   then   then
2598   for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2   for i in ${SMAGESCRIPTSDIR}/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2599   do   do
2600   smage2file="${i}"   smage2file="${i}"
2601   done   done
# Line 2323  mage_install() Line 2606  mage_install()
2606   elif [[ -n ${SPLIT_PACKAGE_BASE} ]]   elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2607   then   then
2608   # basic svn compat   # basic svn compat
2609   if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2610   then   then
2611   for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2   for i in ${SMAGESCRIPTSDIR}/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2612   do   do
2613   smage2file="${i}"   smage2file="${i}"
2614   done   done
# Line 2335  mage_install() Line 2618  mage_install()
2618    
2619   else   else
2620   # basic svn compat   # basic svn compat
2621   if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2622   then   then
2623   for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2   for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2624   do   do
2625   smage2file="${i}"   smage2file="${i}"
2626   done   done
# Line 2476  md5sum_packages() Line 2759  md5sum_packages()
2759   then   then
2760   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2761   echo -ne "checking md5sum (${count_current}/${count_total}): "   echo -ne "checking md5sum (${count_current}/${count_total}): "
2762   ( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed"   ( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed"
2763   else   else
2764   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2765   echo -e "!! no md5sum file found for ${pkgfile} :("   echo -e "!! no md5sum file found for ${pkgfile} :("
# Line 2689  mage_uninstall() Line 2972  mage_uninstall()
2972   unset -f postremove   unset -f postremove
2973  }  }
2974    
2975  show_etc_update_mesg() {  show_etc_update_mesg()
2976    {
2977   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0
2978    
2979   echo   echo
# Line 2851  export_inherits() Line 3135  export_inherits()
3135   eval "${functions}() { ${include}_${functions} ; }"   eval "${functions}() { ${include}_${functions} ; }"
3136    
3137   # debug   # debug
3138   [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"   mqueryfeature "debug" && typeset -f "${functions}"
3139    
3140   shift   shift
3141   done   done
# Line 2923  EOF Line 3207  EOF
3207   return 0   return 0
3208  }  }
3209    
3210    # need_busybox_support ${cmd}
3211    # return 0 (no error = needs busybox support) or return 1 (error = no busybox support required)
3212    need_busybox_support()
3213    {
3214     local cmd
3215     cmd="$1"
3216    
3217     if [[ -x /bin/busybox ]]
3218     then
3219     if [[ $(readlink $(which ${cmd})) = /bin/busybox ]]
3220     then
3221     # needs busybox support
3222     return 0
3223     fi
3224     fi
3225    
3226     # no busybox
3227     return 1
3228    }
3229    
3230    # busybox_filter_wget_options ${wget_opts}
3231    busybox_filter_wget_options()
3232    {
3233     local opts="$@"
3234     local i
3235     local fixed_opts
3236    
3237     if need_busybox_support wget
3238     then
3239     for i in ${opts}
3240     do
3241     # show only the allowed ones
3242     case ${i} in
3243     -c|--continue) fixed_opts+=" -c" ;;
3244     -s|--spider) fixed_opts+=" -s" ;;
3245     -q|--quiet) fixed_opts+=" -q" ;;
3246     -O|--output-document) shift; fixed_opts+=" -O $1" ;;
3247     --header) shift; fixed_opts+=" --header $1" ;;
3248     -Y|--proxy) shift; fixed_opts+=" -Y $1" ;;
3249     -P) shift; fixed_opts+=" -P $1" ;;
3250     --no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;;
3251     -U|--user-agent) shift; fixed_opts+=" -U ${i}" ;;
3252     # simply drop all other opts
3253     *) continue ;;
3254     esac
3255     done
3256    
3257     echo "${fixed_opts}"
3258     else
3259     echo "${opts}"
3260     fi
3261    }
3262    
3263    have_root_privileges()
3264    {
3265     local retval
3266    
3267     if [[ $(id -u) = 0 ]]
3268     then
3269     retval=0
3270     else
3271     retval=1
3272     fi
3273    
3274     return ${retval}
3275    }
3276    
3277    known_mage_feature()
3278    {
3279     local feature="$1"
3280     local retval
3281    
3282     case "${feature}" in
3283     autosvc|!autosvc) retval=0 ;;
3284     buildlog|!buildlog) retval=0 ;;
3285     ccache|!ccache) retval=0 ;;
3286     check|!check) retval=0 ;;
3287     compressdoc|!compressdoc) retval=0 ;;
3288     distcc|!distcc) retval=0 ;;
3289     kernelsrcunpack|!kernelsrcunpack) retval=0 ;;
3290     libtool|!libtool) retval=0 ;;
3291     linuxsymlink|!linuxsymlink) retval=0 ;;
3292     pkgbuild|!pkgbuild) retval=0 ;;
3293     purge|!purge) retval=0 ;;
3294     qalint|!qalint) retval=0 ;;
3295     regentree|!regentree) retval=0 ;;
3296     resume|!resume) retval=0 ;;
3297     stepbystep|!stepbystep) retval=0 ;;
3298     srcpkgbuild|!srcpkgbuild) retval=0 ;;
3299     srcpkgtarball|!srcpkgtarball) retval=0 ;;
3300     strip|!strip) retval=0 ;;
3301     *) retval=1 ;;
3302     esac
3303    
3304     return "${retval}"
3305    }
3306    
3307    load_mage_features()
3308    {
3309     for i in ${MAGE_FEATURES_GLOBAL[*]} ${MAGE_FEATURES[*]}
3310     do
3311     FVERBOSE=off msetfeature ${i}
3312     done
3313    }
3314    
3315    msetfeature()
3316    {
3317     local feature
3318     local count
3319     local i
3320     local found
3321    
3322     for feature in $@
3323     do
3324     found=0
3325     count="${#MAGE_FEATURES_CURRENT[*]}"
3326    
3327     if ! known_mage_feature "${feature}"
3328     then
3329     [[ ${FVERBOSE} = off ]] || echo "unknown feature ${feature}, ignoring it"
3330     return 3
3331     fi
3332    
3333     for ((i=0; i<count; i++))
3334     do
3335     if [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature} ]]
3336     then
3337     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' already enabled${COLDEFAULT}"
3338     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3339     found=1
3340     elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = !${feature} ]]
3341     then
3342     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' currently disabled, enabling it!${COLDEFAULT}"
3343     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3344     found=1
3345     elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature//!} ]]
3346     then
3347     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature//!}' currently enabled, disabling it!${COLDEFAULT}"
3348     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3349     found=1
3350     fi
3351     done
3352    
3353     # if the feature was not found after proccessing the whole array
3354     # it was not declared. in this case enable it
3355     if [[ ${found} = 0 ]]
3356     then
3357     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' was not declared, enabling it!${COLDEFAULT}"
3358     MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )
3359     fi
3360    
3361     export MAGE_FEATURE_CURRENT
3362     done
3363    }
3364    
3365    mqueryfeature()
3366    {
3367     local feature="$1"
3368     local retval=1
3369     local i
3370    
3371     if known_mage_feature "${feature}"
3372     then
3373     for i in ${MAGE_FEATURES_CURRENT[*]}
3374     do
3375     if [[ ${i} = ${feature} ]]
3376     then
3377     retval=0
3378     break # found break here
3379     fi
3380     done
3381     else
3382     retval=3
3383     fi
3384    
3385     return ${retval}
3386    }
3387    
3388    mprintfeatures()
3389    {
3390     echo "Global features:  ${MAGE_FEATURES_GLOBAL[*]}"
3391     echo "Local features:   ${MAGE_FEATURES[*]}"
3392     echo "Current features: ${MAGE_FEATURES_CURRENT[*]}"
3393    }

Legend:
Removed from v.1083  
changed lines
  Added in v.1625