Magellan Linux

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

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

revision 416 by niro, Sun Jan 21 23:29:34 2007 UTC revision 1211 by niro, Fri Jan 28 21:39:01 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.25 2007-01-21 23:29:34 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 198  install_files() Line 198  install_files()
198   is_config_protected "${pathto}"   is_config_protected "${pathto}"
199   retval="$?"   retval="$?"
200    
201   # 0 - not protected        #   # 0 - not protected         #
202   # 1 - error                #   # 1 - error                 #
203   # 2 - protected            #   # 2 - protected             #
204   # 3 - protected but masked #   # 3 - protected but masked  #
205     # 4 - protected but ignored #
206    
207   case ${retval} in   case ${retval} in
208   # file is not protected - (over)write it   # file is not protected - (over)write it
# Line 252  install_files() Line 253  install_files()
253   (( MAGE_PROTECT_COUNTER++ ))   (( MAGE_PROTECT_COUNTER++ ))
254   export MAGE_PROTECT_COUNTER   export MAGE_PROTECT_COUNTER
255   ;;   ;;
256    
257     # file is protected but ignored, delete the update/do nothing
258     4)
259     if [[ ${VERBOSE} = on ]]
260     then
261     echo -en "${COLRED}"
262     echo -n "! ignr "
263     echo -en "${COLDEFAULT}"
264     echo " === FILE: ${MROOT}${pathto}"
265     fi
266     # simply do nothing here
267     ;;
268   esac   esac
269   done < ${BUILDDIR}/${pkgname}/.files   done < ${BUILDDIR}/${pkgname}/.files
270    
# Line 298  install_symlinks() Line 311  install_symlinks()
311    
312   ln -snf "${link}" "${MROOT}${pathto}"   ln -snf "${link}" "${MROOT}${pathto}"
313    
314   # fix mtime and db  # # fix mtime and db
315   fix_descriptor ${pkgname}/.symlinks \  # fix_descriptor ${pkgname}/.symlinks \
316   "${pathto}" \  # "${pathto}" \
317   "${posix}" \  # "${posix}" \
318   "${link}" \  # "${link}" \
319   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \  # "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
320   "${MROOT}${pathto}")"  # "${MROOT}${pathto}")"
321    
322   done < ${BUILDDIR}/${pkgname}/.symlinks   done < ${BUILDDIR}/${pkgname}/.symlinks
323    
324   # now copy the fixed file over the old one  # # now copy the fixed file over the old one
325   [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \  # [ -f ${BUILDDIR}/${pkgname}/.symlinks_fixed ] && \
326   cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,}  # cp -f ${BUILDDIR}/${pkgname}/.symlinks{_fixed,}
327    
328   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
329   IFS=$'\n'   IFS=$'\n'
# Line 326  install_blockdevices() Line 339  install_blockdevices()
339   local pkgname="$1"   local pkgname="$1"
340   local pathto   local pathto
341   local posix   local posix
342     local user
343     local group
344   local IFS   local IFS
345    
346   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 339  install_blockdevices() Line 354  install_blockdevices()
354   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
355   IFS=§   IFS=§
356    
357   while read pathto posix   while read pathto posix user group
358   do   do
359   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
360   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"
361    
362   mkfifo -m "${posix}" "${MROOT}$pathto"   mkfifo -m "${posix}" "${MROOT}${pathto}"
363     # make it optional atm !!
364     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
365     then
366     chown "${user}:${group}" "${MROOT}${pathto}"
367     fi
368   done < ${BUILDDIR}/${pkgname}/.pipes   done < ${BUILDDIR}/${pkgname}/.pipes
369    
370   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
# Line 363  install_characterdevices() Line 383  install_characterdevices()
383   local posix   local posix
384   local major   local major
385   local minor   local minor
386     local user
387     local group
388   local IFS   local IFS
389    
390   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 376  install_characterdevices() Line 398  install_characterdevices()
398   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
399   IFS=§   IFS=§
400    
401   while read pathto posix major minor   while read pathto posix major minor user group
402   do   do
403   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
404   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"
405    
406   mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor}   mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor}
407    
408     # make it optional atm !!
409     if [[ ! -z ${user} ]] && [[ ! -z ${group} ]]
410     then
411     chown "${user}:${group}" "${MROOT}${pathto}"
412     fi
413   done < ${BUILDDIR}/${pkgname}/.char   done < ${BUILDDIR}/${pkgname}/.char
414    
415   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
416   IFS=$'\n'   IFS=$'\n'
417  }  }
418    
419    ###################################################
420    # function install_fifos                          #
421    # install_fifos $PKGNAME                    #
422    ###################################################
423    install_fifos()
424    {
425     local pkgname="$1"
426     local pathto
427     local posix
428     local user
429     local group
430     local IFS
431    
432     # sanity checks; abort if not given
433     [ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given."
434    
435     # check needed global vars
436     [ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set."
437    
438     # make it optional atm !!
439     #[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found"
440     [ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return
441    
442     # sets fieldseperator to "§" instead of " "
443     IFS=§
444    
445     while read pathto posix user group
446     do
447     [ -z "${pathto}" ] && continue
448     [[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}"
449    
450     mkfifo -m "${posix}" "${MROOT}${pathto}"
451     chown "${user}:${group}" "${MROOT}${pathto}"
452     done < ${BUILDDIR}/${pkgname}/.fifo
453    
454     # very important: unsetting the '§' fieldseperator
455     IFS=$'\n'
456    }
457    
458    
459  ###################################################  ###################################################
460  # function build_doinstall                        #  # function build_doinstall                        #
461  # build_doinstall $PKGNAME                  #  # build_doinstall $PKGNAME                  #
462  # NOTE: this is an wrapper do install packages    #  # NOTE: this is an wrapper to install packages    #
463  ###################################################  ###################################################
464  build_doinstall()  build_doinstall()
465  {  {
# Line 415  build_doinstall() Line 482  build_doinstall()
482   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"
483   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"
484   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"
485     install_fifos ${pkgname} || die "install fifos ${pkgname}"
486  }  }
487    
488    
# Line 476  install_database_entry() Line 544  install_database_entry()
544    
545   # create fake file descriptors   # create fake file descriptors
546   # used by virtual and source packages   # used by virtual and source packages
547   for i in .dirs .symlinks .files .pipes .char   for i in .dirs .symlinks .files .pipes .char .fifo
548   do   do
549   touch ${dbrecorddir}/${i}   touch ${dbrecorddir}/${i}
550   done   done
# Line 494  install_database_entry() Line 562  install_database_entry()
562    
563   # normal packages needs these files   # normal packages needs these files
564   local i   local i
565   for i in .char .dirs .files .pipes .symlinks   for i in .char .dirs .files .pipes .symlinks .fifo
566   do   do
567   install -m 0644 ${BUILDDIR}/${pkgname}/${i} \   install -m 0644 ${BUILDDIR}/${pkgname}/${i} \
568   ${dbrecorddir}/${i}   ${dbrecorddir}/${i}
# Line 772  remove_files() Line 840  remove_files()
840   done   done
841    
842   # sanity checks; abort if not given   # sanity checks; abort if not given
843   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_files() \$pcat not given."
844   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_files() \$pname not given."
845   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_files() \$pver not given."
846   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_files() \$pbuild not given."
847   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
848    
849   # check needed global vars   # check needed global vars
# Line 809  remove_files() Line 877  remove_files()
877   is_config_protected "${pathto}"   is_config_protected "${pathto}"
878   retval="$?"   retval="$?"
879    
880   # 0 - not protected        #   # 0 - not protected         #
881   # 1 - error                #   # 1 - error                 #
882   # 2 - protected            #   # 2 - protected             #
883   # 3 - protected but masked #   # 3 - protected but masked  #
884     # 4 - protected but ignored #
885    
886   case ${retval} in   case ${retval} in
887   # file is not protected - delete it   # file is not protected - delete it
# Line 831  remove_files() Line 900  remove_files()
900   echo " === FILE: ${MROOT}${pathto}"   echo " === FILE: ${MROOT}${pathto}"
901   fi   fi
902   ;;   ;;
903    
904     # file is protected but ignored, delete the update/do nothing
905     4)
906     if [[ ${VERBOSE} = on ]]
907     then
908     echo -en "${COLRED}"
909     echo -n "! ignr "
910     echo -en "${COLDEFAULT}"
911     echo " === FILE: ${MROOT}${pathto}"
912     fi
913     # simply do nothing here
914     ;;
915   esac   esac
916   ;;   ;;
917   1)   1)
# Line 853  remove_blockdevices() Line 934  remove_blockdevices()
934  {  {
935   local pathto   local pathto
936   local posix   local posix
937     local user
938     local group
939   local IFS   local IFS
940   local pcat   local pcat
941   local pname   local pname
# Line 876  remove_blockdevices() Line 959  remove_blockdevices()
959   done   done
960    
961   # sanity checks; abort if not given   # sanity checks; abort if not given
962   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given."
963   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_blockdevices() \$pname not given."
964   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_blockdevices() \$pver not given."
965   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given."
966   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
967    
968   # check needed global vars   # check needed global vars
# Line 890  remove_blockdevices() Line 973  remove_blockdevices()
973   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
974   IFS=§   IFS=§
975    
976   while read pathto posix   while read pathto posix user group
977   do   do
978   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
979    
# Line 911  remove_characterdevices() Line 994  remove_characterdevices()
994  {  {
995   local pathto   local pathto
996   local posix   local posix
997     local user
998     local group
999   local IFS   local IFS
1000   local pcat   local pcat
1001   local pname   local pname
# Line 934  remove_characterdevices() Line 1019  remove_characterdevices()
1019   done   done
1020    
1021   # sanity checks; abort if not given   # sanity checks; abort if not given
1022   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given."
1023   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_characterdevices() \$pname not given."
1024   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_characterdevices() \$pver not given."
1025   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given."
1026   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1027    
1028   # check needed global vars   # check needed global vars
# Line 948  remove_characterdevices() Line 1033  remove_characterdevices()
1033   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1034   IFS=§   IFS=§
1035    
1036   while read pathto posix   while read pathto posix user group
1037   do   do
1038   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1039    
# Line 962  remove_characterdevices() Line 1047  remove_characterdevices()
1047    
1048    
1049  ###################################################  ###################################################
1050    # function remove_fifos                           #
1051    # remove_fifos $PKGNAME                     #
1052    ###################################################
1053    remove_fifos()
1054    {
1055     local pathto
1056     local posix
1057     local user
1058     local group
1059     local IFS
1060     local pcat
1061     local pname
1062     local pver
1063     local pbuild
1064     local i
1065     local pfull
1066    
1067     IFS=$'\n'
1068    
1069     # very basic getops
1070     for i in $*
1071     do
1072     case $1 in
1073     --pcat|-c) shift; pcat="$1" ;;
1074     --pname|-n) shift; pname="$1" ;;
1075     --pver|-v) shift; pver="$1" ;;
1076     --pbuild|-b) shift; pbuild="$1" ;;
1077     esac
1078     shift
1079     done
1080    
1081     # sanity checks; abort if not given
1082     [ -z "${pcat}" ] && die "remove_fifos() \$pcat not given."
1083     [ -z "${pname}" ] && die "remove_fifos() \$pname not given."
1084     [ -z "${pver}" ] && die "remove_fifos() \$pver not given."
1085     [ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given."
1086     pfull="${pcat}/${pname}-${pver}-${pbuild}"
1087    
1088     # check needed global vars
1089     [ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set."
1090    
1091     # make it optional atm !!
1092     #[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found"
1093     [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return
1094    
1095     # sets fieldseperator to "§" instead of " "
1096     IFS=§
1097    
1098     while read pathto posix user group
1099     do
1100     [ -z "${pathto}" ] && continue
1101    
1102     [[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}"
1103     rm "${MROOT}${pathto}"
1104     done < ${MROOT}${INSTALLDB}/${pfull}/.fifo
1105    
1106     # very important: unsetting the '§' fieldseperator
1107     IFS=$'\n'
1108    }
1109    
1110    
1111    ###################################################
1112  # function remove_direcories                      #  # function remove_direcories                      #
1113  # remove_direcories $PKGNAME                #  # remove_direcories $PKGNAME                #
1114  ###################################################  ###################################################
# Line 992  remove_directories() Line 1139  remove_directories()
1139   done   done
1140    
1141   # sanity checks; abort if not given   # sanity checks; abort if not given
1142   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_directories() \$pcat not given."
1143   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_directories() \$pname not given."
1144   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_directories() \$pver not given."
1145   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given."
1146   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1147    
1148   # check needed global vars   # check needed global vars
# Line 1049  remove_directories() Line 1196  remove_directories()
1196  ###################################################  ###################################################
1197  # function build_douninstall                      #  # function build_douninstall                      #
1198  # build_douninstall $PKGNAME                #  # build_douninstall $PKGNAME                #
1199  # NOTE: this is an wrapper do remove packages     #  # NOTE: this is an wrapper to remove packages     #
1200  ###################################################  ###################################################
1201  build_douninstall()  build_douninstall()
1202  {  {
# Line 1083  build_douninstall() Line 1230  build_douninstall()
1230   # !! we use § as field seperator !!   # !! we use § as field seperator !!
1231   # doing so prevent us to get errors by filenames with spaces   # doing so prevent us to get errors by filenames with spaces
1232    
1233   for i in symlinks files blockdevices characterdevices directories   for i in symlinks files blockdevices characterdevices directories fifos
1234   do   do
1235   remove_${i} \   remove_${i} \
1236   --pcat "${pcat}" \   --pcat "${pcat}" \
# Line 1106  fetch_packages() Line 1253  fetch_packages()
1253   local count_current   local count_current
1254   local count_total   local count_total
1255    
1256   [ -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}."
1257    
1258   # get count of total packages   # get count of total packages
1259   declare -i count_current=0   declare -i count_current=0
# Line 1153  fetch_packages() Line 1300  fetch_packages()
1300   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1301   [[ ${VERBOSE} = off ]] && opt="--quiet"   [[ ${VERBOSE} = off ]] && opt="--quiet"
1302   wget \   wget \
1303   --passive-ftp \   ${WGET_FETCH_OPTIONS} \
  --tries 3 \  
  --continue \  
  --progress bar \  
1304   --directory-prefix=${PKGDIR} \   --directory-prefix=${PKGDIR} \
1305   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}
1306   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 1181  syncmage() Line 1325  syncmage()
1325  {  {
1326   if [ -z "${RSYNC}" ]   if [ -z "${RSYNC}" ]
1327   then   then
1328   die "You have no rsync-mirrors defined. Please edit your /etc/mage.rc."   die "You have no rsync-mirrors defined. Please edit your ${MAGERC}."
1329   fi   fi
1330    
1331   local i   local i
# Line 1199  syncmage() Line 1343  syncmage()
1343   # clean up backup files (foo~)   # clean up backup files (foo~)
1344   find ${MAGEDIR} -name *~ -exec rm '{}' ';'   find ${MAGEDIR} -name *~ -exec rm '{}' ';'
1345    
1346   # check if an newer mage version is available   # check if a newer mage version is available
1347   is_newer_mage_version_available   is_newer_mage_version_available
1348  }  }
1349    
1350    syncmage_tarball()
1351    {
1352     local latest_tarball
1353     local latest_md5
1354     local temp="$(mktemp -d)"
1355     local mirr mymirr
1356     local opt
1357    
1358     # try to get the md5 marked as latest on the server
1359     latest_md5="mage-latest.md5"
1360    
1361     # try to get the tarball marked as latest on the server
1362     latest_tarball="mage-latest.tar.bz2"
1363    
1364     for mirr in ${MIRRORS}
1365     do
1366     # path without distribution
1367     mymirr="${mirr%/*}"
1368    
1369     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1370     echo "fetching latest md5 from ${mymirr} ..."
1371     [[ ${VERBOSE} = off ]] && opt="--quiet"
1372     wget \
1373     ${WGET_FETCH_OPTIONS} \
1374     --directory-prefix=${temp} \
1375     ${opt} ${mymirr}/rsync/tarballs/${latest_md5}
1376    
1377     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1378     echo "fetching latest tarball from ${mymirr} ..."
1379     wget \
1380     ${WGET_FETCH_OPTIONS} \
1381     --directory-prefix=${temp} \
1382     ${opt} ${mymirr}/rsync/tarballs/${latest_tarball}
1383     if [[ $? = 0 ]]
1384     then
1385     break
1386     else
1387     continue
1388     fi
1389     done
1390    
1391     if [[ -f ${temp}/${latest_tarball} ]]
1392     then
1393     # check md5
1394     if [[ ! -f ${temp}/${latest_md5} ]]
1395     then
1396     die "md5 is missing ... aborting"
1397     else
1398     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1399     echo -n "checking md5sum... "
1400     ( cd ${temp}; md5sum --check ${latest_md5} ) || die "md5 for ${latest_tarball} failed"
1401     fi
1402    
1403     if [[ -d ${MAGEDIR} ]]
1404     then
1405     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1406     echo "cleaning old mage-tree ${MAGEDIR}..."
1407     rm -rf ${MAGEDIR}
1408     fi
1409    
1410     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1411     echo "updating mage-tree from tarball ..."
1412     # unpack in dirname of MAGEDIR, as the tarball has already the mage
1413     tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1414    
1415     if [[ -d ${temp} ]]
1416     then
1417     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1418     echo "cleaning temp-files ..."
1419     rm -rf ${temp}
1420     fi
1421    
1422     # check if a newer mage version is available
1423     is_newer_mage_version_available
1424     else
1425     die "Could not fetch the latest tarball ... aborting"
1426     fi
1427    }
1428    
1429  cleanpkg()  cleanpkg()
1430  {  {
1431   if [ -d "${PKGDIR}" ]   if [ -d "${PKGDIR}" ]
# Line 1240  choppkgname() Line 1463  choppkgname()
1463   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]
1464   then   then
1465   #cuts ARCH and PBUILD   #cuts ARCH and PBUILD
1466   #ARCH comes from /etc/mage.rc   #ARCH comes from ${MAGERC}
1467   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")
1468    
1469   #cuts version number   #cuts version number
# Line 1315  get_highest_magefile() Line 1538  get_highest_magefile()
1538   local PNAME="$2"   local PNAME="$2"
1539   local magefile   local magefile
1540    
1541   for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*)   # do not list the content of a directory, only the name (-d)
1542     for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*)
1543   do   do
1544     [[ -z ${magefile} ]] && continue
1545   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
1546   [ -d ${magefile} ] && continue   [[ -d ${magefile} ]] && continue
1547   if check_stable_package ${magefile}   if check_stable_package ${magefile}
1548   then   then
1549   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
# Line 1363  get_highest_magefile() Line 1588  get_highest_magefile()
1588  #        1 - error                                #  #        1 - error                                #
1589  #        2 - protected                            #  #        2 - protected                            #
1590  #        3 - protected but masked                 #  #        3 - protected but masked                 #
1591    #        4 - protected but ignored                #
1592  #                                                 #  #                                                 #
1593  ###################################################  ###################################################
1594  is_config_protected()  is_config_protected()
# Line 1371  is_config_protected() Line 1597  is_config_protected()
1597   local TEST   local TEST
1598   local PROTECTED   local PROTECTED
1599   local IFS   local IFS
1600     local i
1601     local x
1602    
1603   EXPFILE="${MROOT}$1"   EXPFILE="${MROOT}$1"
1604    
1605   # file does not exist; it can be written   # file does not exist; it can be written
1606   [ ! -e ${EXPFILE} ] && return 0   [[ ! -e ${EXPFILE} ]] && return 0
1607    
1608   # to be safe; it may be '§'   # to be safe; it may be '§'
1609   IFS=' '   IFS=' '
1610    
1611   # check ob in config protect   # check if config protected
1612   for i in ${CONFIG_PROTECT}   for i in ${CONFIG_PROTECT}
1613   do   do
1614   # ersetzen von $i nur wenn am anfang der variable   # only replace $i in the beginning of the variable
1615   TEST="${EXPFILE/#${MROOT}${i}/Protected}"   TEST="${EXPFILE/#${MROOT}${i}/Protected}"
1616   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1617   then   then
1618   # setzen das es protected ist   # file is config proteced
1619   PROTECTED=TRUE   PROTECTED=TRUE
1620    
1621   # check ob nicht doch maskiert   # check if not masked
1622   for x in ${CONFIG_PROTECT_MASK}   for x in ${CONFIG_PROTECT_MASK}
1623   do   do
1624   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"
1625   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1626   then   then
1627   PROTECTED=MASKED   PROTECTED=MASKED
1628   fi   fi
1629   done   done
1630    
1631     # check if not ignored
1632     for x in ${CONFIG_PROTECT_IGNORE}
1633     do
1634     TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}"
1635     if [[ ${TEST} != ${EXPFILE} ]]
1636     then
1637     PROTECTED=IGNORED
1638     fi
1639     done
1640   fi   fi
1641   done   done
1642    
# Line 1413  is_config_protected() Line 1651  is_config_protected()
1651   #echo "I'm protected, but masked - delete me"   #echo "I'm protected, but masked - delete me"
1652   return 3   return 3
1653   ;;   ;;
1654     IGNORED)
1655     #echo "I'm protected, but ignored - keep me, del update"
1656     return 4
1657     ;;
1658   *)   *)
1659   #echo "delete me"   #echo "delete me"
1660   return 0   return 0
# Line 1430  is_config_protected() Line 1672  is_config_protected()
1672  ###################################################  ###################################################
1673  count_protected_files()  count_protected_files()
1674  {  {
1675   ${MLIBDIR}/writeprotected "$1"   local file="$1"
1676     local dirname="${file%/*}"
1677     local filename="${file##*/}"
1678     local count
1679     local output
1680     local i
1681    
1682     declare -i count=0
1683    
1684     # check if there are already protected files
1685     for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" |
1686     sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
1687     sort -t'%' -k3 -k2 | cut -f1 -d'%')
1688     do
1689     count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::")
1690     done
1691     (( count ++ ))
1692    
1693     # fill output up with zeros
1694     for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
1695     output="${output}${count}"
1696    
1697     echo "${output}"
1698  }  }
1699    
1700  # call with  # call with
# Line 1447  get_uninstall_candidates() Line 1711  get_uninstall_candidates()
1711   local list   local list
1712   local pcatdir   local pcatdir
1713   local protected   local protected
1714     local i
1715    
1716   # very basic getops   # very basic getops
1717   for i in $*   for i in $*
# Line 1601  virtuals_add() Line 1866  virtuals_add()
1866    
1867  #deletes pakages from virtual database  #deletes pakages from virtual database
1868  #$1 virtualname; $2 pkgname  #$1 virtualname; $2 pkgname
1869  virtuals_del() {  virtuals_del()
1870    {
1871    
1872   local virtualname="$1"   local virtualname="$1"
1873   local pkgname="$2"   local pkgname="$2"
# Line 1708  minclude() Line 1974  minclude()
1974  {  {
1975   local i   local i
1976    
1977   if [[ -n $@ ]]   if [[ -n $* ]]
1978   then   then
1979   for i in $@   for i in $*
1980   do   do
1981   [[ ${MAGEDEBUG} = on ]] && \   [[ ${MAGEDEBUG} = on ]] && \
1982   echo "--- Including ${MAGEDIR}/include/${i}.minc"   echo "--- Including ${MAGEDIR}/include/${i}.minc"
# Line 1724  sminclude() Line 1990  sminclude()
1990  {  {
1991   local i   local i
1992    
1993   if [ -n "$@" ]   if [[ -n $* ]]
1994   then   then
1995   for i in $@   for i in $*
1996   do   do
1997   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
1998   source ${SMAGESCRIPTSDIR}/include/${i}.sminc   source ${SMAGESCRIPTSDIR}/include/${i}.sminc
# Line 2035  get_value_from_magefile() Line 2301  get_value_from_magefile()
2301   local SDEPEND   local SDEPEND
2302   local PROVIDE   local PROVIDE
2303   local PKGTYPE   local PKGTYPE
2304     local MAGE_TARGETS
2305     local SPLIT_PACKAGE_BASE
2306   local preinstall   local preinstall
2307   local postinstall   local postinstall
2308   local preremove   local preremove
# Line 2081  mage_install() Line 2349  mage_install()
2349   local count_current   local count_current
2350   local magefile   local magefile
2351   local src_install   local src_install
2352     local i
2353    
2354   # very basic getops   # very basic getops
2355   for i in $*   for i in $*
# Line 2154  mage_install() Line 2423  mage_install()
2423   echo B:${pbuild}   echo B:${pbuild}
2424   fi   fi
2425    
2426   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2   if [[ -n ${MAGE_TARGETS} ]]
2427     then
2428     # basic svn compat
2429     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2430     then
2431     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2432     do
2433     smage2file="${i}"
2434     done
2435     else
2436     smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2437     fi
2438    
2439     elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2440     then
2441     # basic svn compat
2442     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2443     then
2444     for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2445     do
2446     smage2file="${i}"
2447     done
2448     else
2449     smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2450     fi
2451    
2452     else
2453     # basic svn compat
2454     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2455     then
2456     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2457     do
2458     smage2file="${i}"
2459     done
2460     else
2461     smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2
2462     fi
2463     fi
2464    
2465   if [ -f "${smage2file}" ]   if [ -f "${smage2file}" ]
2466   then   then
2467   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "   echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "
# Line 2430  mage_uninstall() Line 2737  mage_uninstall()
2737   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2738   echo -e "${COLRED}${pname}-${pver}-${pbuild}${COLDEFAULT}"   echo -e "${COLRED}${pname}-${pver}-${pbuild}${COLDEFAULT}"
2739    
2740   magefile="${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"   magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
2741   source ${magefile}   source ${magefile}
2742    
2743   ## preremove scripts   ## preremove scripts
# Line 2498  mage_uninstall() Line 2805  mage_uninstall()
2805   unset -f postremove   unset -f postremove
2806  }  }
2807    
2808  show_etc_update_mesg() {  show_etc_update_mesg()
2809    {
2810   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0
2811    
2812   echo   echo
# Line 2528  pkgsearch() Line 2836  pkgsearch()
2836   local all_installed   local all_installed
2837   local ipver   local ipver
2838   local ipbuild   local ipbuild
2839     local latest_available
2840     local depsfull
2841     local sdepsfull
2842     local deps
2843     local sdeps
2844     local dep
2845     local sign
2846    
2847   # only names no versions   # only names no versions
2848   result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name '*'${string}'*'| sed '/profiles/d' | sed '/includes/d')"   result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name '*'${string}'*'| sed '/profiles/d' | sed '/includes/d')"
# Line 2545  pkgsearch() Line 2860  pkgsearch()
2860   # get highest version available   # get highest version available
2861   magefile=$(get_highest_magefile ${pcat} ${pname})   magefile=$(get_highest_magefile ${pcat} ${pname})
2862    
2863   # now get all needed infos to print a nice output   if [[ ! -z ${magefile} ]]
2864   pver="$(magename2pver ${magefile})"   then
2865   pbuild="$(magename2pbuild ${magefile})"   # now get all needed infos to print a nice output
2866   state="$(get_value_from_magefile STATE ${magefile})"   pver="$(magename2pver ${magefile})"
2867   description="$(get_value_from_magefile DESCRIPTION ${magefile})"   pbuild="$(magename2pbuild ${magefile})"
2868   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"   state="$(get_value_from_magefile STATE ${magefile})"
2869     description="$(get_value_from_magefile DESCRIPTION ${magefile})"
2870     homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
2871    
2872     # all installed
2873     for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
2874     do
2875     ipver="$(magename2pver ${i})"
2876     ipbuild="$(magename2pbuild ${i})"
2877    
2878     if [[ -z ${all_installed} ]]
2879     then
2880     all_installed="${ipver}-${ipbuild}"
2881     else
2882     all_installed="${all_installed} ${ipver}-${ipbuild}"
2883     fi
2884     done
2885     [[ -z ${all_installed} ]] && all_installed="none"
2886    
2887     case ${state} in
2888     stable) state=${COLGREEN}"[s] ";;
2889     testing) state=${COLYELLOW}"[t] ";;
2890     unstable) state=${COLRED}"[u] ";;
2891     old) state=${COLGRAY}"[o] ";;
2892     esac
2893    
2894   # all installed   latest_available="${pver}-${pbuild}"
2895   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})   else
2896   do   # package is masked
2897   ipver="$(magename2pver ${i})"   state="${COLRED}[m] "
2898   ipbuild="$(magename2pbuild ${i})"   latest_available="${COLRED}masked for this distribution.${COLDEFAULT}"
2899     fi
2900    
2901   if [[ -z ${all_installed} ]]   depsfull="$(get_value_from_magefile DEPEND ${magefile})"
2902   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"  
2903    
2904   case ${state} in   while read sign dep
2905   stable) state=${COLGREEN}"[s] ";;   do
2906   testing) state=${COLYELLOW}"[t] ";;   case ${dep} in
2907   unstable) state=${COLRED}"[u] ";;   "") continue;;
2908   old) state=${COLGRAY}"[o] ";;   esac
2909   esac  
2910     deps="${deps} $(basename ${dep%-*})"
2911     done << EOF
2912    ${depsfull}
2913    EOF
2914    
2915     while read sign dep
2916     do
2917     case ${dep} in
2918     "") continue;;
2919     esac
2920    
2921     sdeps="${sdeps} $(basename ${dep%-*})"
2922     done << EOF
2923    ${sdepsfull}
2924    EOF
2925    
2926   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}
2927   echo "      Latest available:   ${pver}-${pbuild}"   echo -e "      Latest available:   ${latest_available}"
2928   echo "      Installed versions: ${all_installed}"   echo "      Installed versions: ${all_installed}"
2929   echo "      Description: ${description}"   echo "      Description: ${description}"
2930   echo "      Homepage: ${homepage}"   echo "      Homepage: ${homepage}"
2931     echo "      Depends: ${deps}"
2932     echo "      SDepends: ${sdeps}"
2933   echo   echo
2934    
2935   unset pcat   unset pcat
# Line 2592  pkgsearch() Line 2943  pkgsearch()
2943   unset all_installed   unset all_installed
2944   unset ipver   unset ipver
2945   unset ipbuild   unset ipbuild
2946     unset depsfull
2947     unset sdepsfull
2948     unset deps
2949     unset sdeps
2950     unset dep
2951     unset sign
2952   done   done
2953  }  }
2954    
# Line 2634  blacklisted() Line 2991  blacklisted()
2991   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable
2992   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing
2993    
2994   local EXCLUDED="${MROOT}/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"   # support both types for the moment
2995     if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]]
2996     then
2997     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"
2998     else
2999     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}"
3000     fi
3001    
3002   # return 0 if the list not exist; nothin is masked   # return 0 if the list not exist; nothin is masked
3003   [[ ! -f ${EXCLUDED} ]] && return 0   [[ ! -f ${EXCLUDED} ]] && return 0

Legend:
Removed from v.416  
changed lines
  Added in v.1211