Magellan Linux

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

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

revision 385 by niro, Mon Jul 17 20:48:22 2006 UTC revision 1273 by niro, Wed Apr 27 09:45:07 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.20 2006-07-17 20:48:22 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  mage_setup()  mage_setup()
6  {  {
# 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 198  install_files() Line 207  install_files()
207   is_config_protected "${pathto}"   is_config_protected "${pathto}"
208   retval="$?"   retval="$?"
209    
210   # 0 - not protected        #   # 0 - not protected         #
211   # 1 - error                #   # 1 - error                 #
212   # 2 - protected            #   # 2 - protected             #
213   # 3 - protected but masked #   # 3 - protected but masked  #
214     # 4 - protected but ignored #
215    
216   case ${retval} in   case ${retval} in
217   # file is not protected - (over)write it   # file is not protected - (over)write it
# Line 252  install_files() Line 262  install_files()
262   (( MAGE_PROTECT_COUNTER++ ))   (( MAGE_PROTECT_COUNTER++ ))
263   export MAGE_PROTECT_COUNTER   export MAGE_PROTECT_COUNTER
264   ;;   ;;
265    
266     # file is protected but ignored, delete the update/do nothing
267     4)
268     if [[ ${VERBOSE} = on ]]
269     then
270     echo -en "${COLRED}"
271     echo -n "! ignr "
272     echo -en "${COLDEFAULT}"
273     echo " === FILE: ${MROOT}${pathto}"
274     fi
275     # simply do nothing here
276     ;;
277   esac   esac
278   done < ${BUILDDIR}/${pkgname}/.files   done < ${BUILDDIR}/${pkgname}/.files
279    
# Line 298  install_symlinks() Line 320  install_symlinks()
320    
321   ln -snf "${link}" "${MROOT}${pathto}"   ln -snf "${link}" "${MROOT}${pathto}"
322    
323   # fix mtime and db  # # fix mtime and db
324   fix_descriptor ${pkgname}/.symlinks \  # fix_descriptor ${pkgname}/.symlinks \
325   "${pathto}" \  # "${pathto}" \
326   "${posix}" \  # "${posix}" \
327   "${link}" \  # "${link}" \
328   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \  # "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
329   "${MROOT}${pathto}")"  # "${MROOT}${pathto}")"
330    
331   done < ${BUILDDIR}/${pkgname}/.symlinks   done < ${BUILDDIR}/${pkgname}/.symlinks
332    
333   # now copy the fixed file over the old one  # # now copy the fixed file over the old one
334   [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \  # [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \
335   cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,}  # cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,}
336    
337   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
338   IFS=$'\n'   IFS=$'\n'
# Line 326  install_blockdevices() Line 348  install_blockdevices()
348   local pkgname="$1"   local pkgname="$1"
349   local pathto   local pathto
350   local posix   local posix
351     local user
352     local group
353   local IFS   local IFS
354    
355   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 339  install_blockdevices() Line 363  install_blockdevices()
363   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
364   IFS=§   IFS=§
365    
366   while read pathto posix   while read pathto posix major minor user group
367   do   do
368   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
369   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"
370    
371   mkfifo -m "${posix}" "${MROOT}$pathto"   mknod -m "${posix}" "${MROOT}${pathto}"
372     # make it optional atm !!
373     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
374     then
375     chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}"
376     fi
377   done < ${BUILDDIR}/${pkgname}/.pipes   done < ${BUILDDIR}/${pkgname}/.pipes
378    
379   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
# Line 363  install_characterdevices() Line 392  install_characterdevices()
392   local posix   local posix
393   local major   local major
394   local minor   local minor
395     local user
396     local group
397   local IFS   local IFS
398    
399   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 376  install_characterdevices() Line 407  install_characterdevices()
407   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
408   IFS=§   IFS=§
409    
410   while read pathto posix major minor   while read pathto posix major minor user group
411   do   do
412   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
413   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"
414    
415   mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor}   mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}"
416    
417     # make it optional atm !!
418     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
419     then
420     chown "${user}:${group}" "${MROOT}${pathto}"
421     fi
422   done < ${BUILDDIR}/${pkgname}/.char   done < ${BUILDDIR}/${pkgname}/.char
423    
424   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
425   IFS=$'\n'   IFS=$'\n'
426  }  }
427    
428    ###################################################
429    # function install_fifos                          #
430    # install_fifos $PKGNAME                    #
431    ###################################################
432    install_fifos()
433    {
434     local pkgname="$1"
435     local pathto
436     local posix
437     local user
438     local group
439     local IFS
440    
441     # sanity checks; abort if not given
442     [ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given."
443    
444     # check needed global vars
445     [ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set."
446    
447     # make it optional atm !!
448     #[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found"
449     [ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return
450    
451     # sets fieldseperator to "§" instead of " "
452     IFS=§
453    
454     while read pathto posix user group
455     do
456     [ -z "${pathto}" ] && continue
457     [[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}"
458    
459     mkfifo -m "${posix}" "${MROOT}${pathto}"
460     chown "${user}:${group}" "${MROOT}${pathto}"
461     done < ${BUILDDIR}/${pkgname}/.fifo
462    
463     # very important: unsetting the '§' fieldseperator
464     IFS=$'\n'
465    }
466    
467    
468  ###################################################  ###################################################
469  # function build_doinstall                        #  # function build_doinstall                        #
470  # build_doinstall $PKGNAME                  #  # build_doinstall $PKGNAME                  #
471  # NOTE: this is an wrapper do install packages    #  # NOTE: this is an wrapper to install packages    #
472  ###################################################  ###################################################
473  build_doinstall()  build_doinstall()
474  {  {
# Line 415  build_doinstall() Line 491  build_doinstall()
491   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"
492   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"
493   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"
494     install_fifos ${pkgname} || die "install fifos ${pkgname}"
495  }  }
496    
497    
# Line 476  install_database_entry() Line 553  install_database_entry()
553    
554   # create fake file descriptors   # create fake file descriptors
555   # used by virtual and source packages   # used by virtual and source packages
556   for i in .dirs .symlinks .files .pipes .char   for i in .dirs .symlinks .files .pipes .char .fifo
557   do   do
558   touch ${dbrecorddir}/${i}   touch ${dbrecorddir}/${i}
559   done   done
# Line 494  install_database_entry() Line 571  install_database_entry()
571    
572   # normal packages needs these files   # normal packages needs these files
573   local i   local i
574   for i in .char .dirs .files .pipes .symlinks   for i in .char .dirs .files .pipes .symlinks .fifo
575   do   do
576   install -m 0644 ${BUILDDIR}/${pkgname}/${i} \   # make .fifo optional atm
577   ${dbrecorddir}/${i}   if [[ -f ${BUILDDIR}/${pkgname}/${i} ]]
578     then
579     install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i}
580     fi
581   done   done
582   ;;   ;;
583   esac   esac
# Line 772  remove_files() Line 852  remove_files()
852   done   done
853    
854   # sanity checks; abort if not given   # sanity checks; abort if not given
855   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_files() \$pcat not given."
856   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_files() \$pname not given."
857   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_files() \$pver not given."
858   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_files() \$pbuild not given."
859   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
860    
861   # check needed global vars   # check needed global vars
# Line 809  remove_files() Line 889  remove_files()
889   is_config_protected "${pathto}"   is_config_protected "${pathto}"
890   retval="$?"   retval="$?"
891    
892   # 0 - not protected        #   # 0 - not protected         #
893   # 1 - error                #   # 1 - error                 #
894   # 2 - protected            #   # 2 - protected             #
895   # 3 - protected but masked #   # 3 - protected but masked  #
896     # 4 - protected but ignored #
897    
898   case ${retval} in   case ${retval} in
899   # file is not protected - delete it   # file is not protected - delete it
# Line 831  remove_files() Line 912  remove_files()
912   echo " === FILE: ${MROOT}${pathto}"   echo " === FILE: ${MROOT}${pathto}"
913   fi   fi
914   ;;   ;;
915    
916     # file is protected but ignored, delete the update/do nothing
917     4)
918     if [[ ${VERBOSE} = on ]]
919     then
920     echo -en "${COLRED}"
921     echo -n "! ignr "
922     echo -en "${COLDEFAULT}"
923     echo " === FILE: ${MROOT}${pathto}"
924     fi
925     # simply do nothing here
926     ;;
927   esac   esac
928   ;;   ;;
929   1)   1)
# Line 853  remove_blockdevices() Line 946  remove_blockdevices()
946  {  {
947   local pathto   local pathto
948   local posix   local posix
949     local user
950     local group
951   local IFS   local IFS
952   local pcat   local pcat
953   local pname   local pname
# Line 876  remove_blockdevices() Line 971  remove_blockdevices()
971   done   done
972    
973   # sanity checks; abort if not given   # sanity checks; abort if not given
974   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given."
975   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_blockdevices() \$pname not given."
976   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_blockdevices() \$pver not given."
977   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given."
978   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
979    
980   # check needed global vars   # check needed global vars
# Line 890  remove_blockdevices() Line 985  remove_blockdevices()
985   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
986   IFS=§   IFS=§
987    
988   while read pathto posix   while read pathto posix user group
989   do   do
990   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
991    
# Line 911  remove_characterdevices() Line 1006  remove_characterdevices()
1006  {  {
1007   local pathto   local pathto
1008   local posix   local posix
1009     local user
1010     local group
1011   local IFS   local IFS
1012   local pcat   local pcat
1013   local pname   local pname
# Line 934  remove_characterdevices() Line 1031  remove_characterdevices()
1031   done   done
1032    
1033   # sanity checks; abort if not given   # sanity checks; abort if not given
1034   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given."
1035   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_characterdevices() \$pname not given."
1036   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_characterdevices() \$pver not given."
1037   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given."
1038   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1039    
1040   # check needed global vars   # check needed global vars
# Line 948  remove_characterdevices() Line 1045  remove_characterdevices()
1045   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1046   IFS=§   IFS=§
1047    
1048   while read pathto posix   while read pathto posix user group
1049   do   do
1050   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1051    
# Line 962  remove_characterdevices() Line 1059  remove_characterdevices()
1059    
1060    
1061  ###################################################  ###################################################
1062    # function remove_fifos                           #
1063    # remove_fifos $PKGNAME                     #
1064    ###################################################
1065    remove_fifos()
1066    {
1067     local pathto
1068     local posix
1069     local user
1070     local group
1071     local IFS
1072     local pcat
1073     local pname
1074     local pver
1075     local pbuild
1076     local i
1077     local pfull
1078    
1079     IFS=$'\n'
1080    
1081     # very basic getops
1082     for i in $*
1083     do
1084     case $1 in
1085     --pcat|-c) shift; pcat="$1" ;;
1086     --pname|-n) shift; pname="$1" ;;
1087     --pver|-v) shift; pver="$1" ;;
1088     --pbuild|-b) shift; pbuild="$1" ;;
1089     esac
1090     shift
1091     done
1092    
1093     # sanity checks; abort if not given
1094     [ -z "${pcat}" ] && die "remove_fifos() \$pcat not given."
1095     [ -z "${pname}" ] && die "remove_fifos() \$pname not given."
1096     [ -z "${pver}" ] && die "remove_fifos() \$pver not given."
1097     [ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given."
1098     pfull="${pcat}/${pname}-${pver}-${pbuild}"
1099    
1100     # check needed global vars
1101     [ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set."
1102    
1103     # make it optional atm !!
1104     #[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found"
1105     [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return
1106    
1107     # sets fieldseperator to "§" instead of " "
1108     IFS=§
1109    
1110     while read pathto posix user group
1111     do
1112     [ -z "${pathto}" ] && continue
1113    
1114     [[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}"
1115     rm "${MROOT}${pathto}"
1116     done < ${MROOT}${INSTALLDB}/${pfull}/.fifo
1117    
1118     # very important: unsetting the '§' fieldseperator
1119     IFS=$'\n'
1120    }
1121    
1122    
1123    ###################################################
1124  # function remove_direcories                      #  # function remove_direcories                      #
1125  # remove_direcories $PKGNAME                #  # remove_direcories $PKGNAME                #
1126  ###################################################  ###################################################
# Line 992  remove_directories() Line 1151  remove_directories()
1151   done   done
1152    
1153   # sanity checks; abort if not given   # sanity checks; abort if not given
1154   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_directories() \$pcat not given."
1155   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_directories() \$pname not given."
1156   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_directories() \$pver not given."
1157   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given."
1158   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1159    
1160   # check needed global vars   # check needed global vars
# Line 1049  remove_directories() Line 1208  remove_directories()
1208  ###################################################  ###################################################
1209  # function build_douninstall                      #  # function build_douninstall                      #
1210  # build_douninstall $PKGNAME                #  # build_douninstall $PKGNAME                #
1211  # NOTE: this is an wrapper do remove packages     #  # NOTE: this is an wrapper to remove packages     #
1212  ###################################################  ###################################################
1213  build_douninstall()  build_douninstall()
1214  {  {
# Line 1083  build_douninstall() Line 1242  build_douninstall()
1242   # !! we use § as field seperator !!   # !! we use § as field seperator !!
1243   # doing so prevent us to get errors by filenames with spaces   # doing so prevent us to get errors by filenames with spaces
1244    
1245   for i in symlinks files blockdevices characterdevices directories   for i in symlinks files blockdevices characterdevices directories fifos
1246   do   do
1247   remove_${i} \   remove_${i} \
1248   --pcat "${pcat}" \   --pcat "${pcat}" \
# Line 1105  fetch_packages() Line 1264  fetch_packages()
1264   local opt   local opt
1265   local count_current   local count_current
1266   local count_total   local count_total
1267     local wget_opts
1268    
1269   [ -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}."
1270    
1271     # filter wget command if busybox was found
1272     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1273    
1274   # get count of total packages   # get count of total packages
1275   declare -i count_current=0   declare -i count_current=0
# Line 1153  fetch_packages() Line 1316  fetch_packages()
1316   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1317   [[ ${VERBOSE} = off ]] && opt="--quiet"   [[ ${VERBOSE} = off ]] && opt="--quiet"
1318   wget \   wget \
1319   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
1320   --directory-prefix=${PKGDIR} \   --directory-prefix=${PKGDIR} \
1321   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}
1322   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 1181  syncmage() Line 1341  syncmage()
1341  {  {
1342   if [ -z "${RSYNC}" ]   if [ -z "${RSYNC}" ]
1343   then   then
1344   die "You have no rsync-mirrors defined. Please edit your /etc/mage.rc."   die "You have no rsync-mirrors defined. Please edit your ${MAGERC}."
1345   fi   fi
1346    
1347   local i   local i
1348   for i in ${RSYNC}   for i in ${RSYNC}
1349   do   do
1350   rsync \   rsync ${RSYNC_FETCH_OPTIONS} ${i} ${MAGEDIR}
  --recursive \  
  --links \  
  --perms \  
  --times \  
  --devices \  
  --timeout=600 \  
  --verbose \  
  --compress \  
  --progress \  
  --stats \  
  --delete \  
  --delete-after \  
  ${i} ${MAGEDIR}  
1351   if [[ $? = 0 ]]   if [[ $? = 0 ]]
1352   then   then
1353   break   break
# Line 1212  syncmage() Line 1359  syncmage()
1359   # clean up backup files (foo~)   # clean up backup files (foo~)
1360   find ${MAGEDIR} -name *~ -exec rm '{}' ';'   find ${MAGEDIR} -name *~ -exec rm '{}' ';'
1361    
1362   # check if an newer mage version is available   # check if a newer mage version is available
1363   is_newer_mage_version_available   is_newer_mage_version_available
1364  }  }
1365    
1366    syncmage_tarball()
1367    {
1368     local latest_tarball
1369     local latest_md5
1370     local temp="$(mktemp -d)"
1371     local mirr mymirr
1372     local opt
1373     local tar_opts
1374    
1375     # try to get the md5 marked as latest on the server
1376     latest_md5="mage-latest.md5"
1377    
1378     # try to get the tarball marked as latest on the server
1379     latest_tarball="mage-latest.tar.bz2"
1380    
1381     for mirr in ${MIRRORS}
1382     do
1383     # path without distribution
1384     mymirr="${mirr%/*}"
1385    
1386     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1387     echo "fetching latest md5 from ${mymirr} ..."
1388     [[ ${VERBOSE} = off ]] && opt="--quiet"
1389     wget \
1390     ${WGET_FETCH_OPTIONS} \
1391     --directory-prefix=${temp} \
1392     ${opt} ${mymirr}/rsync/tarballs/${latest_md5}
1393    
1394     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1395     echo "fetching latest tarball from ${mymirr} ..."
1396     wget \
1397     ${WGET_FETCH_OPTIONS} \
1398     --directory-prefix=${temp} \
1399     ${opt} ${mymirr}/rsync/tarballs/${latest_tarball}
1400     if [[ $? = 0 ]]
1401     then
1402     break
1403     else
1404     continue
1405     fi
1406     done
1407    
1408     if [[ -f ${temp}/${latest_tarball} ]]
1409     then
1410     # check md5
1411     if [[ ! -f ${temp}/${latest_md5} ]]
1412     then
1413     die "md5 is missing ... aborting"
1414     else
1415     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1416     echo -n "checking md5sum... "
1417     ( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed"
1418     fi
1419    
1420     if [[ -d ${MAGEDIR} ]]
1421     then
1422     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1423     echo "cleaning old mage-tree ${MAGEDIR}..."
1424     rm -rf ${MAGEDIR}
1425     fi
1426    
1427     if need_busybox_support tar
1428     then
1429     tar_opts="xjf"
1430     else
1431     tar_opts="xjmf"
1432     fi
1433    
1434     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1435     echo "updating mage-tree from tarball ..."
1436     # unpack in dirname of MAGEDIR, as the tarball has already the mage
1437     tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1438    
1439     if [[ -d ${temp} ]]
1440     then
1441     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1442     echo "cleaning temp-files ..."
1443     rm -rf ${temp}
1444     fi
1445    
1446     # check if a newer mage version is available
1447     is_newer_mage_version_available
1448     else
1449     die "Could not fetch the latest tarball ... aborting"
1450     fi
1451    }
1452    
1453  cleanpkg()  cleanpkg()
1454  {  {
1455   if [ -d "${PKGDIR}" ]   if [ -d "${PKGDIR}" ]
# Line 1253  choppkgname() Line 1487  choppkgname()
1487   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]
1488   then   then
1489   #cuts ARCH and PBUILD   #cuts ARCH and PBUILD
1490   #ARCH comes from /etc/mage.rc   #ARCH comes from ${MAGERC}
1491   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")
1492    
1493   #cuts version number   #cuts version number
# Line 1328  get_highest_magefile() Line 1562  get_highest_magefile()
1562   local PNAME="$2"   local PNAME="$2"
1563   local magefile   local magefile
1564    
1565   for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*)   # do not list the content of a directory, only the name (-d)
1566     for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*)
1567   do   do
1568     [[ -z ${magefile} ]] && continue
1569   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
1570   [ -d ${magefile} ] && continue   [[ -d ${magefile} ]] && continue
1571   if check_stable_package ${magefile}   if check_stable_package ${magefile}
1572   then   then
1573   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
# Line 1376  get_highest_magefile() Line 1612  get_highest_magefile()
1612  #        1 - error                                #  #        1 - error                                #
1613  #        2 - protected                            #  #        2 - protected                            #
1614  #        3 - protected but masked                 #  #        3 - protected but masked                 #
1615    #        4 - protected but ignored                #
1616  #                                                 #  #                                                 #
1617  ###################################################  ###################################################
1618  is_config_protected()  is_config_protected()
# Line 1384  is_config_protected() Line 1621  is_config_protected()
1621   local TEST   local TEST
1622   local PROTECTED   local PROTECTED
1623   local IFS   local IFS
1624     local i
1625     local x
1626    
1627   EXPFILE="${MROOT}$1"   EXPFILE="${MROOT}$1"
1628    
1629   # file does not exist; it can be written   # file does not exist; it can be written
1630   [ ! -e ${EXPFILE} ] && return 0   [[ ! -e ${EXPFILE} ]] && return 0
1631    
1632   # to be safe; it may be '§'   # to be safe; it may be '§'
1633   IFS=' '   IFS=' '
1634    
1635   # check ob in config protect   # check if config protected
1636   for i in ${CONFIG_PROTECT}   for i in ${CONFIG_PROTECT}
1637   do   do
1638   # ersetzen von $i nur wenn am anfang der variable   # only replace $i in the beginning of the variable
1639   TEST="${EXPFILE/#${MROOT}${i}/Protected}"   TEST="${EXPFILE/#${MROOT}${i}/Protected}"
1640   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1641   then   then
1642   # setzen das es protected ist   # file is config proteced
1643   PROTECTED=TRUE   PROTECTED=TRUE
1644    
1645   # check ob nicht doch maskiert   # check if not masked
1646   for x in ${CONFIG_PROTECT_MASK}   for x in ${CONFIG_PROTECT_MASK}
1647   do   do
1648   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"
1649   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1650   then   then
1651   PROTECTED=MASKED   PROTECTED=MASKED
1652   fi   fi
1653   done   done
1654    
1655     # check if not ignored
1656     for x in ${CONFIG_PROTECT_IGNORE}
1657     do
1658     TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}"
1659     if [[ ${TEST} != ${EXPFILE} ]]
1660     then
1661     PROTECTED=IGNORED
1662     fi
1663     done
1664   fi   fi
1665   done   done
1666    
# Line 1426  is_config_protected() Line 1675  is_config_protected()
1675   #echo "I'm protected, but masked - delete me"   #echo "I'm protected, but masked - delete me"
1676   return 3   return 3
1677   ;;   ;;
1678     IGNORED)
1679     #echo "I'm protected, but ignored - keep me, del update"
1680     return 4
1681     ;;
1682   *)   *)
1683   #echo "delete me"   #echo "delete me"
1684   return 0   return 0
# Line 1443  is_config_protected() Line 1696  is_config_protected()
1696  ###################################################  ###################################################
1697  count_protected_files()  count_protected_files()
1698  {  {
1699   ${MLIBDIR}/writeprotected "$1"   local file="$1"
1700     local dirname="${file%/*}"
1701     local filename="${file##*/}"
1702     local count
1703     local output
1704     local i
1705    
1706     declare -i count=0
1707    
1708     # check if there are already protected files
1709     for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" |
1710     sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
1711     sort -t'%' -k3 -k2 | cut -f1 -d'%')
1712     do
1713     count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::")
1714     done
1715     (( count ++ ))
1716    
1717     # fill output up with zeros
1718     for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
1719     output="${output}${count}"
1720    
1721     echo "${output}"
1722  }  }
1723    
1724  # call with  # call with
# Line 1460  get_uninstall_candidates() Line 1735  get_uninstall_candidates()
1735   local list   local list
1736   local pcatdir   local pcatdir
1737   local protected   local protected
1738     local i
1739    
1740   # very basic getops   # very basic getops
1741   for i in $*   for i in $*
# Line 1614  virtuals_add() Line 1890  virtuals_add()
1890    
1891  #deletes pakages from virtual database  #deletes pakages from virtual database
1892  #$1 virtualname; $2 pkgname  #$1 virtualname; $2 pkgname
1893  virtuals_del() {  virtuals_del()
1894    {
1895    
1896   local virtualname="$1"   local virtualname="$1"
1897   local pkgname="$2"   local pkgname="$2"
# Line 1721  minclude() Line 1998  minclude()
1998  {  {
1999   local i   local i
2000    
2001   if [ -n "$@" ]   if [[ -n $* ]]
2002   then   then
2003   for i in $@   for i in $*
2004   do   do
2005   [[ ${MAGEDEBUG} = on ]] && \   [[ ${MAGEDEBUG} = on ]] && \
2006   echo "--- Including ${MAGEDIR}/include/${i}.minc"   echo "--- Including ${MAGEDIR}/include/${i}.minc"
# Line 1737  sminclude() Line 2014  sminclude()
2014  {  {
2015   local i   local i
2016    
2017   if [ -n "$@" ]   if [[ -n $* ]]
2018   then   then
2019   for i in $@   for i in $*
2020   do   do
2021   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
2022   source ${SMAGESCRIPTSDIR}/include/${i}.sminc   source ${SMAGESCRIPTSDIR}/include/${i}.sminc
# Line 2048  get_value_from_magefile() Line 2325  get_value_from_magefile()
2325   local SDEPEND   local SDEPEND
2326   local PROVIDE   local PROVIDE
2327   local PKGTYPE   local PKGTYPE
2328     local MAGE_TARGETS
2329     local SPLIT_PACKAGE_BASE
2330   local preinstall   local preinstall
2331   local postinstall   local postinstall
2332   local preremove   local preremove
# Line 2094  mage_install() Line 2373  mage_install()
2373   local count_current   local count_current
2374   local magefile   local magefile
2375   local src_install   local src_install
2376     local i
2377    
2378   # very basic getops   # very basic getops
2379   for i in $*   for i in $*
# Line 2167  mage_install() Line 2447  mage_install()
2447   echo B:${pbuild}   echo B:${pbuild}
2448   fi   fi
2449    
2450   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2   if [[ -n ${MAGE_TARGETS} ]]
2451     then
2452     # basic svn compat
2453     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2454     then
2455     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2456     do
2457     smage2file="${i}"
2458     done
2459     else
2460     smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2461     fi
2462    
2463     elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2464     then
2465     # basic svn compat
2466     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2467     then
2468     for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2469     do
2470     smage2file="${i}"
2471     done
2472     else
2473     smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2474     fi
2475    
2476     else
2477     # basic svn compat
2478     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2479     then
2480     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2481     do
2482     smage2file="${i}"
2483     done
2484     else
2485     smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2
2486     fi
2487     fi
2488    
2489   if [ -f "${smage2file}" ]   if [ -f "${smage2file}" ]
2490   then   then
2491   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "
# Line 2298  md5sum_packages() Line 2616  md5sum_packages()
2616   then   then
2617   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2618   echo -ne "checking md5sum (${count_current}/${count_total}): "   echo -ne "checking md5sum (${count_current}/${count_total}): "
2619   ( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed"   ( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed"
2620   else   else
2621   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2622   echo -e "!! no md5sum file found for ${pkgfile} :("   echo -e "!! no md5sum file found for ${pkgfile} :("
# Line 2441  mage_uninstall() Line 2759  mage_uninstall()
2759   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"
2760   echo -n "removing: "   echo -n "removing: "
2761   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2762   echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"   echo -e "${COLRED}${pname}-${pver}-${pbuild}${COLDEFAULT}"
2763    
2764   magefile="${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"   magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
2765   source ${magefile}   source ${magefile}
2766    
2767   ## preremove scripts   ## preremove scripts
# Line 2511  mage_uninstall() Line 2829  mage_uninstall()
2829   unset -f postremove   unset -f postremove
2830  }  }
2831    
2832  show_etc_update_mesg() {  show_etc_update_mesg()
2833    {
2834   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0
2835    
2836   echo   echo
# Line 2541  pkgsearch() Line 2860  pkgsearch()
2860   local all_installed   local all_installed
2861   local ipver   local ipver
2862   local ipbuild   local ipbuild
2863     local latest_available
2864     local depsfull
2865     local sdepsfull
2866     local deps
2867     local sdeps
2868     local dep
2869     local sign
2870    
2871   # only names no versions   # only names no versions
2872   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')"
2873   #result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)"   #result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)"
2874    
2875   # nothing found   # nothing found
# Line 2558  pkgsearch() Line 2884  pkgsearch()
2884   # get highest version available   # get highest version available
2885   magefile=$(get_highest_magefile ${pcat} ${pname})   magefile=$(get_highest_magefile ${pcat} ${pname})
2886    
2887   # now get all needed infos to print a nice output   if [[ ! -z ${magefile} ]]
2888   pver="$(magename2pver ${magefile})"   then
2889   pbuild="$(magename2pbuild ${magefile})"   # now get all needed infos to print a nice output
2890   state="$(get_value_from_magefile STATE ${magefile})"   pver="$(magename2pver ${magefile})"
2891   description="$(get_value_from_magefile DESCRIPTION ${magefile})"   pbuild="$(magename2pbuild ${magefile})"
2892   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"   state="$(get_value_from_magefile STATE ${magefile})"
2893     description="$(get_value_from_magefile DESCRIPTION ${magefile})"
2894     homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
2895    
2896     # all installed
2897     for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
2898     do
2899     ipver="$(magename2pver ${i})"
2900     ipbuild="$(magename2pbuild ${i})"
2901    
2902     if [[ -z ${all_installed} ]]
2903     then
2904     all_installed="${ipver}-${ipbuild}"
2905     else
2906     all_installed="${all_installed} ${ipver}-${ipbuild}"
2907     fi
2908     done
2909     [[ -z ${all_installed} ]] && all_installed="none"
2910    
2911     case ${state} in
2912     stable) state=${COLGREEN}"[s] ";;
2913     testing) state=${COLYELLOW}"[t] ";;
2914     unstable) state=${COLRED}"[u] ";;
2915     old) state=${COLGRAY}"[o] ";;
2916     esac
2917    
2918   # all installed   latest_available="${pver}-${pbuild}"
2919   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})   else
2920   do   # package is masked
2921   ipver="$(magename2pver ${i})"   state="${COLRED}[m] "
2922   ipbuild="$(magename2pbuild ${i})"   latest_available="${COLRED}masked for this distribution.${COLDEFAULT}"
2923     fi
2924    
2925   if [[ -z ${all_installed} ]]   depsfull="$(get_value_from_magefile DEPEND ${magefile})"
2926   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"  
2927    
2928   case ${state} in   while read sign dep
2929   stable) state=${COLGREEN}"[s] ";;   do
2930   testing) state=${COLYELLOW}"[t] ";;   case ${dep} in
2931   unstable) state=${COLRED}"[u] ";;   "") continue;;
2932   old) state=${COLGRAY}"[o] ";;   esac
2933   esac  
2934     deps="${deps} $(basename ${dep%-*})"
2935     done << EOF
2936    ${depsfull}
2937    EOF
2938    
2939     while read sign dep
2940     do
2941     case ${dep} in
2942     "") continue;;
2943     esac
2944    
2945     sdeps="${sdeps} $(basename ${dep%-*})"
2946     done << EOF
2947    ${sdepsfull}
2948    EOF
2949    
2950   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}
2951   echo "      Latest available:   ${pver}-${pbuild}"   echo -e "      Latest available:   ${latest_available}"
2952   echo "      Installed versions: ${all_installed}"   echo "      Installed versions: ${all_installed}"
2953   echo "      Description: ${description}"   echo "      Description: ${description}"
2954   echo "      Homepage: ${homepage}"   echo "      Homepage: ${homepage}"
2955     echo "      Depends: ${deps}"
2956     echo "      SDepends: ${sdeps}"
2957   echo   echo
2958    
2959   unset pcat   unset pcat
# Line 2605  pkgsearch() Line 2967  pkgsearch()
2967   unset all_installed   unset all_installed
2968   unset ipver   unset ipver
2969   unset ipbuild   unset ipbuild
2970     unset depsfull
2971     unset sdepsfull
2972     unset deps
2973     unset sdeps
2974     unset dep
2975     unset sign
2976   done   done
2977  }  }
2978    
# Line 2647  blacklisted() Line 3015  blacklisted()
3015   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable
3016   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing
3017    
3018   local EXCLUDED="${MROOT}/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"   # support both types for the moment
3019     if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]]
3020     then
3021     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"
3022     else
3023     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}"
3024     fi
3025    
3026   # return 0 if the list not exist; nothin is masked   # return 0 if the list not exist; nothin is masked
3027   [[ ! -f ${EXCLUDED} ]] && return 0   [[ ! -f ${EXCLUDED} ]] && return 0
# Line 2690  EOF Line 3064  EOF
3064   return 0   return 0
3065  }  }
3066    
3067    # need_busybox_support ${cmd}
3068    # return 0 (no error = needs busybox support) or return 1 (error = no busybox support required)
3069    need_busybox_support()
3070    {
3071     local cmd
3072     cmd="$1"
3073    
3074     if [[ -x /bin/busybox ]]
3075     then
3076     if [[ $(readlink $(which ${cmd})) = /bin/busybox ]]
3077     then
3078     # needs busybox support
3079     return 0
3080     else
3081     # no busybox
3082     return 1
3083     fi
3084     fi
3085    }
3086    
3087    # busybox_filter_wget_options ${wget_opts}
3088    busybox_filter_wget_options()
3089    {
3090     local opts="$@"
3091     local i
3092     local fixed_opts
3093    
3094     if need_busybox_support wget
3095     then
3096     for i in ${opts}
3097     do
3098     # show only the allowed ones
3099     case ${i} in
3100     -c|--continue) fixed_opts+=" -c" ;;
3101     -s|--spider) fixed_opts+=" -s" ;;
3102     -q|--quiet) fixed_opts+=" -q" ;;
3103     -O|--output-document) shift; fixed_opts+=" -O $1" ;;
3104     --header) shift; fixed_opts+=" --header $1" ;;
3105     -Y|--proxy) shift; fixed_opts+=" -Y $1" ;;
3106     -P) shift; fixed_opts+=" -P $1" ;;
3107     --no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;;
3108     -U|--user-agent) shift; fixed_opts+=" -U ${i}" ;;
3109     # simply drop all other opts
3110     *) continue ;;
3111     esac
3112     done
3113    
3114     echo "${fixed_opts}"
3115     else
3116     echo "${opts}"
3117     fi
3118    }

Legend:
Removed from v.385  
changed lines
  Added in v.1273