--- trunk/mage/usr/lib/mage/mage4.functions.sh 2005/09/09 16:35:46 226 +++ trunk/mage/usr/lib/mage/mage4.functions.sh 2005/09/10 13:35:55 237 @@ -1,6 +1,6 @@ #!/bin/bash # Magellan Linux Installer Functions (mage.functions.sh) -# $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.2 2005-09-10 13:35:55 niro Exp $ mage_setup() { @@ -2415,3 +2415,87 @@ echo "Please run 'etc-update' to update your configuration files." echo } + +pkgsearch() +{ + local string="$1" + local result + local pkg + local pcat + local pname + local magefile + local pver + local pbuild + local state + local descriptiom + local homepage + local i + local all_installed + local ipver + local ipbuild + + # only names no versions + result="$(find ${MAGEDIR} -mindepth 2 -maxdepth 2 -type d -name *${string}*)" + #result="$(find ${MAGEDIR} -type f -name *${string}*.mage | sort)" + + # nothing found + [[ -z ${result} ]] && die "No package found containing '${string}' in the name." + + for pkg in ${result} + do + # dirty, but does the job + pcat="$(magename2pcat ${pkg}/foo)" + pname="$(magename2pname ${pkg}-foo-foo)" + + # get highest version available + magefile=$(get_highest_magefile ${pcat} ${pname}) + + # now get all needed infos to print a nice output + pver="$(magename2pver ${magefile})" + pbuild="$(magename2pbuild ${magefile})" + state="$(get_value_from_magefile STATE ${magefile})" + description="$(get_value_from_magefile DESCRIPTION ${magefile})" + homepage="$(get_value_from_magefile HOMEPAGE ${magefile})" + + # all installed + for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat}) + do + ipver="$(magename2pver ${i})" + ipbuild="$(magename2pbuild ${i})" + + if [[ -z ${all_installed} ]] + then + all_installed="${ipver}-${ipbuild}" + else + all_installed="${all_installed} ${ipver}-${ipbuild}" + fi + done + [[ -z ${all_installed} ]] && all_installed="none" + + case ${state} in + stable) state=${COLGREEN}"[s] ";; + testing) state=${COLYELLOW}"[t] ";; + unstable) state=${COLRED}"[u] ";; + old) state=${COLGRAY}"[o] ";; + esac + + echo -e "${state}${pcat}/${pname}"${COLDEFAULT} + echo " Latest available: ${pver}-${pbuild}" + echo " Installed versions: ${all_installed}" + echo " Description: ${description}" + echo " Homepage: ${homepage}" + echo + + unset pcat + unset pname + unset magefile + unset pver + unset pbuild + unset state + unset descriptiom + unset homepage + unset all_installed + unset ipver + unset ipbuild + done +}