Magellan Linux

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

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

revision 249 by niro, Sun Oct 2 12:20:13 2005 UTC revision 1084 by niro, Mon Jun 28 18:08:15 2010 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.5 2005-10-02 12:20:13 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 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 1035  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 1087  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 1110  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 1141  syncmage() Line 1225  syncmage()
1225   # clean up backup files (foo~)   # clean up backup files (foo~)
1226   find ${MAGEDIR} -name *~ -exec rm '{}' ';'   find ${MAGEDIR} -name *~ -exec rm '{}' ';'
1227    
1228   # check if an newer mage version is available   # check if a newer mage version is available
1229   is_newer_mage_version_available   is_newer_mage_version_available
1230  }  }
1231    
1232    syncmage_tarball()
1233    {
1234     local latest_tarball
1235     local latest_md5
1236     local temp="$(mktemp -d)"
1237     local mirr mymirr
1238    
1239     # try to get the md5 marked as latest on the server
1240     latest_md5="mage-latest.md5"
1241    
1242     # try to get the tarball marked as latest on the server
1243     latest_tarball="mage-latest.tar.bz2"
1244    
1245     for mirr in ${MIRRORS}
1246     do
1247     # path without distribution
1248     mymirr="${mirr%/*}"
1249    
1250     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1251     echo "fetching latest md5 from ${mymirr} ..."
1252     wget \
1253     --passive-ftp \
1254     --tries 3 \
1255     --continue \
1256     --progress bar \
1257     --directory-prefix=${temp} \
1258     ${mymirr}/rsync/tarballs/${latest_md5}
1259    
1260     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1261     echo "fetching latest tarball from ${mymirr} ..."
1262     wget \
1263     --passive-ftp \
1264     --tries 3 \
1265     --continue \
1266     --progress bar \
1267     --directory-prefix=${temp} \
1268     ${mymirr}/rsync/tarballs/${latest_tarball}
1269     if [[ $? = 0 ]]
1270     then
1271     break
1272     else
1273     continue
1274     fi
1275     done
1276    
1277     if [[ -f ${temp}/${latest_tarball} ]]
1278     then
1279     # check md5
1280     if [[ ! -f ${temp}/${latest_md5} ]]
1281     then
1282     die "md5 is missing ... aborting"
1283     else
1284     ( cd ${temp}; md5sum --check ${lastest_md5} ) || die "md5 for ${lastest_tarball} failed"
1285     fi
1286    
1287     if [[ -d ${MAGEDIR} ]]
1288     then
1289     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1290     echo "cleaning old mage-tree ${MAGEDIR}..."
1291     rm -rf ${MAGEDIR}
1292     fi
1293    
1294     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1295     echo "updating mage-tree from tarball ..."
1296     # unpack in dirname of MAGEDIR, as the tarball has already the mage
1297     tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1298    
1299     if [[ -d ${temp} ]]
1300     then
1301     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1302     echo "cleaning temp-files ..."
1303     rm -rf ${temp}
1304     fi
1305    
1306     # check if a newer mage version is available
1307     is_newer_mage_version_available
1308     else
1309     die "Could not fetch the latest tarball ... aborting"
1310     fi
1311    }
1312    
1313  cleanpkg()  cleanpkg()
1314  {  {
1315   if [ -d "${PKGDIR}" ]   if [ -d "${PKGDIR}" ]
# Line 1182  choppkgname() Line 1347  choppkgname()
1347   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]
1348   then   then
1349   #cuts ARCH and PBUILD   #cuts ARCH and PBUILD
1350   #ARCH comes from /etc/mage.rc   #ARCH comes from ${MAGERC}
1351   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")
1352    
1353   #cuts version number   #cuts version number
# Line 1215  pname2pcat() Line 1380  pname2pcat()
1380  # returns 0=stable 1=unstable  # returns 0=stable 1=unstable
1381  check_stable_package()  check_stable_package()
1382  {  {
1383     # first check if this magefile is not blacklisted
1384     blacklisted "$1" || return 1
1385    
1386   local STATE   local STATE
1387   STATE="$(get_value_from_magefile STATE "$1")"   STATE="$(get_value_from_magefile STATE "$1")"
1388    
1389   # state testing   # state testing
1390   if [[ ${USE_TESTING} = true ]]   if [[ ${USE_TESTING} = true ]] || [[ ${MAGE_DISTRIBUTION} = testing ]]
1391   then   then
1392   case ${STATE} in   case ${STATE} in
1393   testing|stable) return 0 ;;   testing|stable) return 0 ;;
# Line 1228  check_stable_package() Line 1396  check_stable_package()
1396   fi   fi
1397    
1398   # state unstable   # state unstable
1399   if [[ ${USE_UNSTABLE} = true ]]   if [[ ${USE_UNSTABLE} = true ]] || [[ ${MAGE_DISTRIBUTION} = unstable ]]
1400   then   then
1401   case ${STATE} in   case ${STATE} in
1402   unstable|testing|stable) return 0 ;;   unstable|testing|stable) return 0 ;;
# Line 1254  get_highest_magefile() Line 1422  get_highest_magefile()
1422   local PNAME="$2"   local PNAME="$2"
1423   local magefile   local magefile
1424    
1425   for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*)   # do not list the content of a directory, only the name (-d)
1426     for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*)
1427   do   do
1428     [[ -z ${magefile} ]] && continue
1429   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
1430   [ -d ${magefile} ] && continue   [[ -d ${magefile} ]] && continue
1431   if check_stable_package ${magefile}   if check_stable_package ${magefile}
1432   then   then
1433   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
# Line 1266  get_highest_magefile() Line 1436  get_highest_magefile()
1436   fi   fi
1437   done   done
1438    
1439   # stop here if HIGHEST_MAGEFILE is zero  # do not so anything
1440   # this package must be unstable or old  # # stop here if HIGHEST_MAGEFILE is zero
1441   if [ -z "${HIGHEST_MAGEFILE}" ]  # # this package must be unstable or old
1442   then  # if [ -z "${HIGHEST_MAGEFILE}" ]
1443   echo  # then
1444   echo -n "All packages named "  # echo
1445   echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT}  # echo -n "All packages named "
1446   echo -n " are marked "  # echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT}
1447   echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT}  # echo -n " are marked "
1448   echo "."  # echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT}
1449   echo "You need to declare USE_UNSTABLE=true to install this."  # echo "."
1450   echo  # echo "You need to declare USE_UNSTABLE=true to install this."
1451   echo "Example:"  # echo
1452   echo "         USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}"  # echo "Example:"
1453   echo  # echo "         USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}"
1454   echo "Be warned that these packages are not stable and may cause serious problems."  # echo
1455   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."
1456   echo  # echo "You should know what you are doing, so don't complain about any damage."
1457   return 1  # echo
1458   fi  # return 1
1459    # fi
1460    
1461   echo "${HIGHEST_MAGEFILE}"   echo "${HIGHEST_MAGEFILE}"
1462   return 0   return 0
# Line 1301  get_highest_magefile() Line 1472  get_highest_magefile()
1472  #        1 - error                                #  #        1 - error                                #
1473  #        2 - protected                            #  #        2 - protected                            #
1474  #        3 - protected but masked                 #  #        3 - protected but masked                 #
1475    #        4 - protected but ignored                #
1476  #                                                 #  #                                                 #
1477  ###################################################  ###################################################
1478  is_config_protected()  is_config_protected()
# Line 1309  is_config_protected() Line 1481  is_config_protected()
1481   local TEST   local TEST
1482   local PROTECTED   local PROTECTED
1483   local IFS   local IFS
1484     local i
1485     local x
1486    
1487   EXPFILE="${MROOT}$1"   EXPFILE="${MROOT}$1"
1488    
1489   # file does not exist; it can be written   # file does not exist; it can be written
1490   [ ! -e ${EXPFILE} ] && return 0   [[ ! -e ${EXPFILE} ]] && return 0
1491    
1492   # to be safe; it may be '§'   # to be safe; it may be '§'
1493   IFS=' '   IFS=' '
1494    
1495   # check ob in config protect   # check if config protected
1496   for i in ${CONFIG_PROTECT}   for i in ${CONFIG_PROTECT}
1497   do   do
1498   # ersetzen von $i nur wenn am anfang der variable   # only replace $i in the beginning of the variable
1499   TEST="${EXPFILE/#${MROOT}${i}/Protected}"   TEST="${EXPFILE/#${MROOT}${i}/Protected}"
1500   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1501   then   then
1502   # setzen das es protected ist   # file is config proteced
1503   PROTECTED=TRUE   PROTECTED=TRUE
1504    
1505   # check ob nicht doch maskiert   # check if not masked
1506   for x in ${CONFIG_PROTECT_MASK}   for x in ${CONFIG_PROTECT_MASK}
1507   do   do
1508   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"
1509   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1510   then   then
1511   PROTECTED=MASKED   PROTECTED=MASKED
1512   fi   fi
1513   done   done
1514    
1515     # check if not ignored
1516     for x in ${CONFIG_PROTECT_IGNORE}
1517     do
1518     TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}"
1519     if [[ ${TEST} != ${EXPFILE} ]]
1520     then
1521     PROTECTED=IGNORED
1522     fi
1523     done
1524   fi   fi
1525   done   done
1526    
# Line 1351  is_config_protected() Line 1535  is_config_protected()
1535   #echo "I'm protected, but masked - delete me"   #echo "I'm protected, but masked - delete me"
1536   return 3   return 3
1537   ;;   ;;
1538     IGNORED)
1539     #echo "I'm protected, but ignored - keep me, del update"
1540     return 4
1541     ;;
1542   *)   *)
1543   #echo "delete me"   #echo "delete me"
1544   return 0   return 0
# Line 1368  is_config_protected() Line 1556  is_config_protected()
1556  ###################################################  ###################################################
1557  count_protected_files()  count_protected_files()
1558  {  {
1559   ${MLIBDIR}/writeprotected "$1"   local file="$1"
1560     local dirname="${file%/*}"
1561     local filename="${file##*/}"
1562     local count
1563     local output
1564     local i
1565    
1566     declare -i count=0
1567    
1568     # check if there are already protected files
1569     for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" |
1570     sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
1571     sort -t'%' -k3 -k2 | cut -f1 -d'%')
1572     do
1573     count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::")
1574     done
1575     (( count ++ ))
1576    
1577     # fill output up with zeros
1578     for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
1579     output="${output}${count}"
1580    
1581     echo "${output}"
1582  }  }
1583    
1584  # call with  # call with
# Line 1385  get_uninstall_candidates() Line 1595  get_uninstall_candidates()
1595   local list   local list
1596   local pcatdir   local pcatdir
1597   local protected   local protected
1598     local i
1599    
1600   # very basic getops   # very basic getops
1601   for i in $*   for i in $*
# Line 1397  get_uninstall_candidates() Line 1608  get_uninstall_candidates()
1608   shift   shift
1609   done   done
1610    
1611   # sanity checks; abort if not given  # it's not good to complain here about empty pnames; better to continue later anyway
1612   [ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given."  # # sanity checks; abort if not given
1613    # [ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given."
1614    
1615    
1616   # check needed global vars   # check needed global vars
1617   [ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set."   [ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set."
1618    
1619   # set pcatdir to '*' if empty   # set pcatdir to '*' if empty
1620   [ -z "${pcatdir}" ] && pcatdir=*   [ -z "${pcatdir}" ] && pcatdir='*'
1621    
1622   for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/*   for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/*
1623   do   do
# Line 1490  virtuals_add() Line 1702  virtuals_add()
1702   local oldline   local oldline
1703   local line i   local line i
1704   local installed_file   local installed_file
1705     local OLDIFS
1706    
1707   if virtuals_read ${virtualname}   if virtuals_read ${virtualname}
1708   then   then
1709   # make shure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already   # make sure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already
1710   for i in $(virtuals_read ${virtualname} showpkgs)   for i in $(virtuals_read ${virtualname} showpkgs)
1711   do   do
1712   if [[ ${i} = ${pkgname} ]]   if [[ ${i} = ${pkgname} ]]
# Line 1512  virtuals_add() Line 1725  virtuals_add()
1725   # make a backup   # make a backup
1726   mv ${MROOT}${VIRTUALDB_FILE} ${MROOT}${VIRTUALDB_FILE}.old   mv ${MROOT}${VIRTUALDB_FILE} ${MROOT}${VIRTUALDB_FILE}.old
1727    
1728     OLDIFS="${IFS}"
1729   IFS=$'\n'   IFS=$'\n'
1730   for line in $(< ${MROOT}${VIRTUALDB_FILE}.old)   for line in $(< ${MROOT}${VIRTUALDB_FILE}.old)
1731   do   do
# Line 1523  virtuals_add() Line 1737  virtuals_add()
1737   echo "${line}" >> ${MROOT}${VIRTUALDB_FILE}   echo "${line}" >> ${MROOT}${VIRTUALDB_FILE}
1738   fi   fi
1739   done   done
1740     # unset IFS
1741   #unset IFS   IFS="${OLDIFS}"
1742   else   else
1743   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} >>> ${COLDEFAULT}"
1744   echo "register ${pkgname} as ${virtualname} ..."   echo "register ${pkgname} as ${virtualname} ..."
1745   echo "${virtualname} ${pkgname}" >> ${MROOT}${VIRTUALDB_FILE}   echo "${virtualname} ${pkgname}" >> ${MROOT}${VIRTUALDB_FILE}
1746   fi   fi
# Line 1538  virtuals_add() Line 1752  virtuals_add()
1752  #$1 virtualname; $2 pkgname  #$1 virtualname; $2 pkgname
1753  virtuals_del() {  virtuals_del() {
1754    
1755   local VIRTUAL_NAME PKG_NAME OLD_LINE METHOD line i x PKG_INSTALLED   local virtualname="$1"
1756     local pkgname="$2"
1757   VIRTUAL_NAME=$1   local oldline
1758   PKG_NAME=$2   local method
1759     local line i x
1760   #first check if exists   local pkg_installed
1761   if virtuals_read ${VIRTUAL_NAME}   local OLDIFS
1762    
1763     # first check if exists
1764     if virtuals_read ${virtualname}
1765   then   then
1766   #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}
1767   declare -i x=0   declare -i x=0
1768   for i in $(virtuals_read ${VIRTUAL_NAME} showpkgs)   for i in $(virtuals_read ${virtualname} showpkgs)
1769   do   do
1770   if [ "${i}" == "${PKG_NAME}" ]   if [[ ${i} = ${pkgname} ]]
1771   then   then
1772   PKG_INSTALLED=true   pkg_installed=true
1773   fi   fi
1774   ((x++))   ((x++))
1775   done   done
1776    
1777   #abort if not installed   # abort if not installed
1778   if [ "${PKG_INSTALLED}" != "true" ]   if [[ ${pkg_installed} != true ]]
1779   then   then
1780   echo "!!!! ${PKG_NAME} does not exists in ${VIRTUAL_NAME}."   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1781     echo "${pkgname} does not exists in ${virtualname}."
1782   return 0   return 0
1783   fi   fi
1784    
1785   if [ ${x} -ge 2 ]   if [ ${x} -ge 2 ]
1786   then   then
1787   METHOD=update   method=update
1788   else   else
1789   METHOD=delall   method=delall
1790   fi   fi
1791    
1792   #get the complete line   # get the complete line
1793   OLD_LINE="$(virtuals_read ${VIRTUAL_NAME} showline)"   oldline="$(virtuals_read ${virtualname} showline)"
1794    
1795   #make a backup   # make a backup of the db
1796   mv ${VIRTUALDB_FILE} ${VIRTUALDB_FILE}.old   mv ${VIRTUALDB_FILE} ${VIRTUALDB_FILE}.old
1797    
1798   #parse virtualdb   # parse virtualdb
1799     OLDIFS="${IFS}"
1800   IFS=$'\n'   IFS=$'\n'
1801   for line in $(< ${VIRTUALDB_FILE}.old)   for line in $(< ${VIRTUALDB_FILE}.old)
1802   do   do
1803   if [ "${line}" == "${OLD_LINE}" ]   if [[ ${line} = ${oldline} ]]
1804   then   then
1805   #delall or update?   #delall or update?
1806   case ${METHOD} in   case ${method} in
1807   update)   update)
1808   echo "<<<< Unlinking ${PKG_NAME} from ${VIRTUAL_NAME} in virtual database ..."   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
1809   #del PKG_NAME from line   echo "Unlinking ${pkgname} from ${virtualname} in virtual database ..."
1810   echo "${line/ ${PKG_NAME}/}" >> ${VIRTUALDB_FILE}   # del PKG_NAME from line
1811     echo "${line/ ${pkgname}/}" >> ${VIRTUALDB_FILE}
1812   ;;   ;;
1813   delall)   delall)
1814   echo "<<<< Deleting ${VIRTUAL_NAME} in virtual database ..."   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"
1815   #continue; do not write anything   echo "Deleting ${virtualname} in virtual database ..."
1816     # continue; do not write anything
1817   continue   continue
1818   ;;   ;;
1819   esac   esac
# Line 1600  virtuals_del() { Line 1821  virtuals_del() {
1821   echo "${line}" >> ${VIRTUALDB_FILE}   echo "${line}" >> ${VIRTUALDB_FILE}
1822   fi   fi
1823   done   done
1824   unset IFS   # unset IFS
1825     IFS="${OLDIFS}"
1826   else   else
1827   echo "!!!! ${VIRTUAL_NAME} does not exists in virtual database."   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1828     echo "${virtualname} does not exists in virtual database."
1829   fi   fi
1830  }  }
1831    
# Line 1634  minclude() Line 1857  minclude()
1857  {  {
1858   local i   local i
1859    
1860   if [ -n "$@" ]   if [[ -n $* ]]
1861   then   then
1862   for i in $@   for i in $*
1863   do   do
1864   [[ ${MAGEDEBUG} = on ]] && \   [[ ${MAGEDEBUG} = on ]] && \
1865   echo "--- Including ${MAGEDIR}/include/${i}.minc"   echo "--- Including ${MAGEDIR}/include/${i}.minc"
# Line 1650  sminclude() Line 1873  sminclude()
1873  {  {
1874   local i   local i
1875    
1876   if [ -n "$@" ]   if [[ -n $* ]]
1877   then   then
1878   for i in $@   for i in $*
1879   do   do
1880   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
1881   source ${SMAGESCRIPTSDIR}/include/${i}.sminc   source ${SMAGESCRIPTSDIR}/include/${i}.sminc
# Line 1667  is_newer_mage_version_available() Line 1890  is_newer_mage_version_available()
1890   local newest_mage   local newest_mage
1891   local installed_mage   local installed_mage
1892    
1893   newest_mage="$( CATEGORIE=app-mage MAGENAME=mage get_highest_magefile;echo $(basename ${MAGEFILE} .mage) )"   newest_mage="$(basename $(get_highest_magefile app-mage mage) .mage)"
1894   installed_mage="$(magequery -n mage | cut -d' ' -f5)"   installed_mage="$(magequery -n mage | cut -d' ' -f5)"
1895    
1896   if [[ ${newest_mage} > ${installed_mage} ]]   if [[ ${newest_mage} > ${installed_mage} ]]
# Line 1676  is_newer_mage_version_available() Line 1899  is_newer_mage_version_available()
1899   echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT}   echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT}
1900   echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT}   echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT}
1901   echo "It is recommened to install this newer version"   echo "It is recommened to install this newer version"
1902   echo "or your current system installation may brake."   echo "or your current system installation may break."
1903   echo   echo
1904   echo -en "Please update mage by running "   echo -en "Please update mage by running "
1905   echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT}   echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT}
# Line 1948  get_value_from_magefile() Line 2171  get_value_from_magefile()
2171   local magefile="$2"   local magefile="$2"
2172   local value   local value
2173    
2174     [[ -z ${var} ]] && return 1
2175     [[ -z ${magefile} ]] && return 1
2176    
2177   # local all possible vars of a mage file   # local all possible vars of a mage file
2178   # to prevent bad issues   # to prevent bad issues
2179   local PKGNAME   local PKGNAME
# Line 1958  get_value_from_magefile() Line 2184  get_value_from_magefile()
2184   local SDEPEND   local SDEPEND
2185   local PROVIDE   local PROVIDE
2186   local PKGTYPE   local PKGTYPE
2187     local MAGE_TARGETS
2188     local SPLIT_PACKAGE_BASE
2189   local preinstall   local preinstall
2190   local postinstall   local postinstall
2191   local preremove   local preremove
# Line 1972  get_value_from_magefile() Line 2200  get_value_from_magefile()
2200   eval value=\$$(echo ${var})   eval value=\$$(echo ${var})
2201   echo "${value}"   echo "${value}"
2202    
2203   unset preinstall   # unset these functions
2204   unset postinstall   unset -f preinstall
2205   unset preremove   unset -f postinstall
2206   unset postremove   unset -f preremove
2207     unset -f postremove
2208  }  }
2209    
2210  mage_install()  mage_install()
# Line 2003  mage_install() Line 2232  mage_install()
2232   local count_current   local count_current
2233   local magefile   local magefile
2234   local src_install   local src_install
2235     local i
2236    
2237   # very basic getops   # very basic getops
2238   for i in $*   for i in $*
# Line 2076  mage_install() Line 2306  mage_install()
2306   echo B:${pbuild}   echo B:${pbuild}
2307   fi   fi
2308    
2309   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2   if [[ -n ${MAGE_TARGETS} ]]
2310     then
2311     # basic svn compat
2312     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2313     then
2314     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2315     do
2316     smage2file="${i}"
2317     done
2318     else
2319     smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2320     fi
2321    
2322     elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2323     then
2324     # basic svn compat
2325     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2326     then
2327     for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2328     do
2329     smage2file="${i}"
2330     done
2331     else
2332     smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2333     fi
2334    
2335     else
2336     # basic svn compat
2337     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2338     then
2339     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2340     do
2341     smage2file="${i}"
2342     done
2343     else
2344     smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2
2345     fi
2346     fi
2347    
2348   if [ -f "${smage2file}" ]   if [ -f "${smage2file}" ]
2349   then   then
2350     echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "
2351   smage2 ${smage2file} || die "compile failed"   smage2 ${smage2file} || die "compile failed"
2352   else   else
2353   echo   echo
# Line 2092  mage_install() Line 2361  mage_install()
2361   if [[ ${PKGTYPE} != virtual ]] && \   if [[ ${PKGTYPE} != virtual ]] && \
2362   [[ ${PKGTYPE} != sources ]]   [[ ${PKGTYPE} != sources ]]
2363   then   then
2364   # 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  
2365   build_doinstall ${PKGNAME}   build_doinstall ${PKGNAME}
2366   fi   fi
2367    
# Line 2156  mage_install() Line 2418  mage_install()
2418  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "
2419   echo "successfully installed."   echo "successfully installed."
2420    
2421   unset preinstall   # unset these functions
2422   unset postinstall   unset -f preinstall
2423   unset preremove   unset -f postinstall
2424   unset postremove   unset -f preremove
2425     unset -f postremove
2426  }  }
2427    
2428  md5sum_packages()  md5sum_packages()
# Line 2355  mage_uninstall() Line 2618  mage_uninstall()
2618   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"
2619   echo -n "removing: "   echo -n "removing: "
2620   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2621   echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"   echo -e "${COLRED}${pname}-${pver}-${pbuild}${COLDEFAULT}"
2622    
2623   magefile="${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"   magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
2624   source ${magefile}   source ${magefile}
2625    
2626   ## preremove scripts   ## preremove scripts
# Line 2418  mage_uninstall() Line 2681  mage_uninstall()
2681  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "
2682   echo "successfully removed."   echo "successfully removed."
2683    
2684   unset preinstall   # unset these functions
2685   unset postinstall   unset -f preinstall
2686   unset preremove   unset -f postinstall
2687   unset postremove   unset -f preremove
2688     unset -f postremove
2689  }  }
2690    
2691  show_etc_update_mesg() {  show_etc_update_mesg() {
# Line 2454  pkgsearch() Line 2718  pkgsearch()
2718   local all_installed   local all_installed
2719   local ipver   local ipver
2720   local ipbuild   local ipbuild
2721     local latest_available
2722     local depsfull
2723     local sdepsfull
2724     local deps
2725     local sdeps
2726     local dep
2727     local sign
2728    
2729   # only names no versions   # only names no versions
2730   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')"
2731   #result="$(find ${MAGEDIR} -type f -name *${string}*.mage | sort)"   #result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)"
2732    
2733   # nothing found   # nothing found
2734   [[ -z ${result} ]] && die "No package found containing '${string}' in the name."   [[ -z ${result} ]] && die "No package found containing '${string}' in the name."
# Line 2471  pkgsearch() Line 2742  pkgsearch()
2742   # get highest version available   # get highest version available
2743   magefile=$(get_highest_magefile ${pcat} ${pname})   magefile=$(get_highest_magefile ${pcat} ${pname})
2744    
2745   # now get all needed infos to print a nice output   if [[ ! -z ${magefile} ]]
2746   pver="$(magename2pver ${magefile})"   then
2747   pbuild="$(magename2pbuild ${magefile})"   # now get all needed infos to print a nice output
2748   state="$(get_value_from_magefile STATE ${magefile})"   pver="$(magename2pver ${magefile})"
2749   description="$(get_value_from_magefile DESCRIPTION ${magefile})"   pbuild="$(magename2pbuild ${magefile})"
2750   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"   state="$(get_value_from_magefile STATE ${magefile})"
2751     description="$(get_value_from_magefile DESCRIPTION ${magefile})"
2752     homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
2753    
2754     # all installed
2755     for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
2756     do
2757     ipver="$(magename2pver ${i})"
2758     ipbuild="$(magename2pbuild ${i})"
2759    
2760     if [[ -z ${all_installed} ]]
2761     then
2762     all_installed="${ipver}-${ipbuild}"
2763     else
2764     all_installed="${all_installed} ${ipver}-${ipbuild}"
2765     fi
2766     done
2767     [[ -z ${all_installed} ]] && all_installed="none"
2768    
2769     case ${state} in
2770     stable) state=${COLGREEN}"[s] ";;
2771     testing) state=${COLYELLOW}"[t] ";;
2772     unstable) state=${COLRED}"[u] ";;
2773     old) state=${COLGRAY}"[o] ";;
2774     esac
2775    
2776   # all installed   latest_available="${pver}-${pbuild}"
2777   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})   else
2778   do   # package is masked
2779   ipver="$(magename2pver ${i})"   state="${COLRED}[m] "
2780   ipbuild="$(magename2pbuild ${i})"   latest_available="${COLRED}masked for this distribution.${COLDEFAULT}"
2781     fi
2782    
2783   if [[ -z ${all_installed} ]]   depsfull="$(get_value_from_magefile DEPEND ${magefile})"
2784   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"  
2785    
2786   case ${state} in   while read sign dep
2787   stable) state=${COLGREEN}"[s] ";;   do
2788   testing) state=${COLYELLOW}"[t] ";;   case ${dep} in
2789   unstable) state=${COLRED}"[u] ";;   "") continue;;
2790   old) state=${COLGRAY}"[o] ";;   esac
2791   esac  
2792     deps="${deps} $(basename ${dep%-*})"
2793     done << EOF
2794    ${depsfull}
2795    EOF
2796    
2797     while read sign dep
2798     do
2799     case ${dep} in
2800     "") continue;;
2801     esac
2802    
2803     sdeps="${sdeps} $(basename ${dep%-*})"
2804     done << EOF
2805    ${sdepsfull}
2806    EOF
2807    
2808   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}
2809   echo "      Latest available:   ${pver}-${pbuild}"   echo -e "      Latest available:   ${latest_available}"
2810   echo "      Installed versions: ${all_installed}"   echo "      Installed versions: ${all_installed}"
2811   echo "      Description: ${description}"   echo "      Description: ${description}"
2812   echo "      Homepage: ${homepage}"   echo "      Homepage: ${homepage}"
2813     echo "      Depends: ${deps}"
2814     echo "      SDepends: ${sdeps}"
2815   echo   echo
2816    
2817   unset pcat   unset pcat
# Line 2518  pkgsearch() Line 2825  pkgsearch()
2825   unset all_installed   unset all_installed
2826   unset ipver   unset ipver
2827   unset ipbuild   unset ipbuild
2828     unset depsfull
2829     unset sdepsfull
2830     unset deps
2831     unset sdeps
2832     unset dep
2833     unset sign
2834   done   done
2835  }  }
2836    
# Line 2542  export_inherits() Line 2855  export_inherits()
2855   shift   shift
2856   done   done
2857  }  }
2858    
2859    mlibdir()
2860    {
2861     local libdir=lib
2862     [[ ${ARCH} = x86_64 ]] && libdir=lib64
2863    
2864     echo "${libdir}"
2865    }
2866    
2867    ## blacklisted ${magefile}
2868    blacklisted()
2869    {
2870     [[ -z ${MAGE_DISTRIBUTION} ]] && local MAGE_DISTRIBUTION=stable
2871    
2872     # compat
2873     [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable
2874     [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing
2875    
2876     # support both types for the moment
2877     if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]]
2878     then
2879     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"
2880     else
2881     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}"
2882     fi
2883    
2884     # return 0 if the list not exist; nothin is masked
2885     [[ ! -f ${EXCLUDED} ]] && return 0
2886    
2887     local MAGEFILE="$1"
2888    
2889     local PCAT="$(magename2pcat ${MAGEFILE})"
2890     local PNAME="$(magename2pname ${MAGEFILE})"
2891     local PVER="$(magename2pver ${MAGEFILE})"
2892     local PBUILD="$(magename2pbuild ${MAGEFILE})"
2893    
2894     local EXPCAT EXPNAME EXPVER EXPBUILD
2895     while read EXPCAT EXPNAME EXPVER EXPBUILD
2896     do
2897     # ignore spaces and comments
2898             case "${EXPCAT}" in
2899                     \#*|"") continue ;;
2900             esac
2901    
2902     # exclude full pver
2903     if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] &&
2904     [[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] &&
2905     [[ -n ${PVER} ]] && [[ -n ${PBUILD} ]] &&
2906     [[ -n ${EXPVER} ]] && [[ -n ${EXPBUILD} ]]
2907     then
2908     [[ ${EXPCAT}/${EXPNAME}-${EXPVER}-${EXPBUILD} = ${PCAT}/${PNAME}-${PVER}-${PBUILD} ]] && return 1
2909     fi
2910    
2911     # exclude pcat/pname only
2912     if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] &&
2913     [[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] &&
2914     [[ -z ${EXPVER} ]] && [[ -z ${EXPBUILD} ]]
2915     then
2916     [[ ${EXPCAT}/${EXPNAME} = ${PCAT}/${PNAME} ]] && return 1
2917     fi
2918     done << EOF
2919    $( cat ${EXCLUDED}; echo)
2920    EOF
2921    
2922     return 0
2923    }
2924    

Legend:
Removed from v.249  
changed lines
  Added in v.1084