Magellan Linux

Diff of /branches/mage-next/src/mage4.functions.sh.in

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

revision 226 by niro, Fri Sep 9 16:35:46 2005 UTC revision 249 by niro, Sun Oct 2 12:20: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.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.5 2005-10-02 12:20:13 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 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 preinstall
1976     unset postinstall
1977     unset preremove
1978     unset postremove
1979  }  }
1980    
1981  mage_install()  mage_install()
# Line 1988  mage_install() Line 1992  mage_install()
1992   local PKGTYPE   local PKGTYPE
1993   local preinstall   local preinstall
1994   local postinstall   local postinstall
1995     local preremove
1996     local postremove
1997    
1998   local pcat   local pcat
1999   local pname   local pname
# Line 2149  mage_install() Line 2155  mage_install()
2155  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2156  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "
2157   echo "successfully installed."   echo "successfully installed."
2158    
2159     unset preinstall
2160     unset postinstall
2161     unset preremove
2162     unset postremove
2163  }  }
2164    
2165  md5sum_packages()  md5sum_packages()
# Line 2253  uninstall_packages() Line 2264  uninstall_packages()
2264   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2265   echo "following candidate(s) will be removed:"   echo "following candidate(s) will be removed:"
2266   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2267   echo -ne "\033[1m${can_pcat}/${can_pname}:${COLDEFAULT}"   echo -ne "${COLBOLD}${can_pcat}/${can_pname}:${COLDEFAULT}"
2268   echo -e "${COLRED} ${can_ver_list} ${COLDEFAULT}"   echo -e "${COLRED} ${can_ver_list} ${COLDEFAULT}"
2269   echo   echo
2270   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   if [ ${MAGE_UNINSTALL_TIMEOUT} -gt 0 ]
2271   echo "( Press [CTRL+C] to abort )"   then
2272   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2273   echo -n "Waiting ${MAGE_UNINSTALL_TIMEOUT} seconds ..."   echo "( Press [CTRL+C] to abort )"
2274   for ((i=MAGE_UNINSTALL_TIMEOUT; i >= 0; i--))   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2275   do   echo -n "Waiting ${MAGE_UNINSTALL_TIMEOUT} seconds ..."
2276   echo -ne "${COLRED} ${i}${COLDEFAULT}"   for ((i=MAGE_UNINSTALL_TIMEOUT; i >= 0; i--))
2277   sleep 1   do
2278   done   echo -ne "${COLRED} ${i}${COLDEFAULT}"
2279   echo   sleep 1
2280   echo   done
2281     echo
2282     echo
2283     fi
2284    
2285   for pkg in ${list}   for pkg in ${list}
2286   do   do
# Line 2304  mage_uninstall() Line 2318  mage_uninstall()
2318   local PKGTYPE   local PKGTYPE
2319   local preinstall   local preinstall
2320   local postinstall   local postinstall
2321     local preremove
2322     local postremove
2323    
2324   local pcat   local pcat
2325   local pname   local pname
# Line 2341  mage_uninstall() Line 2357  mage_uninstall()
2357   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2358   echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"   echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"
2359    
2360   magefile="${MAGEDIR}/${pcat}/${pname}/${pname}-${pver}-${pbuild}.mage"   magefile="${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
2361   source ${magefile}   source ${magefile}
2362    
2363   ## preremove scripts   ## preremove scripts
# Line 2401  mage_uninstall() Line 2417  mage_uninstall()
2417  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"  # echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2418  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "  # echo -ne "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT} "
2419   echo "successfully removed."   echo "successfully removed."
2420    
2421     unset preinstall
2422     unset postinstall
2423     unset preremove
2424     unset postremove
2425  }  }
2426    
2427  show_etc_update_mesg() {  show_etc_update_mesg() {
# Line 2415  show_etc_update_mesg() { Line 2436  show_etc_update_mesg() {
2436   echo "Please run 'etc-update' to update your configuration files."   echo "Please run 'etc-update' to update your configuration files."
2437   echo   echo
2438  }  }
2439    
2440    pkgsearch()
2441    {
2442     local string="$1"
2443     local result
2444     local pkg
2445     local pcat
2446     local pname
2447     local magefile
2448     local pver
2449     local pbuild
2450     local state
2451     local descriptiom
2452     local homepage
2453     local i
2454     local all_installed
2455     local ipver
2456     local ipbuild
2457    
2458     # only names no versions
2459     result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name *${string}*)"
2460     #result="$(find ${MAGEDIR} -type f -name *${string}*.mage | sort)"
2461    
2462     # nothing found
2463     [[ -z ${result} ]] && die "No package found containing '${string}' in the name."
2464    
2465     for pkg in ${result}
2466     do
2467     # dirty, but does the job
2468     pcat="$(magename2pcat ${pkg}/foo)"
2469     pname="$(magename2pname ${pkg}-foo-foo)"
2470    
2471     # get highest version available
2472     magefile=$(get_highest_magefile ${pcat} ${pname})
2473    
2474     # now get all needed infos to print a nice output
2475     pver="$(magename2pver ${magefile})"
2476     pbuild="$(magename2pbuild ${magefile})"
2477     state="$(get_value_from_magefile STATE ${magefile})"
2478     description="$(get_value_from_magefile DESCRIPTION ${magefile})"
2479     homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
2480    
2481     # all installed
2482     for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
2483     do
2484     ipver="$(magename2pver ${i})"
2485     ipbuild="$(magename2pbuild ${i})"
2486    
2487     if [[ -z ${all_installed} ]]
2488     then
2489     all_installed="${ipver}-${ipbuild}"
2490     else
2491     all_installed="${all_installed} ${ipver}-${ipbuild}"
2492     fi
2493     done
2494     [[ -z ${all_installed} ]] && all_installed="none"
2495    
2496     case ${state} in
2497     stable) state=${COLGREEN}"[s] ";;
2498     testing) state=${COLYELLOW}"[t] ";;
2499     unstable) state=${COLRED}"[u] ";;
2500     old) state=${COLGRAY}"[o] ";;
2501     esac
2502    
2503     echo -e "${state}${pcat}/${pname}"${COLDEFAULT}
2504     echo "      Latest available:   ${pver}-${pbuild}"
2505     echo "      Installed versions: ${all_installed}"
2506     echo "      Description: ${description}"
2507     echo "      Homepage: ${homepage}"
2508     echo
2509    
2510     unset pcat
2511     unset pname
2512     unset magefile
2513     unset pver
2514     unset pbuild
2515     unset state
2516     unset descriptiom
2517     unset homepage
2518     unset all_installed
2519     unset ipver
2520     unset ipbuild
2521     done
2522    }
2523    
2524    export_inherits()
2525    {
2526     local include="$1"
2527     shift
2528    
2529     while [ "$1" ]
2530     do
2531     local functions="$1"
2532    
2533     # sanity checks
2534     [ -z "${include}" ] && die "export_inherits(): \$include not given."
2535     [ -z "${functions}" ] && die "export_inherits(): \$functions not given."
2536    
2537     eval "${functions}() { ${include}_${functions} ; }"
2538    
2539     # debug
2540     [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"
2541    
2542     shift
2543     done
2544    }

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