Magellan Linux

Diff of /trunk/mage/usr/lib/mage/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 1502 by niro, Tue Aug 30 10:39:28 2011 UTC
# Line 23  unpack_packages() Line 23  unpack_packages()
23   local pkgtype   local pkgtype
24   local count_current   local count_current
25   local count_total   local count_total
26     local tar_opts
27    
28   # get count of total packages   # get count of total packages
29   declare -i count_current=0   declare -i count_current=0
# Line 54  unpack_packages() Line 55  unpack_packages()
55   continue   continue
56   fi   fi
57    
58     # busybox?
59     if need_busybox_support tar
60     then
61     tar_opts="xjf"
62     else
63     tar_opts="xjmf"
64     fi
65    
66   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "
67   tar xjmf ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"   tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"
68   done   done
69    
70   # add a crlf for a better view   # add a crlf for a better view
# Line 219  install_files() Line 228  install_files()
228   "${user}" \   "${user}" \
229   "${group}" \   "${group}" \
230   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
231   "${MROOT}${pathto}")" \   "${MROOT}${pathto}")" \
232   "${md5sum}"   "${md5sum}"
233   ;;   ;;
234    
# Line 246  install_files() Line 255  install_files()
255   "${user}" \   "${user}" \
256   "${group}" \   "${group}" \
257   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
258   "${dest_protected}")" \   "${dest_protected}")" \
259   "${md5sum}"   "${md5sum}"
260    
261   # update global MAGE_PROTECT_COUNTER   # update global MAGE_PROTECT_COUNTER
# Line 263  install_files() Line 272  install_files()
272   echo -en "${COLDEFAULT}"   echo -en "${COLDEFAULT}"
273   echo " === FILE: ${MROOT}${pathto}"   echo " === FILE: ${MROOT}${pathto}"
274   fi   fi
275   # simply do nothing here   # simply do nothing here - only fix mtime
276     fix_descriptor ${pkgname}/.files \
277     "${pathto}" \
278     "${posix}" \
279     "${user}" \
280     "${group}" \
281     "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
282     "${MROOT}${pathto}")" \
283     "${md5sum}"
284   ;;   ;;
285   esac   esac
286   done < ${BUILDDIR}/${pkgname}/.files   done < ${BUILDDIR}/${pkgname}/.files
# Line 339  install_blockdevices() Line 356  install_blockdevices()
356   local pkgname="$1"   local pkgname="$1"
357   local pathto   local pathto
358   local posix   local posix
359     local user
360     local group
361   local IFS   local IFS
362    
363   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 352  install_blockdevices() Line 371  install_blockdevices()
371   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
372   IFS=§   IFS=§
373    
374   while read pathto posix   while read pathto posix major minor user group
375   do   do
376   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
377   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"
378    
379   mkfifo -m "${posix}" "${MROOT}$pathto"   mknod -m "${posix}" "${MROOT}${pathto}"
380     # make it optional atm !!
381     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
382     then
383     chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}"
384     fi
385   done < ${BUILDDIR}/${pkgname}/.pipes   done < ${BUILDDIR}/${pkgname}/.pipes
386    
387   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
# Line 376  install_characterdevices() Line 400  install_characterdevices()
400   local posix   local posix
401   local major   local major
402   local minor   local minor
403     local user
404     local group
405   local IFS   local IFS
406    
407   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 389  install_characterdevices() Line 415  install_characterdevices()
415   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
416   IFS=§   IFS=§
417    
418   while read pathto posix major minor   while read pathto posix major minor user group
419   do   do
420   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
421   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"
422    
423   mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor}   mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}"
424    
425     # make it optional atm !!
426     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
427     then
428     chown "${user}:${group}" "${MROOT}${pathto}"
429     fi
430   done < ${BUILDDIR}/${pkgname}/.char   done < ${BUILDDIR}/${pkgname}/.char
431    
432   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
433   IFS=$'\n'   IFS=$'\n'
434  }  }
435    
436    ###################################################
437    # function install_fifos                          #
438    # install_fifos $PKGNAME                    #
439    ###################################################
440    install_fifos()
441    {
442     local pkgname="$1"
443     local pathto
444     local posix
445     local user
446     local group
447     local IFS
448    
449     # sanity checks; abort if not given
450     [ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given."
451    
452     # check needed global vars
453     [ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set."
454    
455     # make it optional atm !!
456     #[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found"
457     [ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return
458    
459     # sets fieldseperator to "§" instead of " "
460     IFS=§
461    
462     while read pathto posix user group
463     do
464     [ -z "${pathto}" ] && continue
465     [[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}"
466    
467     mkfifo -m "${posix}" "${MROOT}${pathto}"
468     chown "${user}:${group}" "${MROOT}${pathto}"
469     done < ${BUILDDIR}/${pkgname}/.fifo
470    
471     # very important: unsetting the '§' fieldseperator
472     IFS=$'\n'
473    }
474    
475    
476  ###################################################  ###################################################
477  # function build_doinstall                        #  # function build_doinstall                        #
478  # build_doinstall $PKGNAME                  #  # build_doinstall $PKGNAME                  #
479  # NOTE: this is an wrapper do install packages    #  # NOTE: this is an wrapper to install packages    #
480  ###################################################  ###################################################
481  build_doinstall()  build_doinstall()
482  {  {
# Line 413  build_doinstall() Line 484  build_doinstall()
484    
485   # sanity checks; abort if not given   # sanity checks; abort if not given
486   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."
487    
488   # this is only a wrapper   # this is only a wrapper
489    
490   # NOTE:   # NOTE:
# Line 428  build_doinstall() Line 499  build_doinstall()
499   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"
500   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"
501   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"
502     install_fifos ${pkgname} || die "install fifos ${pkgname}"
503  }  }
504    
505    
# Line 489  install_database_entry() Line 561  install_database_entry()
561    
562   # create fake file descriptors   # create fake file descriptors
563   # used by virtual and source packages   # used by virtual and source packages
564   for i in .dirs .symlinks .files .pipes .char   for i in .dirs .symlinks .files .pipes .char .fifo
565   do   do
566   touch ${dbrecorddir}/${i}   touch ${dbrecorddir}/${i}
567   done   done
# Line 507  install_database_entry() Line 579  install_database_entry()
579    
580   # normal packages needs these files   # normal packages needs these files
581   local i   local i
582   for i in .char .dirs .files .pipes .symlinks   for i in .char .dirs .files .pipes .symlinks .fifo
583   do   do
584   install -m 0644 ${BUILDDIR}/${pkgname}/${i} \   # make .fifo optional atm
585   ${dbrecorddir}/${i}   if [[ -f ${BUILDDIR}/${pkgname}/${i} ]]
586     then
587     install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i}
588     fi
589   done   done
590   ;;   ;;
591   esac   esac
# Line 785  remove_files() Line 860  remove_files()
860   done   done
861    
862   # sanity checks; abort if not given   # sanity checks; abort if not given
863   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_files() \$pcat not given."
864   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_files() \$pname not given."
865   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_files() \$pver not given."
866   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_files() \$pbuild not given."
867   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
868    
869   # check needed global vars   # check needed global vars
# Line 879  remove_blockdevices() Line 954  remove_blockdevices()
954  {  {
955   local pathto   local pathto
956   local posix   local posix
957     local user
958     local group
959   local IFS   local IFS
960   local pcat   local pcat
961   local pname   local pname
# Line 902  remove_blockdevices() Line 979  remove_blockdevices()
979   done   done
980    
981   # sanity checks; abort if not given   # sanity checks; abort if not given
982   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given."
983   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_blockdevices() \$pname not given."
984   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_blockdevices() \$pver not given."
985   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given."
986   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
987    
988   # check needed global vars   # check needed global vars
# Line 916  remove_blockdevices() Line 993  remove_blockdevices()
993   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
994   IFS=§   IFS=§
995    
996   while read pathto posix   while read pathto posix user group
997   do   do
998   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
999    
# Line 937  remove_characterdevices() Line 1014  remove_characterdevices()
1014  {  {
1015   local pathto   local pathto
1016   local posix   local posix
1017     local user
1018     local group
1019   local IFS   local IFS
1020   local pcat   local pcat
1021   local pname   local pname
# Line 960  remove_characterdevices() Line 1039  remove_characterdevices()
1039   done   done
1040    
1041   # sanity checks; abort if not given   # sanity checks; abort if not given
1042   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given."
1043   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_characterdevices() \$pname not given."
1044   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_characterdevices() \$pver not given."
1045   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given."
1046   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1047    
1048   # check needed global vars   # check needed global vars
# Line 974  remove_characterdevices() Line 1053  remove_characterdevices()
1053   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1054   IFS=§   IFS=§
1055    
1056   while read pathto posix   while read pathto posix user group
1057   do   do
1058   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1059    
# Line 988  remove_characterdevices() Line 1067  remove_characterdevices()
1067    
1068    
1069  ###################################################  ###################################################
1070    # function remove_fifos                           #
1071    # remove_fifos $PKGNAME                     #
1072    ###################################################
1073    remove_fifos()
1074    {
1075     local pathto
1076     local posix
1077     local user
1078     local group
1079     local IFS
1080     local pcat
1081     local pname
1082     local pver
1083     local pbuild
1084     local i
1085     local pfull
1086    
1087     IFS=$'\n'
1088    
1089     # very basic getops
1090     for i in $*
1091     do
1092     case $1 in
1093     --pcat|-c) shift; pcat="$1" ;;
1094     --pname|-n) shift; pname="$1" ;;
1095     --pver|-v) shift; pver="$1" ;;
1096     --pbuild|-b) shift; pbuild="$1" ;;
1097     esac
1098     shift
1099     done
1100    
1101     # sanity checks; abort if not given
1102     [ -z "${pcat}" ] && die "remove_fifos() \$pcat not given."
1103     [ -z "${pname}" ] && die "remove_fifos() \$pname not given."
1104     [ -z "${pver}" ] && die "remove_fifos() \$pver not given."
1105     [ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given."
1106     pfull="${pcat}/${pname}-${pver}-${pbuild}"
1107    
1108     # check needed global vars
1109     [ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set."
1110    
1111     # make it optional atm !!
1112     #[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found"
1113     [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return
1114    
1115     # sets fieldseperator to "§" instead of " "
1116     IFS=§
1117    
1118     while read pathto posix user group
1119     do
1120     [ -z "${pathto}" ] && continue
1121    
1122     [[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}"
1123     rm "${MROOT}${pathto}"
1124     done < ${MROOT}${INSTALLDB}/${pfull}/.fifo
1125    
1126     # very important: unsetting the '§' fieldseperator
1127     IFS=$'\n'
1128    }
1129    
1130    
1131    ###################################################
1132  # function remove_direcories                      #  # function remove_direcories                      #
1133  # remove_direcories $PKGNAME                #  # remove_direcories $PKGNAME                #
1134  ###################################################  ###################################################
# Line 1018  remove_directories() Line 1159  remove_directories()
1159   done   done
1160    
1161   # sanity checks; abort if not given   # sanity checks; abort if not given
1162   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_directories() \$pcat not given."
1163   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_directories() \$pname not given."
1164   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_directories() \$pver not given."
1165   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given."
1166   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1167    
1168   # check needed global vars   # check needed global vars
# Line 1075  remove_directories() Line 1216  remove_directories()
1216  ###################################################  ###################################################
1217  # function build_douninstall                      #  # function build_douninstall                      #
1218  # build_douninstall $PKGNAME                #  # build_douninstall $PKGNAME                #
1219  # NOTE: this is an wrapper do remove packages     #  # NOTE: this is an wrapper to remove packages     #
1220  ###################################################  ###################################################
1221  build_douninstall()  build_douninstall()
1222  {  {
# Line 1109  build_douninstall() Line 1250  build_douninstall()
1250   # !! we use § as field seperator !!   # !! we use § as field seperator !!
1251   # doing so prevent us to get errors by filenames with spaces   # doing so prevent us to get errors by filenames with spaces
1252    
1253   for i in symlinks files blockdevices characterdevices directories   for i in symlinks files blockdevices characterdevices directories fifos
1254   do   do
1255   remove_${i} \   remove_${i} \
1256   --pcat "${pcat}" \   --pcat "${pcat}" \
# Line 1131  fetch_packages() Line 1272  fetch_packages()
1272   local opt   local opt
1273   local count_current   local count_current
1274   local count_total   local count_total
1275     local wget_opts
1276    
1277   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."
1278    
1279     # filter wget command if busybox was found
1280     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1281    
1282   # get count of total packages   # get count of total packages
1283   declare -i count_current=0   declare -i count_current=0
1284   declare -i count_total=0   declare -i count_total=0
# Line 1179  fetch_packages() Line 1324  fetch_packages()
1324   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1325   [[ ${VERBOSE} = off ]] && opt="--quiet"   [[ ${VERBOSE} = off ]] && opt="--quiet"
1326   wget \   wget \
1327   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
1328   --directory-prefix=${PKGDIR} \   --directory-prefix=${PKGDIR} \
1329   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}
1330   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 1223  syncmage() Line 1365  syncmage()
1365   done   done
1366    
1367   # clean up backup files (foo~)   # clean up backup files (foo~)
1368   find ${MAGEDIR} -name *~ -exec rm '{}' ';'   find ${MAGEDIR} -name \*~ -exec rm '{}' ';'
1369    
1370   # check if an newer mage version is available   # check if a newer mage version is available
1371   is_newer_mage_version_available   is_newer_mage_version_available
1372  }  }
1373    
1374  syncmage_tarball()  syncmage_tarball()
1375  {  {
1376   local latest_tarball   local latest_tarball
1377     local latest_md5
1378   local temp="$(mktemp -d)"   local temp="$(mktemp -d)"
1379   local mirr mymirr   local mirr mymirr
1380     local opt
1381     local tar_opts
1382     local wget_opts
1383    
1384     # try to get the md5 marked as latest on the server
1385     latest_md5="mage-latest.md5"
1386    
1387   # try to get the tarball marked as latest on the server   # try to get the tarball marked as latest on the server
1388   latest_tarball="mage-latest.tar.bz2"   latest_tarball="mage-latest.tar.bz2"
1389    
1390     # filter wget command if busybox was found
1391     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1392    
1393   for mirr in ${MIRRORS}   for mirr in ${MIRRORS}
1394   do   do
1395   # path without distribution   # path without distribution
1396   mymirr="${mirr%/*}"   mymirr="${mirr%/*}"
1397    
1398   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1399   echo "fetching latest tarball from ${mymirr} ..."   echo "fetching latest md5 from ${mymirr} ..."
1400     [[ ${VERBOSE} = off ]] && opt="--quiet"
1401     wget \
1402     ${wget_opts} \
1403     --directory-prefix=${temp} \
1404     ${opt} ${mymirr}/rsync/tarballs/${latest_md5}
1405    
1406     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1407     echo "fetching latest tarball from ${mymirr} ..."
1408   wget \   wget \
1409   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
1410   --directory-prefix=${temp} \   --directory-prefix=${temp} \
1411   ${mymirr}/rsync/tarballs/${latest_tarball}   ${opt} ${mymirr}/rsync/tarballs/${latest_tarball}
1412   if [[ $? = 0 ]]   if [[ $? = 0 ]]
1413   then   then
1414   break   break
# Line 1263  syncmage_tarball() Line 1419  syncmage_tarball()
1419    
1420   if [[ -f ${temp}/${latest_tarball} ]]   if [[ -f ${temp}/${latest_tarball} ]]
1421   then   then
1422     # check md5
1423     if [[ ! -f ${temp}/${latest_md5} ]]
1424     then
1425     die "md5 is missing ... aborting"
1426     else
1427     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1428     echo -n "checking md5sum... "
1429     ( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed"
1430     fi
1431    
1432   if [[ -d ${MAGEDIR} ]]   if [[ -d ${MAGEDIR} ]]
1433   then   then
1434   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
# Line 1270  syncmage_tarball() Line 1436  syncmage_tarball()
1436   rm -rf ${MAGEDIR}   rm -rf ${MAGEDIR}
1437   fi   fi
1438    
1439     if need_busybox_support tar
1440     then
1441     tar_opts="xjf"
1442     else
1443     tar_opts="xjmf"
1444     fi
1445    
1446   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1447   echo "updating mage-tree from tarball ..."   echo "updating mage-tree from tarball ..."
1448   # unpack in dirname of MAGEDIR, as the tarball has already the mage   # unpack in dirname of MAGEDIR, as the tarball has already the mage
1449   tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"   tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1450    
1451   if [[ -d ${temp} ]]   if [[ -d ${temp} ]]
1452   then   then
1453   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1454   echo "clenaing temp-files ..."   echo "cleaning temp-files ..."
1455   rm -rf ${temp}   rm -rf ${temp}
1456   fi   fi
1457    
1458     # check if a newer mage version is available
1459     is_newer_mage_version_available
1460   else   else
1461   die "Could not fetch the latest tarball ... aborting"   die "Could not fetch the latest tarball ... aborting"
1462   fi   fi
# Line 1399  get_highest_magefile() Line 1575  get_highest_magefile()
1575   local magefile   local magefile
1576    
1577   # do not list the content of a directory, only the name (-d)   # do not list the content of a directory, only the name (-d)
1578   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)
1579   do   do
1580   [[ -z ${magefile} ]] && continue   [[ -z ${magefile} ]] && continue
1581   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
# Line 1726  virtuals_add() Line 1902  virtuals_add()
1902    
1903  #deletes pakages from virtual database  #deletes pakages from virtual database
1904  #$1 virtualname; $2 pkgname  #$1 virtualname; $2 pkgname
1905  virtuals_del() {  virtuals_del()
1906    {
1907    
1908   local virtualname="$1"   local virtualname="$1"
1909   local pkgname="$2"   local pkgname="$2"
# Line 2160  get_value_from_magefile() Line 2337  get_value_from_magefile()
2337   local SDEPEND   local SDEPEND
2338   local PROVIDE   local PROVIDE
2339   local PKGTYPE   local PKGTYPE
2340     local MAGE_TARGETS
2341     local SPLIT_PACKAGE_BASE
2342   local preinstall   local preinstall
2343   local postinstall   local postinstall
2344   local preremove   local preremove
# Line 2280  mage_install() Line 2459  mage_install()
2459   echo B:${pbuild}   echo B:${pbuild}
2460   fi   fi
2461    
2462   if [[ -z ${MAGE_TARGETS} ]]   if [[ -n ${MAGE_TARGETS} ]]
2463   then   then
2464   # basic svn compat   # basic svn compat
2465   if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2466   then   then
2467   for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2   for i in ${SMAGESCRIPTSDIR}/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2468   do   do
2469   smage2file="${i}"   smage2file="${i}"
2470   done   done
2471   else   else
2472   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2   smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2473   fi   fi
2474    
2475     elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2476     then
2477     # basic svn compat
2478     if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2479     then
2480     for i in ${SMAGESCRIPTSDIR}/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2481     do
2482     smage2file="${i}"
2483     done
2484     else
2485     smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2486     fi
2487    
2488   else   else
2489   # basic svn compat   # basic svn compat
2490   if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2491   then   then
2492   for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2   for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2493   do   do
2494   smage2file="${i}"   smage2file="${i}"
2495   done   done
2496   else   else
2497   smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2
2498   fi   fi
2499   fi   fi
2500    
2501   if [ -f "${smage2file}" ]   if [ -f "${smage2file}" ]
2502   then   then
2503   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "
# Line 2434  md5sum_packages() Line 2628  md5sum_packages()
2628   then   then
2629   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2630   echo -ne "checking md5sum (${count_current}/${count_total}): "   echo -ne "checking md5sum (${count_current}/${count_total}): "
2631   ( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed"   ( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed"
2632   else   else
2633   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2634   echo -e "!! no md5sum file found for ${pkgfile} :("   echo -e "!! no md5sum file found for ${pkgfile} :("
# Line 2647  mage_uninstall() Line 2841  mage_uninstall()
2841   unset -f postremove   unset -f postremove
2842  }  }
2843    
2844  show_etc_update_mesg() {  show_etc_update_mesg()
2845    {
2846   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0
2847    
2848   echo   echo
# Line 2881  EOF Line 3076  EOF
3076   return 0   return 0
3077  }  }
3078    
3079    # need_busybox_support ${cmd}
3080    # return 0 (no error = needs busybox support) or return 1 (error = no busybox support required)
3081    need_busybox_support()
3082    {
3083     local cmd
3084     cmd="$1"
3085    
3086     if [[ -x /bin/busybox ]]
3087     then
3088     if [[ $(readlink $(which ${cmd})) = /bin/busybox ]]
3089     then
3090     # needs busybox support
3091     return 0
3092     fi
3093     fi
3094    
3095     # no busybox
3096     return 1
3097    }
3098    
3099    # busybox_filter_wget_options ${wget_opts}
3100    busybox_filter_wget_options()
3101    {
3102     local opts="$@"
3103     local i
3104     local fixed_opts
3105    
3106     if need_busybox_support wget
3107     then
3108     for i in ${opts}
3109     do
3110     # show only the allowed ones
3111     case ${i} in
3112     -c|--continue) fixed_opts+=" -c" ;;
3113     -s|--spider) fixed_opts+=" -s" ;;
3114     -q|--quiet) fixed_opts+=" -q" ;;
3115     -O|--output-document) shift; fixed_opts+=" -O $1" ;;
3116     --header) shift; fixed_opts+=" --header $1" ;;
3117     -Y|--proxy) shift; fixed_opts+=" -Y $1" ;;
3118     -P) shift; fixed_opts+=" -P $1" ;;
3119     --no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;;
3120     -U|--user-agent) shift; fixed_opts+=" -U ${i}" ;;
3121     # simply drop all other opts
3122     *) continue ;;
3123     esac
3124     done
3125    
3126     echo "${fixed_opts}"
3127     else
3128     echo "${opts}"
3129     fi
3130    }

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