Magellan Linux

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

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

revision 226 by niro, Fri Sep 9 16:35:46 2005 UTC revision 942 by niro, Fri Nov 20 21:53:33 2009 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.1 2005-09-09 16:35:38 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 361  install_characterdevices() Line 374  install_characterdevices()
374   local pkgname="$1"   local pkgname="$1"
375   local pathto   local pathto
376   local posix   local posix
377     local major
378     local minor
379   local IFS   local IFS
380    
381   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 374  install_characterdevices() Line 389  install_characterdevices()
389   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
390   IFS=§   IFS=§
391    
392   while read pathto posix   while read pathto posix major minor
393   do   do
394   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
395   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"
396    
397   mknode -m ${posix} -c "${MROOT}${pathto}"   mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor}
398   done < ${BUILDDIR}/${pkgname}/.char   done < ${BUILDDIR}/${pkgname}/.char
399    
400   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
# Line 432  install_database_entry() Line 447  install_database_entry()
447   local magefile   local magefile
448   local dbrecorddir   local dbrecorddir
449   local provide   local provide
450     local i
451    
452   # very basic getops   # very basic getops
453   for i in $*   for i in $*
# Line 473  install_database_entry() Line 489  install_database_entry()
489    
490   # create fake file descriptors   # create fake file descriptors
491   # used by virtual and source packages   # used by virtual and source packages
  local i  
492   for i in .dirs .symlinks .files .pipes .char   for i in .dirs .symlinks .files .pipes .char
493   do   do
494   touch ${dbrecorddir}/${i}   touch ${dbrecorddir}/${i}
# Line 504  install_database_entry() Line 519  install_database_entry()
519   provide="$(get_value_from_magefile PROVIDE ${magefile})"   provide="$(get_value_from_magefile PROVIDE ${magefile})"
520   if [ -n "${provide}" ]   if [ -n "${provide}" ]
521   then   then
522   virtuals_add "${provide}" "${pcat}/${pname}"   for i in ${provide}
523     do
524     virtuals_add "${i}" "${pcat}/${pname}"
525     done
526   fi   fi
527  }  }
528    
# Line 523  remove_database_entry() Line 541  remove_database_entry()
541   local magefile   local magefile
542   local dbrecorddir   local dbrecorddir
543   local provide   local provide
544     local i
545    
546   # very basic getops   # very basic getops
547   for i in $*   for i in $*
# Line 552  remove_database_entry() Line 571  remove_database_entry()
571   # abort if mage file not exists   # abort if mage file not exists
572   [ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist."   [ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist."
573    
574   # first unregister virtuals   # remove virtuals only if no other exist
575   provide="$(get_value_from_magefile PROVIDE ${magefile})"   if [[ $(count_installed_pkgs --pcat ${pcat} --pname ${pname}) -le 1 ]]
  if [ -n "${provide}" ]  
576   then   then
577   virtuals_del "${provide}" "${pcat}/${pname}"   # first unregister virtuals
578     provide="$(get_value_from_magefile PROVIDE ${magefile})"
579     if [ -n "${provide}" ]
580     then
581     for i in ${provide}
582     do
583     virtuals_del "${i}" "${pcat}/${pname}"
584     done
585     fi
586   fi   fi
587    
588   # removes database entry   # removes database entry
# Line 566  remove_database_entry() Line 592  remove_database_entry()
592   fi   fi
593  }  }
594    
595    # get the number of installed packages
596    count_installed_pkgs()
597    {
598     local pcat
599     local pname
600     local pkg
601     local i
602    
603     # very basic getops
604     for i in $*
605     do
606     case $1 in
607     --pcat|-c) shift; pcat="$1" ;;
608     --pname|-n) shift; pname="$1" ;;
609     esac
610     shift
611     done
612    
613     # sanity checks; abort if not given
614     [ -z "${pcat}" ] && die "pkg_count() \$pcat not given."
615     [ -z "${pname}" ] && die "pkg_count() \$pname not given."
616    
617     declare -i i=0
618     for pkg in $(get_uninstall_candidates --pcat ${pcat} --pname ${pname})
619     do
620     (( i++ ))
621     #echo "$i ${pkg}"
622     done
623    
624     # return the value
625     echo "${i}"
626    }
627    
628    
629  ###################################################  ###################################################
630  # function compare_mtime                          #  # function compare_mtime                          #
# Line 744  remove_files() Line 803  remove_files()
803   do   do
804   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
805    
806   if [ -e "${MROOT}${pathto}" ]   if [ ! -e "${MROOT}${pathto}" ]
807   then   then
808   [[ ${VERBOSE} = on ]] && \   [[ ${VERBOSE} = on ]] && \
809   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"
# Line 758  remove_files() Line 817  remove_files()
817   # 1=keep me   #   # 1=keep me   #
818   case ${retval} in   case ${retval} in
819   0)   0)
820   [[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}"   # check if the file is config_protected
821   rm "${MROOT}${pathto}"   # ${MROOT} will automatically added if set !!
822   ;;   is_config_protected "${pathto}"
823     retval="$?"
824    
825     # 0 - not protected         #
826     # 1 - error                 #
827     # 2 - protected             #
828     # 3 - protected but masked  #
829     # 4 - protected but ignored #
830    
831     case ${retval} in
832     # file is not protected - delete it
833     0|3)
834     [[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}"
835     rm "${MROOT}${pathto}"
836     ;;
837    
838     # file is protected, do not delete
839     2)
840     if [[ ${VERBOSE} = on ]]
841     then
842     echo -en "${COLRED}"
843     echo -n "! prot "
844     echo -en "${COLDEFAULT}"
845     echo " === FILE: ${MROOT}${pathto}"
846     fi
847     ;;
848    
849     # file is protected but ignored, delete the update/do nothing
850     4)
851     if [[ ${VERBOSE} = on ]]
852     then
853     echo -en "${COLRED}"
854     echo -n "! ignr "
855     echo -en "${COLDEFAULT}"
856     echo " === FILE: ${MROOT}${pathto}"
857     fi
858     # simply do nothing here
859     ;;
860     esac
861     ;;
862   1)   1)
863   [[ ${VERBOSE} = on ]] && \   [[ ${VERBOSE} = on ]] && \
864   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"
# Line 932  remove_directories() Line 1029  remove_directories()
1029    
1030   [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.char ] && die "remove_directories() .dirs not found"   [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.char ] && die "remove_directories() .dirs not found"
1031    
  # uninstall of dirs ## added small hack to fix dirs  
  # must be reverse -> smage2 doesn't sort them  
  # -> using tac  
   
1032   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1033   IFS=§   IFS=§
1034    
1035   while read pathto posix   # reversed order is mandatory !
1036     tac ${MROOT}${INSTALLDB}/${pfull}/.dirs | while read pathto posix
1037   do   do
1038   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1039    
# Line 954  remove_directories() Line 1048  remove_directories()
1048   if [ -f "${MROOT}${pathto}/.keep" ]   if [ -f "${MROOT}${pathto}/.keep" ]
1049   then   then
1050   [[ ${VERBOSE} = on ]] && \   [[ ${VERBOSE} = on ]] && \
1051   echo -e "${COLRED}  .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1052   continue   continue
1053   fi   fi
1054    
# Line 971  remove_directories() Line 1065  remove_directories()
1065   [[ ${VERBOSE} = on ]] && \   [[ ${VERBOSE} = on ]] && \
1066   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1067   fi   fi
1068   done < ${MROOT}${INSTALLDB}/${pfull}/.dirs   done
1069    
1070   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
1071   IFS=$'\n'   IFS=$'\n'
# Line 1038  fetch_packages() Line 1132  fetch_packages()
1132   local count_current   local count_current
1133   local count_total   local count_total
1134    
1135   [ -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}."
1136    
1137   # get count of total packages   # get count of total packages
1138   declare -i count_current=0   declare -i count_current=0
# Line 1090  fetch_packages() Line 1184  fetch_packages()
1184   --continue \   --continue \
1185   --progress bar \   --progress bar \
1186   --directory-prefix=${PKGDIR} \   --directory-prefix=${PKGDIR} \
1187   ${opt} ${mirr}/packages/${pkg}   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}
1188   if [[ $? = 0 ]]   if [[ $? = 0 ]]
1189   then   then
1190   break   break
# Line 1113  syncmage() Line 1207  syncmage()
1207  {  {
1208   if [ -z "${RSYNC}" ]   if [ -z "${RSYNC}" ]
1209   then   then
1210   die "You have no rsync-mirrors defined. Please edit your /etc/mage.rc."   die "You have no rsync-mirrors defined. Please edit your ${MAGERC}."
1211   fi   fi
1212    
1213   local i   local i
1214   for i in ${RSYNC}   for i in ${RSYNC}
1215   do   do
1216   rsync \   rsync ${RSYNC_FETCH_OPTIONS} ${i} ${MAGEDIR}
  --recursive \  
  --links \  
  --perms \  
  --times \  
  --devices \  
  --timeout=600 \  
  --verbose \  
  --compress \  
  --progress \  
  --stats \  
  --delete \  
  --delete-after \  
  ${i} ${MAGEDIR}  
1217   if [[ $? = 0 ]]   if [[ $? = 0 ]]
1218   then   then
1219   break   break
# Line 1148  syncmage() Line 1229  syncmage()
1229   is_newer_mage_version_available   is_newer_mage_version_available
1230  }  }
1231    
1232    syncmage_tarball()
1233    {
1234     local latest_tarball
1235     local temp="$(mktemp -d)"
1236     local mirr mymirr
1237    
1238     # try to get the tarball marked as latest on the server
1239     latest_tarball="mage-latest.tar.bz2"
1240    
1241     for mirr in ${MIRRORS}
1242     do
1243     # path without distribution
1244     mymirr="${mirr%/*}"
1245    
1246     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1247     echo "fetching latest tarball from ${mymirr} ..."
1248    
1249     wget \
1250     --passive-ftp \
1251     --tries 3 \
1252     --continue \
1253     --progress bar \
1254     --directory-prefix=${temp} \
1255     ${mymirr}/rsync/tarballs/${latest_tarball}
1256     if [[ $? = 0 ]]
1257     then
1258     break
1259     else
1260     continue
1261     fi
1262     done
1263    
1264     if [[ -f ${temp}/${latest_tarball} ]]
1265     then
1266     if [[ -d ${MAGEDIR} ]]
1267     then
1268     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1269     echo "cleaning old mage-tree ${MAGEDIR}..."
1270     rm -rf ${MAGEDIR}
1271     fi
1272    
1273     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1274     echo "updating mage-tree from tarball ..."
1275     # unpack in dirname of MAGEDIR, as the tarball has already the mage
1276     tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1277    
1278     if [[ -d ${temp} ]]
1279     then
1280     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1281     echo "clenaing temp-files ..."
1282     rm -rf ${temp}
1283     fi
1284     else
1285     die "Could not fetch the latest tarball ... aborting"
1286     fi
1287    }
1288    
1289  cleanpkg()  cleanpkg()
1290  {  {
1291   if [ -d "${PKGDIR}" ]   if [ -d "${PKGDIR}" ]
# Line 1185  choppkgname() Line 1323  choppkgname()
1323   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]
1324   then   then
1325   #cuts ARCH and PBUILD   #cuts ARCH and PBUILD
1326   #ARCH comes from /etc/mage.rc   #ARCH comes from ${MAGERC}
1327   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")
1328    
1329   #cuts version number   #cuts version number
# Line 1218  pname2pcat() Line 1356  pname2pcat()
1356  # returns 0=stable 1=unstable  # returns 0=stable 1=unstable
1357  check_stable_package()  check_stable_package()
1358  {  {
1359     # first check if this magefile is not blacklisted
1360     blacklisted "$1" || return 1
1361    
1362   local STATE   local STATE
1363   STATE="$(get_value_from_magefile STATE "$1")"   STATE="$(get_value_from_magefile STATE "$1")"
1364    
1365   # state testing   # state testing
1366   if [[ ${USE_TESTING} = true ]]   if [[ ${USE_TESTING} = true ]] || [[ ${MAGE_DISTRIBUTION} = testing ]]
1367   then   then
1368   case ${STATE} in   case ${STATE} in
1369   testing|stable) return 0 ;;   testing|stable) return 0 ;;
# Line 1231  check_stable_package() Line 1372  check_stable_package()
1372   fi   fi
1373    
1374   # state unstable   # state unstable
1375   if [[ ${USE_UNSTABLE} = true ]]   if [[ ${USE_UNSTABLE} = true ]] || [[ ${MAGE_DISTRIBUTION} = unstable ]]
1376   then   then
1377   case ${STATE} in   case ${STATE} in
1378   unstable|testing|stable) return 0 ;;   unstable|testing|stable) return 0 ;;
# Line 1257  get_highest_magefile() Line 1398  get_highest_magefile()
1398   local PNAME="$2"   local PNAME="$2"
1399   local magefile   local magefile
1400    
1401   for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*)   # do not list the content of a directory, only the name (-d)
1402     for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*)
1403   do   do
1404     [[ -z ${magefile} ]] && continue
1405   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
1406   [ -d ${magefile} ] && continue   [[ -d ${magefile} ]] && continue
1407   if check_stable_package ${magefile}   if check_stable_package ${magefile}
1408   then   then
1409   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
# Line 1269  get_highest_magefile() Line 1412  get_highest_magefile()
1412   fi   fi
1413   done   done
1414    
1415   # stop here if HIGHEST_MAGEFILE is zero  # do not so anything
1416   # this package must be unstable or old  # # stop here if HIGHEST_MAGEFILE is zero
1417   if [ -z "${HIGHEST_MAGEFILE}" ]  # # this package must be unstable or old
1418   then  # if [ -z "${HIGHEST_MAGEFILE}" ]
1419   echo  # then
1420   echo -n "All packages named "  # echo
1421   echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT}  # echo -n "All packages named "
1422   echo -n " are marked "  # echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT}
1423   echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT}  # echo -n " are marked "
1424   echo "."  # echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT}
1425   echo "You need to declare USE_UNSTABLE=true to install this."  # echo "."
1426   echo  # echo "You need to declare USE_UNSTABLE=true to install this."
1427   echo "Example:"  # echo
1428   echo "         USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}"  # echo "Example:"
1429   echo  # echo "         USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}"
1430   echo "Be warned that these packages are not stable and may cause serious problems."  # echo
1431   echo "You should know what you are doing, so don't complain about any damage."  # echo "Be warned that these packages are not stable and may cause serious problems."
1432   echo  # echo "You should know what you are doing, so don't complain about any damage."
1433   return 1  # echo
1434   fi  # return 1
1435    # fi
1436    
1437   echo "${HIGHEST_MAGEFILE}"   echo "${HIGHEST_MAGEFILE}"
1438   return 0   return 0
# Line 1304  get_highest_magefile() Line 1448  get_highest_magefile()
1448  #        1 - error                                #  #        1 - error                                #
1449  #        2 - protected                            #  #        2 - protected                            #
1450  #        3 - protected but masked                 #  #        3 - protected but masked                 #
1451    #        4 - protected but ignored                #
1452  #                                                 #  #                                                 #
1453  ###################################################  ###################################################
1454  is_config_protected()  is_config_protected()
# Line 1312  is_config_protected() Line 1457  is_config_protected()
1457   local TEST   local TEST
1458   local PROTECTED   local PROTECTED
1459   local IFS   local IFS
1460     local i
1461     local x
1462    
1463   EXPFILE="${MROOT}$1"   EXPFILE="${MROOT}$1"
1464    
1465   # file does not exist; it can be written   # file does not exist; it can be written
1466   [ ! -e ${EXPFILE} ] && return 0   [[ ! -e ${EXPFILE} ]] && return 0
1467    
1468   # to be safe; it may be '§'   # to be safe; it may be '§'
1469   IFS=' '   IFS=' '
1470    
1471   # check ob in config protect   # check if config protected
1472   for i in ${CONFIG_PROTECT}   for i in ${CONFIG_PROTECT}
1473   do   do
1474   # ersetzen von $i nur wenn am anfang der variable   # only replace $i in the beginning of the variable
1475   TEST="${EXPFILE/#${MROOT}${i}/Protected}"   TEST="${EXPFILE/#${MROOT}${i}/Protected}"
1476   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1477   then   then
1478   # setzen das es protected ist   # file is config proteced
1479   PROTECTED=TRUE   PROTECTED=TRUE
1480    
1481   # check ob nicht doch maskiert   # check if not masked
1482   for x in ${CONFIG_PROTECT_MASK}   for x in ${CONFIG_PROTECT_MASK}
1483   do   do
1484   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"
1485   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1486   then   then
1487   PROTECTED=MASKED   PROTECTED=MASKED
1488   fi   fi
1489   done   done
1490    
1491     # check if not ignored
1492     for x in ${CONFIG_PROTECT_IGNORE}
1493     do
1494     TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}"
1495     if [[ ${TEST} != ${EXPFILE} ]]
1496     then
1497     PROTECTED=IGNORED
1498     fi
1499     done
1500   fi   fi
1501   done   done
1502    
# Line 1354  is_config_protected() Line 1511  is_config_protected()
1511   #echo "I'm protected, but masked - delete me"   #echo "I'm protected, but masked - delete me"
1512   return 3   return 3
1513   ;;   ;;
1514     IGNORED)
1515     #echo "I'm protected, but ignored - keep me, del update"
1516     return 4
1517     ;;
1518   *)   *)
1519   #echo "delete me"   #echo "delete me"
1520   return 0   return 0
# Line 1371  is_config_protected() Line 1532  is_config_protected()
1532  ###################################################  ###################################################
1533  count_protected_files()  count_protected_files()
1534  {  {
1535   ${MLIBDIR}/writeprotected "$1"   local file="$1"
1536     local dirname="${file%/*}"
1537     local filename="${file##*/}"
1538     local count
1539     local output
1540     local i
1541    
1542     declare -i count=0
1543    
1544     # check if there are already protected files
1545     for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" |
1546     sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
1547     sort -t'%' -k3 -k2 | cut -f1 -d'%')
1548     do
1549     count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::")
1550     done
1551     (( count ++ ))
1552    
1553     # fill output up with zeros
1554     for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
1555     output="${output}${count}"
1556    
1557     echo "${output}"
1558  }  }
1559    
1560  # call with  # call with
# Line 1388  get_uninstall_candidates() Line 1571  get_uninstall_candidates()
1571   local list   local list
1572   local pcatdir   local pcatdir
1573   local protected   local protected
1574     local i
1575    
1576   # very basic getops   # very basic getops
1577   for i in $*   for i in $*
# Line 1400  get_uninstall_candidates() Line 1584  get_uninstall_candidates()
1584   shift   shift
1585   done   done
1586    
1587   # sanity checks; abort if not given  # it's not good to complain here about empty pnames; better to continue later anyway
1588   [ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given."  # # sanity checks; abort if not given
1589    # [ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given."
1590    
1591    
1592   # check needed global vars   # check needed global vars
1593   [ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set."   [ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set."
1594    
1595   # set pcatdir to '*' if empty   # set pcatdir to '*' if empty
1596   [ -z "${pcatdir}" ] && pcatdir=*   [ -z "${pcatdir}" ] && pcatdir='*'
1597    
1598   for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/*   for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/*
1599   do   do
# Line 1493  virtuals_add() Line 1678  virtuals_add()
1678   local oldline   local oldline
1679   local line i   local line i
1680   local installed_file   local installed_file
1681     local OLDIFS
1682    
1683   if virtuals_read ${virtualname}   if virtuals_read ${virtualname}
1684   then   then
1685   # make shure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already   # make sure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already
1686   for i in $(virtuals_read ${virtualname} showpkgs)   for i in $(virtuals_read ${virtualname} showpkgs)
1687   do   do
1688   if [[ ${i} = ${pkgname} ]]   if [[ ${i} = ${pkgname} ]]
# Line 1515  virtuals_add() Line 1701  virtuals_add()
1701   # make a backup   # make a backup
1702   mv ${MROOT}${VIRTUALDB_FILE} ${MROOT}${VIRTUALDB_FILE}.old   mv ${MROOT}${VIRTUALDB_FILE} ${MROOT}${VIRTUALDB_FILE}.old
1703    
1704     OLDIFS="${IFS}"
1705   IFS=$'\n'   IFS=$'\n'
1706   for line in $(< ${MROOT}${VIRTUALDB_FILE}.old)   for line in $(< ${MROOT}${VIRTUALDB_FILE}.old)
1707   do   do
# Line 1526  virtuals_add() Line 1713  virtuals_add()
1713   echo "${line}" >> ${MROOT}${VIRTUALDB_FILE}   echo "${line}" >> ${MROOT}${VIRTUALDB_FILE}
1714   fi   fi
1715   done   done
1716     # unset IFS
1717   #unset IFS   IFS="${OLDIFS}"
1718   else   else
1719   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} >>> ${COLDEFAULT}"
1720   echo "register ${pkgname} as ${virtualname} ..."   echo "register ${pkgname} as ${virtualname} ..."
1721   echo "${virtualname} ${pkgname}" >> ${MROOT}${VIRTUALDB_FILE}   echo "${virtualname} ${pkgname}" >> ${MROOT}${VIRTUALDB_FILE}
1722   fi   fi
# Line 1541  virtuals_add() Line 1728  virtuals_add()
1728  #$1 virtualname; $2 pkgname  #$1 virtualname; $2 pkgname
1729  virtuals_del() {  virtuals_del() {
1730    
1731   local VIRTUAL_NAME PKG_NAME OLD_LINE METHOD line i x PKG_INSTALLED   local virtualname="$1"
1732     local pkgname="$2"
1733   VIRTUAL_NAME=$1   local oldline
1734   PKG_NAME=$2   local method
1735     local line i x
1736   #first check if exists   local pkg_installed
1737   if virtuals_read ${VIRTUAL_NAME}   local OLDIFS
1738    
1739     # first check if exists
1740     if virtuals_read ${virtualname}
1741   then   then
1742   #get method -> delall or update and check if ${PKG_NAME} exists in ${VIRTUAL_NAME}   # get method -> delall or update and check if ${PKG_NAME} exists in ${VIRTUAL_NAME}
1743   declare -i x=0   declare -i x=0
1744   for i in $(virtuals_read ${VIRTUAL_NAME} showpkgs)   for i in $(virtuals_read ${virtualname} showpkgs)
1745   do   do
1746   if [ "${i}" == "${PKG_NAME}" ]   if [[ ${i} = ${pkgname} ]]
1747   then   then
1748   PKG_INSTALLED=true   pkg_installed=true
1749   fi   fi
1750   ((x++))   ((x++))
1751   done   done
1752    
1753   #abort if not installed   # abort if not installed
1754   if [ "${PKG_INSTALLED}" != "true" ]   if [[ ${pkg_installed} != true ]]
1755   then   then
1756   echo "!!!! ${PKG_NAME} does not exists in ${VIRTUAL_NAME}."   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1757     echo "${pkgname} does not exists in ${virtualname}."
1758   return 0   return 0
1759   fi   fi
1760    
1761   if [ ${x} -ge 2 ]   if [ ${x} -ge 2 ]
1762   then   then
1763   METHOD=update   method=update
1764   else   else
1765   METHOD=delall   method=delall
1766   fi   fi
1767    
1768   #get the complete line   # get the complete line
1769   OLD_LINE="$(virtuals_read ${VIRTUAL_NAME} showline)"   oldline="$(virtuals_read ${virtualname} showline)"
1770    
1771   #make a backup   # make a backup of the db
1772   mv ${VIRTUALDB_FILE} ${VIRTUALDB_FILE}.old   mv ${VIRTUALDB_FILE} ${VIRTUALDB_FILE}.old
1773    
1774   #parse virtualdb   # parse virtualdb
1775     OLDIFS="${IFS}"
1776   IFS=$'\n'   IFS=$'\n'
1777   for line in $(< ${VIRTUALDB_FILE}.old)   for line in $(< ${VIRTUALDB_FILE}.old)
1778   do   do
1779   if [ "${line}" == "${OLD_LINE}" ]   if [[ ${line} = ${oldline} ]]
1780   then   then
1781   #delall or update?   #delall or update?
1782   case ${METHOD} in   case ${method} in
1783   update)   update)
1784   echo "<<<< Unlinking ${PKG_NAME} from ${VIRTUAL_NAME} in virtual database ..."   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
1785   #del PKG_NAME from line   echo "Unlinking ${pkgname} from ${virtualname} in virtual database ..."
1786   echo "${line/ ${PKG_NAME}/}" >> ${VIRTUALDB_FILE}   # del PKG_NAME from line
1787     echo "${line/ ${pkgname}/}" >> ${VIRTUALDB_FILE}
1788   ;;   ;;
1789   delall)   delall)
1790   echo "<<<< Deleting ${VIRTUAL_NAME} in virtual database ..."   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"
1791   #continue; do not write anything   echo "Deleting ${virtualname} in virtual database ..."
1792     # continue; do not write anything
1793   continue   continue
1794   ;;   ;;
1795   esac   esac
# Line 1603  virtuals_del() { Line 1797  virtuals_del() {
1797   echo "${line}" >> ${VIRTUALDB_FILE}   echo "${line}" >> ${VIRTUALDB_FILE}
1798   fi   fi
1799   done   done
1800   unset IFS   # unset IFS
1801     IFS="${OLDIFS}"
1802   else   else
1803   echo "!!!! ${VIRTUAL_NAME} does not exists in virtual database."   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1804     echo "${virtualname} does not exists in virtual database."
1805   fi   fi
1806  }  }
1807    
# Line 1637  minclude() Line 1833  minclude()
1833  {  {
1834   local i   local i
1835    
1836   if [ -n "$@" ]   if [[ -n $* ]]
1837   then   then
1838   for i in $@   for i in $*
1839   do   do
1840   [[ ${MAGEDEBUG} = on ]] && \   [[ ${MAGEDEBUG} = on ]] && \
1841   echo "--- Including ${MAGEDIR}/include/${i}.minc"   echo "--- Including ${MAGEDIR}/include/${i}.minc"
# Line 1653  sminclude() Line 1849  sminclude()
1849  {  {
1850   local i   local i
1851    
1852   if [ -n "$@" ]   if [[ -n $* ]]
1853   then   then
1854   for i in $@   for i in $*
1855   do   do
1856   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
1857   source ${SMAGESCRIPTSDIR}/include/${i}.sminc   source ${SMAGESCRIPTSDIR}/include/${i}.sminc
# Line 1670  is_newer_mage_version_available() Line 1866  is_newer_mage_version_available()
1866   local newest_mage   local newest_mage
1867   local installed_mage   local installed_mage
1868    
1869   newest_mage="$( CATEGORIE=app-mage MAGENAME=mage get_highest_magefile;echo $(basename ${MAGEFILE} .mage) )"   newest_mage="$(basename $(get_highest_magefile app-mage mage) .mage)"
1870   installed_mage="$(magequery -n mage | cut -d' ' -f5)"   installed_mage="$(magequery -n mage | cut -d' ' -f5)"
1871    
1872   if [[ ${newest_mage} > ${installed_mage} ]]   if [[ ${newest_mage} > ${installed_mage} ]]
# Line 1679  is_newer_mage_version_available() Line 1875  is_newer_mage_version_available()
1875   echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT}   echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT}
1876   echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT}   echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT}
1877   echo "It is recommened to install this newer version"   echo "It is recommened to install this newer version"
1878   echo "or your current system installation may brake."   echo "or your current system installation may break."
1879   echo   echo
1880   echo -en "Please update mage by running "   echo -en "Please update mage by running "
1881   echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT}   echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT}
# Line 1951  get_value_from_magefile() Line 2147  get_value_from_magefile()
2147   local magefile="$2"   local magefile="$2"
2148   local value   local value
2149    
2150     [[ -z ${var} ]] && return 1
2151     [[ -z ${magefile} ]] && return 1
2152    
2153   # local all possible vars of a mage file   # local all possible vars of a mage file
2154   # to prevent bad issues   # to prevent bad issues
2155   local PKGNAME   local PKGNAME
# Line 1963  get_value_from_magefile() Line 2162  get_value_from_magefile()
2162   local PKGTYPE   local PKGTYPE
2163   local preinstall   local preinstall
2164   local postinstall   local postinstall
2165     local preremove
2166     local postremove
2167    
2168   # sanity checks   # sanity checks
2169   [ -f ${magefile} ] && source ${magefile} || \   [ -f ${magefile} ] && source ${magefile} || \
# Line 1972  get_value_from_magefile() Line 2173  get_value_from_magefile()
2173   source ${magefile}   source ${magefile}
2174   eval value=\$$(echo ${var})   eval value=\$$(echo ${var})
2175   echo "${value}"   echo "${value}"
2176    
2177     # unset these functions
2178     unset -f preinstall
2179     unset -f postinstall
2180     unset -f preremove
2181     unset -f postremove
2182  }  }
2183    
2184  mage_install()  mage_install()
# Line 1988  mage_install() Line 2195  mage_install()
2195   local PKGTYPE   local PKGTYPE
2196   local preinstall   local preinstall
2197   local postinstall   local postinstall
2198     local preremove
2199     local postremove
2200    
2201   local pcat   local pcat
2202   local pname   local pname
# Line 1997  mage_install() Line 2206  mage_install()
2206   local count_current   local count_current
2207   local magefile   local magefile
2208   local src_install   local src_install
2209     local i
2210    
2211   # very basic getops   # very basic getops
2212   for i in $*   for i in $*
# Line 2070  mage_install() Line 2280  mage_install()
2280   echo B:${pbuild}   echo B:${pbuild}
2281   fi   fi
2282    
2283   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2   if [[ -z ${MAGE_TARGETS} ]]
2284     then
2285     # basic svn compat
2286     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2287     then
2288     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2289     do
2290     smage2file="${i}"
2291     done
2292     else
2293     smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2
2294     fi
2295     else
2296     # basic svn compat
2297     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2298     then
2299     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2300     do
2301     smage2file="${i}"
2302     done
2303     else
2304     smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2305     fi
2306     fi
2307   if [ -f "${smage2file}" ]   if [ -f "${smage2file}" ]
2308   then   then
2309     echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "
2310   smage2 ${smage2file} || die "compile failed"   smage2 ${smage2file} || die "compile failed"
2311   else   else
2312   echo   echo
# Line 2086  mage_install() Line 2320  mage_install()
2320   if [[ ${PKGTYPE} != virtual ]] && \   if [[ ${PKGTYPE} != virtual ]] && \
2321   [[ ${PKGTYPE} != sources ]]   [[ ${PKGTYPE} != sources ]]
2322   then   then
2323   # 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  
2324   build_doinstall ${PKGNAME}   build_doinstall ${PKGNAME}
2325   fi   fi
2326    
# Line 2149  mage_install() Line 2376  mage_install()
2376  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2377  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "
2378   echo "successfully installed."   echo "successfully installed."
2379    
2380     # unset these functions
2381     unset -f preinstall
2382     unset -f postinstall
2383     unset -f preremove
2384     unset -f postremove
2385  }  }
2386    
2387  md5sum_packages()  md5sum_packages()
# Line 2253  uninstall_packages() Line 2486  uninstall_packages()
2486   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2487   echo "following candidate(s) will be removed:"   echo "following candidate(s) will be removed:"
2488   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2489   echo -ne "\033[1m${can_pcat}/${can_pname}:${COLDEFAULT}"   echo -ne "${COLBOLD}${can_pcat}/${can_pname}:${COLDEFAULT}"
2490   echo -e "${COLRED} ${can_ver_list} ${COLDEFAULT}"   echo -e "${COLRED} ${can_ver_list} ${COLDEFAULT}"
2491   echo   echo
2492   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   if [ ${MAGE_UNINSTALL_TIMEOUT} -gt 0 ]
2493   echo "( Press [CTRL+C] to abort )"   then
2494   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2495   echo -n "Waiting ${MAGE_UNINSTALL_TIMEOUT} seconds ..."   echo "( Press [CTRL+C] to abort )"
2496   for ((i=MAGE_UNINSTALL_TIMEOUT; i >= 0; i--))   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2497   do   echo -n "Waiting ${MAGE_UNINSTALL_TIMEOUT} seconds ..."
2498   echo -ne "${COLRED} ${i}${COLDEFAULT}"   for ((i=MAGE_UNINSTALL_TIMEOUT; i >= 0; i--))
2499   sleep 1   do
2500   done   echo -ne "${COLRED} ${i}${COLDEFAULT}"
2501   echo   sleep 1
2502   echo   done
2503     echo
2504     echo
2505     fi
2506    
2507   for pkg in ${list}   for pkg in ${list}
2508   do   do
# Line 2304  mage_uninstall() Line 2540  mage_uninstall()
2540   local PKGTYPE   local PKGTYPE
2541   local preinstall   local preinstall
2542   local postinstall   local postinstall
2543     local preremove
2544     local postremove
2545    
2546   local pcat   local pcat
2547   local pname   local pname
# Line 2339  mage_uninstall() Line 2577  mage_uninstall()
2577   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"
2578   echo -n "removing: "   echo -n "removing: "
2579   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2580   echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"   echo -e "${COLRED}${pname}-${pver}-${pbuild}${COLDEFAULT}"
2581    
2582   magefile="${MAGEDIR}/${pcat}/${pname}/${pname}-${pver}-${pbuild}.mage"   magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
2583   source ${magefile}   source ${magefile}
2584    
2585   ## preremove scripts   ## preremove scripts
# Line 2401  mage_uninstall() Line 2639  mage_uninstall()
2639  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2640  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "
2641   echo "successfully removed."   echo "successfully removed."
2642    
2643     # unset these functions
2644     unset -f preinstall
2645     unset -f postinstall
2646     unset -f preremove
2647     unset -f postremove
2648  }  }
2649    
2650  show_etc_update_mesg() {  show_etc_update_mesg() {
# Line 2415  show_etc_update_mesg() { Line 2659  show_etc_update_mesg() {
2659   echo "Please run 'etc-update' to update your configuration files."   echo "Please run 'etc-update' to update your configuration files."
2660   echo   echo
2661  }  }
2662    
2663    pkgsearch()
2664    {
2665     local string="$1"
2666     local result
2667     local pkg
2668     local pcat
2669     local pname
2670     local magefile
2671     local pver
2672     local pbuild
2673     local state
2674     local descriptiom
2675     local homepage
2676     local i
2677     local all_installed
2678     local ipver
2679     local ipbuild
2680     local latest_available
2681     local depsfull
2682     local sdepsfull
2683     local deps
2684     local sdeps
2685     local dep
2686     local sign
2687    
2688     # only names no versions
2689     result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name '*'${string}'*'| sed '/profiles/d' | sed '/includes/d')"
2690     #result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)"
2691    
2692     # nothing found
2693     [[ -z ${result} ]] && die "No package found containing '${string}' in the name."
2694    
2695     for pkg in ${result}
2696     do
2697     # dirty, but does the job
2698     pcat="$(magename2pcat ${pkg}/foo)"
2699     pname="$(magename2pname ${pkg}-foo-foo)"
2700    
2701     # get highest version available
2702     magefile=$(get_highest_magefile ${pcat} ${pname})
2703    
2704     if [[ ! -z ${magefile} ]]
2705     then
2706     # now get all needed infos to print a nice output
2707     pver="$(magename2pver ${magefile})"
2708     pbuild="$(magename2pbuild ${magefile})"
2709     state="$(get_value_from_magefile STATE ${magefile})"
2710     description="$(get_value_from_magefile DESCRIPTION ${magefile})"
2711     homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
2712    
2713     # all installed
2714     for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
2715     do
2716     ipver="$(magename2pver ${i})"
2717     ipbuild="$(magename2pbuild ${i})"
2718    
2719     if [[ -z ${all_installed} ]]
2720     then
2721     all_installed="${ipver}-${ipbuild}"
2722     else
2723     all_installed="${all_installed} ${ipver}-${ipbuild}"
2724     fi
2725     done
2726     [[ -z ${all_installed} ]] && all_installed="none"
2727    
2728     case ${state} in
2729     stable) state=${COLGREEN}"[s] ";;
2730     testing) state=${COLYELLOW}"[t] ";;
2731     unstable) state=${COLRED}"[u] ";;
2732     old) state=${COLGRAY}"[o] ";;
2733     esac
2734    
2735     latest_available="${pver}-${pbuild}"
2736     else
2737     # package is masked
2738     state="${COLRED}[m] "
2739     latest_available="${COLRED}masked for this distribution.${COLDEFAULT}"
2740     fi
2741    
2742     depsfull="$(get_value_from_magefile DEPEND ${magefile})"
2743     sdepsfull="$(get_value_from_magefile SDEPEND ${magefile})"
2744    
2745     while read sign dep
2746     do
2747     case ${dep} in
2748     "") continue;;
2749     esac
2750    
2751     deps="${deps} $(basename ${dep%-*})"
2752     done << EOF
2753    ${depsfull}
2754    EOF
2755    
2756     while read sign dep
2757     do
2758     case ${dep} in
2759     "") continue;;
2760     esac
2761    
2762     sdeps="${sdeps} $(basename ${dep%-*})"
2763     done << EOF
2764    ${sdepsfull}
2765    EOF
2766    
2767     echo -e "${state}${pcat}/${pname}"${COLDEFAULT}
2768     echo -e "      Latest available:   ${latest_available}"
2769     echo "      Installed versions: ${all_installed}"
2770     echo "      Description: ${description}"
2771     echo "      Homepage: ${homepage}"
2772     echo "      Depends: ${deps}"
2773     echo "      SDepends: ${sdeps}"
2774     echo
2775    
2776     unset pcat
2777     unset pname
2778     unset magefile
2779     unset pver
2780     unset pbuild
2781     unset state
2782     unset descriptiom
2783     unset homepage
2784     unset all_installed
2785     unset ipver
2786     unset ipbuild
2787     unset depsfull
2788     unset sdepsfull
2789     unset deps
2790     unset sdeps
2791     unset dep
2792     unset sign
2793     done
2794    }
2795    
2796    export_inherits()
2797    {
2798     local include="$1"
2799     shift
2800    
2801     while [ "$1" ]
2802     do
2803     local functions="$1"
2804    
2805     # sanity checks
2806     [ -z "${include}" ] && die "export_inherits(): \$include not given."
2807     [ -z "${functions}" ] && die "export_inherits(): \$functions not given."
2808    
2809     eval "${functions}() { ${include}_${functions} ; }"
2810    
2811     # debug
2812     [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"
2813    
2814     shift
2815     done
2816    }
2817    
2818    mlibdir()
2819    {
2820     local libdir=lib
2821     [[ ${ARCH} = x86_64 ]] && libdir=lib64
2822    
2823     echo "${libdir}"
2824    }
2825    
2826    ## blacklisted ${magefile}
2827    blacklisted()
2828    {
2829     [[ -z ${MAGE_DISTRIBUTION} ]] && local MAGE_DISTRIBUTION=stable
2830    
2831     # compat
2832     [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable
2833     [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing
2834    
2835     # support both types for the moment
2836     if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]]
2837     then
2838     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"
2839     else
2840     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}"
2841     fi
2842    
2843     # return 0 if the list not exist; nothin is masked
2844     [[ ! -f ${EXCLUDED} ]] && return 0
2845    
2846     local MAGEFILE="$1"
2847    
2848     local PCAT="$(magename2pcat ${MAGEFILE})"
2849     local PNAME="$(magename2pname ${MAGEFILE})"
2850     local PVER="$(magename2pver ${MAGEFILE})"
2851     local PBUILD="$(magename2pbuild ${MAGEFILE})"
2852    
2853     local EXPCAT EXPNAME EXPVER EXPBUILD
2854     while read EXPCAT EXPNAME EXPVER EXPBUILD
2855     do
2856     # ignore spaces and comments
2857             case "${EXPCAT}" in
2858                     \#*|"") continue ;;
2859             esac
2860    
2861     # exclude full pver
2862     if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] &&
2863     [[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] &&
2864     [[ -n ${PVER} ]] && [[ -n ${PBUILD} ]] &&
2865     [[ -n ${EXPVER} ]] && [[ -n ${EXPBUILD} ]]
2866     then
2867     [[ ${EXPCAT}/${EXPNAME}-${EXPVER}-${EXPBUILD} = ${PCAT}/${PNAME}-${PVER}-${PBUILD} ]] && return 1
2868     fi
2869    
2870     # exclude pcat/pname only
2871     if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] &&
2872     [[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] &&
2873     [[ -z ${EXPVER} ]] && [[ -z ${EXPBUILD} ]]
2874     then
2875     [[ ${EXPCAT}/${EXPNAME} = ${PCAT}/${PNAME} ]] && return 1
2876     fi
2877     done << EOF
2878    $( cat ${EXCLUDED}; echo)
2879    EOF
2880    
2881     return 0
2882    }
2883    

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