Skip to content

Commit

Permalink
Merge branch 'cleanup'
Browse files Browse the repository at this point in the history
* cleanup:
  cleanup: Add functions to wrap bee-tools to increase readability
  • Loading branch information
mariux committed Mar 10, 2013
2 parents f009e28 + 69b1eed commit 7807570
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 22 deletions.
15 changes: 10 additions & 5 deletions src/bee-check.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ fi
VERSION=${BEE_VERSION}

: ${BEE_BINDIR:=@BINDIR@}
: ${BEE_LIBEXECDIR:=@LIBEXECDIR@}

function bee-list() {
${BEE_LIBEXECDIR}/bee/bee.d/bee-list "${@}"
}

###############################################################################
##
Expand All @@ -58,10 +63,10 @@ function pkg_check_all() {
##
##
function pkg_check_deps() {
installed=$(${BEE_LIBEXECDIR}/bee/bee.d/bee-list --installed --by-pkgfullname ${1})
installed=$(bee-list --installed --by-pkgfullname ${1})

if [ ! "${installed}" -a $OPT_F -gt 0 ] ; then
installed=$(${BEE_LIBEXECDIR}/bee/bee.d/bee-list --installed "${1}")
installed=$(bee-list --installed "${1}")
fi

if [ "${installed}" ] ; then
Expand All @@ -76,10 +81,10 @@ function pkg_check_deps() {
##
##
function pkg_check() {
installed=$(${BEE_LIBEXECDIR}/bee/bee.d/bee-list --installed --by-pkgfullname ${1})
installed=$(bee-list --installed --by-pkgfullname ${1})

if [ ! "${installed}" -a $OPT_F -gt 0 ] ; then
installed=$(${BEE_LIBEXECDIR}/bee/bee.d/bee-list --installed "${1}")
installed=$(bee-list --installed "${1}")
fi

if [ "${installed}" ] ; then
Expand All @@ -89,7 +94,7 @@ function pkg_check() {
return 0
fi

installed=$(${BEE_LIBEXECDIR}/bee/bee.d/bee-list --installed "${1}")
installed=$(bee-list --installed "${1}")

if [ "${installed}" ] ; then
echo "packages matching '${1}':"
Expand Down
29 changes: 19 additions & 10 deletions src/bee-install.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ fi
VERSION=${BEE_VERSION}

: ${BEE_BINDIR:=@BINDIR@}
: ${BEE_LIBEXECDIR:=@LIBEXECDIR@}

function bee-cache() {
${BEE_LIBEXECDIR}/bee/bee.d/bee-cache "${@}"
}

function bee-list() {
${BEE_LIBEXECDIR}/bee/bee.d/bee-list "${@}"
}

function bee-remove() {
${BEE_LIBEXECDIR}/bee/bee.d/bee-remove "${@}"
}

function debug_msg() {
if [ "${OPT_DEBUG}" != "1" ] ; then
Expand Down Expand Up @@ -147,7 +160,7 @@ function pkg_install() {
fi

# pkg not found yet - lets search a little deeper
available=( $(${BEE_LIBEXECDIR}/bee/bee.d/bee-list --available "${search}") )
available=( $(bee-list --available "${search}") )

if [ ${#available[@]} -eq 0 ] ; then
echo >&2 "bee-install: ${search}: No packages available matching your query."
Expand Down Expand Up @@ -183,11 +196,11 @@ function pkg_install() {
return
fi

available=( $(${BEE_LIBEXECDIR}/bee/bee.d/bee-list --available --exact "${fullname}" | grep ${search}) )
available=( $(bee-list --available --exact "${fullname}" | grep ${search}) )

maxavail=$(${BEE_BINDIR}/beeversion -max ${available[@]})

fileavail=( $(${BEE_LIBEXECDIR}/bee/bee.d/bee-list --available --exact --display-pathname ${maxavail}) )
fileavail=( $(bee-list --available --exact --display-pathname ${maxavail}) )

assert "${#fileavail[@]}" = 1

Expand All @@ -202,7 +215,7 @@ function do_remove() {
echo "REMOVE ${p}"
continue
fi
${BEE_LIBEXECDIR}/bee/bee.d/bee-remove ${p}
bee-remove ${p}
done
}

Expand Down Expand Up @@ -236,8 +249,8 @@ function do_install() {
debug_msg "do_install file=${file}"
debug_msg "do_install pkg=${pkg}"

installed=( $(${BEE_LIBEXECDIR}/bee/bee.d/bee-list --installed --exact "${fullname}" | grep -v "${pkg}") )
isinstalled=( $(${BEE_LIBEXECDIR}/bee/bee.d/bee-list --installed --exact "${pkg}") )
installed=( $(bee-list --installed --exact "${fullname}" | grep -v "${pkg}") )
isinstalled=( $(bee-list --installed --exact "${pkg}") )

assert ${#isinstalled[@]} -le 1

Expand Down Expand Up @@ -344,10 +357,6 @@ function do_install() {
return
}

function bee-cache() {
${BEE_LIBEXECDIR}/bee/bee.d/bee-cache "${@}"
}

function do_install_file() {
local file=$1
local beefile="$(${BEE_BINDIR}/beeversion ${pkg} --format='%F').bee"
Expand Down
8 changes: 7 additions & 1 deletion src/bee-list.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ fi
VERSION=${BEE_VERSION}

: ${BEE_BINDIR:=@BINDIR@}
: ${BEE_LIBEXECDIR:=@LIBEXECDIR@}

: ${BEESORT:=${BEE_BINDIR}/beesort}

function bee-list() {
${BEE_LIBEXECDIR}/bee/bee.d/bee-list "${@}"
}

#
# BUGS TO FIX/FEATURES TO ADD:
# - check for grep -P support and use it..
Expand Down Expand Up @@ -244,7 +250,7 @@ function list_updatable() {
pkgs=$(${BEE_BINDIR}/beeversion --max ${pkgs})
for a in ${pkgs} ; do
pname=$(${BEE_BINDIR}/beeversion --pkgfullname "${a}")
installed=$(${BEE_LIBEXECDIR}/bee/bee.d/bee-list --exact "${pname}")
installed=$(bee-list --exact "${pname}")
if [ -z "${installed}" ] ; then
if [ "${OPT_UNINSTALLED}" = "yes" ] ; then
echo -e "${COLOR_INSTALLABLE}${a}${COLOR_NORMAL}"
Expand Down
7 changes: 6 additions & 1 deletion src/bee-query.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ fi
VERSION=${BEE_VERSION}

: ${BEE_BINDIR:=@BINDIR@}
: ${BEE_LIBEXECDIR:=@LIBEXECDIR@}

function bee-list() {
${BEE_LIBEXECDIR}/bee/bee.d/bee-list "${@}"
}

BEESEP=${BEE_BINDIR}/beesep

Expand Down Expand Up @@ -79,7 +84,7 @@ function get_files() {
function get_pkgs() {
f=$1

for pkg in $(${BEE_LIBEXECDIR}/bee/bee.d/bee-list --installed) ; do
for pkg in $(bee-list --installed) ; do

if egrep -q "file=.*${f}" "${BEE_METADIR}/${pkg}/CONTENT" ; then
echo ${pkg}
Expand Down
14 changes: 9 additions & 5 deletions src/beesh.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ VERSION=${BEE_VERSION}
# load libs
. ${BEE_LIBEXECDIR}/bee/beelib.config.sh

function bee-cache() {
${BEE_LIBEXECDIR}/bee/bee.d/bee-cache "${@}"
}

function bee-install() {
${BEE_LIBEXECDIR}/bee/bee.d/bee-install "${@}"
}

###############################################################################
###############################################################################
###############################################################################
Expand Down Expand Up @@ -1049,10 +1057,6 @@ bee_crosscheck

bee_pkg_pack

function bee-cache() {
${BEE_LIBEXECDIR}/bee/bee.d/bee-cache "${@}"
}

function bee_check_conflicts() {
${BEE_LIBEXECDIR}/bee/bee-cache-inventory CONTENT \
--prepend "${PKGALLPKG} " \
Expand Down Expand Up @@ -1095,5 +1099,5 @@ echo
if [ "${OPT_INSTALL}" = "yes" ] ; then

print_info "installing ${PKGALLPKG} .."
${BEE_LIBEXECDIR}/bee/bee.d/bee-install ${OPT_FORCE:+-f} ${OPT_UPDATE:+-u} ${BEE_PKGDIR}/${PKGALLPKG}.bee.tar.bz2
bee-install ${OPT_FORCE:+-f} ${OPT_UPDATE:+-u} ${BEE_PKGDIR}/${PKGALLPKG}.bee.tar.bz2
fi

0 comments on commit 7807570

Please sign in to comment.