No, I'm not getting filosofical here. ;)

Hallo all,

Sometimes one wants to know what depends on a package or vice versa.

To find out, using the local setup.inis, I wrote following script.
It uses make to recursively find and display all dependencies in
either direction.

To find out what needs less:
cyg-deps less
To find out what man needs:
cyg-deps -r man

Insert a '-v' after the script's name to see any messages from make.
(e.g. about circular dependencies.)


This script requires /bin/sh, cat, sed, cygpath, (g)awk, make, a
package-dir left by setup, /etc/setup/last-mirror and
/etc/setup/last-cache.


I hope anyone likes and/or can find a use for it.


L8r,

Buzz.
-- 
  ) |  | ---/ ---/  Yes, this | This message consists of true | I do not
--  |  |   /    /   really is |   and false bits entirely.    | mail for
  ) |  |  /    /    a 72 by 4 +-------------------------------+ any1 but
--  \--| /--- /---  .sigfile. |   |perl -pe "s.u(z)\1.as."    | me. 4^re
#!/bin/sh

# Copyright (C) Bas van Gompel 2004.

# All rights reserved. No warranties.
# This software may not be used for aggressive purposes.

RCS_ID='$Id: cyg-deps,v 1.6 2004/12/05 06:54:56 Buzz Exp Buzz $'

this_one='p'
op=' ": " '
the_others='gensub (/^requires: /, "", 1)'

relation="${the_others}${op}${this_one}"

exec 6>/dev/null

while test "$1"x = "-v"x -o "$1"x = "-r"x; do
  if test "$1"x = "-v"x; then
    exec 6>&2
    shift
  fi
  if test "$1"x = "-r"x; then
    relation="${this_one}${op}${the_others}"
    shift
  fi
done

if test -f /etc/setup/last-mirror; then
  for f in $(cat /etc/setup/last-mirror); do
        cache_file="$(cygpath -u $(cat /etc/setup/last-cache))/$(\
                echo "$f"|sed 's,:,%3a,g;s,/,%2f,g')/setup.ini"
        if test -f "$cache_file"; then
                awk -f - ${cache_file} <<-EOA \
                |make -f - "$@" 2>&6
                        BEGIN {print "all:"}
                        /^@/ {ib=1;p=\$2;l=l " " p;next}
                        /^requires: / {
                          print ${relation}
                          print p ":"
                          print "       @echo " p
                        }
                        END {print ".PHONY: all" l}
                        EOA
                break
        fi
        echo "$0: Can not read cache-file ${cache_file}" >&2
  done
else
  echo "$0: Can not read mirror-file /etc/setup/last-mirror" >&2
fi

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Reply via email to