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 240 by niro, Sun Sep 11 19:47:08 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.3 2005-09-11 19:47:08 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 2253  uninstall_packages() Line 2250  uninstall_packages()
2250   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2251   echo "following candidate(s) will be removed:"   echo "following candidate(s) will be removed:"
2252   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2253   echo -ne "\033[1m${can_pcat}/${can_pname}:${COLDEFAULT}"   echo -ne "${COLBOLD}${can_pcat}/${can_pname}:${COLDEFAULT}"
2254   echo -e "${COLRED} ${can_ver_list} ${COLDEFAULT}"   echo -e "${COLRED} ${can_ver_list} ${COLDEFAULT}"
2255   echo   echo
2256   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   if [ ${MAGE_UNINSTALL_TIMEOUT} -gt 0 ]
2257   echo "( Press [CTRL+C] to abort )"   then
2258   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2259   echo -n "Waiting ${MAGE_UNINSTALL_TIMEOUT} seconds ..."   echo "( Press [CTRL+C] to abort )"
2260   for ((i=MAGE_UNINSTALL_TIMEOUT; i >= 0; i--))   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2261   do   echo -n "Waiting ${MAGE_UNINSTALL_TIMEOUT} seconds ..."
2262   echo -ne "${COLRED} ${i}${COLDEFAULT}"   for ((i=MAGE_UNINSTALL_TIMEOUT; i >= 0; i--))
2263   sleep 1   do
2264   done   echo -ne "${COLRED} ${i}${COLDEFAULT}"
2265   echo   sleep 1
2266   echo   done
2267     echo
2268     echo
2269     fi
2270    
2271   for pkg in ${list}   for pkg in ${list}
2272   do   do
# Line 2341  mage_uninstall() Line 2341  mage_uninstall()
2341   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"   echo -ne "${COLBLUE}${pcat}/${COLDEFAULT}"
2342   echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"   echo -e "${COLGREEN}${pname}-${pver}-${pbuild}${COLDEFAULT}"
2343    
2344   magefile="${MAGEDIR}/${pcat}/${pname}/${pname}-${pver}-${pbuild}.mage"   magefile="${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
2345   source ${magefile}   source ${magefile}
2346    
2347   ## preremove scripts   ## preremove scripts
# Line 2415  show_etc_update_mesg() { Line 2415  show_etc_update_mesg() {
2415   echo "Please run 'etc-update' to update your configuration files."   echo "Please run 'etc-update' to update your configuration files."
2416   echo   echo
2417  }  }
2418    
2419    pkgsearch()
2420    {
2421     local string="$1"
2422     local result
2423     local pkg
2424     local pcat
2425     local pname
2426     local magefile
2427     local pver
2428     local pbuild
2429     local state
2430     local descriptiom
2431     local homepage
2432     local i
2433     local all_installed
2434     local ipver
2435     local ipbuild
2436    
2437     # only names no versions
2438     result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name *${string}*)"
2439     #result="$(find ${MAGEDIR} -type f -name *${string}*.mage | sort)"
2440    
2441     # nothing found
2442     [[ -z ${result} ]] && die "No package found containing '${string}' in the name."
2443    
2444     for pkg in ${result}
2445     do
2446     # dirty, but does the job
2447     pcat="$(magename2pcat ${pkg}/foo)"
2448     pname="$(magename2pname ${pkg}-foo-foo)"
2449    
2450     # get highest version available
2451     magefile=$(get_highest_magefile ${pcat} ${pname})
2452    
2453     # now get all needed infos to print a nice output
2454     pver="$(magename2pver ${magefile})"
2455     pbuild="$(magename2pbuild ${magefile})"
2456     state="$(get_value_from_magefile STATE ${magefile})"
2457     description="$(get_value_from_magefile DESCRIPTION ${magefile})"
2458     homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
2459    
2460     # all installed
2461     for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
2462     do
2463     ipver="$(magename2pver ${i})"
2464     ipbuild="$(magename2pbuild ${i})"
2465    
2466     if [[ -z ${all_installed} ]]
2467     then
2468     all_installed="${ipver}-${ipbuild}"
2469     else
2470     all_installed="${all_installed} ${ipver}-${ipbuild}"
2471     fi
2472     done
2473     [[ -z ${all_installed} ]] && all_installed="none"
2474    
2475     case ${state} in
2476     stable) state=${COLGREEN}"[s] ";;
2477     testing) state=${COLYELLOW}"[t] ";;
2478     unstable) state=${COLRED}"[u] ";;
2479     old) state=${COLGRAY}"[o] ";;
2480     esac
2481    
2482     echo -e "${state}${pcat}/${pname}"${COLDEFAULT}
2483     echo "      Latest available:   ${pver}-${pbuild}"
2484     echo "      Installed versions: ${all_installed}"
2485     echo "      Description: ${description}"
2486     echo "      Homepage: ${homepage}"
2487     echo
2488    
2489     unset pcat
2490     unset pname
2491     unset magefile
2492     unset pver
2493     unset pbuild
2494     unset state
2495     unset descriptiom
2496     unset homepage
2497     unset all_installed
2498     unset ipver
2499     unset ipbuild
2500     done
2501    }

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