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 258 by niro, Tue Oct 4 14:35:21 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.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.7 2005-10-04 14:35:21 niro Exp $
4    
5  mage_setup()  mage_setup()
6  {  {
# Line 744  remove_files() Line 744  remove_files()
744   do   do
745   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
746    
747   if [ -e "${MROOT}${pathto}" ]   if [ ! -e "${MROOT}${pathto}" ]
748   then   then
749   [[ ${VERBOSE} = on ]] && \   [[ ${VERBOSE} = on ]] && \
750   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"
# Line 932  remove_directories() Line 932  remove_directories()
932    
933   [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.char ] && die "remove_directories() .dirs not found"   [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.char ] && die "remove_directories() .dirs not found"
934    
  # uninstall of dirs ## added small hack to fix dirs  
  # must be reverse -> smage2 doesn't sort them  
  # -> using tac  
   
935   # sets fieldseperator to "§" instead of " "   # sets fieldseperator to "§" instead of " "
936   IFS=§   IFS=§
937    
938   while read pathto posix   # reversed order is mandatory !
939     tac ${MROOT}${INSTALLDB}/${pfull}/.dirs | while read pathto posix
940   do   do
941   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
942    
# Line 954  remove_directories() Line 951  remove_directories()
951   if [ -f "${MROOT}${pathto}/.keep" ]   if [ -f "${MROOT}${pathto}/.keep" ]
952   then   then
953   [[ ${VERBOSE} = on ]] && \   [[ ${VERBOSE} = on ]] && \
954   echo -e "${COLRED}  .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
955   continue   continue
956   fi   fi
957    
# Line 971  remove_directories() Line 968  remove_directories()
968   [[ ${VERBOSE} = on ]] && \   [[ ${VERBOSE} = on ]] && \
969   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
970   fi   fi
971   done < ${MROOT}${INSTALLDB}/${pfull}/.dirs   done
972    
973   # very important: unsetting the '§' fieldseperator   # very important: unsetting the '§' fieldseperator
974   IFS=$'\n'   IFS=$'\n'
# Line 1670  is_newer_mage_version_available() Line 1667  is_newer_mage_version_available()
1667   local newest_mage   local newest_mage
1668   local installed_mage   local installed_mage
1669    
1670   newest_mage="$( CATEGORIE=app-mage MAGENAME=mage get_highest_magefile;echo $(basename ${MAGEFILE} .mage) )"   newest_mage="$(basename $(get_highest_magefile app-mage mage) .mage)"
1671   installed_mage="$(magequery -n mage | cut -d' ' -f5)"   installed_mage="$(magequery -n mage | cut -d' ' -f5)"
1672    
1673   if [[ ${newest_mage} > ${installed_mage} ]]   if [[ ${newest_mage} > ${installed_mage} ]]
# Line 1963  get_value_from_magefile() Line 1960  get_value_from_magefile()
1960   local PKGTYPE   local PKGTYPE
1961   local preinstall   local preinstall
1962   local postinstall   local postinstall
1963     local preremove
1964     local postremove
1965    
1966   # sanity checks   # sanity checks
1967   [ -f ${magefile} ] && source ${magefile} || \   [ -f ${magefile} ] && source ${magefile} || \
# Line 1972  get_value_from_magefile() Line 1971  get_value_from_magefile()
1971   source ${magefile}   source ${magefile}
1972   eval value=\$$(echo ${var})   eval value=\$$(echo ${var})
1973   echo "${value}"   echo "${value}"
1974    
1975     # unset these functions
1976     unset -f preinstall
1977     unset -f postinstall
1978     unset -f preremove
1979     unset -f postremove
1980  }  }
1981    
1982  mage_install()  mage_install()
# Line 1988  mage_install() Line 1993  mage_install()
1993   local PKGTYPE   local PKGTYPE
1994   local preinstall   local preinstall
1995   local postinstall   local postinstall
1996     local preremove
1997     local postremove
1998    
1999   local pcat   local pcat
2000   local pname   local pname
# Line 2149  mage_install() Line 2156  mage_install()
2156  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2157  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "
2158   echo "successfully installed."   echo "successfully installed."
2159    
2160     # unset these functions
2161     unset -f preinstall
2162     unset -f postinstall
2163     unset -f preremove
2164     unset -f postremove
2165  }  }
2166    
2167  md5sum_packages()  md5sum_packages()
# Line 2253  uninstall_packages() Line 2266  uninstall_packages()
2266   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2267   echo "following candidate(s) will be removed:"   echo "following candidate(s) will be removed:"
2268   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2269   echo -ne "\033[1m${can_pcat}/${can_pname}:${COLDEFAULT}"   echo -ne "${COLBOLD}${can_pcat}/${can_pname}:${COLDEFAULT}"
2270   echo -e "${COLRED} ${can_ver_list} ${COLDEFAULT}"   echo -e "${COLRED} ${can_ver_list} ${COLDEFAULT}"
2271   echo   echo
2272   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   if [ ${MAGE_UNINSTALL_TIMEOUT} -gt 0 ]
2273   echo "( Press [CTRL+C] to abort )"   then
2274   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2275   echo -n "Waiting ${MAGE_UNINSTALL_TIMEOUT} seconds ..."   echo "( Press [CTRL+C] to abort )"
2276   for ((i=MAGE_UNINSTALL_TIMEOUT; i >= 0; i--))   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2277   do   echo -n "Waiting ${MAGE_UNINSTALL_TIMEOUT} seconds ..."
2278   echo -ne "${COLRED} ${i}${COLDEFAULT}"   for ((i=MAGE_UNINSTALL_TIMEOUT; i >= 0; i--))
2279   sleep 1   do
2280   done   echo -ne "${COLRED} ${i}${COLDEFAULT}"
2281   echo   sleep 1
2282   echo   done
2283     echo
2284     echo
2285     fi
2286    
2287   for pkg in ${list}   for pkg in ${list}
2288   do   do
# Line 2304  mage_uninstall() Line 2320  mage_uninstall()
2320   local PKGTYPE   local PKGTYPE
2321   local preinstall   local preinstall
2322   local postinstall   local postinstall
2323     local preremove
2324     local postremove
2325    
2326   local pcat   local pcat
2327   local pname   local pname
# Line 2341  mage_uninstall() Line 2359  mage_uninstall()
2359   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2360   echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"   echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"
2361    
2362   magefile="${MAGEDIR}/${pcat}/${pname}/${pname}-${pver}-${pbuild}.mage"   magefile="${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
2363   source ${magefile}   source ${magefile}
2364    
2365   ## preremove scripts   ## preremove scripts
# Line 2401  mage_uninstall() Line 2419  mage_uninstall()
2419  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2420  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "
2421   echo "successfully removed."   echo "successfully removed."
2422    
2423     # unset these functions
2424     unset -f preinstall
2425     unset -f postinstall
2426     unset -f preremove
2427     unset -f postremove
2428  }  }
2429    
2430  show_etc_update_mesg() {  show_etc_update_mesg() {
# Line 2415  show_etc_update_mesg() { Line 2439  show_etc_update_mesg() {
2439   echo "Please run 'etc-update' to update your configuration files."   echo "Please run 'etc-update' to update your configuration files."
2440   echo   echo
2441  }  }
2442    
2443    pkgsearch()
2444    {
2445     local string="$1"
2446     local result
2447     local pkg
2448     local pcat
2449     local pname
2450     local magefile
2451     local pver
2452     local pbuild
2453     local state
2454     local descriptiom
2455     local homepage
2456     local i
2457     local all_installed
2458     local ipver
2459     local ipbuild
2460    
2461     # only names no versions
2462     result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name *${string}*)"
2463     #result="$(find ${MAGEDIR} -type f -name *${string}*.mage | sort)"
2464    
2465     # nothing found
2466     [[ -z ${result} ]] && die "No package found containing '${string}' in the name."
2467    
2468     for pkg in ${result}
2469     do
2470     # dirty, but does the job
2471     pcat="$(magename2pcat ${pkg}/foo)"
2472     pname="$(magename2pname ${pkg}-foo-foo)"
2473    
2474     # get highest version available
2475     magefile=$(get_highest_magefile ${pcat} ${pname})
2476    
2477     # now get all needed infos to print a nice output
2478     pver="$(magename2pver ${magefile})"
2479     pbuild="$(magename2pbuild ${magefile})"
2480     state="$(get_value_from_magefile STATE ${magefile})"
2481     description="$(get_value_from_magefile DESCRIPTION ${magefile})"
2482     homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
2483    
2484     # all installed
2485     for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
2486     do
2487     ipver="$(magename2pver ${i})"
2488     ipbuild="$(magename2pbuild ${i})"
2489    
2490     if [[ -z ${all_installed} ]]
2491     then
2492     all_installed="${ipver}-${ipbuild}"
2493     else
2494     all_installed="${all_installed} ${ipver}-${ipbuild}"
2495     fi
2496     done
2497     [[ -z ${all_installed} ]] && all_installed="none"
2498    
2499     case ${state} in
2500     stable) state=${COLGREEN}"[s] ";;
2501     testing) state=${COLYELLOW}"[t] ";;
2502     unstable) state=${COLRED}"[u] ";;
2503     old) state=${COLGRAY}"[o] ";;
2504     esac
2505    
2506     echo -e "${state}${pcat}/${pname}"${COLDEFAULT}
2507     echo "      Latest available:   ${pver}-${pbuild}"
2508     echo "      Installed versions: ${all_installed}"
2509     echo "      Description: ${description}"
2510     echo "      Homepage: ${homepage}"
2511     echo
2512    
2513     unset pcat
2514     unset pname
2515     unset magefile
2516     unset pver
2517     unset pbuild
2518     unset state
2519     unset descriptiom
2520     unset homepage
2521     unset all_installed
2522     unset ipver
2523     unset ipbuild
2524     done
2525    }
2526    
2527    export_inherits()
2528    {
2529     local include="$1"
2530     shift
2531    
2532     while [ "$1" ]
2533     do
2534     local functions="$1"
2535    
2536     # sanity checks
2537     [ -z "${include}" ] && die "export_inherits(): \$include not given."
2538     [ -z "${functions}" ] && die "export_inherits(): \$functions not given."
2539    
2540     eval "${functions}() { ${include}_${functions} ; }"
2541    
2542     # debug
2543     [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"
2544    
2545     shift
2546     done
2547    }

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