Magellan Linux

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

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

revision 273 by niro, Fri Oct 21 14:50:13 2005 UTC revision 1085 by niro, Mon Jun 28 18:15:44 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.8 2005-10-21 14:50: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 556  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   for i in ${provide}   # first unregister virtuals
578   do   provide="$(get_value_from_magefile PROVIDE ${magefile})"
579   virtuals_del "${i}" "${pcat}/${pname}"   if [ -n "${provide}" ]
580   done   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 573  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 765  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 1042  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 1089  fetch_packages() Line 1179  fetch_packages()
1179   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1180   [[ ${VERBOSE} = off ]] && opt="--quiet"   [[ ${VERBOSE} = off ]] && opt="--quiet"
1181   wget \   wget \
1182   --passive-ftp \   ${WGET_FETCH_OPTIONS} \
  --tries 3 \  
  --continue \  
  --progress bar \  
1183   --directory-prefix=${PKGDIR} \   --directory-prefix=${PKGDIR} \
1184   ${opt} ${mirr}/packages/${pkg}   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}
1185   if [[ $? = 0 ]]   if [[ $? = 0 ]]
1186   then   then
1187   break   break
# Line 1117  syncmage() Line 1204  syncmage()
1204  {  {
1205   if [ -z "${RSYNC}" ]   if [ -z "${RSYNC}" ]
1206   then   then
1207   die "You have no rsync-mirrors defined. Please edit your /etc/mage.rc."   die "You have no rsync-mirrors defined. Please edit your ${MAGERC}."
1208   fi   fi
1209    
1210   local i   local i
1211   for i in ${RSYNC}   for i in ${RSYNC}
1212   do   do
1213   rsync \   rsync ${RSYNC_FETCH_OPTIONS} ${i} ${MAGEDIR}
  --recursive \  
  --links \  
  --perms \  
  --times \  
  --devices \  
  --timeout=600 \  
  --verbose \  
  --compress \  
  --progress \  
  --stats \  
  --delete \  
  --delete-after \  
  ${i} ${MAGEDIR}  
1214   if [[ $? = 0 ]]   if [[ $? = 0 ]]
1215   then   then
1216   break   break
# Line 1148  syncmage() Line 1222  syncmage()
1222   # clean up backup files (foo~)   # clean up backup files (foo~)
1223   find ${MAGEDIR} -name *~ -exec rm '{}' ';'   find ${MAGEDIR} -name *~ -exec rm '{}' ';'
1224    
1225   # check if an newer mage version is available   # check if a newer mage version is available
1226   is_newer_mage_version_available   is_newer_mage_version_available
1227  }  }
1228    
1229    syncmage_tarball()
1230    {
1231     local latest_tarball
1232     local latest_md5
1233     local temp="$(mktemp -d)"
1234     local mirr mymirr
1235    
1236     # try to get the md5 marked as latest on the server
1237     latest_md5="mage-latest.md5"
1238    
1239     # try to get the tarball marked as latest on the server
1240     latest_tarball="mage-latest.tar.bz2"
1241    
1242     for mirr in ${MIRRORS}
1243     do
1244     # path without distribution
1245     mymirr="${mirr%/*}"
1246    
1247     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1248     echo "fetching latest md5 from ${mymirr} ..."
1249     wget \
1250     ${WGET_FETCH_OPTIONS} \
1251     --directory-prefix=${temp} \
1252     ${mymirr}/rsync/tarballs/${latest_md5}
1253    
1254     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1255     echo "fetching latest tarball from ${mymirr} ..."
1256     wget \
1257     ${WGET_FETCH_OPTIONS} \
1258     --directory-prefix=${temp} \
1259     ${mymirr}/rsync/tarballs/${latest_tarball}
1260     if [[ $? = 0 ]]
1261     then
1262     break
1263     else
1264     continue
1265     fi
1266     done
1267    
1268     if [[ -f ${temp}/${latest_tarball} ]]
1269     then
1270     # check md5
1271     if [[ ! -f ${temp}/${latest_md5} ]]
1272     then
1273     die "md5 is missing ... aborting"
1274     else
1275     ( cd ${temp}; md5sum --check ${lastest_md5} ) || die "md5 for ${lastest_tarball} failed"
1276     fi
1277    
1278     if [[ -d ${MAGEDIR} ]]
1279     then
1280     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1281     echo "cleaning old mage-tree ${MAGEDIR}..."
1282     rm -rf ${MAGEDIR}
1283     fi
1284    
1285     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1286     echo "updating mage-tree from tarball ..."
1287     # unpack in dirname of MAGEDIR, as the tarball has already the mage
1288     tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1289    
1290     if [[ -d ${temp} ]]
1291     then
1292     echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1293     echo "cleaning temp-files ..."
1294     rm -rf ${temp}
1295     fi
1296    
1297     # check if a newer mage version is available
1298     is_newer_mage_version_available
1299     else
1300     die "Could not fetch the latest tarball ... aborting"
1301     fi
1302    }
1303    
1304  cleanpkg()  cleanpkg()
1305  {  {
1306   if [ -d "${PKGDIR}" ]   if [ -d "${PKGDIR}" ]
# Line 1189  choppkgname() Line 1338  choppkgname()
1338   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]
1339   then   then
1340   #cuts ARCH and PBUILD   #cuts ARCH and PBUILD
1341   #ARCH comes from /etc/mage.rc   #ARCH comes from ${MAGERC}
1342   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")
1343    
1344   #cuts version number   #cuts version number
# Line 1222  pname2pcat() Line 1371  pname2pcat()
1371  # returns 0=stable 1=unstable  # returns 0=stable 1=unstable
1372  check_stable_package()  check_stable_package()
1373  {  {
1374     # first check if this magefile is not blacklisted
1375     blacklisted "$1" || return 1
1376    
1377   local STATE   local STATE
1378   STATE="$(get_value_from_magefile STATE "$1")"   STATE="$(get_value_from_magefile STATE "$1")"
1379    
1380   # state testing   # state testing
1381   if [[ ${USE_TESTING} = true ]]   if [[ ${USE_TESTING} = true ]] || [[ ${MAGE_DISTRIBUTION} = testing ]]
1382   then   then
1383   case ${STATE} in   case ${STATE} in
1384   testing|stable) return 0 ;;   testing|stable) return 0 ;;
# Line 1235  check_stable_package() Line 1387  check_stable_package()
1387   fi   fi
1388    
1389   # state unstable   # state unstable
1390   if [[ ${USE_UNSTABLE} = true ]]   if [[ ${USE_UNSTABLE} = true ]] || [[ ${MAGE_DISTRIBUTION} = unstable ]]
1391   then   then
1392   case ${STATE} in   case ${STATE} in
1393   unstable|testing|stable) return 0 ;;   unstable|testing|stable) return 0 ;;
# Line 1261  get_highest_magefile() Line 1413  get_highest_magefile()
1413   local PNAME="$2"   local PNAME="$2"
1414   local magefile   local magefile
1415    
1416   for magefile in $(ls --format=single-column -v ${MAGEDIR}/${PCAT}/${PNAME}/*)   # do not list the content of a directory, only the name (-d)
1417     for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*)
1418   do   do
1419     [[ -z ${magefile} ]] && continue
1420   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
1421   [ -d ${magefile} ] && continue   [[ -d ${magefile} ]] && continue
1422   if check_stable_package ${magefile}   if check_stable_package ${magefile}
1423   then   then
1424   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
# Line 1273  get_highest_magefile() Line 1427  get_highest_magefile()
1427   fi   fi
1428   done   done
1429    
1430   # stop here if HIGHEST_MAGEFILE is zero  # do not so anything
1431   # this package must be unstable or old  # # stop here if HIGHEST_MAGEFILE is zero
1432   if [ -z "${HIGHEST_MAGEFILE}" ]  # # this package must be unstable or old
1433   then  # if [ -z "${HIGHEST_MAGEFILE}" ]
1434   echo  # then
1435   echo -n "All packages named "  # echo
1436   echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT}  # echo -n "All packages named "
1437   echo -n " are marked "  # echo -en ${COLRED}\""${PKGNAME%-*-*-*}\""${COLDEFAULT}
1438   echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT}  # echo -n " are marked "
1439   echo "."  # echo -en ${COLRED}"*UNSTABLE*"${COLDEFAULT}
1440   echo "You need to declare USE_UNSTABLE=true to install this."  # echo "."
1441   echo  # echo "You need to declare USE_UNSTABLE=true to install this."
1442   echo "Example:"  # echo
1443   echo "         USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}"  # echo "Example:"
1444   echo  # echo "         USE_UNSTABLE=true mage install ${PKGNAME%-*-*-*}"
1445   echo "Be warned that these packages are not stable and may cause serious problems."  # echo
1446   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."
1447   echo  # echo "You should know what you are doing, so don't complain about any damage."
1448   return 1  # echo
1449   fi  # return 1
1450    # fi
1451    
1452   echo "${HIGHEST_MAGEFILE}"   echo "${HIGHEST_MAGEFILE}"
1453   return 0   return 0
# Line 1308  get_highest_magefile() Line 1463  get_highest_magefile()
1463  #        1 - error                                #  #        1 - error                                #
1464  #        2 - protected                            #  #        2 - protected                            #
1465  #        3 - protected but masked                 #  #        3 - protected but masked                 #
1466    #        4 - protected but ignored                #
1467  #                                                 #  #                                                 #
1468  ###################################################  ###################################################
1469  is_config_protected()  is_config_protected()
# Line 1316  is_config_protected() Line 1472  is_config_protected()
1472   local TEST   local TEST
1473   local PROTECTED   local PROTECTED
1474   local IFS   local IFS
1475     local i
1476     local x
1477    
1478   EXPFILE="${MROOT}$1"   EXPFILE="${MROOT}$1"
1479    
1480   # file does not exist; it can be written   # file does not exist; it can be written
1481   [ ! -e ${EXPFILE} ] && return 0   [[ ! -e ${EXPFILE} ]] && return 0
1482    
1483   # to be safe; it may be '§'   # to be safe; it may be '§'
1484   IFS=' '   IFS=' '
1485    
1486   # check ob in config protect   # check if config protected
1487   for i in ${CONFIG_PROTECT}   for i in ${CONFIG_PROTECT}
1488   do   do
1489   # ersetzen von $i nur wenn am anfang der variable   # only replace $i in the beginning of the variable
1490   TEST="${EXPFILE/#${MROOT}${i}/Protected}"   TEST="${EXPFILE/#${MROOT}${i}/Protected}"
1491   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1492   then   then
1493   # setzen das es protected ist   # file is config proteced
1494   PROTECTED=TRUE   PROTECTED=TRUE
1495    
1496   # check ob nicht doch maskiert   # check if not masked
1497   for x in ${CONFIG_PROTECT_MASK}   for x in ${CONFIG_PROTECT_MASK}
1498   do   do
1499   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"   TEST="${EXPFILE/#${MROOT}${x}/Protect_Masked}"
1500   if [ "${TEST}" != "${EXPFILE}" ]   if [[ ${TEST} != ${EXPFILE} ]]
1501   then   then
1502   PROTECTED=MASKED   PROTECTED=MASKED
1503   fi   fi
1504   done   done
1505    
1506     # check if not ignored
1507     for x in ${CONFIG_PROTECT_IGNORE}
1508     do
1509     TEST="${EXPFILE/#${MROOT}${x}/Protect_Ignored}"
1510     if [[ ${TEST} != ${EXPFILE} ]]
1511     then
1512     PROTECTED=IGNORED
1513     fi
1514     done
1515   fi   fi
1516   done   done
1517    
# Line 1358  is_config_protected() Line 1526  is_config_protected()
1526   #echo "I'm protected, but masked - delete me"   #echo "I'm protected, but masked - delete me"
1527   return 3   return 3
1528   ;;   ;;
1529     IGNORED)
1530     #echo "I'm protected, but ignored - keep me, del update"
1531     return 4
1532     ;;
1533   *)   *)
1534   #echo "delete me"   #echo "delete me"
1535   return 0   return 0
# Line 1375  is_config_protected() Line 1547  is_config_protected()
1547  ###################################################  ###################################################
1548  count_protected_files()  count_protected_files()
1549  {  {
1550   ${MLIBDIR}/writeprotected "$1"   local file="$1"
1551     local dirname="${file%/*}"
1552     local filename="${file##*/}"
1553     local count
1554     local output
1555     local i
1556    
1557     declare -i count=0
1558    
1559     # check if there are already protected files
1560     for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" |
1561     sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
1562     sort -t'%' -k3 -k2 | cut -f1 -d'%')
1563     do
1564     count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::")
1565     done
1566     (( count ++ ))
1567    
1568     # fill output up with zeros
1569     for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
1570     output="${output}${count}"
1571    
1572     echo "${output}"
1573  }  }
1574    
1575  # call with  # call with
# Line 1392  get_uninstall_candidates() Line 1586  get_uninstall_candidates()
1586   local list   local list
1587   local pcatdir   local pcatdir
1588   local protected   local protected
1589     local i
1590    
1591   # very basic getops   # very basic getops
1592   for i in $*   for i in $*
# Line 1404  get_uninstall_candidates() Line 1599  get_uninstall_candidates()
1599   shift   shift
1600   done   done
1601    
1602   # sanity checks; abort if not given  # it's not good to complain here about empty pnames; better to continue later anyway
1603   [ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given."  # # sanity checks; abort if not given
1604    # [ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given."
1605    
1606    
1607   # check needed global vars   # check needed global vars
1608   [ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set."   [ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set."
1609    
1610   # set pcatdir to '*' if empty   # set pcatdir to '*' if empty
1611   [ -z "${pcatdir}" ] && pcatdir=*   [ -z "${pcatdir}" ] && pcatdir='*'
1612    
1613   for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/*   for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/*
1614   do   do
# Line 1501  virtuals_add() Line 1697  virtuals_add()
1697    
1698   if virtuals_read ${virtualname}   if virtuals_read ${virtualname}
1699   then   then
1700   # make shure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already   # make sure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already
1701   for i in $(virtuals_read ${virtualname} showpkgs)   for i in $(virtuals_read ${virtualname} showpkgs)
1702   do   do
1703   if [[ ${i} = ${pkgname} ]]   if [[ ${i} = ${pkgname} ]]
# Line 1652  minclude() Line 1848  minclude()
1848  {  {
1849   local i   local i
1850    
1851   if [ -n "$@" ]   if [[ -n $* ]]
1852   then   then
1853   for i in $@   for i in $*
1854   do   do
1855   [[ ${MAGEDEBUG} = on ]] && \   [[ ${MAGEDEBUG} = on ]] && \
1856   echo "--- Including ${MAGEDIR}/include/${i}.minc"   echo "--- Including ${MAGEDIR}/include/${i}.minc"
# Line 1668  sminclude() Line 1864  sminclude()
1864  {  {
1865   local i   local i
1866    
1867   if [ -n "$@" ]   if [[ -n $* ]]
1868   then   then
1869   for i in $@   for i in $*
1870   do   do
1871   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
1872   source ${SMAGESCRIPTSDIR}/include/${i}.sminc   source ${SMAGESCRIPTSDIR}/include/${i}.sminc
# Line 1694  is_newer_mage_version_available() Line 1890  is_newer_mage_version_available()
1890   echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT}   echo -en ${COLRED}"An update for your packetmanager is available. "${COLDEFAULT}
1891   echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT}   echo -e ${COLBLUE}"[ ${newest_mage} ]"${COLDEFAULT}
1892   echo "It is recommened to install this newer version"   echo "It is recommened to install this newer version"
1893   echo "or your current system installation may brake."   echo "or your current system installation may break."
1894   echo   echo
1895   echo -en "Please update mage by running "   echo -en "Please update mage by running "
1896   echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT}   echo -e ${COLGREEN}"'mage install mage'"${COLDEFAULT}
# Line 1966  get_value_from_magefile() Line 2162  get_value_from_magefile()
2162   local magefile="$2"   local magefile="$2"
2163   local value   local value
2164    
2165     [[ -z ${var} ]] && return 1
2166     [[ -z ${magefile} ]] && return 1
2167    
2168   # local all possible vars of a mage file   # local all possible vars of a mage file
2169   # to prevent bad issues   # to prevent bad issues
2170   local PKGNAME   local PKGNAME
# Line 1976  get_value_from_magefile() Line 2175  get_value_from_magefile()
2175   local SDEPEND   local SDEPEND
2176   local PROVIDE   local PROVIDE
2177   local PKGTYPE   local PKGTYPE
2178     local MAGE_TARGETS
2179     local SPLIT_PACKAGE_BASE
2180   local preinstall   local preinstall
2181   local postinstall   local postinstall
2182   local preremove   local preremove
# Line 2022  mage_install() Line 2223  mage_install()
2223   local count_current   local count_current
2224   local magefile   local magefile
2225   local src_install   local src_install
2226     local i
2227    
2228   # very basic getops   # very basic getops
2229   for i in $*   for i in $*
# Line 2095  mage_install() Line 2297  mage_install()
2297   echo B:${pbuild}   echo B:${pbuild}
2298   fi   fi
2299    
2300   smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2   if [[ -n ${MAGE_TARGETS} ]]
2301     then
2302     # basic svn compat
2303     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2304     then
2305     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2306     do
2307     smage2file="${i}"
2308     done
2309     else
2310     smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2311     fi
2312    
2313     elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2314     then
2315     # basic svn compat
2316     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2317     then
2318     for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2319     do
2320     smage2file="${i}"
2321     done
2322     else
2323     smage2file=${SMAGESCRIPTSDIR}/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2324     fi
2325    
2326     else
2327     # basic svn compat
2328     if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]
2329     then
2330     for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2331     do
2332     smage2file="${i}"
2333     done
2334     else
2335     smage2file=${SMAGESCRIPTSDIR}/${pname}/${pname}-${pver}-${pbuild}.smage2
2336     fi
2337     fi
2338    
2339   if [ -f "${smage2file}" ]   if [ -f "${smage2file}" ]
2340   then   then
2341     echo -e " ${COLBLUE}***${COLDEFAULT} building package from source ... "
2342   smage2 ${smage2file} || die "compile failed"   smage2 ${smage2file} || die "compile failed"
2343   else   else
2344   echo   echo
# Line 2111  mage_install() Line 2352  mage_install()
2352   if [[ ${PKGTYPE} != virtual ]] && \   if [[ ${PKGTYPE} != virtual ]] && \
2353   [[ ${PKGTYPE} != sources ]]   [[ ${PKGTYPE} != sources ]]
2354   then   then
2355   # 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  
2356   build_doinstall ${PKGNAME}   build_doinstall ${PKGNAME}
2357   fi   fi
2358    
# Line 2375  mage_uninstall() Line 2609  mage_uninstall()
2609   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"
2610   echo -n "removing: "   echo -n "removing: "
2611   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2612   echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"   echo -e "${COLRED}${pname}-${pver}-${pbuild}${COLDEFAULT}"
2613    
2614   magefile="${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"   magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
2615   source ${magefile}   source ${magefile}
2616    
2617   ## preremove scripts   ## preremove scripts
# Line 2475  pkgsearch() Line 2709  pkgsearch()
2709   local all_installed   local all_installed
2710   local ipver   local ipver
2711   local ipbuild   local ipbuild
2712     local latest_available
2713     local depsfull
2714     local sdepsfull
2715     local deps
2716     local sdeps
2717     local dep
2718     local sign
2719    
2720   # only names no versions   # only names no versions
2721   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')"
2722   #result="$(find ${MAGEDIR} -type f -name *${string}*.mage | sort)"   #result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)"
2723    
2724   # nothing found   # nothing found
2725   [[ -z ${result} ]] && die "No package found containing '${string}' in the name."   [[ -z ${result} ]] && die "No package found containing '${string}' in the name."
# Line 2492  pkgsearch() Line 2733  pkgsearch()
2733   # get highest version available   # get highest version available
2734   magefile=$(get_highest_magefile ${pcat} ${pname})   magefile=$(get_highest_magefile ${pcat} ${pname})
2735    
2736   # now get all needed infos to print a nice output   if [[ ! -z ${magefile} ]]
2737   pver="$(magename2pver ${magefile})"   then
2738   pbuild="$(magename2pbuild ${magefile})"   # now get all needed infos to print a nice output
2739   state="$(get_value_from_magefile STATE ${magefile})"   pver="$(magename2pver ${magefile})"
2740   description="$(get_value_from_magefile DESCRIPTION ${magefile})"   pbuild="$(magename2pbuild ${magefile})"
2741   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"   state="$(get_value_from_magefile STATE ${magefile})"
2742     description="$(get_value_from_magefile DESCRIPTION ${magefile})"
2743     homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
2744    
2745     # all installed
2746     for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
2747     do
2748     ipver="$(magename2pver ${i})"
2749     ipbuild="$(magename2pbuild ${i})"
2750    
2751     if [[ -z ${all_installed} ]]
2752     then
2753     all_installed="${ipver}-${ipbuild}"
2754     else
2755     all_installed="${all_installed} ${ipver}-${ipbuild}"
2756     fi
2757     done
2758     [[ -z ${all_installed} ]] && all_installed="none"
2759    
2760     case ${state} in
2761     stable) state=${COLGREEN}"[s] ";;
2762     testing) state=${COLYELLOW}"[t] ";;
2763     unstable) state=${COLRED}"[u] ";;
2764     old) state=${COLGRAY}"[o] ";;
2765     esac
2766    
2767   # all installed   latest_available="${pver}-${pbuild}"
2768   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})   else
2769   do   # package is masked
2770   ipver="$(magename2pver ${i})"   state="${COLRED}[m] "
2771   ipbuild="$(magename2pbuild ${i})"   latest_available="${COLRED}masked for this distribution.${COLDEFAULT}"
2772     fi
2773    
2774   if [[ -z ${all_installed} ]]   depsfull="$(get_value_from_magefile DEPEND ${magefile})"
2775   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"  
2776    
2777   case ${state} in   while read sign dep
2778   stable) state=${COLGREEN}"[s] ";;   do
2779   testing) state=${COLYELLOW}"[t] ";;   case ${dep} in
2780   unstable) state=${COLRED}"[u] ";;   "") continue;;
2781   old) state=${COLGRAY}"[o] ";;   esac
2782   esac  
2783     deps="${deps} $(basename ${dep%-*})"
2784     done << EOF
2785    ${depsfull}
2786    EOF
2787    
2788     while read sign dep
2789     do
2790     case ${dep} in
2791     "") continue;;
2792     esac
2793    
2794     sdeps="${sdeps} $(basename ${dep%-*})"
2795     done << EOF
2796    ${sdepsfull}
2797    EOF
2798    
2799   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}   echo -e "${state}${pcat}/${pname}"${COLDEFAULT}
2800   echo "      Latest available:   ${pver}-${pbuild}"   echo -e "      Latest available:   ${latest_available}"
2801   echo "      Installed versions: ${all_installed}"   echo "      Installed versions: ${all_installed}"
2802   echo "      Description: ${description}"   echo "      Description: ${description}"
2803   echo "      Homepage: ${homepage}"   echo "      Homepage: ${homepage}"
2804     echo "      Depends: ${deps}"
2805     echo "      SDepends: ${sdeps}"
2806   echo   echo
2807    
2808   unset pcat   unset pcat
# Line 2539  pkgsearch() Line 2816  pkgsearch()
2816   unset all_installed   unset all_installed
2817   unset ipver   unset ipver
2818   unset ipbuild   unset ipbuild
2819     unset depsfull
2820     unset sdepsfull
2821     unset deps
2822     unset sdeps
2823     unset dep
2824     unset sign
2825   done   done
2826  }  }
2827    
# Line 2563  export_inherits() Line 2846  export_inherits()
2846   shift   shift
2847   done   done
2848  }  }
2849    
2850    mlibdir()
2851    {
2852     local libdir=lib
2853     [[ ${ARCH} = x86_64 ]] && libdir=lib64
2854    
2855     echo "${libdir}"
2856    }
2857    
2858    ## blacklisted ${magefile}
2859    blacklisted()
2860    {
2861     [[ -z ${MAGE_DISTRIBUTION} ]] && local MAGE_DISTRIBUTION=stable
2862    
2863     # compat
2864     [[ ${USE_UNSTABLE} = true ]] && local MAGE_DISTRIBUTION=unstable
2865     [[ ${USE_TESTING} = true ]] && local MAGE_DISTRIBUTION=testing
2866    
2867     # support both types for the moment
2868     if [[ -f /etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION} ]]
2869     then
2870     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}-${MAGE_DISTRIBUTION}"
2871     else
2872     local EXCLUDED="/etc/mage-profile/package.blacklist-${ARCH}"
2873     fi
2874    
2875     # return 0 if the list not exist; nothin is masked
2876     [[ ! -f ${EXCLUDED} ]] && return 0
2877    
2878     local MAGEFILE="$1"
2879    
2880     local PCAT="$(magename2pcat ${MAGEFILE})"
2881     local PNAME="$(magename2pname ${MAGEFILE})"
2882     local PVER="$(magename2pver ${MAGEFILE})"
2883     local PBUILD="$(magename2pbuild ${MAGEFILE})"
2884    
2885     local EXPCAT EXPNAME EXPVER EXPBUILD
2886     while read EXPCAT EXPNAME EXPVER EXPBUILD
2887     do
2888     # ignore spaces and comments
2889             case "${EXPCAT}" in
2890                     \#*|"") continue ;;
2891             esac
2892    
2893     # exclude full pver
2894     if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] &&
2895     [[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] &&
2896     [[ -n ${PVER} ]] && [[ -n ${PBUILD} ]] &&
2897     [[ -n ${EXPVER} ]] && [[ -n ${EXPBUILD} ]]
2898     then
2899     [[ ${EXPCAT}/${EXPNAME}-${EXPVER}-${EXPBUILD} = ${PCAT}/${PNAME}-${PVER}-${PBUILD} ]] && return 1
2900     fi
2901    
2902     # exclude pcat/pname only
2903     if [[ -n ${PCAT} ]] && [[ -n ${PNAME} ]] &&
2904     [[ -n ${EXPCAT} ]] && [[ -n ${EXPNAME} ]] &&
2905     [[ -z ${EXPVER} ]] && [[ -z ${EXPBUILD} ]]
2906     then
2907     [[ ${EXPCAT}/${EXPNAME} = ${PCAT}/${PNAME} ]] && return 1
2908     fi
2909     done << EOF
2910    $( cat ${EXCLUDED}; echo)
2911    EOF
2912    
2913     return 0
2914    }
2915    

Legend:
Removed from v.273  
changed lines
  Added in v.1085