Magellan Linux

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

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

revision 943 by niro, Fri Nov 20 22:39:11 2009 UTC revision 1653 by niro, Fri Jan 13 23:17:40 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    mcheckemptydir()
86    {
87     local dir="$1"
88     local retval=1
89    
90     if [[ ! -d ${dir} ]]
91     then
92     echo "mcheckemptydir(): '${dir}' is not a directory!"
93     retval=3
94     else
95     shopt -s nullglob dotglob
96     files=( ${dir}/* )
97     (( ${#files[*]} )) || retval=0
98     shopt -u nullglob dotglob
99     fi
100    
101     return ${retval}
102    }
103    
104  unpack_packages()  unpack_packages()
105  {  {
106   local list="$@"   local list="$@"
# Line 23  unpack_packages() Line 109  unpack_packages()
109   local pkgtype   local pkgtype
110   local count_current   local count_current
111   local count_total   local count_total
112     local tar_opts
113    
114   # get count of total packages   # get count of total packages
115   declare -i count_current=0   declare -i count_current=0
# Line 54  unpack_packages() Line 141  unpack_packages()
141   continue   continue
142   fi   fi
143    
144     # busybox?
145     if need_busybox_support tar
146     then
147     tar_opts="xjf"
148     else
149     tar_opts="xjmf"
150     fi
151    
152   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "
153   tar xjmf ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"   tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"
154   done   done
155    
156   # add a crlf for a better view   # add a crlf for a better view
# Line 130  install_directories() Line 225  install_directories()
225   while read pathto posix user group   while read pathto posix user group
226   do   do
227   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
228   [[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR:  ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> DIR:  ${MROOT}${pathto}"
   
229    
230   # monitors /etc/env.d -> env-rebuild   # monitors /etc/env.d -> env-rebuild
231   [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true   [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true
# Line 207  install_files() Line 301  install_files()
301   case ${retval} in   case ${retval} in
302   # file is not protected - (over)write it   # file is not protected - (over)write it
303   0|3)   0|3)
304   [[ ${VERBOSE} = on ]] && echo -e "\t>>> FILE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> FILE: ${MROOT}${pathto}"
305   install -m "${posix}" -o "${user}" -g "${group}" \   install -m "${posix}" -o "${user}" -g "${group}" \
306   ${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \   ${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \
307   "${MROOT}${pathto}"   "${MROOT}${pathto}"
# Line 219  install_files() Line 313  install_files()
313   "${user}" \   "${user}" \
314   "${group}" \   "${group}" \
315   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
316   "${MROOT}${pathto}")" \   "${MROOT}${pathto}")" \
317   "${md5sum}"   "${md5sum}"
318   ;;   ;;
319    
320   # file is protected, write backup file   # file is protected, write backup file
321   2)   2)
322   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
323   then   then
324   echo -en "${COLRED}"   echo -en "${COLRED}"
325   echo -n "! prot "   echo -n "! prot "
# Line 246  install_files() Line 340  install_files()
340   "${user}" \   "${user}" \
341   "${group}" \   "${group}" \
342   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
343   "${dest_protected}")" \   "${dest_protected}")" \
344   "${md5sum}"   "${md5sum}"
345    
346   # update global MAGE_PROTECT_COUNTER   # update global MAGE_PROTECT_COUNTER
# Line 256  install_files() Line 350  install_files()
350    
351   # file is protected but ignored, delete the update/do nothing   # file is protected but ignored, delete the update/do nothing
352   4)   4)
353   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
354   then   then
355   echo -en "${COLRED}"   echo -en "${COLRED}"
356   echo -n "! ignr "   echo -n "! ignr "
357   echo -en "${COLDEFAULT}"   echo -en "${COLDEFAULT}"
358   echo " === FILE: ${MROOT}${pathto}"   echo " === FILE: ${MROOT}${pathto}"
359   fi   fi
360   # simply do nothing here   # simply do nothing here - only fix mtime
361     fix_descriptor ${pkgname}/.files \
362     "${pathto}" \
363     "${posix}" \
364     "${user}" \
365     "${group}" \
366     "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
367     "${MROOT}${pathto}")" \
368     "${md5sum}"
369   ;;   ;;
370   esac   esac
371   done < ${BUILDDIR}/${pkgname}/.files   done < ${BUILDDIR}/${pkgname}/.files
# Line 307  install_symlinks() Line 409  install_symlinks()
409   while read pathto posix link mtime   while read pathto posix link mtime
410   do   do
411   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
412   [[ ${VERBOSE} = on ]] && echo -e "\t>>> LINK: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> LINK: ${MROOT}${pathto}"
413    
414   ln -snf "${link}" "${MROOT}${pathto}"   ln -snf "${link}" "${MROOT}${pathto}"
415    
# Line 339  install_blockdevices() Line 441  install_blockdevices()
441   local pkgname="$1"   local pkgname="$1"
442   local pathto   local pathto
443   local posix   local posix
444     local user
445     local group
446   local IFS   local IFS
447    
448   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 352  install_blockdevices() Line 456  install_blockdevices()
456   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
457   IFS=§   IFS=§
458    
459   while read pathto posix   while read pathto posix major minor user group
460   do   do
461   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
462   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> PIPE: ${MROOT}${pathto}"
463    
464   mkfifo -m "${posix}" "${MROOT}$pathto"   mknod -m "${posix}" "${MROOT}${pathto}"
465     # make it optional atm !!
466     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
467     then
468     chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}"
469     fi
470   done < ${BUILDDIR}/${pkgname}/.pipes   done < ${BUILDDIR}/${pkgname}/.pipes
471    
472   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
# Line 376  install_characterdevices() Line 485  install_characterdevices()
485   local posix   local posix
486   local major   local major
487   local minor   local minor
488     local user
489     local group
490   local IFS   local IFS
491    
492   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 389  install_characterdevices() Line 500  install_characterdevices()
500   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
501   IFS=§   IFS=§
502    
503   while read pathto posix major minor   while read pathto posix major minor user group
504   do   do
505   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
506   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> CHAR: ${MROOT}${pathto}"
507    
508   mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor}   mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}"
509    
510     # make it optional atm !!
511     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
512     then
513     chown "${user}:${group}" "${MROOT}${pathto}"
514     fi
515   done < ${BUILDDIR}/${pkgname}/.char   done < ${BUILDDIR}/${pkgname}/.char
516    
517   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
518   IFS=$'\n'   IFS=$'\n'
519  }  }
520    
521    ###################################################
522    # function install_fifos                          #
523    # install_fifos $PKGNAME                    #
524    ###################################################
525    install_fifos()
526    {
527     local pkgname="$1"
528     local pathto
529     local posix
530     local user
531     local group
532     local IFS
533    
534     # sanity checks; abort if not given
535     [ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given."
536    
537     # check needed global vars
538     [ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set."
539    
540     # make it optional atm !!
541     #[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found"
542     [ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return
543    
544     # sets fieldseperator to "§" instead of " "
545     IFS=§
546    
547     while read pathto posix user group
548     do
549     [ -z "${pathto}" ] && continue
550     mqueryfeature "verbose" && echo -e "\t>>> FIFO: ${MROOT}${pathto}"
551    
552     mkfifo -m "${posix}" "${MROOT}${pathto}"
553     chown "${user}:${group}" "${MROOT}${pathto}"
554     done < ${BUILDDIR}/${pkgname}/.fifo
555    
556     # very important: unsetting the '§' fieldseperator
557     IFS=$'\n'
558    }
559    
560    
561  ###################################################  ###################################################
562  # function build_doinstall                        #  # function build_doinstall                        #
563  # build_doinstall $PKGNAME                  #  # build_doinstall $PKGNAME                  #
564  # NOTE: this is an wrapper do install packages    #  # NOTE: this is an wrapper to install packages    #
565  ###################################################  ###################################################
566  build_doinstall()  build_doinstall()
567  {  {
# Line 413  build_doinstall() Line 569  build_doinstall()
569    
570   # sanity checks; abort if not given   # sanity checks; abort if not given
571   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."
572    
573   # this is only a wrapper   # this is only a wrapper
574    
575   # NOTE:   # NOTE:
# Line 428  build_doinstall() Line 584  build_doinstall()
584   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"
585   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"
586   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"
587     install_fifos ${pkgname} || die "install fifos ${pkgname}"
588  }  }
589    
590    
# Line 489  install_database_entry() Line 646  install_database_entry()
646    
647   # create fake file descriptors   # create fake file descriptors
648   # used by virtual and source packages   # used by virtual and source packages
649   for i in .dirs .symlinks .files .pipes .char   for i in .dirs .symlinks .files .pipes .char .fifo
650   do   do
651   touch ${dbrecorddir}/${i}   touch ${dbrecorddir}/${i}
652   done   done
# Line 507  install_database_entry() Line 664  install_database_entry()
664    
665   # normal packages needs these files   # normal packages needs these files
666   local i   local i
667   for i in .char .dirs .files .pipes .symlinks   for i in .char .dirs .files .pipes .symlinks .fifo
668   do   do
669   install -m 0644 ${BUILDDIR}/${pkgname}/${i} \   # make .fifo optional atm
670   ${dbrecorddir}/${i}   if [[ -f ${BUILDDIR}/${pkgname}/${i} ]]
671     then
672     install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i}
673     fi
674   done   done
675   ;;   ;;
676   esac   esac
# Line 721  remove_symlinks() Line 881  remove_symlinks()
881   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
882   if [ ! -L "${MROOT}${pathto}" ]   if [ ! -L "${MROOT}${pathto}" ]
883   then   then
884   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
885   echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}"
886   continue   continue
887   fi   fi
# Line 733  remove_symlinks() Line 893  remove_symlinks()
893   # 1=keep me   #   # 1=keep me   #
894   case ${retval} in   case ${retval} in
895   0)   0)
896   [[ ${VERBOSE} = on ]] && echo -e "\t<<< LINK: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< LINK: ${MROOT}${pathto}"
897   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
898   ;;   ;;
899    
900   1)   1)
901   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
902   echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}"
903   ;;   ;;
904   esac   esac
# Line 785  remove_files() Line 945  remove_files()
945   done   done
946    
947   # sanity checks; abort if not given   # sanity checks; abort if not given
948   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_files() \$pcat not given."
949   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_files() \$pname not given."
950   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_files() \$pver not given."
951   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_files() \$pbuild not given."
952   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
953    
954   # check needed global vars   # check needed global vars
# Line 805  remove_files() Line 965  remove_files()
965    
966   if [ ! -e "${MROOT}${pathto}" ]   if [ ! -e "${MROOT}${pathto}" ]
967   then   then
968   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
969   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"
970   continue   continue
971   fi   fi
# Line 831  remove_files() Line 991  remove_files()
991   case ${retval} in   case ${retval} in
992   # file is not protected - delete it   # file is not protected - delete it
993   0|3)   0|3)
994   [[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< FILE: ${MROOT}${pathto}"
995   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
996   ;;   ;;
997    
998   # file is protected, do not delete   # file is protected, do not delete
999   2)   2)
1000   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
1001   then   then
1002   echo -en "${COLRED}"   echo -en "${COLRED}"
1003   echo -n "! prot "   echo -n "! prot "
# Line 848  remove_files() Line 1008  remove_files()
1008    
1009   # file is protected but ignored, delete the update/do nothing   # file is protected but ignored, delete the update/do nothing
1010   4)   4)
1011   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
1012   then   then
1013   echo -en "${COLRED}"   echo -en "${COLRED}"
1014   echo -n "! ignr "   echo -n "! ignr "
# Line 860  remove_files() Line 1020  remove_files()
1020   esac   esac
1021   ;;   ;;
1022   1)   1)
1023   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1024   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"
1025   ;;   ;;
1026   esac   esac
# Line 879  remove_blockdevices() Line 1039  remove_blockdevices()
1039  {  {
1040   local pathto   local pathto
1041   local posix   local posix
1042     local user
1043     local group
1044   local IFS   local IFS
1045   local pcat   local pcat
1046   local pname   local pname
# Line 902  remove_blockdevices() Line 1064  remove_blockdevices()
1064   done   done
1065    
1066   # sanity checks; abort if not given   # sanity checks; abort if not given
1067   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given."
1068   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_blockdevices() \$pname not given."
1069   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_blockdevices() \$pver not given."
1070   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given."
1071   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1072    
1073   # check needed global vars   # check needed global vars
# Line 916  remove_blockdevices() Line 1078  remove_blockdevices()
1078   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1079   IFS=§   IFS=§
1080    
1081   while read pathto posix   while read pathto posix user group
1082   do   do
1083   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1084    
1085   [[ ${VERBOSE} = on ]] && echo -e "\t<<< PIPE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< PIPE: ${MROOT}${pathto}"
1086   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1087   done < ${MROOT}${INSTALLDB}/${pfull}/.pipes   done < ${MROOT}${INSTALLDB}/${pfull}/.pipes
1088    
# Line 937  remove_characterdevices() Line 1099  remove_characterdevices()
1099  {  {
1100   local pathto   local pathto
1101   local posix   local posix
1102     local user
1103     local group
1104   local IFS   local IFS
1105   local pcat   local pcat
1106   local pname   local pname
# Line 960  remove_characterdevices() Line 1124  remove_characterdevices()
1124   done   done
1125    
1126   # sanity checks; abort if not given   # sanity checks; abort if not given
1127   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given."
1128   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_characterdevices() \$pname not given."
1129   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_characterdevices() \$pver not given."
1130   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given."
1131   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1132    
1133   # check needed global vars   # check needed global vars
# Line 974  remove_characterdevices() Line 1138  remove_characterdevices()
1138   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1139   IFS=§   IFS=§
1140    
1141   while read pathto posix   while read pathto posix user group
1142   do   do
1143   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1144    
1145   [[ ${VERBOSE} = on ]] && echo -e "\t<<< CHAR: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< CHAR: ${MROOT}${pathto}"
1146   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1147   done < ${MROOT}${INSTALLDB}/${pfull}/.char   done < ${MROOT}${INSTALLDB}/${pfull}/.char
1148    
# Line 988  remove_characterdevices() Line 1152  remove_characterdevices()
1152    
1153    
1154  ###################################################  ###################################################
1155    # function remove_fifos                           #
1156    # remove_fifos $PKGNAME                     #
1157    ###################################################
1158    remove_fifos()
1159    {
1160     local pathto
1161     local posix
1162     local user
1163     local group
1164     local IFS
1165     local pcat
1166     local pname
1167     local pver
1168     local pbuild
1169     local i
1170     local pfull
1171    
1172     IFS=$'\n'
1173    
1174     # very basic getops
1175     for i in $*
1176     do
1177     case $1 in
1178     --pcat|-c) shift; pcat="$1" ;;
1179     --pname|-n) shift; pname="$1" ;;
1180     --pver|-v) shift; pver="$1" ;;
1181     --pbuild|-b) shift; pbuild="$1" ;;
1182     esac
1183     shift
1184     done
1185    
1186     # sanity checks; abort if not given
1187     [ -z "${pcat}" ] && die "remove_fifos() \$pcat not given."
1188     [ -z "${pname}" ] && die "remove_fifos() \$pname not given."
1189     [ -z "${pver}" ] && die "remove_fifos() \$pver not given."
1190     [ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given."
1191     pfull="${pcat}/${pname}-${pver}-${pbuild}"
1192    
1193     # check needed global vars
1194     [ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set."
1195    
1196     # make it optional atm !!
1197     #[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found"
1198     [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return
1199    
1200     # sets fieldseperator to "§" instead of " "
1201     IFS=§
1202    
1203     while read pathto posix user group
1204     do
1205     [ -z "${pathto}" ] && continue
1206    
1207     mqueryfeature "verbose" && echo -e "\t<<< FIFO: ${MROOT}${pathto}"
1208     rm "${MROOT}${pathto}"
1209     done < ${MROOT}${INSTALLDB}/${pfull}/.fifo
1210    
1211     # very important: unsetting the '§' fieldseperator
1212     IFS=$'\n'
1213    }
1214    
1215    
1216    ###################################################
1217  # function remove_direcories                      #  # function remove_direcories                      #
1218  # remove_direcories $PKGNAME                #  # remove_direcories $PKGNAME                #
1219  ###################################################  ###################################################
# Line 1018  remove_directories() Line 1244  remove_directories()
1244   done   done
1245    
1246   # sanity checks; abort if not given   # sanity checks; abort if not given
1247   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_directories() \$pcat not given."
1248   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_directories() \$pname not given."
1249   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_directories() \$pver not given."
1250   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given."
1251   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1252    
1253   # check needed global vars   # check needed global vars
# Line 1039  remove_directories() Line 1265  remove_directories()
1265    
1266   if [ ! -d "${MROOT}${pathto}" ]   if [ ! -d "${MROOT}${pathto}" ]
1267   then   then
1268   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1269   echo -e "${COLRED}! exist${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1270   continue   continue
1271   fi   fi
# Line 1047  remove_directories() Line 1273  remove_directories()
1273   # exclude .keep directories   # exclude .keep directories
1274   if [ -f "${MROOT}${pathto}/.keep" ]   if [ -f "${MROOT}${pathto}/.keep" ]
1275   then   then
1276   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1277   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1278   continue   continue
1279   fi   fi
# Line 1060  remove_directories() Line 1286  remove_directories()
1286    
1287   if rmdir "${MROOT}${pathto}" &> /dev/null   if rmdir "${MROOT}${pathto}" &> /dev/null
1288   then   then
1289   [[ ${VERBOSE} = on ]] && echo -e "\t<<< DIR:  ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< DIR:  ${MROOT}${pathto}"
1290   else   else
1291   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1292   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1293   fi   fi
1294   done   done
# Line 1075  remove_directories() Line 1301  remove_directories()
1301  ###################################################  ###################################################
1302  # function build_douninstall                      #  # function build_douninstall                      #
1303  # build_douninstall $PKGNAME                #  # build_douninstall $PKGNAME                #
1304  # NOTE: this is an wrapper do remove packages     #  # NOTE: this is an wrapper to remove packages     #
1305  ###################################################  ###################################################
1306  build_douninstall()  build_douninstall()
1307  {  {
# Line 1109  build_douninstall() Line 1335  build_douninstall()
1335   # !! we use § as field seperator !!   # !! we use § as field seperator !!
1336   # doing so prevent us to get errors by filenames with spaces   # doing so prevent us to get errors by filenames with spaces
1337    
1338   for i in symlinks files blockdevices characterdevices directories   for i in symlinks files blockdevices characterdevices directories fifos
1339   do   do
1340   remove_${i} \   remove_${i} \
1341   --pcat "${pcat}" \   --pcat "${pcat}" \
# Line 1120  build_douninstall() Line 1346  build_douninstall()
1346   done   done
1347  }  }
1348    
1349    # convertmirrors [uri]
1350    convertmirrors()
1351    {
1352     local uri="$1"
1353     local scheme
1354     local mirror
1355     local mirrors
1356     local addon
1357     local real_uri
1358     local output
1359    
1360     # needs
1361     [[ -z ${MIRRORS} ]] && die "convertmirrors(): no mirrors defined!"
1362     [[ -z ${SOURCEFORGE_MIRRORS} ]] && die "convertmirrors(): no sourceforge mirrors defined!"
1363     [[ -z ${GNU_MIRRORS} ]] && die "convertmirrors(): no gnu mirrors defined!"
1364     [[ -z ${GNOME_MIRRORS} ]] && die "convertmirrors(): no gnome mirrors defined!"
1365     [[ -z ${KDE_MIRRORS} ]] && die "convertmirrors(): no kde mirrors defined!"
1366    
1367     # check known uri schemes
1368     case ${uri} in
1369     http://*|https://*|ftp://*|ftps://*) mirrors="" ;;
1370     mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;;
1371     package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;;
1372     gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;;
1373     sourceforge://*) mirrors="${SOURCEFORGE_MIRRORS}"; scheme="sourceforge://" ;;
1374     gnome://*) mirrors="${GNOME_MIRRORS}"; scheme="gnome://" ;;
1375     kde://*) mirrors="${KDE_MIRRORS}"; scheme="kde://" ;;
1376     *) die "convertmirror(): unsupported uri scheme in '${uri}'!" ;;
1377     esac
1378    
1379     if [[ ! -z ${mirrors} ]]
1380     then
1381     for mirror in ${mirrors}
1382     do
1383     # add a whitespace to the output
1384     [[ -z ${output} ]] || output+=" "
1385     output+="${mirror}${addon}/${uri/${scheme}/}"
1386     done
1387     else
1388     output="${uri}"
1389     fi
1390    
1391     echo "${output}"
1392    }
1393    
1394    mdownload()
1395    {
1396     local i
1397     local uri
1398     local real_uris
1399     local mirror
1400     local outputfile
1401     local outputdir
1402     local retval
1403     local wget_opts
1404    
1405     # very basic getops
1406     for i in $*
1407     do
1408     case $1 in
1409     --uri|-u) shift; uri="$1" ;;
1410     --dir|-d) shift; outputdir="$1" ;;
1411     esac
1412     shift
1413     done
1414    
1415     # sanity checks; abort if not given
1416     [[ -z ${uri} ]] && die "mdownload(): no uri given!"
1417     [[ -z ${outputdir} ]] && die "mdownload(): no dir given!"
1418    
1419     # convert mirrored uris to the real ones
1420     real_uris="$(convertmirrors ${uri})"
1421    
1422     # verbose or not
1423     mqueryfeature "!verbose" && wget_opts+=" --quiet"
1424    
1425     # filter wget options if busybox was found
1426     wget_opts+=" $(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1427    
1428     # create outputdir
1429     [[ ! -d ${outputdir} ]] && install -d "${outputdir}"
1430    
1431     for mirror in ${real_uris}
1432     do
1433     # get the name of the output file
1434     outputfile="${mirror##*/}"
1435    
1436     wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}"
1437     retval="$?"
1438     if [[ ${retval} = 0 ]]
1439     then
1440     break
1441     else
1442     continue
1443     fi
1444     done
1445    
1446     # return wget retval
1447     return "${retval}"
1448    }
1449    
1450  # fetch_packages /path/to/mage/file1 /path/to/mage/file2  # fetch_packages /path/to/mage/file1 /path/to/mage/file2
1451  fetch_packages()  fetch_packages()
1452  {  {
1453     local i
1454   local list="$@"   local list="$@"
1455   local pkg   local pkg
1456   local mirr   local mirr
# Line 1131  fetch_packages() Line 1459  fetch_packages()
1459   local opt   local opt
1460   local count_current   local count_current
1461   local count_total   local count_total
1462     local wget_opts
1463    
1464   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."
1465    
1466     # filter wget command if busybox was found
1467     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1468    
1469   # get count of total packages   # get count of total packages
1470   declare -i count_current=0   declare -i count_current=0
1471   declare -i count_total=0   declare -i count_total=0
# Line 1172  fetch_packages() Line 1504  fetch_packages()
1504   continue   continue
1505   fi   fi
1506    
1507   for mirr in ${MIRRORS}   echo -ne " ${COLBLUE}***${COLDEFAULT}"
1508   do   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1509   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  
   
1510   if [ ! -f ${PKGDIR}/${pkg} ]   if [ ! -f ${PKGDIR}/${pkg} ]
1511   then   then
1512   die "Could not download ${pkg}"   die "Package '${pkg}' after download not found in '${PKGDIR}'"
1513   fi   fi
1514   done   done
1515    
# Line 1223  syncmage() Line 1537  syncmage()
1537   done   done
1538    
1539   # clean up backup files (foo~)   # clean up backup files (foo~)
1540   find ${MAGEDIR} -name *~ -exec rm '{}' ';'   find ${MAGEDIR} -name \*~ -exec rm '{}' ';'
1541    
1542   # check if an newer mage version is available   # check if a newer mage version is available
1543   is_newer_mage_version_available   is_newer_mage_version_available
1544  }  }
1545    
1546  syncmage_tarball()  syncmage_tarball()
1547  {  {
1548   local latest_tarball   local latest_tarball
1549     local latest_md5
1550   local temp="$(mktemp -d)"   local temp="$(mktemp -d)"
1551   local mirr mymirr   local mirr mymirr
1552     local opt
1553     local tar_opts
1554     local wget_opts
1555    
1556     # try to get the md5 marked as latest on the server
1557     latest_md5="mage-latest.md5"
1558    
1559   # try to get the tarball marked as latest on the server   # try to get the tarball marked as latest on the server
1560   latest_tarball="mage-latest.tar.bz2"   latest_tarball="mage-latest.tar.bz2"
1561    
1562     # filter wget command if busybox was found
1563     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1564    
1565   for mirr in ${MIRRORS}   for mirr in ${MIRRORS}
1566   do   do
1567   # path without distribution   # path without distribution
1568   mymirr="${mirr%/*}"   mymirr="${mirr%/*}"
1569    
1570   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1571   echo "fetching latest tarball from ${mymirr} ..."   echo "fetching latest md5 from ${mymirr} ..."
1572     mqueryfeature "!verbose" && opt="--quiet"
1573     wget \
1574     ${wget_opts} \
1575     --directory-prefix=${temp} \
1576     ${opt} ${mymirr}/rsync/tarballs/${latest_md5}
1577    
1578     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1579     echo "fetching latest tarball from ${mymirr} ..."
1580   wget \   wget \
1581   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
1582   --directory-prefix=${temp} \   --directory-prefix=${temp} \
1583   ${mymirr}/rsync/tarballs/${latest_tarball}   ${opt} ${mymirr}/rsync/tarballs/${latest_tarball}
1584   if [[ $? = 0 ]]   if [[ $? = 0 ]]
1585   then   then
1586   break   break
# Line 1263  syncmage_tarball() Line 1591  syncmage_tarball()
1591    
1592   if [[ -f ${temp}/${latest_tarball} ]]   if [[ -f ${temp}/${latest_tarball} ]]
1593   then   then
1594     # check md5
1595     if [[ ! -f ${temp}/${latest_md5} ]]
1596     then
1597     die "md5 is missing ... aborting"
1598     else
1599     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1600     echo -n "checking md5sum... "
1601     mchecksum --rundir "${temp}" --file "${latest_md5}" --method md5 || die "md5 for ${latest_tarball} failed"
1602     fi
1603    
1604   if [[ -d ${MAGEDIR} ]]   if [[ -d ${MAGEDIR} ]]
1605   then   then
1606   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
# Line 1270  syncmage_tarball() Line 1608  syncmage_tarball()
1608   rm -rf ${MAGEDIR}   rm -rf ${MAGEDIR}
1609   fi   fi
1610    
1611     if need_busybox_support tar
1612     then
1613     tar_opts="xjf"
1614     else
1615     tar_opts="xjmf"
1616     fi
1617    
1618   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1619   echo "updating mage-tree from tarball ..."   echo "updating mage-tree from tarball ..."
1620   # unpack in dirname of MAGEDIR, as the tarball has already the mage   # unpack in dirname of MAGEDIR, as the tarball has already the mage
1621   tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"   tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1622    
1623   if [[ -d ${temp} ]]   if [[ -d ${temp} ]]
1624   then   then
1625   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1626   echo "clenaing temp-files ..."   echo "cleaning temp-files ..."
1627   rm -rf ${temp}   rm -rf ${temp}
1628   fi   fi
1629    
1630     # check if a newer mage version is available
1631     is_newer_mage_version_available
1632   else   else
1633   die "Could not fetch the latest tarball ... aborting"   die "Could not fetch the latest tarball ... aborting"
1634   fi   fi
# Line 1316  xtitleclean() Line 1664  xtitleclean()
1664  }  }
1665    
1666    
1667  # cuts full pathnames or versioniezed names down to basename  # unused?
1668  choppkgname()  #
1669  {  # # cuts full pathnames or versionized names down to basename
1670   #we want this only if full name was used  # choppkgname()
1671   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]  # {
1672   then  # #we want this only if full name was used
1673   #cuts ARCH and PBUILD  # if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]
1674   #ARCH comes from ${MAGERC}  # then
1675   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")  # #cuts ARCH and PBUILD
1676    # #ARCH comes from ${MAGERC}
1677    # MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}$(print_distrotag)-r*.::g")
1678    #
1679    # #cuts version number
1680    # MAGENAME=$(basename ${MAGENAME%-*} .mage)
1681    # fi
1682    # }
1683    
  #cuts version number  
  MAGENAME=$(basename ${MAGENAME%-*} .mage)  
  fi  
 }  
1684    
1685  # get_categorie $PNAME, returns CATEGORIE  # get_categorie $PNAME, returns CATEGORIE
1686  # $1=pname  # $1=pname
# Line 1399  get_highest_magefile() Line 1750  get_highest_magefile()
1750   local magefile   local magefile
1751    
1752   # do not list the content of a directory, only the name (-d)   # do not list the content of a directory, only the name (-d)
1753   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)
1754   do   do
1755   [[ -z ${magefile} ]] && continue   [[ -z ${magefile} ]] && continue
1756   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
# Line 1408  get_highest_magefile() Line 1759  get_highest_magefile()
1759   then   then
1760   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
1761   #for debug only   #for debug only
1762   [[ ${MAGEDEBUG} = on ]] && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"   mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"
1763   fi   fi
1764   done   done
1765    
 # 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  
   
1766   echo "${HIGHEST_MAGEFILE}"   echo "${HIGHEST_MAGEFILE}"
1767   return 0   return 0
1768  }  }
# Line 1726  virtuals_add() Line 2055  virtuals_add()
2055    
2056  #deletes pakages from virtual database  #deletes pakages from virtual database
2057  #$1 virtualname; $2 pkgname  #$1 virtualname; $2 pkgname
2058  virtuals_del() {  virtuals_del()
2059    {
2060    
2061   local virtualname="$1"   local virtualname="$1"
2062   local pkgname="$2"   local pkgname="$2"
# Line 1837  minclude() Line 2167  minclude()
2167   then   then
2168   for i in $*   for i in $*
2169   do   do
2170   [[ ${MAGEDEBUG} = on ]] && \   mqueryfeature "debug" && \
2171   echo "--- Including ${MAGEDIR}/include/${i}.minc"   echo "--- Including ${MAGEDIR}/include/${i}.minc"
2172   source ${MAGEDIR}/include/${i}.minc   source ${MAGEDIR}/include/${i}.minc
2173   done   done
2174   [[ ${MAGEDEBUG} = on ]] && echo   mqueryfeature "debug" && echo
2175   fi   fi
2176  }  }
2177    
# Line 2285  mage_install() Line 2615  mage_install()
2615   if [[ -n ${MAGE_TARGETS} ]]   if [[ -n ${MAGE_TARGETS} ]]
2616   then   then
2617   # basic svn compat   # basic svn compat
2618   if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2619   then   then
2620   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
2621   do   do
2622   smage2file="${i}"   smage2file="${i}"
2623   done   done
# Line 2298  mage_install() Line 2628  mage_install()
2628   elif [[ -n ${SPLIT_PACKAGE_BASE} ]]   elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2629   then   then
2630   # basic svn compat   # basic svn compat
2631   if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2632   then   then
2633   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
2634   do   do
2635   smage2file="${i}"   smage2file="${i}"
2636   done   done
# Line 2310  mage_install() Line 2640  mage_install()
2640    
2641   else   else
2642   # basic svn compat   # basic svn compat
2643   if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2644   then   then
2645   for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2   for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2646   do   do
2647   smage2file="${i}"   smage2file="${i}"
2648   done   done
# Line 2451  md5sum_packages() Line 2781  md5sum_packages()
2781   then   then
2782   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2783   echo -ne "checking md5sum (${count_current}/${count_total}): "   echo -ne "checking md5sum (${count_current}/${count_total}): "
2784   ( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed"   mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 || die "md5 for ${pkgfile} failed"
2785   else   else
2786   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2787   echo -e "!! no md5sum file found for ${pkgfile} :("   echo -e "!! no md5sum file found for ${pkgfile} :("
# Line 2664  mage_uninstall() Line 2994  mage_uninstall()
2994   unset -f postremove   unset -f postremove
2995  }  }
2996    
2997  show_etc_update_mesg() {  show_etc_update_mesg()
2998    {
2999   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0
3000    
3001   echo   echo
# Line 2690  pkgsearch() Line 3021  pkgsearch()
3021   local state   local state
3022   local descriptiom   local descriptiom
3023   local homepage   local homepage
3024     local license
3025   local i   local i
3026   local all_installed   local all_installed
3027   local ipver   local ipver
# Line 2726  pkgsearch() Line 3058  pkgsearch()
3058   state="$(get_value_from_magefile STATE ${magefile})"   state="$(get_value_from_magefile STATE ${magefile})"
3059   description="$(get_value_from_magefile DESCRIPTION ${magefile})"   description="$(get_value_from_magefile DESCRIPTION ${magefile})"
3060   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
3061     license="$(get_value_from_magefile LICENSE ${magefile})"
3062    
3063   # all installed   # all installed
3064   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
3065   do   do
3066   ipver="$(magename2pver ${i})"   ipver="$(magename2pver ${i})"
3067   ipbuild="$(magename2pbuild ${i})"   ipbuild="$(magename2pbuild ${i})"
3068    
3069   if [[ -z ${all_installed} ]]   if [[ -z ${all_installed} ]]
3070   then   then
3071   all_installed="${ipver}-${ipbuild}"   all_installed="${ipver}-${ipbuild}"
# Line 2741  pkgsearch() Line 3074  pkgsearch()
3074   fi   fi
3075   done   done
3076   [[ -z ${all_installed} ]] && all_installed="none"   [[ -z ${all_installed} ]] && all_installed="none"
3077    
3078   case ${state} in   case ${state} in
3079   stable) state=${COLGREEN}"[s] ";;   stable) state=${COLGREEN}"[s] ";;
3080   testing) state=${COLYELLOW}"[t] ";;   testing) state=${COLYELLOW}"[t] ";;
# Line 2786  EOF Line 3119  EOF
3119   echo "      Installed versions: ${all_installed}"   echo "      Installed versions: ${all_installed}"
3120   echo "      Description: ${description}"   echo "      Description: ${description}"
3121   echo "      Homepage: ${homepage}"   echo "      Homepage: ${homepage}"
3122     if [[ ! -z ${license} ]]
3123     then
3124     echo "      License:  ${license}"
3125     fi
3126   echo "      Depends: ${deps}"   echo "      Depends: ${deps}"
3127   echo "      SDepends: ${sdeps}"   echo "      SDepends: ${sdeps}"
3128   echo   echo
# Line 2826  export_inherits() Line 3163  export_inherits()
3163   eval "${functions}() { ${include}_${functions} ; }"   eval "${functions}() { ${include}_${functions} ; }"
3164    
3165   # debug   # debug
3166   [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"   mqueryfeature "debug" && typeset -f "${functions}"
3167    
3168   shift   shift
3169   done   done
# Line 2898  EOF Line 3235  EOF
3235   return 0   return 0
3236  }  }
3237    
3238    # need_busybox_support ${cmd}
3239    # return 0 (no error = needs busybox support) or return 1 (error = no busybox support required)
3240    need_busybox_support()
3241    {
3242     local cmd
3243     cmd="$1"
3244    
3245     if [[ -x /bin/busybox ]]
3246     then
3247     if [[ $(readlink $(which ${cmd})) = /bin/busybox ]]
3248     then
3249     # needs busybox support
3250     return 0
3251     fi
3252     fi
3253    
3254     # no busybox
3255     return 1
3256    }
3257    
3258    # busybox_filter_wget_options ${wget_opts}
3259    busybox_filter_wget_options()
3260    {
3261     local opts="$@"
3262     local i
3263     local fixed_opts
3264    
3265     if need_busybox_support wget
3266     then
3267     for i in ${opts}
3268     do
3269     # show only the allowed ones
3270     case ${i} in
3271     -c|--continue) fixed_opts+=" -c" ;;
3272     -s|--spider) fixed_opts+=" -s" ;;
3273     -q|--quiet) fixed_opts+=" -q" ;;
3274     -O|--output-document) shift; fixed_opts+=" -O $1" ;;
3275     --header) shift; fixed_opts+=" --header $1" ;;
3276     -Y|--proxy) shift; fixed_opts+=" -Y $1" ;;
3277     -P) shift; fixed_opts+=" -P $1" ;;
3278     --no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;;
3279     -U|--user-agent) shift; fixed_opts+=" -U ${i}" ;;
3280     # simply drop all other opts
3281     *) continue ;;
3282     esac
3283     done
3284    
3285     echo "${fixed_opts}"
3286     else
3287     echo "${opts}"
3288     fi
3289    }
3290    
3291    have_root_privileges()
3292    {
3293     local retval
3294    
3295     if [[ $(id -u) = 0 ]]
3296     then
3297     retval=0
3298     else
3299     retval=1
3300     fi
3301    
3302     return ${retval}
3303    }
3304    
3305    known_mage_feature()
3306    {
3307     local feature="$1"
3308     local retval
3309    
3310     case "${feature}" in
3311     autosvc|!autosvc) retval=0 ;;
3312     buildlog|!buildlog) retval=0 ;;
3313     ccache|!ccache) retval=0 ;;
3314     check|!check) retval=0 ;;
3315     compressdoc|!compressdoc) retval=0 ;;
3316     debug|!debug) retval=0 ;;
3317     distcc|!distcc) retval=0 ;;
3318     kernelsrcunpack|!kernelsrcunpack) retval=0 ;;
3319     libtool|!libtool) retval=0 ;;
3320     linuxsymlink|!linuxsymlink) retval=0 ;;
3321     pkgbuild|!pkgbuild) retval=0 ;;
3322     pkgdistrotag|!pkgdistrotag) retval=0 ;;
3323     purge|!purge) retval=0 ;;
3324     qalint|!qalint) retval=0 ;;
3325     regentree|!regentree) retval=0 ;;
3326     resume|!resume) retval=0 ;;
3327     srcpkgbuild|!srcpkgbuild) retval=0 ;;
3328     srcpkgtarball|!srcpkgtarball) retval=0 ;;
3329     static|!static) retval=0 ;;
3330     stepbystep|!stepbystep) retval=0 ;;
3331     strip|!strip) retval=0 ;;
3332     verbose|!verbose) retval=0 ;;
3333     *) retval=1 ;;
3334     esac
3335    
3336     return "${retval}"
3337    }
3338    
3339    load_mage_features()
3340    {
3341     for i in ${MAGE_FEATURES_GLOBAL[*]} ${MAGE_FEATURES[*]}
3342     do
3343     FVERBOSE=off msetfeature ${i}
3344     done
3345    }
3346    
3347    msetfeature()
3348    {
3349     local feature
3350     local count
3351     local i
3352     local found
3353    
3354     for feature in $@
3355     do
3356     found=0
3357     count="${#MAGE_FEATURES_CURRENT[*]}"
3358    
3359     if ! known_mage_feature "${feature}"
3360     then
3361     [[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}"
3362     return 3
3363     fi
3364    
3365     for ((i=0; i<count; i++))
3366     do
3367     if [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature} ]]
3368     then
3369     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' already enabled${COLDEFAULT}"
3370     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3371     found=1
3372     elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = !${feature} ]]
3373     then
3374     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' currently disabled, enabling it!${COLDEFAULT}"
3375     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3376     found=1
3377     elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature//!} ]]
3378     then
3379     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature//!}' currently enabled, disabling it!${COLDEFAULT}"
3380     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3381     found=1
3382     fi
3383     done
3384    
3385     # if the feature was not found after proccessing the whole array
3386     # it was not declared. in this case enable it
3387     if [[ ${found} = 0 ]]
3388     then
3389     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' was not declared, enabling it!${COLDEFAULT}"
3390     MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )
3391     fi
3392    
3393     export MAGE_FEATURE_CURRENT
3394     done
3395    }
3396    
3397    mqueryfeature()
3398    {
3399     local feature="$1"
3400     local retval=1
3401     local i
3402    
3403     if known_mage_feature "${feature}"
3404     then
3405     for i in ${MAGE_FEATURES_CURRENT[*]}
3406     do
3407     if [[ ${i} = ${feature} ]]
3408     then
3409     retval=0
3410     break # found break here
3411     fi
3412     done
3413     else
3414     [[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}"
3415     retval=3
3416     fi
3417    
3418     return ${retval}
3419    }
3420    
3421    mprintfeatures()
3422    {
3423     echo "Global features:  ${MAGE_FEATURES_GLOBAL[*]}"
3424     echo "Local features:   ${MAGE_FEATURES[*]}"
3425     echo "Current features: ${MAGE_FEATURES_CURRENT[*]}"
3426    }

Legend:
Removed from v.943  
changed lines
  Added in v.1653