nix-tools/bin/finddeps.in
2014-10-04 15:41:22 +02:00

46 lines
1.4 KiB
Bash

#!/bin/bash
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# if [[ -r @libdir@/functions.sh ]];then
# source @libdir@/functions.sh
# fi
match=$1
if [[ -z $match ]]; then
echo 'Usage: finddeps <depname>'
echo ''
echo 'Find packages that depend on a given depname.'
echo 'Run this script from the top-level directory of your ABS tree.'
echo ''
exit 1
fi
find . -type d | while read d; do
if [[ -f "$d/PKGBUILD" ]]; then
unset pkgname depends makedepends optdepends
. "$d/PKGBUILD"
for dep in "${depends[@]}"; do
# lose the version comparator, if any
depname=${dep%%[<>=]*}
[[ $depname = $match ]] && echo "$d (depends)"
done
for dep in "${makedepends[@]}"; do
# lose the version comparator, if any
depname=${dep%%[<>=]*}
[[ $depname = $match ]] && echo "$d (makedepends)"
done
for dep in "${optdepends[@]/:*}"; do
# lose the version comaparator, if any
depname=${dep%%[<>=]*}
[[ $depname = $match ]] && echo "$d (optdepends)"
done
fi
done