Magellan Linux

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

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

revision 942 by niro, Fri Nov 20 21:53:33 2009 UTC revision 1658 by niro, Sat Jan 14 00:00:53 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     # be verbose here
76     ${cmd} -c ${file} #&> /dev/null
77     retval="$?"
78     popd &> /dev/null
79     else
80     retval=1
81     fi
82    
83     return "${retval}"
84    }
85    
86    mcheckemptydir()
87    {
88     local dir="$1"
89     local retval=1
90    
91     if [[ ! -d ${dir} ]]
92     then
93     echo "mcheckemptydir(): '${dir}' is not a directory!"
94     retval=3
95     else
96     shopt -s nullglob dotglob
97     files=( ${dir}/* )
98     (( ${#files[*]} )) || retval=0
99     shopt -u nullglob dotglob
100     fi
101    
102     return ${retval}
103    }
104    
105  unpack_packages()  unpack_packages()
106  {  {
107   local list="$@"   local list="$@"
# Line 23  unpack_packages() Line 110  unpack_packages()
110   local pkgtype   local pkgtype
111   local count_current   local count_current
112   local count_total   local count_total
113     local tar_opts
114    
115   # get count of total packages   # get count of total packages
116   declare -i count_current=0   declare -i count_current=0
# Line 54  unpack_packages() Line 142  unpack_packages()
142   continue   continue
143   fi   fi
144    
145     # busybox?
146     if need_busybox_support tar
147     then
148     tar_opts="xjf"
149     else
150     tar_opts="xjmf"
151     fi
152    
153   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "
154   tar xjmf ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"   tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"
155   done   done
156    
157   # add a crlf for a better view   # add a crlf for a better view
# Line 130  install_directories() Line 226  install_directories()
226   while read pathto posix user group   while read pathto posix user group
227   do   do
228   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
229   [[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR:  ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> DIR:  ${MROOT}${pathto}"
   
230    
231   # monitors /etc/env.d -> env-rebuild   # monitors /etc/env.d -> env-rebuild
232   [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true   [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true
# Line 207  install_files() Line 302  install_files()
302   case ${retval} in   case ${retval} in
303   # file is not protected - (over)write it   # file is not protected - (over)write it
304   0|3)   0|3)
305   [[ ${VERBOSE} = on ]] && echo -e "\t>>> FILE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> FILE: ${MROOT}${pathto}"
306   install -m "${posix}" -o "${user}" -g "${group}" \   install -m "${posix}" -o "${user}" -g "${group}" \
307   ${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \   ${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \
308   "${MROOT}${pathto}"   "${MROOT}${pathto}"
# Line 219  install_files() Line 314  install_files()
314   "${user}" \   "${user}" \
315   "${group}" \   "${group}" \
316   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
317   "${MROOT}${pathto}")" \   "${MROOT}${pathto}")" \
318   "${md5sum}"   "${md5sum}"
319   ;;   ;;
320    
321   # file is protected, write backup file   # file is protected, write backup file
322   2)   2)
323   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
324   then   then
325   echo -en "${COLRED}"   echo -en "${COLRED}"
326   echo -n "! prot "   echo -n "! prot "
# Line 246  install_files() Line 341  install_files()
341   "${user}" \   "${user}" \
342   "${group}" \   "${group}" \
343   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
344   "${dest_protected}")" \   "${dest_protected}")" \
345   "${md5sum}"   "${md5sum}"
346    
347   # update global MAGE_PROTECT_COUNTER   # update global MAGE_PROTECT_COUNTER
# Line 256  install_files() Line 351  install_files()
351    
352   # file is protected but ignored, delete the update/do nothing   # file is protected but ignored, delete the update/do nothing
353   4)   4)
354   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
355   then   then
356   echo -en "${COLRED}"   echo -en "${COLRED}"
357   echo -n "! ignr "   echo -n "! ignr "
358   echo -en "${COLDEFAULT}"   echo -en "${COLDEFAULT}"
359   echo " === FILE: ${MROOT}${pathto}"   echo " === FILE: ${MROOT}${pathto}"
360   fi   fi
361   # simply do nothing here   # simply do nothing here - only fix mtime
362     fix_descriptor ${pkgname}/.files \
363     "${pathto}" \
364     "${posix}" \
365     "${user}" \
366     "${group}" \
367     "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
368     "${MROOT}${pathto}")" \
369     "${md5sum}"
370   ;;   ;;
371   esac   esac
372   done < ${BUILDDIR}/${pkgname}/.files   done < ${BUILDDIR}/${pkgname}/.files
# Line 307  install_symlinks() Line 410  install_symlinks()
410   while read pathto posix link mtime   while read pathto posix link mtime
411   do   do
412   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
413   [[ ${VERBOSE} = on ]] && echo -e "\t>>> LINK: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> LINK: ${MROOT}${pathto}"
414    
415   ln -snf "${link}" "${MROOT}${pathto}"   ln -snf "${link}" "${MROOT}${pathto}"
416    
# Line 339  install_blockdevices() Line 442  install_blockdevices()
442   local pkgname="$1"   local pkgname="$1"
443   local pathto   local pathto
444   local posix   local posix
445     local user
446     local group
447   local IFS   local IFS
448    
449   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 352  install_blockdevices() Line 457  install_blockdevices()
457   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
458   IFS=§   IFS=§
459    
460   while read pathto posix   while read pathto posix major minor user group
461   do   do
462   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
463   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> PIPE: ${MROOT}${pathto}"
464    
465   mkfifo -m "${posix}" "${MROOT}$pathto"   mknod -m "${posix}" "${MROOT}${pathto}"
466     # make it optional atm !!
467     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
468     then
469     chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}"
470     fi
471   done < ${BUILDDIR}/${pkgname}/.pipes   done < ${BUILDDIR}/${pkgname}/.pipes
472    
473   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
# Line 376  install_characterdevices() Line 486  install_characterdevices()
486   local posix   local posix
487   local major   local major
488   local minor   local minor
489     local user
490     local group
491   local IFS   local IFS
492    
493   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 389  install_characterdevices() Line 501  install_characterdevices()
501   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
502   IFS=§   IFS=§
503    
504   while read pathto posix major minor   while read pathto posix major minor user group
505   do   do
506   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
507   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> CHAR: ${MROOT}${pathto}"
508    
509   mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor}   mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}"
510    
511     # make it optional atm !!
512     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
513     then
514     chown "${user}:${group}" "${MROOT}${pathto}"
515     fi
516   done < ${BUILDDIR}/${pkgname}/.char   done < ${BUILDDIR}/${pkgname}/.char
517    
518   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
519   IFS=$'\n'   IFS=$'\n'
520  }  }
521    
522    ###################################################
523    # function install_fifos                          #
524    # install_fifos $PKGNAME                    #
525    ###################################################
526    install_fifos()
527    {
528     local pkgname="$1"
529     local pathto
530     local posix
531     local user
532     local group
533     local IFS
534    
535     # sanity checks; abort if not given
536     [ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given."
537    
538     # check needed global vars
539     [ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set."
540    
541     # make it optional atm !!
542     #[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found"
543     [ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return
544    
545     # sets fieldseperator to "§" instead of " "
546     IFS=§
547    
548     while read pathto posix user group
549     do
550     [ -z "${pathto}" ] && continue
551     mqueryfeature "verbose" && echo -e "\t>>> FIFO: ${MROOT}${pathto}"
552    
553     mkfifo -m "${posix}" "${MROOT}${pathto}"
554     chown "${user}:${group}" "${MROOT}${pathto}"
555     done < ${BUILDDIR}/${pkgname}/.fifo
556    
557     # very important: unsetting the '§' fieldseperator
558     IFS=$'\n'
559    }
560    
561    
562  ###################################################  ###################################################
563  # function build_doinstall                        #  # function build_doinstall                        #
564  # build_doinstall $PKGNAME                  #  # build_doinstall $PKGNAME                  #
565  # NOTE: this is an wrapper do install packages    #  # NOTE: this is an wrapper to install packages    #
566  ###################################################  ###################################################
567  build_doinstall()  build_doinstall()
568  {  {
# Line 413  build_doinstall() Line 570  build_doinstall()
570    
571   # sanity checks; abort if not given   # sanity checks; abort if not given
572   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."
573    
574   # this is only a wrapper   # this is only a wrapper
575    
576   # NOTE:   # NOTE:
# Line 428  build_doinstall() Line 585  build_doinstall()
585   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"
586   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"
587   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"
588     install_fifos ${pkgname} || die "install fifos ${pkgname}"
589  }  }
590    
591    
# Line 489  install_database_entry() Line 647  install_database_entry()
647    
648   # create fake file descriptors   # create fake file descriptors
649   # used by virtual and source packages   # used by virtual and source packages
650   for i in .dirs .symlinks .files .pipes .char   for i in .dirs .symlinks .files .pipes .char .fifo
651   do   do
652   touch ${dbrecorddir}/${i}   touch ${dbrecorddir}/${i}
653   done   done
# Line 507  install_database_entry() Line 665  install_database_entry()
665    
666   # normal packages needs these files   # normal packages needs these files
667   local i   local i
668   for i in .char .dirs .files .pipes .symlinks   for i in .char .dirs .files .pipes .symlinks .fifo
669   do   do
670   install -m 0644 ${BUILDDIR}/${pkgname}/${i} \   # make .fifo optional atm
671   ${dbrecorddir}/${i}   if [[ -f ${BUILDDIR}/${pkgname}/${i} ]]
672     then
673     install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i}
674     fi
675   done   done
676   ;;   ;;
677   esac   esac
# Line 721  remove_symlinks() Line 882  remove_symlinks()
882   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
883   if [ ! -L "${MROOT}${pathto}" ]   if [ ! -L "${MROOT}${pathto}" ]
884   then   then
885   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
886   echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}"
887   continue   continue
888   fi   fi
# Line 733  remove_symlinks() Line 894  remove_symlinks()
894   # 1=keep me   #   # 1=keep me   #
895   case ${retval} in   case ${retval} in
896   0)   0)
897   [[ ${VERBOSE} = on ]] && echo -e "\t<<< LINK: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< LINK: ${MROOT}${pathto}"
898   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
899   ;;   ;;
900    
901   1)   1)
902   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
903   echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}"
904   ;;   ;;
905   esac   esac
# Line 785  remove_files() Line 946  remove_files()
946   done   done
947    
948   # sanity checks; abort if not given   # sanity checks; abort if not given
949   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_files() \$pcat not given."
950   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_files() \$pname not given."
951   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_files() \$pver not given."
952   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_files() \$pbuild not given."
953   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
954    
955   # check needed global vars   # check needed global vars
# Line 805  remove_files() Line 966  remove_files()
966    
967   if [ ! -e "${MROOT}${pathto}" ]   if [ ! -e "${MROOT}${pathto}" ]
968   then   then
969   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
970   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"
971   continue   continue
972   fi   fi
# Line 831  remove_files() Line 992  remove_files()
992   case ${retval} in   case ${retval} in
993   # file is not protected - delete it   # file is not protected - delete it
994   0|3)   0|3)
995   [[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< FILE: ${MROOT}${pathto}"
996   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
997   ;;   ;;
998    
999   # file is protected, do not delete   # file is protected, do not delete
1000   2)   2)
1001   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
1002   then   then
1003   echo -en "${COLRED}"   echo -en "${COLRED}"
1004   echo -n "! prot "   echo -n "! prot "
# Line 848  remove_files() Line 1009  remove_files()
1009    
1010   # file is protected but ignored, delete the update/do nothing   # file is protected but ignored, delete the update/do nothing
1011   4)   4)
1012   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
1013   then   then
1014   echo -en "${COLRED}"   echo -en "${COLRED}"
1015   echo -n "! ignr "   echo -n "! ignr "
# Line 860  remove_files() Line 1021  remove_files()
1021   esac   esac
1022   ;;   ;;
1023   1)   1)
1024   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1025   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"
1026   ;;   ;;
1027   esac   esac
# Line 879  remove_blockdevices() Line 1040  remove_blockdevices()
1040  {  {
1041   local pathto   local pathto
1042   local posix   local posix
1043     local user
1044     local group
1045   local IFS   local IFS
1046   local pcat   local pcat
1047   local pname   local pname
# Line 902  remove_blockdevices() Line 1065  remove_blockdevices()
1065   done   done
1066    
1067   # sanity checks; abort if not given   # sanity checks; abort if not given
1068   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given."
1069   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_blockdevices() \$pname not given."
1070   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_blockdevices() \$pver not given."
1071   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given."
1072   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1073    
1074   # check needed global vars   # check needed global vars
# Line 916  remove_blockdevices() Line 1079  remove_blockdevices()
1079   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1080   IFS=§   IFS=§
1081    
1082   while read pathto posix   while read pathto posix user group
1083   do   do
1084   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1085    
1086   [[ ${VERBOSE} = on ]] && echo -e "\t<<< PIPE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< PIPE: ${MROOT}${pathto}"
1087   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1088   done < ${MROOT}${INSTALLDB}/${pfull}/.pipes   done < ${MROOT}${INSTALLDB}/${pfull}/.pipes
1089    
# Line 937  remove_characterdevices() Line 1100  remove_characterdevices()
1100  {  {
1101   local pathto   local pathto
1102   local posix   local posix
1103     local user
1104     local group
1105   local IFS   local IFS
1106   local pcat   local pcat
1107   local pname   local pname
# Line 960  remove_characterdevices() Line 1125  remove_characterdevices()
1125   done   done
1126    
1127   # sanity checks; abort if not given   # sanity checks; abort if not given
1128   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given."
1129   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_characterdevices() \$pname not given."
1130   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_characterdevices() \$pver not given."
1131   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given."
1132   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1133    
1134   # check needed global vars   # check needed global vars
# Line 974  remove_characterdevices() Line 1139  remove_characterdevices()
1139   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1140   IFS=§   IFS=§
1141    
1142   while read pathto posix   while read pathto posix user group
1143   do   do
1144   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1145    
1146   [[ ${VERBOSE} = on ]] && echo -e "\t<<< CHAR: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< CHAR: ${MROOT}${pathto}"
1147   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1148   done < ${MROOT}${INSTALLDB}/${pfull}/.char   done < ${MROOT}${INSTALLDB}/${pfull}/.char
1149    
# Line 988  remove_characterdevices() Line 1153  remove_characterdevices()
1153    
1154    
1155  ###################################################  ###################################################
1156    # function remove_fifos                           #
1157    # remove_fifos $PKGNAME                     #
1158    ###################################################
1159    remove_fifos()
1160    {
1161     local pathto
1162     local posix
1163     local user
1164     local group
1165     local IFS
1166     local pcat
1167     local pname
1168     local pver
1169     local pbuild
1170     local i
1171     local pfull
1172    
1173     IFS=$'\n'
1174    
1175     # very basic getops
1176     for i in $*
1177     do
1178     case $1 in
1179     --pcat|-c) shift; pcat="$1" ;;
1180     --pname|-n) shift; pname="$1" ;;
1181     --pver|-v) shift; pver="$1" ;;
1182     --pbuild|-b) shift; pbuild="$1" ;;
1183     esac
1184     shift
1185     done
1186    
1187     # sanity checks; abort if not given
1188     [ -z "${pcat}" ] && die "remove_fifos() \$pcat not given."
1189     [ -z "${pname}" ] && die "remove_fifos() \$pname not given."
1190     [ -z "${pver}" ] && die "remove_fifos() \$pver not given."
1191     [ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given."
1192     pfull="${pcat}/${pname}-${pver}-${pbuild}"
1193    
1194     # check needed global vars
1195     [ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set."
1196    
1197     # make it optional atm !!
1198     #[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found"
1199     [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return
1200    
1201     # sets fieldseperator to "§" instead of " "
1202     IFS=§
1203    
1204     while read pathto posix user group
1205     do
1206     [ -z "${pathto}" ] && continue
1207    
1208     mqueryfeature "verbose" && echo -e "\t<<< FIFO: ${MROOT}${pathto}"
1209     rm "${MROOT}${pathto}"
1210     done < ${MROOT}${INSTALLDB}/${pfull}/.fifo
1211    
1212     # very important: unsetting the '§' fieldseperator
1213     IFS=$'\n'
1214    }
1215    
1216    
1217    ###################################################
1218  # function remove_direcories                      #  # function remove_direcories                      #
1219  # remove_direcories $PKGNAME                #  # remove_direcories $PKGNAME                #
1220  ###################################################  ###################################################
# Line 1018  remove_directories() Line 1245  remove_directories()
1245   done   done
1246    
1247   # sanity checks; abort if not given   # sanity checks; abort if not given
1248   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_directories() \$pcat not given."
1249   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_directories() \$pname not given."
1250   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_directories() \$pver not given."
1251   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given."
1252   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1253    
1254   # check needed global vars   # check needed global vars
# Line 1039  remove_directories() Line 1266  remove_directories()
1266    
1267   if [ ! -d "${MROOT}${pathto}" ]   if [ ! -d "${MROOT}${pathto}" ]
1268   then   then
1269   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1270   echo -e "${COLRED}! exist${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1271   continue   continue
1272   fi   fi
# Line 1047  remove_directories() Line 1274  remove_directories()
1274   # exclude .keep directories   # exclude .keep directories
1275   if [ -f "${MROOT}${pathto}/.keep" ]   if [ -f "${MROOT}${pathto}/.keep" ]
1276   then   then
1277   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1278   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1279   continue   continue
1280   fi   fi
# Line 1060  remove_directories() Line 1287  remove_directories()
1287    
1288   if rmdir "${MROOT}${pathto}" &> /dev/null   if rmdir "${MROOT}${pathto}" &> /dev/null
1289   then   then
1290   [[ ${VERBOSE} = on ]] && echo -e "\t<<< DIR:  ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< DIR:  ${MROOT}${pathto}"
1291   else   else
1292   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1293   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1294   fi   fi
1295   done   done
# Line 1075  remove_directories() Line 1302  remove_directories()
1302  ###################################################  ###################################################
1303  # function build_douninstall                      #  # function build_douninstall                      #
1304  # build_douninstall $PKGNAME                #  # build_douninstall $PKGNAME                #
1305  # NOTE: this is an wrapper do remove packages     #  # NOTE: this is an wrapper to remove packages     #
1306  ###################################################  ###################################################
1307  build_douninstall()  build_douninstall()
1308  {  {
# Line 1109  build_douninstall() Line 1336  build_douninstall()
1336   # !! we use § as field seperator !!   # !! we use § as field seperator !!
1337   # doing so prevent us to get errors by filenames with spaces   # doing so prevent us to get errors by filenames with spaces
1338    
1339   for i in symlinks files blockdevices characterdevices directories   for i in symlinks files blockdevices characterdevices directories fifos
1340   do   do
1341   remove_${i} \   remove_${i} \
1342   --pcat "${pcat}" \   --pcat "${pcat}" \
# Line 1120  build_douninstall() Line 1347  build_douninstall()
1347   done   done
1348  }  }
1349    
1350    # convertmirrors [uri]
1351    convertmirrors()
1352    {
1353     local uri="$1"
1354     local scheme
1355     local mirror
1356     local mirrors
1357     local addon
1358     local real_uri
1359     local output
1360    
1361     # needs
1362     [[ -z ${MIRRORS} ]] && die "convertmirrors(): no mirrors defined!"
1363     [[ -z ${SOURCEFORGE_MIRRORS} ]] && die "convertmirrors(): no sourceforge mirrors defined!"
1364     [[ -z ${GNU_MIRRORS} ]] && die "convertmirrors(): no gnu mirrors defined!"
1365     [[ -z ${GNOME_MIRRORS} ]] && die "convertmirrors(): no gnome mirrors defined!"
1366     [[ -z ${KDE_MIRRORS} ]] && die "convertmirrors(): no kde mirrors defined!"
1367    
1368     # check known uri schemes
1369     case ${uri} in
1370     http://*|https://*|ftp://*|ftps://*) mirrors="" ;;
1371     mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;;
1372     package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;;
1373     gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;;
1374     sourceforge://*) mirrors="${SOURCEFORGE_MIRRORS}"; scheme="sourceforge://" ;;
1375     gnome://*) mirrors="${GNOME_MIRRORS}"; scheme="gnome://" ;;
1376     kde://*) mirrors="${KDE_MIRRORS}"; scheme="kde://" ;;
1377     *) die "convertmirror(): unsupported uri scheme in '${uri}'!" ;;
1378     esac
1379    
1380     if [[ ! -z ${mirrors} ]]
1381     then
1382     for mirror in ${mirrors}
1383     do
1384     # add a whitespace to the output
1385     [[ -z ${output} ]] || output+=" "
1386     output+="${mirror}${addon}/${uri/${scheme}/}"
1387     done
1388     else
1389     output="${uri}"
1390     fi
1391    
1392     echo "${output}"
1393    }
1394    
1395    mdownload()
1396    {
1397     local i
1398     local uri
1399     local real_uris
1400     local mirror
1401     local outputfile
1402     local outputdir
1403     local retval
1404     local wget_opts
1405    
1406     # very basic getops
1407     for i in $*
1408     do
1409     case $1 in
1410     --uri|-u) shift; uri="$1" ;;
1411     --dir|-d) shift; outputdir="$1" ;;
1412     esac
1413     shift
1414     done
1415    
1416     # sanity checks; abort if not given
1417     [[ -z ${uri} ]] && die "mdownload(): no uri given!"
1418     [[ -z ${outputdir} ]] && die "mdownload(): no dir given!"
1419    
1420     # convert mirrored uris to the real ones
1421     real_uris="$(convertmirrors ${uri})"
1422    
1423     # verbose or not
1424     mqueryfeature "!verbose" && wget_opts+=" --quiet"
1425    
1426     # filter wget options if busybox was found
1427     wget_opts+=" $(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1428    
1429     # create outputdir
1430     [[ ! -d ${outputdir} ]] && install -d "${outputdir}"
1431    
1432     for mirror in ${real_uris}
1433     do
1434     # get the name of the output file
1435     outputfile="${mirror##*/}"
1436    
1437     wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}"
1438     retval="$?"
1439     if [[ ${retval} = 0 ]]
1440     then
1441     break
1442     else
1443     continue
1444     fi
1445     done
1446    
1447     # return wget retval
1448     return "${retval}"
1449    }
1450    
1451  # fetch_packages /path/to/mage/file1 /path/to/mage/file2  # fetch_packages /path/to/mage/file1 /path/to/mage/file2
1452  fetch_packages()  fetch_packages()
1453  {  {
1454     local i
1455   local list="$@"   local list="$@"
1456   local pkg   local pkg
1457   local mirr   local mirr
# Line 1131  fetch_packages() Line 1460  fetch_packages()
1460   local opt   local opt
1461   local count_current   local count_current
1462   local count_total   local count_total
1463     local wget_opts
1464    
1465   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."
1466    
1467     # filter wget command if busybox was found
1468     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1469    
1470   # get count of total packages   # get count of total packages
1471   declare -i count_current=0   declare -i count_current=0
1472   declare -i count_total=0   declare -i count_total=0
# Line 1172  fetch_packages() Line 1505  fetch_packages()
1505   continue   continue
1506   fi   fi
1507    
1508   for mirr in ${MIRRORS}   echo -ne " ${COLBLUE}***${COLDEFAULT}"
1509   do   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1510   echo -ne " ${COLBLUE}***${COLDEFAULT}"   mdownload --uri "package://${pkg}" --dir "${PKGDIR}" || die "Could not download ${pkg}"
  #echo -e " fetching (${count_current}/${count_total}): ${mirr}/${pkg} ... "  
  echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "  
  [[ ${VERBOSE} = off ]] && opt="--quiet"  
  wget \  
  --passive-ftp \  
  --tries 3 \  
  --continue \  
  --progress bar \  
  --directory-prefix=${PKGDIR} \  
  ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}  
  if [[ $? = 0 ]]  
  then  
  break  
  else  
  continue  
  fi  
  done  
   
1511   if [ ! -f ${PKGDIR}/${pkg} ]   if [ ! -f ${PKGDIR}/${pkg} ]
1512   then   then
1513   die "Could not download ${pkg}"   die "Package '${pkg}' after download not found in '${PKGDIR}'"
1514   fi   fi
1515   done   done
1516    
# Line 1223  syncmage() Line 1538  syncmage()
1538   done   done
1539    
1540   # clean up backup files (foo~)   # clean up backup files (foo~)
1541   find ${MAGEDIR} -name *~ -exec rm '{}' ';'   find ${MAGEDIR} -name \*~ -exec rm '{}' ';'
1542    
1543   # check if an newer mage version is available   # check if a newer mage version is available
1544   is_newer_mage_version_available   is_newer_mage_version_available
1545  }  }
1546    
1547  syncmage_tarball()  syncmage_tarball()
1548  {  {
1549   local latest_tarball   local latest_tarball
1550     local latest_md5
1551   local temp="$(mktemp -d)"   local temp="$(mktemp -d)"
1552   local mirr mymirr   local mirr mymirr
1553     local opt
1554     local tar_opts
1555     local wget_opts
1556    
1557     # try to get the md5 marked as latest on the server
1558     latest_md5="mage-latest.md5"
1559    
1560   # try to get the tarball marked as latest on the server   # try to get the tarball marked as latest on the server
1561   latest_tarball="mage-latest.tar.bz2"   latest_tarball="mage-latest.tar.bz2"
1562    
1563     # filter wget command if busybox was found
1564     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1565    
1566   for mirr in ${MIRRORS}   for mirr in ${MIRRORS}
1567   do   do
1568   # path without distribution   # path without distribution
1569   mymirr="${mirr%/*}"   mymirr="${mirr%/*}"
1570    
1571   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1572   echo "fetching latest tarball from ${mymirr} ..."   echo "fetching latest md5 from ${mymirr} ..."
1573     mqueryfeature "!verbose" && opt="--quiet"
1574     wget \
1575     ${wget_opts} \
1576     --directory-prefix=${temp} \
1577     ${opt} ${mymirr}/rsync/tarballs/${latest_md5}
1578    
1579     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1580     echo "fetching latest tarball from ${mymirr} ..."
1581   wget \   wget \
1582   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
1583   --directory-prefix=${temp} \   --directory-prefix=${temp} \
1584   ${mymirr}/rsync/tarballs/${latest_tarball}   ${opt} ${mymirr}/rsync/tarballs/${latest_tarball}
1585   if [[ $? = 0 ]]   if [[ $? = 0 ]]
1586   then   then
1587   break   break
# Line 1263  syncmage_tarball() Line 1592  syncmage_tarball()
1592    
1593   if [[ -f ${temp}/${latest_tarball} ]]   if [[ -f ${temp}/${latest_tarball} ]]
1594   then   then
1595     # check md5
1596     if [[ ! -f ${temp}/${latest_md5} ]]
1597     then
1598     die "md5 is missing ... aborting"
1599     else
1600     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1601     echo -n "checking md5sum... "
1602     mchecksum --rundir "${temp}" --file "${latest_md5}" --method md5 || die "md5 for ${latest_tarball} failed"
1603     fi
1604    
1605   if [[ -d ${MAGEDIR} ]]   if [[ -d ${MAGEDIR} ]]
1606   then   then
1607   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1608   echo "cleaning old mage-tree ${MAGEDIR}..."   echo "cleaning old mage-tree ${MAGEDIR}..."
1609   rm -rf ${MAGEDIR}   # honor mountpoints and empty dirs
1610     if mountpoint -q ${MAGEDIR}
1611     then
1612     if ! mcheckemptydir ${MAGEDIR}
1613     then
1614     find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xarg --no-run-if-empty rm -r
1615     fi
1616     else
1617     rm -rf ${MAGEDIR}
1618     fi
1619     fi
1620    
1621     if need_busybox_support tar
1622     then
1623     tar_opts="xjf"
1624     else
1625     tar_opts="xjmf"
1626   fi   fi
1627    
1628   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1629   echo "updating mage-tree from tarball ..."   echo "updating mage-tree from tarball ..."
1630   # unpack in dirname of MAGEDIR, as the tarball has already the mage   # unpack in dirname of MAGEDIR, as the tarball has already the mage
1631   tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"   tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1632    
1633   if [[ -d ${temp} ]]   if [[ -d ${temp} ]]
1634   then   then
1635   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1636   echo "clenaing temp-files ..."   echo "cleaning temp-files ..."
1637   rm -rf ${temp}   rm -rf ${temp}
1638   fi   fi
1639    
1640     # check if a newer mage version is available
1641     is_newer_mage_version_available
1642   else   else
1643   die "Could not fetch the latest tarball ... aborting"   die "Could not fetch the latest tarball ... aborting"
1644   fi   fi
# Line 1316  xtitleclean() Line 1674  xtitleclean()
1674  }  }
1675    
1676    
1677  # cuts full pathnames or versioniezed names down to basename  # unused?
1678  choppkgname()  #
1679  {  # # cuts full pathnames or versionized names down to basename
1680   #we want this only if full name was used  # choppkgname()
1681   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]  # {
1682   then  # #we want this only if full name was used
1683   #cuts ARCH and PBUILD  # if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]
1684   #ARCH comes from ${MAGERC}  # then
1685   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")  # #cuts ARCH and PBUILD
1686    # #ARCH comes from ${MAGERC}
1687    # MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}$(print_distrotag)-r*.::g")
1688    #
1689    # #cuts version number
1690    # MAGENAME=$(basename ${MAGENAME%-*} .mage)
1691    # fi
1692    # }
1693    
  #cuts version number  
  MAGENAME=$(basename ${MAGENAME%-*} .mage)  
  fi  
 }  
1694    
1695  # get_categorie $PNAME, returns CATEGORIE  # get_categorie $PNAME, returns CATEGORIE
1696  # $1=pname  # $1=pname
# Line 1399  get_highest_magefile() Line 1760  get_highest_magefile()
1760   local magefile   local magefile
1761    
1762   # do not list the content of a directory, only the name (-d)   # do not list the content of a directory, only the name (-d)
1763   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)
1764   do   do
1765   [[ -z ${magefile} ]] && continue   [[ -z ${magefile} ]] && continue
1766   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
# Line 1408  get_highest_magefile() Line 1769  get_highest_magefile()
1769   then   then
1770   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
1771   #for debug only   #for debug only
1772   [[ ${MAGEDEBUG} = on ]] && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"   mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"
1773   fi   fi
1774   done   done
1775    
 # 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  
   
1776   echo "${HIGHEST_MAGEFILE}"   echo "${HIGHEST_MAGEFILE}"
1777   return 0   return 0
1778  }  }
# Line 1726  virtuals_add() Line 2065  virtuals_add()
2065    
2066  #deletes pakages from virtual database  #deletes pakages from virtual database
2067  #$1 virtualname; $2 pkgname  #$1 virtualname; $2 pkgname
2068  virtuals_del() {  virtuals_del()
2069    {
2070    
2071   local virtualname="$1"   local virtualname="$1"
2072   local pkgname="$2"   local pkgname="$2"
# Line 1837  minclude() Line 2177  minclude()
2177   then   then
2178   for i in $*   for i in $*
2179   do   do
2180   [[ ${MAGEDEBUG} = on ]] && \   mqueryfeature "debug" && \
2181   echo "--- Including ${MAGEDIR}/include/${i}.minc"   echo "--- Including ${MAGEDIR}/include/${i}.minc"
2182   source ${MAGEDIR}/include/${i}.minc   source ${MAGEDIR}/include/${i}.minc
2183   done   done
2184   [[ ${MAGEDEBUG} = on ]] && echo   mqueryfeature "debug" && echo
2185   fi   fi
2186  }  }
2187    
# Line 2160  get_value_from_magefile() Line 2500  get_value_from_magefile()
2500   local SDEPEND   local SDEPEND
2501   local PROVIDE   local PROVIDE
2502   local PKGTYPE   local PKGTYPE
2503     local MAGE_TARGETS
2504     local SPLIT_PACKAGE_BASE
2505   local preinstall   local preinstall
2506   local postinstall   local postinstall
2507   local preremove   local preremove
# Line 2280  mage_install() Line 2622  mage_install()
2622   echo B:${pbuild}   echo B:${pbuild}
2623   fi   fi
2624    
2625   if [[ -z ${MAGE_TARGETS} ]]   if [[ -n ${MAGE_TARGETS} ]]
2626   then   then
2627   # basic svn compat   # basic svn compat
2628   if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2629   then   then
2630   for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2   for i in ${SMAGESCRIPTSDIR}/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2631   do   do
2632   smage2file="${i}"   smage2file="${i}"
2633   done   done
2634   else   else
2635   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2   smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2636   fi   fi
2637    
2638     elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2639     then
2640     # basic svn compat
2641     if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2642     then
2643     for i in ${SMAGESCRIPTSDIR}/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2644     do
2645     smage2file="${i}"
2646     done
2647     else
2648     smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2649     fi
2650    
2651   else   else
2652   # basic svn compat   # basic svn compat
2653   if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2654   then   then
2655   for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2   for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2656   do   do
2657   smage2file="${i}"   smage2file="${i}"
2658   done   done
2659   else   else
2660   smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2
2661   fi   fi
2662   fi   fi
2663    
2664   if [ -f "${smage2file}" ]   if [ -f "${smage2file}" ]
2665   then   then
2666   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "
# Line 2434  md5sum_packages() Line 2791  md5sum_packages()
2791   then   then
2792   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2793   echo -ne "checking md5sum (${count_current}/${count_total}): "   echo -ne "checking md5sum (${count_current}/${count_total}): "
2794   ( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed"   mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 || die "md5 for ${pkgfile} failed"
2795   else   else
2796   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2797   echo -e "!! no md5sum file found for ${pkgfile} :("   echo -e "!! no md5sum file found for ${pkgfile} :("
# Line 2647  mage_uninstall() Line 3004  mage_uninstall()
3004   unset -f postremove   unset -f postremove
3005  }  }
3006    
3007  show_etc_update_mesg() {  show_etc_update_mesg()
3008    {
3009   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0
3010    
3011   echo   echo
# Line 2673  pkgsearch() Line 3031  pkgsearch()
3031   local state   local state
3032   local descriptiom   local descriptiom
3033   local homepage   local homepage
3034     local license
3035   local i   local i
3036   local all_installed   local all_installed
3037   local ipver   local ipver
# Line 2709  pkgsearch() Line 3068  pkgsearch()
3068   state="$(get_value_from_magefile STATE ${magefile})"   state="$(get_value_from_magefile STATE ${magefile})"
3069   description="$(get_value_from_magefile DESCRIPTION ${magefile})"   description="$(get_value_from_magefile DESCRIPTION ${magefile})"
3070   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
3071     license="$(get_value_from_magefile LICENSE ${magefile})"
3072    
3073   # all installed   # all installed
3074   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
3075   do   do
3076   ipver="$(magename2pver ${i})"   ipver="$(magename2pver ${i})"
3077   ipbuild="$(magename2pbuild ${i})"   ipbuild="$(magename2pbuild ${i})"
3078    
3079   if [[ -z ${all_installed} ]]   if [[ -z ${all_installed} ]]
3080   then   then
3081   all_installed="${ipver}-${ipbuild}"   all_installed="${ipver}-${ipbuild}"
# Line 2724  pkgsearch() Line 3084  pkgsearch()
3084   fi   fi
3085   done   done
3086   [[ -z ${all_installed} ]] && all_installed="none"   [[ -z ${all_installed} ]] && all_installed="none"
3087    
3088   case ${state} in   case ${state} in
3089   stable) state=${COLGREEN}"[s] ";;   stable) state=${COLGREEN}"[s] ";;
3090   testing) state=${COLYELLOW}"[t] ";;   testing) state=${COLYELLOW}"[t] ";;
# Line 2769  EOF Line 3129  EOF
3129   echo "      Installed versions: ${all_installed}"   echo "      Installed versions: ${all_installed}"
3130   echo "      Description: ${description}"   echo "      Description: ${description}"
3131   echo "      Homepage: ${homepage}"   echo "      Homepage: ${homepage}"
3132     if [[ ! -z ${license} ]]
3133     then
3134     echo "      License:  ${license}"
3135     fi
3136   echo "      Depends: ${deps}"   echo "      Depends: ${deps}"
3137   echo "      SDepends: ${sdeps}"   echo "      SDepends: ${sdeps}"
3138   echo   echo
# Line 2809  export_inherits() Line 3173  export_inherits()
3173   eval "${functions}() { ${include}_${functions} ; }"   eval "${functions}() { ${include}_${functions} ; }"
3174    
3175   # debug   # debug
3176   [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"   mqueryfeature "debug" && typeset -f "${functions}"
3177    
3178   shift   shift
3179   done   done
# Line 2881  EOF Line 3245  EOF
3245   return 0   return 0
3246  }  }
3247    
3248    # need_busybox_support ${cmd}
3249    # return 0 (no error = needs busybox support) or return 1 (error = no busybox support required)
3250    need_busybox_support()
3251    {
3252     local cmd
3253     cmd="$1"
3254    
3255     if [[ -x /bin/busybox ]]
3256     then
3257     if [[ $(readlink $(which ${cmd})) = /bin/busybox ]]
3258     then
3259     # needs busybox support
3260     return 0
3261     fi
3262     fi
3263    
3264     # no busybox
3265     return 1
3266    }
3267    
3268    # busybox_filter_wget_options ${wget_opts}
3269    busybox_filter_wget_options()
3270    {
3271     local opts="$@"
3272     local i
3273     local fixed_opts
3274    
3275     if need_busybox_support wget
3276     then
3277     for i in ${opts}
3278     do
3279     # show only the allowed ones
3280     case ${i} in
3281     -c|--continue) fixed_opts+=" -c" ;;
3282     -s|--spider) fixed_opts+=" -s" ;;
3283     -q|--quiet) fixed_opts+=" -q" ;;
3284     -O|--output-document) shift; fixed_opts+=" -O $1" ;;
3285     --header) shift; fixed_opts+=" --header $1" ;;
3286     -Y|--proxy) shift; fixed_opts+=" -Y $1" ;;
3287     -P) shift; fixed_opts+=" -P $1" ;;
3288     --no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;;
3289     -U|--user-agent) shift; fixed_opts+=" -U ${i}" ;;
3290     # simply drop all other opts
3291     *) continue ;;
3292     esac
3293     done
3294    
3295     echo "${fixed_opts}"
3296     else
3297     echo "${opts}"
3298     fi
3299    }
3300    
3301    have_root_privileges()
3302    {
3303     local retval
3304    
3305     if [[ $(id -u) = 0 ]]
3306     then
3307     retval=0
3308     else
3309     retval=1
3310     fi
3311    
3312     return ${retval}
3313    }
3314    
3315    known_mage_feature()
3316    {
3317     local feature="$1"
3318     local retval
3319    
3320     case "${feature}" in
3321     autosvc|!autosvc) retval=0 ;;
3322     buildlog|!buildlog) retval=0 ;;
3323     ccache|!ccache) retval=0 ;;
3324     check|!check) retval=0 ;;
3325     compressdoc|!compressdoc) retval=0 ;;
3326     debug|!debug) retval=0 ;;
3327     distcc|!distcc) retval=0 ;;
3328     kernelsrcunpack|!kernelsrcunpack) retval=0 ;;
3329     libtool|!libtool) retval=0 ;;
3330     linuxsymlink|!linuxsymlink) retval=0 ;;
3331     pkgbuild|!pkgbuild) retval=0 ;;
3332     pkgdistrotag|!pkgdistrotag) retval=0 ;;
3333     purge|!purge) retval=0 ;;
3334     qalint|!qalint) retval=0 ;;
3335     regentree|!regentree) retval=0 ;;
3336     resume|!resume) retval=0 ;;
3337     srcpkgbuild|!srcpkgbuild) retval=0 ;;
3338     srcpkgtarball|!srcpkgtarball) retval=0 ;;
3339     static|!static) retval=0 ;;
3340     stepbystep|!stepbystep) retval=0 ;;
3341     strip|!strip) retval=0 ;;
3342     verbose|!verbose) retval=0 ;;
3343     *) retval=1 ;;
3344     esac
3345    
3346     return "${retval}"
3347    }
3348    
3349    load_mage_features()
3350    {
3351     for i in ${MAGE_FEATURES_GLOBAL[*]} ${MAGE_FEATURES[*]}
3352     do
3353     FVERBOSE=off msetfeature ${i}
3354     done
3355    }
3356    
3357    msetfeature()
3358    {
3359     local feature
3360     local count
3361     local i
3362     local found
3363    
3364     for feature in $@
3365     do
3366     found=0
3367     count="${#MAGE_FEATURES_CURRENT[*]}"
3368    
3369     if ! known_mage_feature "${feature}"
3370     then
3371     [[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}"
3372     return 3
3373     fi
3374    
3375     for ((i=0; i<count; i++))
3376     do
3377     if [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature} ]]
3378     then
3379     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' already enabled${COLDEFAULT}"
3380     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3381     found=1
3382     elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = !${feature} ]]
3383     then
3384     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' currently disabled, enabling it!${COLDEFAULT}"
3385     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3386     found=1
3387     elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature//!} ]]
3388     then
3389     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature//!}' currently enabled, disabling it!${COLDEFAULT}"
3390     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3391     found=1
3392     fi
3393     done
3394    
3395     # if the feature was not found after proccessing the whole array
3396     # it was not declared. in this case enable it
3397     if [[ ${found} = 0 ]]
3398     then
3399     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' was not declared, enabling it!${COLDEFAULT}"
3400     MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )
3401     fi
3402    
3403     export MAGE_FEATURE_CURRENT
3404     done
3405    }
3406    
3407    mqueryfeature()
3408    {
3409     local feature="$1"
3410     local retval=1
3411     local i
3412    
3413     if known_mage_feature "${feature}"
3414     then
3415     for i in ${MAGE_FEATURES_CURRENT[*]}
3416     do
3417     if [[ ${i} = ${feature} ]]
3418     then
3419     retval=0
3420     break # found break here
3421     fi
3422     done
3423     else
3424     [[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}"
3425     retval=3
3426     fi
3427    
3428     return ${retval}
3429    }
3430    
3431    mprintfeatures()
3432    {
3433     echo "Global features:  ${MAGE_FEATURES_GLOBAL[*]}"
3434     echo "Local features:   ${MAGE_FEATURES[*]}"
3435     echo "Current features: ${MAGE_FEATURES_CURRENT[*]}"
3436    }

Legend:
Removed from v.942  
changed lines
  Added in v.1658