Magellan Linux

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

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

revision 226 by niro, Fri Sep 9 16:35:46 2005 UTC revision 329 by niro, Thu Feb 16 22:11:06 2006 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  # Magellan Linux Installer Functions (mage.functions.sh)  # Magellan Linux Installer Functions (mage.functions.sh)
3  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.1 2005-09-09 16:35:38 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.16 2006-02-16 22:11:06 niro Exp $
4    
5  mage_setup()  mage_setup()
6  {  {
# Line 361  install_characterdevices() Line 361  install_characterdevices()
361   local pkgname="$1"   local pkgname="$1"
362   local pathto   local pathto
363   local posix   local posix
364     local major
365     local minor
366   local IFS   local IFS
367    
368   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 374  install_characterdevices() Line 376  install_characterdevices()
376   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
377   IFS=§   IFS=§
378    
379   while read pathto posix   while read pathto posix major minor
380   do   do
381   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
382   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"
383    
384   mknode -m ${posix} -c "${MROOT}${pathto}"   mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor}
385   done < ${BUILDDIR}/${pkgname}/.char   done < ${BUILDDIR}/${pkgname}/.char
386    
387   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
# Line 432  install_database_entry() Line 434  install_database_entry()
434   local magefile   local magefile
435   local dbrecorddir   local dbrecorddir
436   local provide   local provide
437     local i
438    
439   # very basic getops   # very basic getops
440   for i in $*   for i in $*
# Line 473  install_database_entry() Line 476  install_database_entry()
476    
477   # create fake file descriptors   # create fake file descriptors
478   # used by virtual and source packages   # used by virtual and source packages
  local i  
479   for i in .dirs .symlinks .files .pipes .char   for i in .dirs .symlinks .files .pipes .char
480   do   do
481   touch ${dbrecorddir}/${i}   touch ${dbrecorddir}/${i}
# Line 504  install_database_entry() Line 506  install_database_entry()
506   provide="$(get_value_from_magefile PROVIDE ${magefile})"   provide="$(get_value_from_magefile PROVIDE ${magefile})"
507   if [ -n "${provide}" ]   if [ -n "${provide}" ]
508   then   then
509   virtuals_add "${provide}" "${pcat}/${pname}"   for i in ${provide}
510     do
511     virtuals_add "${i}" "${pcat}/${pname}"
512     done
513   fi   fi
514  }  }
515    
# Line 523  remove_database_entry() Line 528  remove_database_entry()
528   local magefile   local magefile
529   local dbrecorddir   local dbrecorddir
530   local provide   local provide
531     local i
532    
533   # very basic getops   # very basic getops
534   for i in $*   for i in $*
# Line 552  remove_database_entry() Line 558  remove_database_entry()
558   # abort if mage file not exists   # abort if mage file not exists
559   [ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist."   [ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist."
560    
561   # first unregister virtuals   # remove virtuals only if no other exist
562   provide="$(get_value_from_magefile PROVIDE ${magefile})"   if [[ $(count_installed_pkgs --pcat ${pcat} --pname ${pname}) -le 1 ]]
  if [ -n "${provide}" ]  
563   then   then
564   virtuals_del "${provide}" "${pcat}/${pname}"   # first unregister virtuals
565     provide="$(get_value_from_magefile PROVIDE ${magefile})"
566     if [ -n "${provide}" ]
567     then
568     for i in ${provide}
569     do
570     virtuals_del "${i}" "${pcat}/${pname}"
571     done
572     fi
573   fi   fi
574    
575   # removes database entry   # removes database entry
# Line 566  remove_database_entry() Line 579  remove_database_entry()
579   fi   fi
580  }  }
581    
582    # get the number of installed packages
583    count_installed_pkgs()
584    {
585     local pcat
586     local pname
587     local pkg
588     local i
589    
590     # very basic getops
591     for i in $*
592     do
593     case $1 in
594     --pcat|-c) shift; pcat="$1" ;;
595     --pname|-n) shift; pname="$1" ;;
596     esac
597     shift
598     done
599    
600     # sanity checks; abort if not given
601     [ -z "${pcat}" ] && die "pkg_count() \$pcat not given."
602     [ -z "${pname}" ] && die "pkg_count() \$pname not given."
603    
604     declare -i i=0
605     for pkg in $(get_uninstall_candidates --pcat ${pcat} --pname ${pname})
606     do
607     (( i++ ))
608     #echo "$i ${pkg}"
609     done
610    
611     # return the value
612     echo "${i}"
613    }
614    
615    
616  ###################################################  ###################################################
617  # function compare_mtime                          #  # function compare_mtime                          #
# Line 744  remove_files() Line 790  remove_files()
790   do   do
791   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
792    
793   if [ -e "${MROOT}${pathto}" ]   if [ ! -e "${MROOT}${pathto}" ]
794   then   then
795   [[ ${VERBOSE} = on ]] && \   [[ ${VERBOSE} = on ]] && \
796   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"
# Line 758  remove_files() Line 804  remove_files()
804   # 1=keep me   #   # 1=keep me   #
805   case ${retval} in   case ${retval} in
806   0)   0)
807   [[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}"   # check if the file is config_protected
808   rm "${MROOT}${pathto}"   # ${MROOT} will automatically added if set !!
809   ;;   is_config_protected "${pathto}"
810     retval="$?"
811    
812     # 0 - not protected        #
813     # 1 - error                #
814     # 2 - protected            #
815     # 3 - protected but masked #
816    
817     case ${retval} in
818     # file is not protected - delete it
819     0|3)
820     [[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}"
821     rm "${MROOT}${pathto}"
822     ;;
823    
824     # file is protected, do not delete
825     2)
826     if [[ ${VERBOSE} = on ]]
827     then
828     echo -en "${COLRED}"
829     echo -n "! prot "
830     echo -en "${COLDEFAULT}"
831     echo " === FILE: ${MROOT}${pathto}"
832     fi
833     ;;
834     esac
835     ;;
836   1)   1)
837   [[ ${VERBOSE} = on ]] && \   [[ ${VERBOSE} = on ]] && \
838   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"
# Line 932  remove_directories() Line 1003  remove_directories()
1003    
1004   [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.char ] && die "remove_directories() .dirs not found"   [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.char ] && die "remove_directories() .dirs not found"
1005    
  # uninstall of dirs ## added small hack to fix dirs  
  # must be reverse -> smage2 doesn't sort them  
  # -> using tac  
   
1006   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
1007   IFS=§   IFS=§
1008    
1009   while read pathto posix   # reversed order is mandatory !
1010     tac ${MROOT}${INSTALLDB}/${pfull}/.dirs | while read pathto posix
1011   do   do
1012   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1013    
# Line 954  remove_directories() Line 1022  remove_directories()
1022   if [ -f "${MROOT}${pathto}/.keep" ]   if [ -f "${MROOT}${pathto}/.keep" ]
1023   then   then
1024   [[ ${VERBOSE} = on ]] && \   [[ ${VERBOSE} = on ]] && \
1025   echo -e "${COLRED}  .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1026   continue   continue
1027   fi   fi
1028    
# Line 971  remove_directories() Line 1039  remove_directories()
1039   [[ ${VERBOSE} = on ]] && \   [[ ${VERBOSE} = on ]] && \
1040   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1041   fi   fi
1042   done < ${MROOT}${INSTALLDB}/${pfull}/.dirs   done
1043    
1044   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
1045   IFS=$'\n'   IFS=$'\n'
# Line 1090  fetch_packages() Line 1158  fetch_packages()
1158   --continue \   --continue \
1159   --progress bar \   --progress bar \
1160   --directory-prefix=${PKGDIR} \   --directory-prefix=${PKGDIR} \
1161   ${opt} ${mirr}/packages/${pkg}   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}
1162   if [[ $? = 0 ]]   if [[ $? = 0 ]]
1163   then   then
1164   break   break
# Line 1222  check_stable_package() Line 1290  check_stable_package()
1290   STATE="$(get_value_from_magefile STATE "$1")"   STATE="$(get_value_from_magefile STATE "$1")"
1291    
1292   # state testing   # state testing
1293   if [[ ${USE_TESTING} = true ]]   if [[ ${USE_TESTING} = true ]] || [[ ${MAGE_DISTRIBUTION} = testing ]]
1294   then   then
1295   case ${STATE} in   case ${STATE} in
1296   testing|stable) return 0 ;;   testing|stable) return 0 ;;
# Line 1231  check_stable_package() Line 1299  check_stable_package()
1299   fi   fi
1300    
1301   # state unstable   # state unstable
1302   if [[ ${USE_UNSTABLE} = true ]]   if [[ ${USE_UNSTABLE} = true ]] || [[ ${MAGE_DISTRIBUTION} = unstable ]]
1303   then   then
1304   case ${STATE} in   case ${STATE} in
1305   unstable|testing|stable) return 0 ;;   unstable|testing|stable) return 0 ;;
# Line 1400  get_uninstall_candidates() Line 1468  get_uninstall_candidates()
1468   shift   shift
1469   done   done
1470    
1471   # sanity checks; abort if not given  # it's not good to complain here about empty pnames; better to continue later anyway
1472   [ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given."  # # sanity checks; abort if not given
1473    # [ -z "${search_pname}" ] && die "get_uninstall_candidates() \$search_pname not given."
1474    
1475    
1476   # check needed global vars   # check needed global vars
1477   [ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set."   [ -z "${INSTALLDB}" ] && die "get_uninstall_candidates() \$INSTALLDB not set."
1478    
1479   # set pcatdir to '*' if empty   # set pcatdir to '*' if empty
1480   [ -z "${pcatdir}" ] && pcatdir=*   [ -z "${pcatdir}" ] && pcatdir='*'
1481    
1482   for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/*   for pkg in ${MROOT}${INSTALLDB}/${pcatdir}/*
1483   do   do
# Line 1493  virtuals_add() Line 1562  virtuals_add()
1562   local oldline   local oldline
1563   local line i   local line i
1564   local installed_file   local installed_file
1565     local OLDIFS
1566    
1567   if virtuals_read ${virtualname}   if virtuals_read ${virtualname}
1568   then   then
1569   # make shure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already   # make sure ${PKG_NAME} is *not* in ${VIRTUAL_NAME} already
1570   for i in $(virtuals_read ${virtualname} showpkgs)   for i in $(virtuals_read ${virtualname} showpkgs)
1571   do   do
1572   if [[ ${i} = ${pkgname} ]]   if [[ ${i} = ${pkgname} ]]
# Line 1515  virtuals_add() Line 1585  virtuals_add()
1585   # make a backup   # make a backup
1586   mv ${MROOT}${VIRTUALDB_FILE} ${MROOT}${VIRTUALDB_FILE}.old   mv ${MROOT}${VIRTUALDB_FILE} ${MROOT}${VIRTUALDB_FILE}.old
1587    
1588     OLDIFS="${IFS}"
1589   IFS=$'\n'   IFS=$'\n'
1590   for line in $(< ${MROOT}${VIRTUALDB_FILE}.old)   for line in $(< ${MROOT}${VIRTUALDB_FILE}.old)
1591   do   do
# Line 1526  virtuals_add() Line 1597  virtuals_add()
1597   echo "${line}" >> ${MROOT}${VIRTUALDB_FILE}   echo "${line}" >> ${MROOT}${VIRTUALDB_FILE}
1598   fi   fi
1599   done   done
1600     # unset IFS
1601   #unset IFS   IFS="${OLDIFS}"
1602   else   else
1603   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} >>> ${COLDEFAULT}"
1604   echo "register ${pkgname} as ${virtualname} ..."   echo "register ${pkgname} as ${virtualname} ..."
1605   echo "${virtualname} ${pkgname}" >> ${MROOT}${VIRTUALDB_FILE}   echo "${virtualname} ${pkgname}" >> ${MROOT}${VIRTUALDB_FILE}
1606   fi   fi
# Line 1541  virtuals_add() Line 1612  virtuals_add()
1612  #$1 virtualname; $2 pkgname  #$1 virtualname; $2 pkgname
1613  virtuals_del() {  virtuals_del() {
1614    
1615   local VIRTUAL_NAME PKG_NAME OLD_LINE METHOD line i x PKG_INSTALLED   local virtualname="$1"
1616     local pkgname="$2"
1617   VIRTUAL_NAME=$1   local oldline
1618   PKG_NAME=$2   local method
1619     local line i x
1620   #first check if exists   local pkg_installed
1621   if virtuals_read ${VIRTUAL_NAME}   local OLDIFS
1622    
1623     # first check if exists
1624     if virtuals_read ${virtualname}
1625   then   then
1626   #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}
1627   declare -i x=0   declare -i x=0
1628   for i in $(virtuals_read ${VIRTUAL_NAME} showpkgs)   for i in $(virtuals_read ${virtualname} showpkgs)
1629   do   do
1630   if [ "${i}" == "${PKG_NAME}" ]   if [[ ${i} = ${pkgname} ]]
1631   then   then
1632   PKG_INSTALLED=true   pkg_installed=true
1633   fi   fi
1634   ((x++))   ((x++))
1635   done   done
1636    
1637   #abort if not installed   # abort if not installed
1638   if [ "${PKG_INSTALLED}" != "true" ]   if [[ ${pkg_installed} != true ]]
1639   then   then
1640   echo "!!!! ${PKG_NAME} does not exists in ${VIRTUAL_NAME}."   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1641     echo "${pkgname} does not exists in ${virtualname}."
1642   return 0   return 0
1643   fi   fi
1644    
1645   if [ ${x} -ge 2 ]   if [ ${x} -ge 2 ]
1646   then   then
1647   METHOD=update   method=update
1648   else   else
1649   METHOD=delall   method=delall
1650   fi   fi
1651    
1652   #get the complete line   # get the complete line
1653   OLD_LINE="$(virtuals_read ${VIRTUAL_NAME} showline)"   oldline="$(virtuals_read ${virtualname} showline)"
1654    
1655   #make a backup   # make a backup of the db
1656   mv ${VIRTUALDB_FILE} ${VIRTUALDB_FILE}.old   mv ${VIRTUALDB_FILE} ${VIRTUALDB_FILE}.old
1657    
1658   #parse virtualdb   # parse virtualdb
1659     OLDIFS="${IFS}"
1660   IFS=$'\n'   IFS=$'\n'
1661   for line in $(< ${VIRTUALDB_FILE}.old)   for line in $(< ${VIRTUALDB_FILE}.old)
1662   do   do
1663   if [ "${line}" == "${OLD_LINE}" ]   if [[ ${line} = ${oldline} ]]
1664   then   then
1665   #delall or update?   #delall or update?
1666   case ${METHOD} in   case ${method} in
1667   update)   update)
1668   echo "<<<< Unlinking ${PKG_NAME} from ${VIRTUAL_NAME} in virtual database ..."   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
1669   #del PKG_NAME from line   echo "Unlinking ${pkgname} from ${virtualname} in virtual database ..."
1670   echo "${line/ ${PKG_NAME}/}" >> ${VIRTUALDB_FILE}   # del PKG_NAME from line
1671     echo "${line/ ${pkgname}/}" >> ${VIRTUALDB_FILE}
1672   ;;   ;;
1673   delall)   delall)
1674   echo "<<<< Deleting ${VIRTUAL_NAME} in virtual database ..."   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"
1675   #continue; do not write anything   echo "Deleting ${virtualname} in virtual database ..."
1676     # continue; do not write anything
1677   continue   continue
1678   ;;   ;;
1679   esac   esac
# Line 1603  virtuals_del() { Line 1681  virtuals_del() {
1681   echo "${line}" >> ${VIRTUALDB_FILE}   echo "${line}" >> ${VIRTUALDB_FILE}
1682   fi   fi
1683   done   done
1684   unset IFS   # unset IFS
1685     IFS="${OLDIFS}"
1686   else   else
1687   echo "!!!! ${VIRTUAL_NAME} does not exists in virtual database."   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1688     echo "${virtualname} does not exists in virtual database."
1689   fi   fi
1690  }  }
1691    
# Line 1670  is_newer_mage_version_available() Line 1750  is_newer_mage_version_available()
1750   local newest_mage   local newest_mage
1751   local installed_mage   local installed_mage
1752    
1753   newest_mage="$( CATEGORIE=app-mage MAGENAME=mage get_highest_magefile;echo $(basename ${MAGEFILE} .mage) )"   newest_mage="$(basename $(get_highest_magefile app-mage mage) .mage)"
1754   installed_mage="$(magequery -n mage | cut -d' ' -f5)"   installed_mage="$(magequery -n mage | cut -d' ' -f5)"
1755    
1756   if [[ ${newest_mage} > ${installed_mage} ]]   if [[ ${newest_mage} > ${installed_mage} ]]
# Line 1963  get_value_from_magefile() Line 2043  get_value_from_magefile()
2043   local PKGTYPE   local PKGTYPE
2044   local preinstall   local preinstall
2045   local postinstall   local postinstall
2046     local preremove
2047     local postremove
2048    
2049   # sanity checks   # sanity checks
2050   [ -f ${magefile} ] && source ${magefile} || \   [ -f ${magefile} ] && source ${magefile} || \
# Line 1972  get_value_from_magefile() Line 2054  get_value_from_magefile()
2054   source ${magefile}   source ${magefile}
2055   eval value=\$$(echo ${var})   eval value=\$$(echo ${var})
2056   echo "${value}"   echo "${value}"
2057    
2058     # unset these functions
2059     unset -f preinstall
2060     unset -f postinstall
2061     unset -f preremove
2062     unset -f postremove
2063  }  }
2064    
2065  mage_install()  mage_install()
# Line 1988  mage_install() Line 2076  mage_install()
2076   local PKGTYPE   local PKGTYPE
2077   local preinstall   local preinstall
2078   local postinstall   local postinstall
2079     local preremove
2080     local postremove
2081    
2082   local pcat   local pcat
2083   local pname   local pname
# Line 2149  mage_install() Line 2239  mage_install()
2239  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2240  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "
2241   echo "successfully installed."   echo "successfully installed."
2242    
2243     # unset these functions
2244     unset -f preinstall
2245     unset -f postinstall
2246     unset -f preremove
2247     unset -f postremove
2248  }  }
2249    
2250  md5sum_packages()  md5sum_packages()
# Line 2253  uninstall_packages() Line 2349  uninstall_packages()
2349   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2350   echo "following candidate(s) will be removed:"   echo "following candidate(s) will be removed:"
2351   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2352   echo -ne "\033[1m${can_pcat}/${can_pname}:${COLDEFAULT}"   echo -ne "${COLBOLD}${can_pcat}/${can_pname}:${COLDEFAULT}"
2353   echo -e "${COLRED} ${can_ver_list} ${COLDEFAULT}"   echo -e "${COLRED} ${can_ver_list} ${COLDEFAULT}"
2354   echo   echo
2355   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   if [ ${MAGE_UNINSTALL_TIMEOUT} -gt 0 ]
2356   echo "( Press [CTRL+C] to abort )"   then
2357   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2358   echo -n "Waiting ${MAGE_UNINSTALL_TIMEOUT} seconds ..."   echo "( Press [CTRL+C] to abort )"
2359   for ((i=MAGE_UNINSTALL_TIMEOUT; i >= 0; i--))   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2360   do   echo -n "Waiting ${MAGE_UNINSTALL_TIMEOUT} seconds ..."
2361   echo -ne "${COLRED} ${i}${COLDEFAULT}"   for ((i=MAGE_UNINSTALL_TIMEOUT; i >= 0; i--))
2362   sleep 1   do
2363   done   echo -ne "${COLRED} ${i}${COLDEFAULT}"
2364   echo   sleep 1
2365   echo   done
2366     echo
2367     echo
2368     fi
2369    
2370   for pkg in ${list}   for pkg in ${list}
2371   do   do
# Line 2304  mage_uninstall() Line 2403  mage_uninstall()
2403   local PKGTYPE   local PKGTYPE
2404   local preinstall   local preinstall
2405   local postinstall   local postinstall
2406     local preremove
2407     local postremove
2408    
2409   local pcat   local pcat
2410   local pname   local pname
# Line 2341  mage_uninstall() Line 2442  mage_uninstall()
2442   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2443   echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"   echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"
2444    
2445   magefile="${MAGEDIR}/${pcat}/${pname}/${pname}-${pver}-${pbuild}.mage"   magefile="${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
2446   source ${magefile}   source ${magefile}
2447    
2448   ## preremove scripts   ## preremove scripts
# Line 2401  mage_uninstall() Line 2502  mage_uninstall()
2502  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2503  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "
2504   echo "successfully removed."   echo "successfully removed."
2505    
2506     # unset these functions
2507     unset -f preinstall
2508     unset -f postinstall
2509     unset -f preremove
2510     unset -f postremove
2511  }  }
2512    
2513  show_etc_update_mesg() {  show_etc_update_mesg() {
# Line 2415  show_etc_update_mesg() { Line 2522  show_etc_update_mesg() {
2522   echo "Please run 'etc-update' to update your configuration files."   echo "Please run 'etc-update' to update your configuration files."
2523   echo   echo
2524  }  }
2525    
2526    pkgsearch()
2527    {
2528     local string="$1"
2529     local result
2530     local pkg
2531     local pcat
2532     local pname
2533     local magefile
2534     local pver
2535     local pbuild
2536     local state
2537     local descriptiom
2538     local homepage
2539     local i
2540     local all_installed
2541     local ipver
2542     local ipbuild
2543    
2544     # only names no versions
2545     result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name '*'${string}'*')"
2546     #result="$(find ${MAGEDIR} -type f -name '*'${string}'*'.mage | sort)"
2547    
2548     # nothing found
2549     [[ -z ${result} ]] && die "No package found containing '${string}' in the name."
2550    
2551     for pkg in ${result}
2552     do
2553     # dirty, but does the job
2554     pcat="$(magename2pcat ${pkg}/foo)"
2555     pname="$(magename2pname ${pkg}-foo-foo)"
2556    
2557     # get highest version available
2558     magefile=$(get_highest_magefile ${pcat} ${pname})
2559    
2560     # now get all needed infos to print a nice output
2561     pver="$(magename2pver ${magefile})"
2562     pbuild="$(magename2pbuild ${magefile})"
2563     state="$(get_value_from_magefile STATE ${magefile})"
2564     description="$(get_value_from_magefile DESCRIPTION ${magefile})"
2565     homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
2566    
2567     # all installed
2568     for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
2569     do
2570     ipver="$(magename2pver ${i})"
2571     ipbuild="$(magename2pbuild ${i})"
2572    
2573     if [[ -z ${all_installed} ]]
2574     then
2575     all_installed="${ipver}-${ipbuild}"
2576     else
2577     all_installed="${all_installed} ${ipver}-${ipbuild}"
2578     fi
2579     done
2580     [[ -z ${all_installed} ]] && all_installed="none"
2581    
2582     case ${state} in
2583     stable) state=${COLGREEN}"[s] ";;
2584     testing) state=${COLYELLOW}"[t] ";;
2585     unstable) state=${COLRED}"[u] ";;
2586     old) state=${COLGRAY}"[o] ";;
2587     esac
2588    
2589     echo -e "${state}${pcat}/${pname}"${COLDEFAULT}
2590     echo "      Latest available:   ${pver}-${pbuild}"
2591     echo "      Installed versions: ${all_installed}"
2592     echo "      Description: ${description}"
2593     echo "      Homepage: ${homepage}"
2594     echo
2595    
2596     unset pcat
2597     unset pname
2598     unset magefile
2599     unset pver
2600     unset pbuild
2601     unset state
2602     unset descriptiom
2603     unset homepage
2604     unset all_installed
2605     unset ipver
2606     unset ipbuild
2607     done
2608    }
2609    
2610    export_inherits()
2611    {
2612     local include="$1"
2613     shift
2614    
2615     while [ "$1" ]
2616     do
2617     local functions="$1"
2618    
2619     # sanity checks
2620     [ -z "${include}" ] && die "export_inherits(): \$include not given."
2621     [ -z "${functions}" ] && die "export_inherits(): \$functions not given."
2622    
2623     eval "${functions}() { ${include}_${functions} ; }"
2624    
2625     # debug
2626     [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"
2627    
2628     shift
2629     done
2630    }

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