Magellan Linux

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

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

revision 373 by niro, Thu Apr 27 17:15:23 2006 UTC revision 1547 by niro, Tue Dec 27 09:58:03 2011 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  # Magellan Linux Installer Functions (mage.functions.sh)  # Magellan Linux Installer Functions (mage.functions.sh)
3  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.19 2006-04-27 17:15:23 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.38 2008-10-05 10:32:24 niro Exp $
4    
5    COLRED="\033[1;6m\033[31m"
6    COLGREEN="\033[1;6m\033[32m"
7    COLYELLOW="\033[1;6m\033[33m"
8    COLBLUE="\033[1;6m\033[34m"
9    COLMAGENTA="\033[1;6m\033[35m"
10    COLWHITE="\033[1;6m\033[37m"
11    COLGRAY="\033[0;6m\033[37m"
12    COLBOLD="\033[1m"
13    COLDEFAULT="\033[0m"
14    
15    if [[ ${NOCOLORS} = true ]]
16    then
17     COLRED=""
18     COLGREEN=""
19     COLYELLOW=""
20     COLBLUE=""
21     COLMAGENTA=""
22     COLWHITE=""
23     COLGRAY=""
24     COLBOLD=""
25     COLDEFAULT=""
26    fi
27    
28  mage_setup()  mage_setup()
29  {  {
# Line 23  unpack_packages() Line 46  unpack_packages()
46   local pkgtype   local pkgtype
47   local count_current   local count_current
48   local count_total   local count_total
49     local tar_opts
50    
51   # get count of total packages   # get count of total packages
52   declare -i count_current=0   declare -i count_current=0
# Line 54  unpack_packages() Line 78  unpack_packages()
78   continue   continue
79   fi   fi
80    
81     # busybox?
82     if need_busybox_support tar
83     then
84     tar_opts="xjf"
85     else
86     tar_opts="xjmf"
87     fi
88    
89   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "
90   tar xjmf ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"   tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"
91   done   done
92    
93   # add a crlf for a better view   # add a crlf for a better view
# Line 198  install_files() Line 230  install_files()
230   is_config_protected "${pathto}"   is_config_protected "${pathto}"
231   retval="$?"   retval="$?"
232    
233   # 0 - not protected        #   # 0 - not protected         #
234   # 1 - error                #   # 1 - error                 #
235   # 2 - protected            #   # 2 - protected             #
236   # 3 - protected but masked #   # 3 - protected but masked  #
237     # 4 - protected but ignored #
238    
239   case ${retval} in   case ${retval} in
240   # file is not protected - (over)write it   # file is not protected - (over)write it
# Line 218  install_files() Line 251  install_files()
251   "${user}" \   "${user}" \
252   "${group}" \   "${group}" \
253   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
254   "${MROOT}${pathto}")" \   "${MROOT}${pathto}")" \
255   "${md5sum}"   "${md5sum}"
256   ;;   ;;
257    
# Line 245  install_files() Line 278  install_files()
278   "${user}" \   "${user}" \
279   "${group}" \   "${group}" \
280   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
281   "${dest_protected}")" \   "${dest_protected}")" \
282   "${md5sum}"   "${md5sum}"
283    
284   # update global MAGE_PROTECT_COUNTER   # update global MAGE_PROTECT_COUNTER
285   (( MAGE_PROTECT_COUNTER++ ))   (( MAGE_PROTECT_COUNTER++ ))
286   export MAGE_PROTECT_COUNTER   export MAGE_PROTECT_COUNTER
287   ;;   ;;
288    
289     # file is protected but ignored, delete the update/do nothing
290     4)
291     if [[ ${VERBOSE} = on ]]
292     then
293     echo -en "${COLRED}"
294     echo -n "! ignr "
295     echo -en "${COLDEFAULT}"
296     echo " === FILE: ${MROOT}${pathto}"
297     fi
298     # simply do nothing here - only fix mtime
299     fix_descriptor ${pkgname}/.files \
300     "${pathto}" \
301     "${posix}" \
302     "${user}" \
303     "${group}" \
304     "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
305     "${MROOT}${pathto}")" \
306     "${md5sum}"
307     ;;
308   esac   esac
309   done < ${BUILDDIR}/${pkgname}/.files   done < ${BUILDDIR}/${pkgname}/.files
310    
# Line 298  install_symlinks() Line 351  install_symlinks()
351    
352   ln -snf "${link}" "${MROOT}${pathto}"   ln -snf "${link}" "${MROOT}${pathto}"
353    
354   # fix mtime and db  # # fix mtime and db
355   fix_descriptor ${pkgname}/.symlinks \  # fix_descriptor ${pkgname}/.symlinks \
356   "${pathto}" \  # "${pathto}" \
357   "${posix}" \  # "${posix}" \
358   "${link}" \  # "${link}" \
359   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \  # "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
360   "${MROOT}${pathto}")"  # "${MROOT}${pathto}")"
361    
362   done < ${BUILDDIR}/${pkgname}/.symlinks   done < ${BUILDDIR}/${pkgname}/.symlinks
363    
364   # now copy the fixed file over the old one  # # now copy the fixed file over the old one
365   [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \  # [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \
366   cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,}  # cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,}
367    
368   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
369   IFS=$'\n'   IFS=$'\n'
# Line 326  install_blockdevices() Line 379  install_blockdevices()
379   local pkgname="$1"   local pkgname="$1"
380   local pathto   local pathto
381   local posix   local posix
382     local user
383     local group
384   local IFS   local IFS
385    
386   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 339  install_blockdevices() Line 394  install_blockdevices()
394   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
395   IFS=§   IFS=§
396    
397   while read pathto posix   while read pathto posix major minor user group
398   do   do
399   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
400   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"
401    
402   mkfifo -m "${posix}" "${MROOT}$pathto"   mknod -m "${posix}" "${MROOT}${pathto}"
403     # make it optional atm !!
404     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
405     then
406     chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}"
407     fi
408   done < ${BUILDDIR}/${pkgname}/.pipes   done < ${BUILDDIR}/${pkgname}/.pipes
409    
410   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
# Line 363  install_characterdevices() Line 423  install_characterdevices()
423   local posix   local posix
424   local major   local major
425   local minor   local minor
426     local user
427     local group
428   local IFS   local IFS
429    
430   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 376  install_characterdevices() Line 438  install_characterdevices()
438   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
439   IFS=§   IFS=§
440    
441   while read pathto posix major minor   while read pathto posix major minor user group
442   do   do
443   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
444   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"
445    
446   mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor}   mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}"
447    
448     # make it optional atm !!
449     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
450     then
451     chown "${user}:${group}" "${MROOT}${pathto}"
452     fi
453   done < ${BUILDDIR}/${pkgname}/.char   done < ${BUILDDIR}/${pkgname}/.char
454    
455   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
456   IFS=$'\n'   IFS=$'\n'
457  }  }
458    
459    ###################################################
460    # function install_fifos                          #
461    # install_fifos $PKGNAME                    #
462    ###################################################
463    install_fifos()
464    {
465     local pkgname="$1"
466     local pathto
467     local posix
468     local user
469     local group
470     local IFS
471    
472     # sanity checks; abort if not given
473     [ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given."
474    
475     # check needed global vars
476     [ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set."
477    
478     # make it optional atm !!
479     #[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found"
480     [ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return
481    
482     # sets fieldseperator to "§" instead of " "
483     IFS=§
484    
485     while read pathto posix user group
486     do
487     [ -z "${pathto}" ] && continue
488     [[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}"
489    
490     mkfifo -m "${posix}" "${MROOT}${pathto}"
491     chown "${user}:${group}" "${MROOT}${pathto}"
492     done < ${BUILDDIR}/${pkgname}/.fifo
493    
494     # very important: unsetting the '§' fieldseperator
495     IFS=$'\n'
496    }
497    
498    
499  ###################################################  ###################################################
500  # function build_doinstall                        #  # function build_doinstall                        #
501  # build_doinstall $PKGNAME                  #  # build_doinstall $PKGNAME                  #
502  # NOTE: this is an wrapper do install packages    #  # NOTE: this is an wrapper to install packages    #
503  ###################################################  ###################################################
504  build_doinstall()  build_doinstall()
505  {  {
# Line 400  build_doinstall() Line 507  build_doinstall()
507    
508   # sanity checks; abort if not given   # sanity checks; abort if not given
509   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."
510    
511   # this is only a wrapper   # this is only a wrapper
512    
513   # NOTE:   # NOTE:
# Line 415  build_doinstall() Line 522  build_doinstall()
522   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"
523   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"
524   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"
525     install_fifos ${pkgname} || die "install fifos ${pkgname}"
526  }  }
527    
528    
# Line 476  install_database_entry() Line 584  install_database_entry()
584    
585   # create fake file descriptors   # create fake file descriptors
586   # used by virtual and source packages   # used by virtual and source packages
587   for i in .dirs .symlinks .files .pipes .char   for i in .dirs .symlinks .files .pipes .char .fifo
588   do   do
589   touch ${dbrecorddir}/${i}   touch ${dbrecorddir}/${i}
590   done   done
# Line 494  install_database_entry() Line 602  install_database_entry()
602    
603   # normal packages needs these files   # normal packages needs these files
604   local i   local i
605   for i in .char .dirs .files .pipes .symlinks   for i in .char .dirs .files .pipes .symlinks .fifo
606   do   do
607   install -m 0644 ${BUILDDIR}/${pkgname}/${i} \   # make .fifo optional atm
608   ${dbrecorddir}/${i}   if [[ -f ${BUILDDIR}/${pkgname}/${i} ]]
609     then
610     install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i}
611     fi
612   done   done
613   ;;   ;;
614   esac   esac
# Line 772  remove_files() Line 883  remove_files()
883   done   done
884    
885   # sanity checks; abort if not given   # sanity checks; abort if not given
886   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_files() \$pcat not given."
887   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_files() \$pname not given."
888   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_files() \$pver not given."
889   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_files() \$pbuild not given."
890   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
891    
892   # check needed global vars   # check needed global vars
# Line 809  remove_files() Line 920  remove_files()
920   is_config_protected "${pathto}"   is_config_protected "${pathto}"
921   retval="$?"   retval="$?"
922    
923   # 0 - not protected        #   # 0 - not protected         #
924   # 1 - error                #   # 1 - error                 #
925   # 2 - protected            #   # 2 - protected             #
926   # 3 - protected but masked #   # 3 - protected but masked  #
927     # 4 - protected but ignored #
928    
929   case ${retval} in   case ${retval} in
930   # file is not protected - delete it   # file is not protected - delete it
# Line 831  remove_files() Line 943  remove_files()
943   echo " === FILE: ${MROOT}${pathto}"   echo " === FILE: ${MROOT}${pathto}"
944   fi   fi
945   ;;   ;;
946    
947     # file is protected but ignored, delete the update/do nothing
948     4)
949     if [[ ${VERBOSE} = on ]]
950     then
951     echo -en "${COLRED}"
952     echo -n "! ignr "
953     echo -en "${COLDEFAULT}"
954     echo " === FILE: ${MROOT}${pathto}"
955     fi
956     # simply do nothing here
957     ;;
958   esac   esac
959   ;;   ;;
960   1)   1)
# Line 853  remove_blockdevices() Line 977  remove_blockdevices()
977  {  {
978   local pathto   local pathto
979   local posix   local posix
980     local user
981     local group
982   local IFS   local IFS
983   local pcat   local pcat
984   local pname   local pname
# Line 876  remove_blockdevices() Line 1002  remove_blockdevices()
1002   done   done
1003    
1004   # sanity checks; abort if not given   # sanity checks; abort if not given
1005   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given."
1006   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_blockdevices() \$pname not given."
1007   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_blockdevices() \$pver not given."
1008   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given."
1009   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1010    
1011   # check needed global vars   # check needed global vars
# Line 890  remove_blockdevices() Line 1016  remove_blockdevices()
1016   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1017   IFS=§   IFS=§
1018    
1019   while read pathto posix   while read pathto posix user group
1020   do   do
1021   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1022    
# Line 911  remove_characterdevices() Line 1037  remove_characterdevices()
1037  {  {
1038   local pathto   local pathto
1039   local posix   local posix
1040     local user
1041     local group
1042   local IFS   local IFS
1043   local pcat   local pcat
1044   local pname   local pname
# Line 934  remove_characterdevices() Line 1062  remove_characterdevices()
1062   done   done
1063    
1064   # sanity checks; abort if not given   # sanity checks; abort if not given
1065   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given."
1066   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_characterdevices() \$pname not given."
1067   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_characterdevices() \$pver not given."
1068   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given."
1069   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1070    
1071   # check needed global vars   # check needed global vars
# Line 948  remove_characterdevices() Line 1076  remove_characterdevices()
1076   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1077   IFS=§   IFS=§
1078    
1079   while read pathto posix   while read pathto posix user group
1080   do   do
1081   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1082    
# Line 962  remove_characterdevices() Line 1090  remove_characterdevices()
1090    
1091    
1092  ###################################################  ###################################################
1093    # function remove_fifos                           #
1094    # remove_fifos $PKGNAME                     #
1095    ###################################################
1096    remove_fifos()
1097    {
1098     local pathto
1099     local posix
1100     local user
1101     local group
1102     local IFS
1103     local pcat
1104     local pname
1105     local pver
1106     local pbuild
1107     local i
1108     local pfull
1109    
1110     IFS=$'\n'
1111    
1112     # very basic getops
1113     for i in $*
1114     do
1115     case $1 in
1116     --pcat|-c) shift; pcat="$1" ;;
1117     --pname|-n) shift; pname="$1" ;;
1118     --pver|-v) shift; pver="$1" ;;
1119     --pbuild|-b) shift; pbuild="$1" ;;
1120     esac
1121     shift
1122     done
1123    
1124     # sanity checks; abort if not given
1125     [ -z "${pcat}" ] && die "remove_fifos() \$pcat not given."
1126     [ -z "${pname}" ] && die "remove_fifos() \$pname not given."
1127     [ -z "${pver}" ] && die "remove_fifos() \$pver not given."
1128     [ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given."
1129     pfull="${pcat}/${pname}-${pver}-${pbuild}"
1130    
1131     # check needed global vars
1132     [ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set."
1133    
1134     # make it optional atm !!
1135     #[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found"
1136     [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return
1137    
1138     # sets fieldseperator to "§" instead of " "
1139     IFS=§
1140    
1141     while read pathto posix user group
1142     do
1143     [ -z "${pathto}" ] && continue
1144    
1145     [[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}"
1146     rm "${MROOT}${pathto}"
1147     done < ${MROOT}${INSTALLDB}/${pfull}/.fifo
1148    
1149     # very important: unsetting the '§' fieldseperator
1150     IFS=$'\n'
1151    }
1152    
1153    
1154    ###################################################
1155  # function remove_direcories                      #  # function remove_direcories                      #
1156  # remove_direcories $PKGNAME                #  # remove_direcories $PKGNAME                #
1157  ###################################################  ###################################################
# Line 992  remove_directories() Line 1182  remove_directories()
1182   done   done
1183    
1184   # sanity checks; abort if not given   # sanity checks; abort if not given
1185   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_directories() \$pcat not given."
1186   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_directories() \$pname not given."
1187   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_directories() \$pver not given."
1188   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given."
1189   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1190    
1191   # check needed global vars   # check needed global vars
# Line 1049  remove_directories() Line 1239  remove_directories()
1239  ###################################################  ###################################################
1240  # function build_douninstall                      #  # function build_douninstall                      #
1241  # build_douninstall $PKGNAME                #  # build_douninstall $PKGNAME                #
1242  # NOTE: this is an wrapper do remove packages     #  # NOTE: this is an wrapper to remove packages     #
1243  ###################################################  ###################################################
1244  build_douninstall()  build_douninstall()
1245  {  {
# Line 1083  build_douninstall() Line 1273  build_douninstall()
1273   # !! we use § as field seperator !!   # !! we use § as field seperator !!
1274   # doing so prevent us to get errors by filenames with spaces   # doing so prevent us to get errors by filenames with spaces
1275    
1276   for i in symlinks files blockdevices characterdevices directories   for i in symlinks files blockdevices characterdevices directories fifos
1277   do   do
1278   remove_${i} \   remove_${i} \
1279   --pcat "${pcat}" \   --pcat "${pcat}" \
# Line 1105  fetch_packages() Line 1295  fetch_packages()
1295   local opt   local opt
1296   local count_current   local count_current
1297   local count_total   local count_total
1298     local wget_opts
1299    
1300   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your /etc/mage.rc."   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."
1301    
1302     # filter wget command if busybox was found
1303     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1304    
1305   # get count of total packages   # get count of total packages
1306   declare -i count_current=0   declare -i count_current=0
# Line 1153  fetch_packages() Line 1347  fetch_packages()
1347   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1348   [[ ${VERBOSE} = off ]] && opt="--quiet"   [[ ${VERBOSE} = off ]] && opt="--quiet"
1349   wget \   wget \
1350   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
1351   --directory-prefix=${PKGDIR} \   --directory-prefix=${PKGDIR} \
1352   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}
1353   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 1181  syncmage() Line 1372  syncmage()
1372  {  {
1373   if [ -z "${RSYNC}" ]   if [ -z "${RSYNC}" ]
1374   then   then
1375   die "You have no rsync-mirrors defined. Please edit your /etc/mage.rc."   die "You have no rsync-mirrors defined. Please edit your ${MAGERC}."
1376   fi   fi
1377    
1378   local i   local i
1379   for i in ${RSYNC}   for i in ${RSYNC}
1380   do   do
1381   rsync \   rsync ${RSYNC_FETCH_OPTIONS} ${i} ${MAGEDIR}
  --recursive \  
  --links \  
  --perms \  
  --times \  
  --devices \  
  --timeout=600 \  
  --verbose \  
  --compress \  
  --progress \  
  --stats \  
  --delete \  
  --delete-after \  
  ${i} ${MAGEDIR}  
1382   if [[ $? = 0 ]]   if [[ $? = 0 ]]
1383   then   then
1384   break   break
# Line 1210  syncmage() Line 1388  syncmage()
1388   done   done
1389    
1390   # clean up backup files (foo~)   # clean up backup files (foo~)
1391   find ${MAGEDIR} -name *~ -exec rm '{}' ';'   find ${MAGEDIR} -name \*~ -exec rm '{}' ';'
1392    
1393   # check if an newer mage version is available   # check if a newer mage version is available
1394   is_newer_mage_version_available   is_newer_mage_version_available
1395  }  }
1396    
1397    syncmage_tarball()
1398    {
1399     local latest_tarball
1400     local latest_md5
1401     local temp="$(mktemp -d)"
1402     local mirr mymirr
1403     local opt
1404     local tar_opts
1405     local wget_opts
1406    
1407     # try to get the md5 marked as latest on the server
1408     latest_md5="mage-latest.md5"
1409    
1410     # try to get the tarball marked as latest on the server
1411     latest_tarball="mage-latest.tar.bz2"
1412    
1413     # filter wget command if busybox was found
1414     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1415    
1416     for mirr in ${MIRRORS}
1417     do
1418     # path without distribution
1419     mymirr="${mirr%/*}"
1420    
1421     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1422     echo "fetching latest md5 from ${mymirr} ..."
1423     [[ ${VERBOSE} = off ]] && opt="--quiet"
1424     wget \
1425     ${wget_opts} \
1426     --directory-prefix=${temp} \
1427     ${opt} ${mymirr}/rsync/tarballs/${latest_md5}
1428    
1429     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1430     echo "fetching latest tarball from ${mymirr} ..."
1431     wget \
1432     ${wget_opts} \
1433     --directory-prefix=${temp} \
1434     ${opt} ${mymirr}/rsync/tarballs/${latest_tarball}
1435     if [[ $? = 0 ]]
1436     then
1437     break
1438     else
1439     continue
1440     fi
1441     done
1442    
1443     if [[ -f ${temp}/${latest_tarball} ]]
1444     then
1445     # check md5
1446     if [[ ! -f ${temp}/${latest_md5} ]]
1447     then
1448     die "md5 is missing ... aborting"
1449     else
1450     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1451     echo -n "checking md5sum... "
1452     ( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed"
1453     fi
1454    
1455     if [[ -d ${MAGEDIR} ]]
1456     then
1457     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1458     echo "cleaning old mage-tree ${MAGEDIR}..."
1459     rm -rf ${MAGEDIR}
1460     fi
1461    
1462     if need_busybox_support tar
1463     then
1464     tar_opts="xjf"
1465     else
1466     tar_opts="xjmf"
1467     fi
1468    
1469     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1470     echo "updating mage-tree from tarball ..."
1471     # unpack in dirname of MAGEDIR, as the tarball has already the mage
1472     tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1473    
1474     if [[ -d ${temp} ]]
1475     then
1476     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1477     echo "cleaning temp-files ..."
1478     rm -rf ${temp}
1479     fi
1480    
1481     # check if a newer mage version is available
1482     is_newer_mage_version_available
1483     else
1484     die "Could not fetch the latest tarball ... aborting"
1485     fi
1486    }
1487    
1488  cleanpkg()  cleanpkg()
1489  {  {
1490   if [ -d "${PKGDIR}" ]   if [ -d "${PKGDIR}" ]
# Line 1253  choppkgname() Line 1522  choppkgname()
1522   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]
1523   then   then
1524   #cuts ARCH and PBUILD   #cuts ARCH and PBUILD
1525   #ARCH comes from /etc/mage.rc   #ARCH comes from ${MAGERC}
1526   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")
1527    
1528   #cuts version number   #cuts version number
# Line 1328  get_highest_magefile() Line 1597  get_highest_magefile()
1597   local PNAME="$2"   local PNAME="$2"
1598   local magefile   local magefile
1599    
1600   for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*)   # do not list the content of a directory, only the name (-d)
1601     for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/* 2> /dev/null)
1602   do   do
1603     [[ -z ${magefile} ]] && continue
1604   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
1605   [ -d ${magefile} ] && continue   [[ -d ${magefile} ]] && continue
1606   if check_stable_package ${magefile}   if check_stable_package ${magefile}
1607   then   then
1608   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
# Line 1376  get_highest_magefile() Line 1647  get_highest_magefile()
1647  #        1 - error                                #  #        1 - error                                #
1648  #        2 - protected                            #  #        2 - protected                            #
1649  #        3 - protected but masked                 #  #        3 - protected but masked                 #
1650    #        4 - protected but ignored                #
1651  #                                                 #  #                                                 #
1652  ###################################################  ###################################################
1653  is_config_protected()  is_config_protected()
# Line 1384  is_config_protected() Line 1656  is_config_protected()
1656   local TEST   local TEST
1657   local PROTECTED   local PROTECTED
1658   local IFS   local IFS
1659     local i
1660     local x
1661    
1662   EXPFILE="${MROOT}$1"   EXPFILE="${MROOT}$1"
1663    
1664   # file does not exist; it can be written   # file does not exist; it can be written
1665   [ ! -e ${EXPFILE} ] && return 0   [[ ! -e ${EXPFILE} ]] && return 0
1666    
1667   # to be safe; it may be '§'   # to be safe; it may be '§'
1668   IFS=' '   IFS=' '
1669    
1670   # check ob in config protect   # check if config protected
1671   for i in ${CONFIG_PROTECT}   for i in ${CONFIG_PROTECT}
1672   do   do
1673   # ersetzen von $i nur wenn am anfang der variable   # only replace $i in the beginning of the variable
1674   TEST="${EXPFILE/#${MROOT}${i}/Protected}"   TEST="${EXPFILE/#${MROOT}${i}/Protected}"
1675   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1676   then   then
1677   # setzen das es protected ist   # file is config proteced
1678   PROTECTED=TRUE   PROTECTED=TRUE
1679    
1680   # check ob nicht doch maskiert   # check if not masked
1681   for x in ${CONFIG_PROTECT_MASK}   for x in ${CONFIG_PROTECT_MASK}
1682   do   do
1683   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"
1684   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1685   then   then
1686   PROTECTED=MASKED   PROTECTED=MASKED
1687   fi   fi
1688   done   done
1689    
1690     # check if not ignored
1691     for x in ${CONFIG_PROTECT_IGNORE}
1692     do
1693     TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}"
1694     if [[ ${TEST} != ${EXPFILE} ]]
1695     then
1696     PROTECTED=IGNORED
1697     fi
1698     done
1699   fi   fi
1700   done   done
1701    
# Line 1426  is_config_protected() Line 1710  is_config_protected()
1710   #echo "I'm protected, but masked - delete me"   #echo "I'm protected, but masked - delete me"
1711   return 3   return 3
1712   ;;   ;;
1713     IGNORED)
1714     #echo "I'm protected, but ignored - keep me, del update"
1715     return 4
1716     ;;
1717   *)   *)
1718   #echo "delete me"   #echo "delete me"
1719   return 0   return 0
# Line 1443  is_config_protected() Line 1731  is_config_protected()
1731  ###################################################  ###################################################
1732  count_protected_files()  count_protected_files()
1733  {  {
1734   ${MLIBDIR}/writeprotected "$1"   local file="$1"
1735     local dirname="${file%/*}"
1736     local filename="${file##*/}"
1737     local count
1738     local output
1739     local i
1740    
1741     declare -i count=0
1742    
1743     # check if there are already protected files
1744     for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" |
1745     sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
1746     sort -t'%' -k3 -k2 | cut -f1 -d'%')
1747     do
1748     count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::")
1749     done
1750     (( count ++ ))
1751    
1752     # fill output up with zeros
1753     for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
1754     output="${output}${count}"
1755    
1756     echo "${output}"
1757  }  }
1758    
1759  # call with  # call with
# Line 1460  get_uninstall_candidates() Line 1770  get_uninstall_candidates()
1770   local list   local list
1771   local pcatdir   local pcatdir
1772   local protected   local protected
1773     local i
1774    
1775   # very basic getops   # very basic getops
1776   for i in $*   for i in $*
# Line 1614  virtuals_add() Line 1925  virtuals_add()
1925    
1926  #deletes pakages from virtual database  #deletes pakages from virtual database
1927  #$1 virtualname; $2 pkgname  #$1 virtualname; $2 pkgname
1928  virtuals_del() {  virtuals_del()
1929    {
1930    
1931   local virtualname="$1"   local virtualname="$1"
1932   local pkgname="$2"   local pkgname="$2"
# Line 1721  minclude() Line 2033  minclude()
2033  {  {
2034   local i   local i
2035    
2036   if [ -n "$@" ]   if [[ -n $* ]]
2037   then   then
2038   for i in $@   for i in $*
2039   do   do
2040   [[ ${MAGEDEBUG} = on ]] && \   [[ ${MAGEDEBUG} = on ]] && \
2041   echo "--- Including ${MAGEDIR}/include/${i}.minc"   echo "--- Including ${MAGEDIR}/include/${i}.minc"
# Line 1737  sminclude() Line 2049  sminclude()
2049  {  {
2050   local i   local i
2051    
2052   if [ -n "$@" ]   if [[ -n $* ]]
2053   then   then
2054   for i in $@   for i in $*
2055   do   do
2056   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
2057   source ${SMAGESCRIPTSDIR}/include/${i}.sminc   source ${SMAGESCRIPTSDIR}/include/${i}.sminc
# Line 2048  get_value_from_magefile() Line 2360  get_value_from_magefile()
2360   local SDEPEND   local SDEPEND
2361   local PROVIDE   local PROVIDE
2362   local PKGTYPE   local PKGTYPE
2363     local MAGE_TARGETS
2364     local SPLIT_PACKAGE_BASE
2365   local preinstall   local preinstall
2366   local postinstall   local postinstall
2367   local preremove   local preremove
# Line 2094  mage_install() Line 2408  mage_install()
2408   local count_current   local count_current
2409   local magefile   local magefile
2410   local src_install   local src_install
2411     local i
2412    
2413   # very basic getops   # very basic getops
2414   for i in $*   for i in $*
# Line 2167  mage_install() Line 2482  mage_install()
2482   echo B:${pbuild}   echo B:${pbuild}
2483   fi   fi
2484    
2485   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2   if [[ -n ${MAGE_TARGETS} ]]
2486     then
2487     # basic svn compat
2488     if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2489     then
2490     for i in ${SMAGESCRIPTSDIR}/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2491     do
2492     smage2file="${i}"
2493     done
2494     else
2495     smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2496     fi
2497    
2498     elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2499     then
2500     # basic svn compat
2501     if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2502     then
2503     for i in ${SMAGESCRIPTSDIR}/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2504     do
2505     smage2file="${i}"
2506     done
2507     else
2508     smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2509     fi
2510    
2511     else
2512     # basic svn compat
2513     if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2514     then
2515     for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2516     do
2517     smage2file="${i}"
2518     done
2519     else
2520     smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2
2521     fi
2522     fi
2523    
2524   if [ -f "${smage2file}" ]   if [ -f "${smage2file}" ]
2525   then   then
2526     echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "
2527   smage2 ${smage2file} || die "compile failed"   smage2 ${smage2file} || die "compile failed"
2528   else   else
2529   echo   echo
# Line 2183  mage_install() Line 2537  mage_install()
2537   if [[ ${PKGTYPE} != virtual ]] && \   if [[ ${PKGTYPE} != virtual ]] && \
2538   [[ ${PKGTYPE} != sources ]]   [[ ${PKGTYPE} != sources ]]
2539   then   then
2540   # show a verbose message on src-install   echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... "
  if [[ ${src_install} = true ]]  
  then  
  echo -ne "${COLBLUE} *** ${COLDEFAULT}"  
  echo -ne "merging files: "  
  echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"  
  echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"  
  fi  
2541   build_doinstall ${PKGNAME}   build_doinstall ${PKGNAME}
2542   fi   fi
2543    
# Line 2304  md5sum_packages() Line 2651  md5sum_packages()
2651   then   then
2652   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2653   echo -ne "checking md5sum (${count_current}/${count_total}): "   echo -ne "checking md5sum (${count_current}/${count_total}): "
2654   ( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed"   ( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed"
2655   else   else
2656   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2657   echo -e "!! no md5sum file found for ${pkgfile} :("   echo -e "!! no md5sum file found for ${pkgfile} :("
# Line 2447  mage_uninstall() Line 2794  mage_uninstall()
2794   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"
2795   echo -n "removing: "   echo -n "removing: "
2796   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2797   echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"   echo -e "${COLRED}${pname}-${pver}-${pbuild}${COLDEFAULT}"
2798    
2799   magefile="${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"   magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
2800   source ${magefile}   source ${magefile}
2801    
2802   ## preremove scripts   ## preremove scripts
# Line 2517  mage_uninstall() Line 2864  mage_uninstall()
2864   unset -f postremove   unset -f postremove
2865  }  }
2866    
2867  show_etc_update_mesg() {  show_etc_update_mesg()
2868    {
2869   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0
2870    
2871   echo   echo
# Line 2547  pkgsearch() Line 2895  pkgsearch()
2895   local all_installed   local all_installed
2896   local ipver   local ipver
2897   local ipbuild   local ipbuild
2898     local latest_available
2899     local depsfull
2900     local sdepsfull
2901     local deps
2902     local sdeps
2903     local dep
2904     local sign
2905    
2906   # only names no versions   # only names no versions
2907   result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name '*'${string}'*')"   result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name '*'${string}'*'| sed '/profiles/d' | sed '/includes/d')"
2908   #result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)"   #result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)"
2909    
2910   # nothing found   # nothing found
# Line 2564  pkgsearch() Line 2919  pkgsearch()
2919   # get highest version available   # get highest version available
2920   magefile=$(get_highest_magefile ${pcat} ${pname})   magefile=$(get_highest_magefile ${pcat} ${pname})
2921    
2922   # now get all needed infos to print a nice output   if [[ ! -z ${magefile} ]]
2923   pver="$(magename2pver ${magefile})"   then
2924   pbuild="$(magename2pbuild ${magefile})"   # now get all needed infos to print a nice output
2925   state="$(get_value_from_magefile STATE ${magefile})"   pver="$(magename2pver ${magefile})"
2926   description="$(get_value_from_magefile DESCRIPTION ${magefile})"   pbuild="$(magename2pbuild ${magefile})"
2927   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"   state="$(get_value_from_magefile STATE ${magefile})"
2928     description="$(get_value_from_magefile DESCRIPTION ${magefile})"
2929     homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
2930    
2931     # all installed
2932     for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
2933     do
2934     ipver="$(magename2pver ${i})"
2935     ipbuild="$(magename2pbuild ${i})"
2936    
2937     if [[ -z ${all_installed} ]]
2938     then
2939     all_installed="${ipver}-${ipbuild}"
2940     else
2941     all_installed="${all_installed} ${ipver}-${ipbuild}"
2942     fi
2943     done
2944     [[ -z ${all_installed} ]] && all_installed="none"
2945    
2946     case ${state} in
2947     stable) state=${COLGREEN}"[s] ";;
2948     testing) state=${COLYELLOW}"[t] ";;
2949     unstable) state=${COLRED}"[u] ";;
2950     old) state=${COLGRAY}"[o] ";;
2951     esac
2952    
2953   # all installed   latest_available="${pver}-${pbuild}"
2954   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})   else
2955   do   # package is masked
2956   ipver="$(magename2pver ${i})"   state="${COLRED}[m] "
2957   ipbuild="$(magename2pbuild ${i})"   latest_available="${COLRED}masked for this distribution.${COLDEFAULT}"
2958     fi
2959    
2960   if [[ -z ${all_installed} ]]   depsfull="$(get_value_from_magefile DEPEND ${magefile})"
2961   then   sdepsfull="$(get_value_from_magefile SDEPEND ${magefile})"
  all_installed="${ipver}-${ipbuild}"  
  else  
  all_installed="${all_installed} ${ipver}-${ipbuild}"  
  fi  
  done  
  [[ -z ${all_installed} ]] && all_installed="none"  
2962    
2963   case ${state} in   while read sign dep
2964   stable) state=${COLGREEN}"[s] ";;   do
2965   testing) state=${COLYELLOW}"[t] ";;   case ${dep} in
2966   unstable) state=${COLRED}"[u] ";;   "") continue;;
2967   old) state=${COLGRAY}"[o] ";;   esac
2968   esac  
2969     deps="${deps} $(basename ${dep%-*})"
2970     done << EOF
2971    ${depsfull}
2972    EOF
2973    
2974     while read sign dep
2975     do
2976     case ${dep} in
2977     "") continue;;
2978     esac
2979    
2980     sdeps="${sdeps} $(basename ${dep%-*})"
2981     done << EOF
2982    ${sdepsfull}
2983    EOF
2984    
2985   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}
2986   echo "      Latest available:   ${pver}-${pbuild}"   echo -e "      Latest available:   ${latest_available}"
2987   echo "      Installed versions: ${all_installed}"   echo "      Installed versions: ${all_installed}"
2988   echo "      Description: ${description}"   echo "      Description: ${description}"
2989   echo "      Homepage: ${homepage}"   echo "      Homepage: ${homepage}"
2990     echo "      Depends: ${deps}"
2991     echo "      SDepends: ${sdeps}"
2992   echo   echo
2993    
2994   unset pcat   unset pcat
# Line 2611  pkgsearch() Line 3002  pkgsearch()
3002   unset all_installed   unset all_installed
3003   unset ipver   unset ipver
3004   unset ipbuild   unset ipbuild
3005     unset depsfull
3006     unset sdepsfull
3007     unset deps
3008     unset sdeps
3009     unset dep
3010     unset sign
3011   done   done
3012  }  }
3013    
# Line 2653  blacklisted() Line 3050  blacklisted()
3050   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable
3051   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing
3052    
3053   local EXCLUDED="${MROOT}/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"   # support both types for the moment
3054     if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]]
3055     then
3056     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"
3057     else
3058     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}"
3059     fi
3060    
3061   # return 0 if the list not exist; nothin is masked   # return 0 if the list not exist; nothin is masked
3062   [[ ! -f ${EXCLUDED} ]] && return 0   [[ ! -f ${EXCLUDED} ]] && return 0
# Line 2696  EOF Line 3099  EOF
3099   return 0   return 0
3100  }  }
3101    
3102    # need_busybox_support ${cmd}
3103    # return 0 (no error = needs busybox support) or return 1 (error = no busybox support required)
3104    need_busybox_support()
3105    {
3106     local cmd
3107     cmd="$1"
3108    
3109     if [[ -x /bin/busybox ]]
3110     then
3111     if [[ $(readlink $(which ${cmd})) = /bin/busybox ]]
3112     then
3113     # needs busybox support
3114     return 0
3115     fi
3116     fi
3117    
3118     # no busybox
3119     return 1
3120    }
3121    
3122    # busybox_filter_wget_options ${wget_opts}
3123    busybox_filter_wget_options()
3124    {
3125     local opts="$@"
3126     local i
3127     local fixed_opts
3128    
3129     if need_busybox_support wget
3130     then
3131     for i in ${opts}
3132     do
3133     # show only the allowed ones
3134     case ${i} in
3135     -c|--continue) fixed_opts+=" -c" ;;
3136     -s|--spider) fixed_opts+=" -s" ;;
3137     -q|--quiet) fixed_opts+=" -q" ;;
3138     -O|--output-document) shift; fixed_opts+=" -O $1" ;;
3139     --header) shift; fixed_opts+=" --header $1" ;;
3140     -Y|--proxy) shift; fixed_opts+=" -Y $1" ;;
3141     -P) shift; fixed_opts+=" -P $1" ;;
3142     --no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;;
3143     -U|--user-agent) shift; fixed_opts+=" -U ${i}" ;;
3144     # simply drop all other opts
3145     *) continue ;;
3146     esac
3147     done
3148    
3149     echo "${fixed_opts}"
3150     else
3151     echo "${opts}"
3152     fi
3153    }
3154    
3155    have_root_privileges()
3156    {
3157     local retval
3158    
3159     if [[ $(id -u) = 0 ]]
3160     then
3161     retval=0
3162     else
3163     retval=1
3164     fi
3165    
3166     return ${retval}
3167    }

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