Skip to content

Commit

Permalink
Merge pull request #59 from mariux64/fix-symlink-dirs
Browse files Browse the repository at this point in the history
Better handle files installed via existing symlinks ( e.g. /lib -> /usr/lib )
  • Loading branch information
donald authored May 14, 2024
2 parents 60a9cce + a015a23 commit 79a61e6
Show file tree
Hide file tree
Showing 5 changed files with 500 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
/beeversion
/beegetopt
/beeflock
/beeissue.sh
/beeindextr
/beelib.config.sh
/bee.1
/bee-check.1
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ HELPER_BEE_SHELL+=bee-remove
HELPER_BEE_SHELL+=bee-update

HELPER_C+=bee-cache-inventory
HELPER_C+=beeindextr

HELPER_SHELL+=compat-filesfile2contentfile
HELPER_SHELL+=compat-fixmetadir
Expand Down Expand Up @@ -134,6 +135,7 @@ BEESORT_OBJECTS=bee_tree.o bee_version_compare.o bee_version_output.o bee_versio
BEEGETOPT_OBJECTS=bee_getopt.o beegetopt.o
BEEFLOCK_OBJECTS=bee_getopt.o beeflock.o
BEECACHEINVENTORY_OBJECTS=bee-cache-inventory.o bee_getopt.o
BEEICANONDIRS_OBJECTS=beeindextr.o

bee_BUILDTYPES=$(addsuffix .sh,$(addprefix buildtypes/,$(BUILDTYPES)))

Expand Down Expand Up @@ -166,6 +168,9 @@ beeflock: $(addprefix src/, ${BEEFLOCK_OBJECTS})
bee-cache-inventory: $(addprefix src/, ${BEECACHEINVENTORY_OBJECTS})
$(call quiet-command,${CC} ${LDFLAGS} -o $@ $^,"LD $@")

beeindextr: $(addprefix src/, ${BEEICANONDIRS_OBJECTS})
$(call quiet-command,${CC} ${LDFLAGS} -o $@ $^,"LD $@")

%.o: %.c
$(call quiet-command,${CC} ${CFLAGS} -o $@ -c $^,"CC $@")

Expand Down
12 changes: 1 addition & 11 deletions src/bee-cache.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ function cache_update_pkg() {
return 0
}

function cache_grep() {
${BEEFLOCK} --shared ${BEECACHE_INVENTORY} \
grep "${@}" ${BEECACHE_INVENTORY}
}

function print_conflicts() {
local pkg=${1}

Expand Down Expand Up @@ -169,8 +164,7 @@ function print_missing_files() {
}

function tmp_merge_install_inventory_files() {
${BEEFLOCK} --shared ${BEECACHE_INVENTORY} sort -m -u -r -k8 -k1 \
${BEECACHE_INVENTORY} "${@}"
${BEEFLOCK} --shared ${BEECACHE_INVENTORY} ${BEE_LIBEXECDIR}/bee/beeindextr ${BEECACHE_INVENTORY} "${@}" | sort -u -r -k8 -k1
}

function tmpinstall_to_filenames() {
Expand Down Expand Up @@ -225,7 +219,6 @@ function usage() {
-h, --help display this help
Commands:
grep <pattern>
rebuild
update <pkgname...>
print-uniq-files <pkgname>
Expand Down Expand Up @@ -284,9 +277,6 @@ cache_verify
tmpinstall_to_filenames

case "${cmd}" in
grep)
cache_grep "${@}" | cut -d ' ' -f${FIELDS}
;;
rebuild)
cache_rebuild
;;
Expand Down
31 changes: 19 additions & 12 deletions src/bee-query.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ VERSION=${BEE_VERSION}

: ${BEE_BINDIR:=@BINDIR@}
: ${BEE_LIBEXECDIR:=@LIBEXECDIR@}
: ${BEEFLOCK=${BEE_BINDIR}/beeflock}
: ${BEECACHE_CACHEDIR=${BEE_CACHEDIR}/bee-cache}
: ${BEECACHE_INVENTORY=${BEECACHE_CACHEDIR}/INVENTORY}

function bee-list() {
${BEE_LIBEXECDIR}/bee/bee.d/bee-list "${@}"
Expand Down Expand Up @@ -81,18 +84,22 @@ function get_files() {
}

function get_pkgs() {
f=$1

for pkg in $(bee-list --installed) ; do

if egrep -q "file=.*${f}" "${BEE_METADIR}/${pkg}/CONTENT" ; then
echo ${pkg}
while read line ; do
eval $(${BEESEP} "${line}")
echo " ${file}"
done < <(egrep "file=.*${f}" "${BEE_METADIR}/${pkg}/CONTENT")
fi
done
file_pattern="$1"
last_pkg=''

${BEEFLOCK} --shared ${BEECACHE_INVENTORY} \
${BEE_LIBEXECDIR}/bee/beeindextr ${BEECACHE_INVENTORY} | \
grep -- "$file_pattern" | \
sort | \
while read -r pkg mtime uid gid mode size md5 filename; do
if [[ $filename =~ $file_pattern ]]; then
if [ "$pkg" != "$last_pkg" ]; then
echo $pkg
last_pkg="$pkg"
fi
printf " %s\n" "$filename"
fi
done
}


Expand Down
Loading

0 comments on commit 79a61e6

Please sign in to comment.