Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # This scripts checks the given list of packages if they have
  4. # reverse dependencies (i.e. there are packages which depends on them).
  5. # Dependencies that are on the list are excluded.
  6. #
  7. # Usage: $0 LIST
  8. set -eu
  9.  
  10. SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
  11.  
  12. find_revdeps() {
  13. local pkgname="$1"
  14. local excludes="$2"
  15.  
  16. "$SCRIPT_DIR"/abuild-revdeps $pkgname \
  17. | xargs -I% "$SCRIPT_DIR"/abuild-origin % \
  18. | grep -vFf "$excludes" \
  19. | sort | uniq
  20. }
  21.  
  22. has_maintainer() {
  23. local pkgname="$1"
  24. local abuild="$pkgname/APKBUILD"
  25.  
  26. if [ -f "$abuild" ]; then
  27. grep -qE '# Maintainer: *\w+' "$abuild"
  28. else
  29. echo "ERROR: $abuild does not exist!" >&2
  30. fi
  31. }
  32.  
  33. mark_unmaintained() {
  34. local pkg; for pkg in $@; do
  35. if has_maintainer $pkg; then
  36. printf "%s " $pkg
  37. else
  38. printf "%s* " $pkg
  39. fi
  40. done
  41. }
  42.  
  43.  
  44. pkglist="$1"
  45.  
  46. echo '# PKGNAME <- list of packages that (make)depends on PKGNAME' >&2
  47.  
  48. cat "$pkglist" | while read pkgname; do
  49. revdeps="$(find_revdeps "$pkgname" "$pkglist")"
  50.  
  51. if [ -n "$revdeps" ]; then
  52. printf "%s <- %s\n" "$pkgname" "$(mark_unmaintained $revdeps)"
  53. fi
  54. done
  55.  
  56. echo ''
  57. echo '* package without a maintainer' >&2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement