From b0bb8be92495c20b8d7f77f6cfbc36900e54b857 Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Tue, 7 Aug 2012 15:27:16 +0200 Subject: [PATCH 1/2] bee-cache: let cache_verify rebuild the main INVENTORY on error --- src/bee-cache.sh.in | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bee-cache.sh.in b/src/bee-cache.sh.in index aff3a95..b852843 100644 --- a/src/bee-cache.sh.in +++ b/src/bee-cache.sh.in @@ -36,12 +36,16 @@ VERSION=${BEE_VERSION} : ${BEECACHE_INVENTORY=${BEECACHE_CACHEDIR}/INVENTORY} function cache_verify() { - if ! ${BEEFLOCK} --shared "${BEECACHE_INVENTORY}" \ + if ${BEEFLOCK} --shared "${BEECACHE_INVENTORY}" \ sort -c -u -r -k8 -k1 "${BEECACHE_INVENTORY}" 2>/dev/null ; then - rm -fr "${BEECACHE_CACHEDIR}" + return fi + rm -fr "${BEECACHE_CACHEDIR}" mkdir -p "${BEECACHE_CACHEDIR}" + + ${BEEFLOCK} ${BEECACHE_INVENTORY} \ + ${BEE_LIBEXECDIR}/bee/bee-cache-update >/dev/null } function cache_update() { From 3361347425fdb503110bebbcfec5a5853d3abeb5 Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Tue, 7 Aug 2012 15:55:40 +0200 Subject: [PATCH 2/2] bee-cache: New command 'grep [grep-options] [pattern]' Allows to grep in INVENTORY file and just print matching/non-matching lines dependent on grep options. Calls system grep and takes all options the system grep handles. If no search pattern is given, undefined behavior occurs. --- src/bee-cache.sh.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bee-cache.sh.in b/src/bee-cache.sh.in index b852843..0ec8df5 100644 --- a/src/bee-cache.sh.in +++ b/src/bee-cache.sh.in @@ -71,6 +71,11 @@ function cache_update_pkg() { return 0 } +function cache_grep() { + ${BEEFLOCK} --shared ${BEECACHE_INVENTORY} \ + grep "${@}" ${BEECACHE_INVENTORY} +} + function print_conflicts() { local pkg=${1} @@ -239,6 +244,9 @@ cache_verify tmpinstall_to_filenames case "${cmd}" in + grep) + cache_grep "${@}" | cut -d ' ' -f${FIELDS} + ;; update) cache_update "${@}" ;;