summaryrefslogtreecommitdiffstats
path: root/sogrep
blob: b80d66f9388237a403431ac813247b6f15a38ece (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash

home="$(dirname "${0}")"
target="${home}/repo"
tmp=$(mktemp -d)
arches=('i686' 'x86_64')
lock='/tmp/mirrorsync.lck'

[ -f "${lock}" ] && exit 1

if [ $# -ne 2 ]; then
	echo "usage: $(basename $0) <repo> <soname>"
	exit 1
fi

repo="${1}"
lib="${2}"

for arch in ${arches[@]}; do
	db=${target}/${repo}/os/${arch}/${repo}.links.tar.gz
	if [ -f ${db} ]; then
		mkdir -p ${tmp}/${repo}/${arch}
		bsdtar -xf ${db} -C ${tmp}/${repo}/${arch}
	else
		echo "${db} not found!"
		exit 1
	fi
done

for i in $(grep -rl "${lib}" ${tmp}); do
	pkg=$(basename $(dirname $i))
	echo ${pkg%-*-*}
done | sort -u

rm -rf ${tmp}