Magellan Linux

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

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

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

Legend:
Removed from v.252  
changed lines
  Added in v.1083