Magellan Linux

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

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

revision 240 by niro, Sun Sep 11 19:47:08 2005 UTC revision 273 by niro, Fri Oct 21 14:50:13 2005 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.3 2005-09-11 19:47:08 niro Exp $  # $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 $
4    
5  mage_setup()  mage_setup()
6  {  {
# Line 432  install_database_entry() Line 432  install_database_entry()
432   local magefile   local magefile
433   local dbrecorddir   local dbrecorddir
434   local provide   local provide
435     local i
436    
437   # very basic getops   # very basic getops
438   for i in $*   for i in $*
# Line 473  install_database_entry() Line 474  install_database_entry()
474    
475   # create fake file descriptors   # create fake file descriptors
476   # used by virtual and source packages   # used by virtual and source packages
  local i  
477   for i in .dirs .symlinks .files .pipes .char   for i in .dirs .symlinks .files .pipes .char
478   do   do
479   touch ${dbrecorddir}/${i}   touch ${dbrecorddir}/${i}
# Line 504  install_database_entry() Line 504  install_database_entry()
504   provide="$(get_value_from_magefile PROVIDE ${magefile})"   provide="$(get_value_from_magefile PROVIDE ${magefile})"
505   if [ -n "${provide}" ]   if [ -n "${provide}" ]
506   then   then
507   virtuals_add "${provide}" "${pcat}/${pname}"   for i in ${provide}
508     do
509     virtuals_add "${i}" "${pcat}/${pname}"
510     done
511   fi   fi
512  }  }
513    
# Line 523  remove_database_entry() Line 526  remove_database_entry()
526   local magefile   local magefile
527   local dbrecorddir   local dbrecorddir
528   local provide   local provide
529     local i
530    
531   # very basic getops   # very basic getops
532   for i in $*   for i in $*
# Line 556  remove_database_entry() Line 560  remove_database_entry()
560   provide="$(get_value_from_magefile PROVIDE ${magefile})"   provide="$(get_value_from_magefile PROVIDE ${magefile})"
561   if [ -n "${provide}" ]   if [ -n "${provide}" ]
562   then   then
563   virtuals_del "${provide}" "${pcat}/${pname}"   for i in ${provide}
564     do
565     virtuals_del "${i}" "${pcat}/${pname}"
566     done
567   fi   fi
568    
569   # removes database entry   # removes database entry
# Line 1490  virtuals_add() Line 1497  virtuals_add()
1497   local oldline   local oldline
1498   local line i   local line i
1499   local installed_file   local installed_file
1500     local OLDIFS
1501    
1502   if virtuals_read ${virtualname}   if virtuals_read ${virtualname}
1503   then   then
# Line 1512  virtuals_add() Line 1520  virtuals_add()
1520   # make a backup   # make a backup
1521   mv ${MROOT}${VIRTUALDB_FILE} ${MROOT}${VIRTUALDB_FILE}.old   mv ${MROOT}${VIRTUALDB_FILE} ${MROOT}${VIRTUALDB_FILE}.old
1522    
1523     OLDIFS="${IFS}"
1524   IFS=$'\n'   IFS=$'\n'
1525   for line in $(< ${MROOT}${VIRTUALDB_FILE}.old)   for line in $(< ${MROOT}${VIRTUALDB_FILE}.old)
1526   do   do
# Line 1523  virtuals_add() Line 1532  virtuals_add()
1532   echo "${line}" >> ${MROOT}${VIRTUALDB_FILE}   echo "${line}" >> ${MROOT}${VIRTUALDB_FILE}
1533   fi   fi
1534   done   done
1535     # unset IFS
1536   #unset IFS   IFS="${OLDIFS}"
1537   else   else
1538   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} >>> ${COLDEFAULT}"
1539   echo "register ${pkgname} as ${virtualname} ..."   echo "register ${pkgname} as ${virtualname} ..."
1540   echo "${virtualname} ${pkgname}" >> ${MROOT}${VIRTUALDB_FILE}   echo "${virtualname} ${pkgname}" >> ${MROOT}${VIRTUALDB_FILE}
1541   fi   fi
# Line 1538  virtuals_add() Line 1547  virtuals_add()
1547  #$1 virtualname; $2 pkgname  #$1 virtualname; $2 pkgname
1548  virtuals_del() {  virtuals_del() {
1549    
1550   local VIRTUAL_NAME PKG_NAME OLD_LINE METHOD line i x PKG_INSTALLED   local virtualname="$1"
1551     local pkgname="$2"
1552   VIRTUAL_NAME=$1   local oldline
1553   PKG_NAME=$2   local method
1554     local line i x
1555   #first check if exists   local pkg_installed
1556   if virtuals_read ${VIRTUAL_NAME}   local OLDIFS
1557    
1558     # first check if exists
1559     if virtuals_read ${virtualname}
1560   then   then
1561   #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}
1562   declare -i x=0   declare -i x=0
1563   for i in $(virtuals_read ${VIRTUAL_NAME} showpkgs)   for i in $(virtuals_read ${virtualname} showpkgs)
1564   do   do
1565   if [ "${i}" == "${PKG_NAME}" ]   if [[ ${i} = ${pkgname} ]]
1566   then   then
1567   PKG_INSTALLED=true   pkg_installed=true
1568   fi   fi
1569   ((x++))   ((x++))
1570   done   done
1571    
1572   #abort if not installed   # abort if not installed
1573   if [ "${PKG_INSTALLED}" != "true" ]   if [[ ${pkg_installed} != true ]]
1574   then   then
1575   echo "!!!! ${PKG_NAME} does not exists in ${VIRTUAL_NAME}."   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1576     echo "${pkgname} does not exists in ${virtualname}."
1577   return 0   return 0
1578   fi   fi
1579    
1580   if [ ${x} -ge 2 ]   if [ ${x} -ge 2 ]
1581   then   then
1582   METHOD=update   method=update
1583   else   else
1584   METHOD=delall   method=delall
1585   fi   fi
1586    
1587   #get the complete line   # get the complete line
1588   OLD_LINE="$(virtuals_read ${VIRTUAL_NAME} showline)"   oldline="$(virtuals_read ${virtualname} showline)"
1589    
1590   #make a backup   # make a backup of the db
1591   mv ${VIRTUALDB_FILE} ${VIRTUALDB_FILE}.old   mv ${VIRTUALDB_FILE} ${VIRTUALDB_FILE}.old
1592    
1593   #parse virtualdb   # parse virtualdb
1594     OLDIFS="${IFS}"
1595   IFS=$'\n'   IFS=$'\n'
1596   for line in $(< ${VIRTUALDB_FILE}.old)   for line in $(< ${VIRTUALDB_FILE}.old)
1597   do   do
1598   if [ "${line}" == "${OLD_LINE}" ]   if [[ ${line} = ${oldline} ]]
1599   then   then
1600   #delall or update?   #delall or update?
1601   case ${METHOD} in   case ${method} in
1602   update)   update)
1603   echo "<<<< Unlinking ${PKG_NAME} from ${VIRTUAL_NAME} in virtual database ..."   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
1604   #del PKG_NAME from line   echo "Unlinking ${pkgname} from ${virtualname} in virtual database ..."
1605   echo "${line/ ${PKG_NAME}/}" >> ${VIRTUALDB_FILE}   # del PKG_NAME from line
1606     echo "${line/ ${pkgname}/}" >> ${VIRTUALDB_FILE}
1607   ;;   ;;
1608   delall)   delall)
1609   echo "<<<< Deleting ${VIRTUAL_NAME} in virtual database ..."   echo -ne "${COLBLUE} <<< ${COLDEFAULT}"
1610   #continue; do not write anything   echo "Deleting ${virtualname} in virtual database ..."
1611     # continue; do not write anything
1612   continue   continue
1613   ;;   ;;
1614   esac   esac
# Line 1600  virtuals_del() { Line 1616  virtuals_del() {
1616   echo "${line}" >> ${VIRTUALDB_FILE}   echo "${line}" >> ${VIRTUALDB_FILE}
1617   fi   fi
1618   done   done
1619   unset IFS   # unset IFS
1620     IFS="${OLDIFS}"
1621   else   else
1622   echo "!!!! ${VIRTUAL_NAME} does not exists in virtual database."   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1623     echo "${virtualname} does not exists in virtual database."
1624   fi   fi
1625  }  }
1626    
# Line 1667  is_newer_mage_version_available() Line 1685  is_newer_mage_version_available()
1685   local newest_mage   local newest_mage
1686   local installed_mage   local installed_mage
1687    
1688   newest_mage="$( CATEGORIE=app-mage MAGENAME=mage get_highest_magefile;echo $(basename ${MAGEFILE} .mage) )"   newest_mage="$(basename $(get_highest_magefile app-mage mage) .mage)"
1689   installed_mage="$(magequery -n mage | cut -d' ' -f5)"   installed_mage="$(magequery -n mage | cut -d' ' -f5)"
1690    
1691   if [[ ${newest_mage} > ${installed_mage} ]]   if [[ ${newest_mage} > ${installed_mage} ]]
# Line 1960  get_value_from_magefile() Line 1978  get_value_from_magefile()
1978   local PKGTYPE   local PKGTYPE
1979   local preinstall   local preinstall
1980   local postinstall   local postinstall
1981     local preremove
1982     local postremove
1983    
1984   # sanity checks   # sanity checks
1985   [ -f ${magefile} ] && source ${magefile} || \   [ -f ${magefile} ] && source ${magefile} || \
# Line 1969  get_value_from_magefile() Line 1989  get_value_from_magefile()
1989   source ${magefile}   source ${magefile}
1990   eval value=\$$(echo ${var})   eval value=\$$(echo ${var})
1991   echo "${value}"   echo "${value}"
1992    
1993     # unset these functions
1994     unset -f preinstall
1995     unset -f postinstall
1996     unset -f preremove
1997     unset -f postremove
1998  }  }
1999    
2000  mage_install()  mage_install()
# Line 1985  mage_install() Line 2011  mage_install()
2011   local PKGTYPE   local PKGTYPE
2012   local preinstall   local preinstall
2013   local postinstall   local postinstall
2014     local preremove
2015     local postremove
2016    
2017   local pcat   local pcat
2018   local pname   local pname
# Line 2146  mage_install() Line 2174  mage_install()
2174  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2175  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "
2176   echo "successfully installed."   echo "successfully installed."
2177    
2178     # unset these functions
2179     unset -f preinstall
2180     unset -f postinstall
2181     unset -f preremove
2182     unset -f postremove
2183  }  }
2184    
2185  md5sum_packages()  md5sum_packages()
# Line 2304  mage_uninstall() Line 2338  mage_uninstall()
2338   local PKGTYPE   local PKGTYPE
2339   local preinstall   local preinstall
2340   local postinstall   local postinstall
2341     local preremove
2342     local postremove
2343    
2344   local pcat   local pcat
2345   local pname   local pname
# Line 2401  mage_uninstall() Line 2437  mage_uninstall()
2437  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2438  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "
2439   echo "successfully removed."   echo "successfully removed."
2440    
2441     # unset these functions
2442     unset -f preinstall
2443     unset -f postinstall
2444     unset -f preremove
2445     unset -f postremove
2446  }  }
2447    
2448  show_etc_update_mesg() {  show_etc_update_mesg() {
# Line 2499  pkgsearch() Line 2541  pkgsearch()
2541   unset ipbuild   unset ipbuild
2542   done   done
2543  }  }
2544    
2545    export_inherits()
2546    {
2547     local include="$1"
2548     shift
2549    
2550     while [ "$1" ]
2551     do
2552     local functions="$1"
2553    
2554     # sanity checks
2555     [ -z "${include}" ] && die "export_inherits(): \$include not given."
2556     [ -z "${functions}" ] && die "export_inherits(): \$functions not given."
2557    
2558     eval "${functions}() { ${include}_${functions} ; }"
2559    
2560     # debug
2561     [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"
2562    
2563     shift
2564     done
2565    }

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