Magellan Linux

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

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

revision 373 by niro, Thu Apr 27 17:15:23 2006 UTC revision 1209 by niro, Fri Jan 28 20:37:27 2011 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  # Magellan Linux Installer Functions (mage.functions.sh)  # Magellan Linux Installer Functions (mage.functions.sh)
3  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.19 2006-04-27 17:15:23 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.38 2008-10-05 10:32:24 niro Exp $
4    
5  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     chown "${user}:${group}" "${MROOT}${pathto}"
364   done < ${BUILDDIR}/${pkgname}/.pipes   done < ${BUILDDIR}/${pkgname}/.pipes
365    
366   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
# Line 363  install_characterdevices() Line 379  install_characterdevices()
379   local posix   local posix
380   local major   local major
381   local minor   local minor
382     local user
383     local group
384   local IFS   local IFS
385    
386   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 376  install_characterdevices() Line 394  install_characterdevices()
394   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
395   IFS=§   IFS=§
396    
397   while read pathto posix major minor   while read pathto posix major minor user group
398   do   do
399   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
400   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"
401    
402   mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor}   mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor}
403     chown "${user}:${group}" "${MROOT}${pathto}"
404   done < ${BUILDDIR}/${pkgname}/.char   done < ${BUILDDIR}/${pkgname}/.char
405    
406   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
407   IFS=$'\n'   IFS=$'\n'
408  }  }
409    
410    ###################################################
411    # function install_fifos                          #
412    # install_fifos $PKGNAME                    #
413    ###################################################
414    install_fifos()
415    {
416     local pkgname="$1"
417     local pathto
418     local posix
419     local user
420     local group
421     local IFS
422    
423     # sanity checks; abort if not given
424     [ -z "${pkgname}" ] && die "install_fifos() \$pkgname not given."
425    
426     # check needed global vars
427     [ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set."
428    
429     [ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found"
430    
431     # sets fieldseperator to "§" instead of " "
432     IFS=§
433    
434     while read pathto posix user group
435     do
436     [ -z "${pathto}" ] && continue
437     [[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}"
438    
439     mkfifo -m "${posix}" "${MROOT}${pathto}"
440     chown "${user}:${group}" "${MROOT}${pathto}"
441     done < ${BUILDDIR}/${pkgname}/.fifo
442    
443     # very important: unsetting the '§' fieldseperator
444     IFS=$'\n'
445    }
446    
447    
448  ###################################################  ###################################################
449  # function build_doinstall                        #  # function build_doinstall                        #
450  # build_doinstall $PKGNAME                  #  # build_doinstall $PKGNAME                  #
451  # NOTE: this is an wrapper do install packages    #  # NOTE: this is an wrapper to install packages    #
452  ###################################################  ###################################################
453  build_doinstall()  build_doinstall()
454  {  {
# Line 415  build_doinstall() Line 471  build_doinstall()
471   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"   install_symlinks ${pkgname} || die "install symlinks ${pkgname}"
472   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"   install_blockdevices ${pkgname} || die "install blockdevices ${pkgname}"
473   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"   install_characterdevices ${pkgname} || die "install chardevices ${pkgname}"
474     install_fifos ${pkgname} || die "install fifos ${pkgname}"
475  }  }
476    
477    
# Line 476  install_database_entry() Line 533  install_database_entry()
533    
534   # create fake file descriptors   # create fake file descriptors
535   # used by virtual and source packages   # used by virtual and source packages
536   for i in .dirs .symlinks .files .pipes .char   for i in .dirs .symlinks .files .pipes .char .fifo
537   do   do
538   touch ${dbrecorddir}/${i}   touch ${dbrecorddir}/${i}
539   done   done
# Line 494  install_database_entry() Line 551  install_database_entry()
551    
552   # normal packages needs these files   # normal packages needs these files
553   local i   local i
554   for i in .char .dirs .files .pipes .symlinks   for i in .char .dirs .files .pipes .symlinks .fifo
555   do   do
556   install -m 0644 ${BUILDDIR}/${pkgname}/${i} \   install -m 0644 ${BUILDDIR}/${pkgname}/${i} \
557   ${dbrecorddir}/${i}   ${dbrecorddir}/${i}
# Line 772  remove_files() Line 829  remove_files()
829   done   done
830    
831   # sanity checks; abort if not given   # sanity checks; abort if not given
832   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_files() \$pcat not given."
833   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_files() \$pname not given."
834   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_files() \$pver not given."
835   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_files() \$pbuild not given."
836   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
837    
838   # check needed global vars   # check needed global vars
# Line 809  remove_files() Line 866  remove_files()
866   is_config_protected "${pathto}"   is_config_protected "${pathto}"
867   retval="$?"   retval="$?"
868    
869   # 0 - not protected        #   # 0 - not protected         #
870   # 1 - error                #   # 1 - error                 #
871   # 2 - protected            #   # 2 - protected             #
872   # 3 - protected but masked #   # 3 - protected but masked  #
873     # 4 - protected but ignored #
874    
875   case ${retval} in   case ${retval} in
876   # file is not protected - delete it   # file is not protected - delete it
# Line 831  remove_files() Line 889  remove_files()
889   echo " === FILE: ${MROOT}${pathto}"   echo " === FILE: ${MROOT}${pathto}"
890   fi   fi
891   ;;   ;;
892    
893     # file is protected but ignored, delete the update/do nothing
894     4)
895     if [[ ${VERBOSE} = on ]]
896     then
897     echo -en "${COLRED}"
898     echo -n "! ignr "
899     echo -en "${COLDEFAULT}"
900     echo " === FILE: ${MROOT}${pathto}"
901     fi
902     # simply do nothing here
903     ;;
904   esac   esac
905   ;;   ;;
906   1)   1)
# Line 853  remove_blockdevices() Line 923  remove_blockdevices()
923  {  {
924   local pathto   local pathto
925   local posix   local posix
926     local user
927     local group
928   local IFS   local IFS
929   local pcat   local pcat
930   local pname   local pname
# Line 876  remove_blockdevices() Line 948  remove_blockdevices()
948   done   done
949    
950   # sanity checks; abort if not given   # sanity checks; abort if not given
951   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_blockdevices() \$pcat not given."
952   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_blockdevices() \$pname not given."
953   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_blockdevices() \$pver not given."
954   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_blockdevices() \$pbuild not given."
955   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
956    
957   # check needed global vars   # check needed global vars
# Line 890  remove_blockdevices() Line 962  remove_blockdevices()
962   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
963   IFS=§   IFS=§
964    
965   while read pathto posix   while read pathto posix user group
966   do   do
967   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
968    
# Line 911  remove_characterdevices() Line 983  remove_characterdevices()
983  {  {
984   local pathto   local pathto
985   local posix   local posix
986     local user
987     local group
988   local IFS   local IFS
989   local pcat   local pcat
990   local pname   local pname
# Line 934  remove_characterdevices() Line 1008  remove_characterdevices()
1008   done   done
1009    
1010   # sanity checks; abort if not given   # sanity checks; abort if not given
1011   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_characterdevices() \$pcat not given."
1012   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_characterdevices() \$pname not given."
1013   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_characterdevices() \$pver not given."
1014   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_characterdevices() \$pbuild not given."
1015   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1016    
1017   # check needed global vars   # check needed global vars
# Line 948  remove_characterdevices() Line 1022  remove_characterdevices()
1022   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1023   IFS=§   IFS=§
1024    
1025   while read pathto posix   while read pathto posix user group
1026   do   do
1027   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1028    
# Line 962  remove_characterdevices() Line 1036  remove_characterdevices()
1036    
1037    
1038  ###################################################  ###################################################
1039    # function remove_fifos                           #
1040    # remove_fifos $PKGNAME                     #
1041    ###################################################
1042    remove_fifos()
1043    {
1044     local pathto
1045     local posix
1046     local user
1047     local group
1048     local IFS
1049     local pcat
1050     local pname
1051     local pver
1052     local pbuild
1053     local i
1054     local pfull
1055    
1056     IFS=$'\n'
1057    
1058     # very basic getops
1059     for i in $*
1060     do
1061     case $1 in
1062     --pcat|-c) shift; pcat="$1" ;;
1063     --pname|-n) shift; pname="$1" ;;
1064     --pver|-v) shift; pver="$1" ;;
1065     --pbuild|-b) shift; pbuild="$1" ;;
1066     esac
1067     shift
1068     done
1069    
1070     # sanity checks; abort if not given
1071     [ -z "${pcat}" ] && die "remove_fifos() \$pcat not given."
1072     [ -z "${pname}" ] && die "remove_fifos() \$pname not given."
1073     [ -z "${pver}" ] && die "remove_fifos() \$pver not given."
1074     [ -z "${pbuild}" ] && die "remove_fifos() \$pbuild not given."
1075     pfull="${pcat}/${pname}-${pver}-${pbuild}"
1076    
1077     # check needed global vars
1078     [ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set."
1079    
1080     [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found"
1081    
1082     # sets fieldseperator to "§" instead of " "
1083     IFS=§
1084    
1085     while read pathto posix user group
1086     do
1087     [ -z "${pathto}" ] && continue
1088    
1089     [[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}"
1090     rm "${MROOT}${pathto}"
1091     done < ${MROOT}${INSTALLDB}/${pfull}/.fifo
1092    
1093     # very important: unsetting the '§' fieldseperator
1094     IFS=$'\n'
1095    }
1096    
1097    
1098    ###################################################
1099  # function remove_direcories                      #  # function remove_direcories                      #
1100  # remove_direcories $PKGNAME                #  # remove_direcories $PKGNAME                #
1101  ###################################################  ###################################################
# Line 992  remove_directories() Line 1126  remove_directories()
1126   done   done
1127    
1128   # sanity checks; abort if not given   # sanity checks; abort if not given
1129   [ -z "${pcat}" ] && die "remove_symlinks() \$pcat not given."   [ -z "${pcat}" ] && die "remove_directories() \$pcat not given."
1130   [ -z "${pname}" ] && die "remove_symlinks() \$pname not given."   [ -z "${pname}" ] && die "remove_directories() \$pname not given."
1131   [ -z "${pver}" ] && die "remove_symlinks() \$pver not given."   [ -z "${pver}" ] && die "remove_directories() \$pver not given."
1132   [ -z "${pbuild}" ] && die "remove_symlinks() \$pbuild not given."   [ -z "${pbuild}" ] && die "remove_directories() \$pbuild not given."
1133   pfull="${pcat}/${pname}-${pver}-${pbuild}"   pfull="${pcat}/${pname}-${pver}-${pbuild}"
1134    
1135   # check needed global vars   # check needed global vars
# Line 1049  remove_directories() Line 1183  remove_directories()
1183  ###################################################  ###################################################
1184  # function build_douninstall                      #  # function build_douninstall                      #
1185  # build_douninstall $PKGNAME                #  # build_douninstall $PKGNAME                #
1186  # NOTE: this is an wrapper do remove packages     #  # NOTE: this is an wrapper to remove packages     #
1187  ###################################################  ###################################################
1188  build_douninstall()  build_douninstall()
1189  {  {
# Line 1083  build_douninstall() Line 1217  build_douninstall()
1217   # !! we use § as field seperator !!   # !! we use § as field seperator !!
1218   # doing so prevent us to get errors by filenames with spaces   # doing so prevent us to get errors by filenames with spaces
1219    
1220   for i in symlinks files blockdevices characterdevices directories   for i in symlinks files blockdevices characterdevices directories fifos
1221   do   do
1222   remove_${i} \   remove_${i} \
1223   --pcat "${pcat}" \   --pcat "${pcat}" \
# Line 1106  fetch_packages() Line 1240  fetch_packages()
1240   local count_current   local count_current
1241   local count_total   local count_total
1242    
1243   [ -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}."
1244    
1245   # get count of total packages   # get count of total packages
1246   declare -i count_current=0   declare -i count_current=0
# Line 1153  fetch_packages() Line 1287  fetch_packages()
1287   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1288   [[ ${VERBOSE} = off ]] && opt="--quiet"   [[ ${VERBOSE} = off ]] && opt="--quiet"
1289   wget \   wget \
1290   --passive-ftp \   ${WGET_FETCH_OPTIONS} \
  --tries 3 \  
  --continue \  
  --progress bar \  
1291   --directory-prefix=${PKGDIR} \   --directory-prefix=${PKGDIR} \
1292   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}
1293   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 1181  syncmage() Line 1312  syncmage()
1312  {  {
1313   if [ -z "${RSYNC}" ]   if [ -z "${RSYNC}" ]
1314   then   then
1315   die "You have no rsync-mirrors defined. Please edit your /etc/mage.rc."   die "You have no rsync-mirrors defined. Please edit your ${MAGERC}."
1316   fi   fi
1317    
1318   local i   local i
1319   for i in ${RSYNC}   for i in ${RSYNC}
1320   do   do
1321   rsync \   rsync ${RSYNC_FETCH_OPTIONS} ${i} ${MAGEDIR}
  --recursive \  
  --links \  
  --perms \  
  --times \  
  --devices \  
  --timeout=600 \  
  --verbose \  
  --compress \  
  --progress \  
  --stats \  
  --delete \  
  --delete-after \  
  ${i} ${MAGEDIR}  
1322   if [[ $? = 0 ]]   if [[ $? = 0 ]]
1323   then   then
1324   break   break
# Line 1212  syncmage() Line 1330  syncmage()
1330   # clean up backup files (foo~)   # clean up backup files (foo~)
1331   find ${MAGEDIR} -name *~ -exec rm '{}' ';'   find ${MAGEDIR} -name *~ -exec rm '{}' ';'
1332    
1333   # check if an newer mage version is available   # check if a newer mage version is available
1334   is_newer_mage_version_available   is_newer_mage_version_available
1335  }  }
1336    
1337    syncmage_tarball()
1338    {
1339     local latest_tarball
1340     local latest_md5
1341     local temp="$(mktemp -d)"
1342     local mirr mymirr
1343     local opt
1344    
1345     # try to get the md5 marked as latest on the server
1346     latest_md5="mage-latest.md5"
1347    
1348     # try to get the tarball marked as latest on the server
1349     latest_tarball="mage-latest.tar.bz2"
1350    
1351     for mirr in ${MIRRORS}
1352     do
1353     # path without distribution
1354     mymirr="${mirr%/*}"
1355    
1356     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1357     echo "fetching latest md5 from ${mymirr} ..."
1358     [[ ${VERBOSE} = off ]] && opt="--quiet"
1359     wget \
1360     ${WGET_FETCH_OPTIONS} \
1361     --directory-prefix=${temp} \
1362     ${opt} ${mymirr}/rsync/tarballs/${latest_md5}
1363    
1364     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1365     echo "fetching latest tarball from ${mymirr} ..."
1366     wget \
1367     ${WGET_FETCH_OPTIONS} \
1368     --directory-prefix=${temp} \
1369     ${opt} ${mymirr}/rsync/tarballs/${latest_tarball}
1370     if [[ $? = 0 ]]
1371     then
1372     break
1373     else
1374     continue
1375     fi
1376     done
1377    
1378     if [[ -f ${temp}/${latest_tarball} ]]
1379     then
1380     # check md5
1381     if [[ ! -f ${temp}/${latest_md5} ]]
1382     then
1383     die "md5 is missing ... aborting"
1384     else
1385     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1386     echo -n "checking md5sum... "
1387     ( cd ${temp}; md5sum --check ${latest_md5} ) || die "md5 for ${latest_tarball} failed"
1388     fi
1389    
1390     if [[ -d ${MAGEDIR} ]]
1391     then
1392     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1393     echo "cleaning old mage-tree ${MAGEDIR}..."
1394     rm -rf ${MAGEDIR}
1395     fi
1396    
1397     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1398     echo "updating mage-tree from tarball ..."
1399     # unpack in dirname of MAGEDIR, as the tarball has already the mage
1400     tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1401    
1402     if [[ -d ${temp} ]]
1403     then
1404     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1405     echo "cleaning temp-files ..."
1406     rm -rf ${temp}
1407     fi
1408    
1409     # check if a newer mage version is available
1410     is_newer_mage_version_available
1411     else
1412     die "Could not fetch the latest tarball ... aborting"
1413     fi
1414    }
1415    
1416  cleanpkg()  cleanpkg()
1417  {  {
1418   if [ -d "${PKGDIR}" ]   if [ -d "${PKGDIR}" ]
# Line 1253  choppkgname() Line 1450  choppkgname()
1450   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]
1451   then   then
1452   #cuts ARCH and PBUILD   #cuts ARCH and PBUILD
1453   #ARCH comes from /etc/mage.rc   #ARCH comes from ${MAGERC}
1454   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")
1455    
1456   #cuts version number   #cuts version number
# Line 1328  get_highest_magefile() Line 1525  get_highest_magefile()
1525   local PNAME="$2"   local PNAME="$2"
1526   local magefile   local magefile
1527    
1528   for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*)   # do not list the content of a directory, only the name (-d)
1529     for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*)
1530   do   do
1531     [[ -z ${magefile} ]] && continue
1532   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
1533   [ -d ${magefile} ] && continue   [[ -d ${magefile} ]] && continue
1534   if check_stable_package ${magefile}   if check_stable_package ${magefile}
1535   then   then
1536   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
# Line 1376  get_highest_magefile() Line 1575  get_highest_magefile()
1575  #        1 - error                                #  #        1 - error                                #
1576  #        2 - protected                            #  #        2 - protected                            #
1577  #        3 - protected but masked                 #  #        3 - protected but masked                 #
1578    #        4 - protected but ignored                #
1579  #                                                 #  #                                                 #
1580  ###################################################  ###################################################
1581  is_config_protected()  is_config_protected()
# Line 1384  is_config_protected() Line 1584  is_config_protected()
1584   local TEST   local TEST
1585   local PROTECTED   local PROTECTED
1586   local IFS   local IFS
1587     local i
1588     local x
1589    
1590   EXPFILE="${MROOT}$1"   EXPFILE="${MROOT}$1"
1591    
1592   # file does not exist; it can be written   # file does not exist; it can be written
1593   [ ! -e ${EXPFILE} ] && return 0   [[ ! -e ${EXPFILE} ]] && return 0
1594    
1595   # to be safe; it may be '§'   # to be safe; it may be '§'
1596   IFS=' '   IFS=' '
1597    
1598   # check ob in config protect   # check if config protected
1599   for i in ${CONFIG_PROTECT}   for i in ${CONFIG_PROTECT}
1600   do   do
1601   # ersetzen von $i nur wenn am anfang der variable   # only replace $i in the beginning of the variable
1602   TEST="${EXPFILE/#${MROOT}${i}/Protected}"   TEST="${EXPFILE/#${MROOT}${i}/Protected}"
1603   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1604   then   then
1605   # setzen das es protected ist   # file is config proteced
1606   PROTECTED=TRUE   PROTECTED=TRUE
1607    
1608   # check ob nicht doch maskiert   # check if not masked
1609   for x in ${CONFIG_PROTECT_MASK}   for x in ${CONFIG_PROTECT_MASK}
1610   do   do
1611   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"
1612   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1613   then   then
1614   PROTECTED=MASKED   PROTECTED=MASKED
1615   fi   fi
1616   done   done
1617    
1618     # check if not ignored
1619     for x in ${CONFIG_PROTECT_IGNORE}
1620     do
1621     TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}"
1622     if [[ ${TEST} != ${EXPFILE} ]]
1623     then
1624     PROTECTED=IGNORED
1625     fi
1626     done
1627   fi   fi
1628   done   done
1629    
# Line 1426  is_config_protected() Line 1638  is_config_protected()
1638   #echo "I'm protected, but masked - delete me"   #echo "I'm protected, but masked - delete me"
1639   return 3   return 3
1640   ;;   ;;
1641     IGNORED)
1642     #echo "I'm protected, but ignored - keep me, del update"
1643     return 4
1644     ;;
1645   *)   *)
1646   #echo "delete me"   #echo "delete me"
1647   return 0   return 0
# Line 1443  is_config_protected() Line 1659  is_config_protected()
1659  ###################################################  ###################################################
1660  count_protected_files()  count_protected_files()
1661  {  {
1662   ${MLIBDIR}/writeprotected "$1"   local file="$1"
1663     local dirname="${file%/*}"
1664     local filename="${file##*/}"
1665     local count
1666     local output
1667     local i
1668    
1669     declare -i count=0
1670    
1671     # check if there are already protected files
1672     for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" |
1673     sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
1674     sort -t'%' -k3 -k2 | cut -f1 -d'%')
1675     do
1676     count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::")
1677     done
1678     (( count ++ ))
1679    
1680     # fill output up with zeros
1681     for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
1682     output="${output}${count}"
1683    
1684     echo "${output}"
1685  }  }
1686    
1687  # call with  # call with
# Line 1460  get_uninstall_candidates() Line 1698  get_uninstall_candidates()
1698   local list   local list
1699   local pcatdir   local pcatdir
1700   local protected   local protected
1701     local i
1702    
1703   # very basic getops   # very basic getops
1704   for i in $*   for i in $*
# Line 1614  virtuals_add() Line 1853  virtuals_add()
1853    
1854  #deletes pakages from virtual database  #deletes pakages from virtual database
1855  #$1 virtualname; $2 pkgname  #$1 virtualname; $2 pkgname
1856  virtuals_del() {  virtuals_del()
1857    {
1858    
1859   local virtualname="$1"   local virtualname="$1"
1860   local pkgname="$2"   local pkgname="$2"
# Line 1721  minclude() Line 1961  minclude()
1961  {  {
1962   local i   local i
1963    
1964   if [ -n "$@" ]   if [[ -n $* ]]
1965   then   then
1966   for i in $@   for i in $*
1967   do   do
1968   [[ ${MAGEDEBUG} = on ]] && \   [[ ${MAGEDEBUG} = on ]] && \
1969   echo "--- Including ${MAGEDIR}/include/${i}.minc"   echo "--- Including ${MAGEDIR}/include/${i}.minc"
# Line 1737  sminclude() Line 1977  sminclude()
1977  {  {
1978   local i   local i
1979    
1980   if [ -n "$@" ]   if [[ -n $* ]]
1981   then   then
1982   for i in $@   for i in $*
1983   do   do
1984   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
1985   source ${SMAGESCRIPTSDIR}/include/${i}.sminc   source ${SMAGESCRIPTSDIR}/include/${i}.sminc
# Line 2048  get_value_from_magefile() Line 2288  get_value_from_magefile()
2288   local SDEPEND   local SDEPEND
2289   local PROVIDE   local PROVIDE
2290   local PKGTYPE   local PKGTYPE
2291     local MAGE_TARGETS
2292     local SPLIT_PACKAGE_BASE
2293   local preinstall   local preinstall
2294   local postinstall   local postinstall
2295   local preremove   local preremove
# Line 2094  mage_install() Line 2336  mage_install()
2336   local count_current   local count_current
2337   local magefile   local magefile
2338   local src_install   local src_install
2339     local i
2340    
2341   # very basic getops   # very basic getops
2342   for i in $*   for i in $*
# Line 2167  mage_install() Line 2410  mage_install()
2410   echo B:${pbuild}   echo B:${pbuild}
2411   fi   fi
2412    
2413   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2   if [[ -n ${MAGE_TARGETS} ]]
2414     then
2415     # basic svn compat
2416     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2417     then
2418     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2419     do
2420     smage2file="${i}"
2421     done
2422     else
2423     smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2424     fi
2425    
2426     elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2427     then
2428     # basic svn compat
2429     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2430     then
2431     for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2432     do
2433     smage2file="${i}"
2434     done
2435     else
2436     smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2437     fi
2438    
2439     else
2440     # basic svn compat
2441     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2442     then
2443     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2444     do
2445     smage2file="${i}"
2446     done
2447     else
2448     smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2
2449     fi
2450     fi
2451    
2452   if [ -f "${smage2file}" ]   if [ -f "${smage2file}" ]
2453   then   then
2454     echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "
2455   smage2 ${smage2file} || die "compile failed"   smage2 ${smage2file} || die "compile failed"
2456   else   else
2457   echo   echo
# Line 2183  mage_install() Line 2465  mage_install()
2465   if [[ ${PKGTYPE} != virtual ]] && \   if [[ ${PKGTYPE} != virtual ]] && \
2466   [[ ${PKGTYPE} != sources ]]   [[ ${PKGTYPE} != sources ]]
2467   then   then
2468   # show a verbose message on src-install   echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... "
  if [[ ${src_install} = true ]]  
  then  
  echo -ne "${COLBLUE} *** ${COLDEFAULT}"  
  echo -ne "merging files: "  
  echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"  
  echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"  
  fi  
2469   build_doinstall ${PKGNAME}   build_doinstall ${PKGNAME}
2470   fi   fi
2471    
# Line 2447  mage_uninstall() Line 2722  mage_uninstall()
2722   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"
2723   echo -n "removing: "   echo -n "removing: "
2724   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2725   echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"   echo -e "${COLRED}${pname}-${pver}-${pbuild}${COLDEFAULT}"
2726    
2727   magefile="${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"   magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
2728   source ${magefile}   source ${magefile}
2729    
2730   ## preremove scripts   ## preremove scripts
# Line 2517  mage_uninstall() Line 2792  mage_uninstall()
2792   unset -f postremove   unset -f postremove
2793  }  }
2794    
2795  show_etc_update_mesg() {  show_etc_update_mesg()
2796    {
2797   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0
2798    
2799   echo   echo
# Line 2547  pkgsearch() Line 2823  pkgsearch()
2823   local all_installed   local all_installed
2824   local ipver   local ipver
2825   local ipbuild   local ipbuild
2826     local latest_available
2827     local depsfull
2828     local sdepsfull
2829     local deps
2830     local sdeps
2831     local dep
2832     local sign
2833    
2834   # only names no versions   # only names no versions
2835   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')"
2836   #result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)"   #result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)"
2837    
2838   # nothing found   # nothing found
# Line 2564  pkgsearch() Line 2847  pkgsearch()
2847   # get highest version available   # get highest version available
2848   magefile=$(get_highest_magefile ${pcat} ${pname})   magefile=$(get_highest_magefile ${pcat} ${pname})
2849    
2850   # now get all needed infos to print a nice output   if [[ ! -z ${magefile} ]]
2851   pver="$(magename2pver ${magefile})"   then
2852   pbuild="$(magename2pbuild ${magefile})"   # now get all needed infos to print a nice output
2853   state="$(get_value_from_magefile STATE ${magefile})"   pver="$(magename2pver ${magefile})"
2854   description="$(get_value_from_magefile DESCRIPTION ${magefile})"   pbuild="$(magename2pbuild ${magefile})"
2855   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"   state="$(get_value_from_magefile STATE ${magefile})"
2856     description="$(get_value_from_magefile DESCRIPTION ${magefile})"
2857     homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
2858    
2859     # all installed
2860     for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
2861     do
2862     ipver="$(magename2pver ${i})"
2863     ipbuild="$(magename2pbuild ${i})"
2864    
2865     if [[ -z ${all_installed} ]]
2866     then
2867     all_installed="${ipver}-${ipbuild}"
2868     else
2869     all_installed="${all_installed} ${ipver}-${ipbuild}"
2870     fi
2871     done
2872     [[ -z ${all_installed} ]] && all_installed="none"
2873    
2874     case ${state} in
2875     stable) state=${COLGREEN}"[s] ";;
2876     testing) state=${COLYELLOW}"[t] ";;
2877     unstable) state=${COLRED}"[u] ";;
2878     old) state=${COLGRAY}"[o] ";;
2879     esac
2880    
2881   # all installed   latest_available="${pver}-${pbuild}"
2882   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})   else
2883   do   # package is masked
2884   ipver="$(magename2pver ${i})"   state="${COLRED}[m] "
2885   ipbuild="$(magename2pbuild ${i})"   latest_available="${COLRED}masked for this distribution.${COLDEFAULT}"
2886     fi
2887    
2888   if [[ -z ${all_installed} ]]   depsfull="$(get_value_from_magefile DEPEND ${magefile})"
2889   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"  
2890    
2891   case ${state} in   while read sign dep
2892   stable) state=${COLGREEN}"[s] ";;   do
2893   testing) state=${COLYELLOW}"[t] ";;   case ${dep} in
2894   unstable) state=${COLRED}"[u] ";;   "") continue;;
2895   old) state=${COLGRAY}"[o] ";;   esac
2896   esac  
2897     deps="${deps} $(basename ${dep%-*})"
2898     done << EOF
2899    ${depsfull}
2900    EOF
2901    
2902     while read sign dep
2903     do
2904     case ${dep} in
2905     "") continue;;
2906     esac
2907    
2908     sdeps="${sdeps} $(basename ${dep%-*})"
2909     done << EOF
2910    ${sdepsfull}
2911    EOF
2912    
2913   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}
2914   echo "      Latest available:   ${pver}-${pbuild}"   echo -e "      Latest available:   ${latest_available}"
2915   echo "      Installed versions: ${all_installed}"   echo "      Installed versions: ${all_installed}"
2916   echo "      Description: ${description}"   echo "      Description: ${description}"
2917   echo "      Homepage: ${homepage}"   echo "      Homepage: ${homepage}"
2918     echo "      Depends: ${deps}"
2919     echo "      SDepends: ${sdeps}"
2920   echo   echo
2921    
2922   unset pcat   unset pcat
# Line 2611  pkgsearch() Line 2930  pkgsearch()
2930   unset all_installed   unset all_installed
2931   unset ipver   unset ipver
2932   unset ipbuild   unset ipbuild
2933     unset depsfull
2934     unset sdepsfull
2935     unset deps
2936     unset sdeps
2937     unset dep
2938     unset sign
2939   done   done
2940  }  }
2941    
# Line 2653  blacklisted() Line 2978  blacklisted()
2978   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable   [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable
2979   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing   [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing
2980    
2981   local EXCLUDED="${MROOT}/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"   # support both types for the moment
2982     if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]]
2983     then
2984     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"
2985     else
2986     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}"
2987     fi
2988    
2989   # return 0 if the list not exist; nothin is masked   # return 0 if the list not exist; nothin is masked
2990   [[ ! -f ${EXCLUDED} ]] && return 0   [[ ! -f ${EXCLUDED} ]] && return 0

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