-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathpackagedeps
executable file
·105 lines (81 loc) · 2.67 KB
/
packagedeps
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/sh
#+
# Name:
# packagedeps
# Purpose:
# Report all the packages that a package depends on, given the
# package name.
# Description:
# Uses the "echodeps" command to obtain a list of all the packages
# that the named package depends on, it then goes on to get the
# packages that these packages depend on and so on until all
# dependent packages have been identified. These are then listed.
# If no packages are required then a message:
#
# "Package $package has no known dependencies"
#
# is reported. Note this must be run from the "source" directory.
# The results of the dependency check are also returned in the
# file: "$1".depends.
# Type of Module:
# Shell script.
# Copyright:
# Copyright (C) 2003 Central Laboratory of the Research Councils
# Authors:
# PWD: P.W. Draper (Starlink, Durham University)
# {enter_new_authors_here}
# History:
# 30-SEP-2003 (PWD):
# Original version.
# {enter_further_changes_here}
# Bugs:
# {note_any_bugs_here}
#-
if test "$1" = ""; then
echo "Usage: ./scripts/packagedeps package"
exit
fi
# See if a properties file exists for this package, and if it also
# contains a "jar.class.path" property.
package=$1
properties=${package}/.properties
if test ! -f $properties; then
echo "Package $package has no known dependencies"
exit
fi
jarpath=`grep 'jar\.class\.path=' $properties`
if test -z "$jarpath"; then
echo "Package $package has no known dependencies"
exit
fi
# Dodgy algorithm as we don't have hashed arrays so uniqueness
# is hard to establish. Keep two files -- one has the list of
# dependencies from last time and one is appended to by all the
# dependencies of the currently known packages. Keep doing this until
# both these files have the same content (when passed through uniq).
dependsfile=${package}.depends
lastdependsfile=${package}.last
# Get dependencies of the primary package.
./scripts/echodeps $properties > $dependsfile
# The dependencies last time list is initially empty.
if test -f $lastdependsfile; then
rm $lastdependsfile
fi
touch $lastdependsfile
# Compare the two dependency files until they are the same.
until cmp -s $lastdependsfile $dependsfile; do
cp $dependsfile $lastdependsfile
# Look over the current packages getting their dependencies.
for f in `cat $lastdependsfile`; do
if test -f $f/.properties; then
./scripts/echodeps $f/.properties >> $dependsfile
fi
done
# Make all dependencies unique.
cat $dependsfile | sort | uniq > tmp.depends
mv tmp.depends $dependsfile
done
# Echo the dependencies
cat $dependsfile
rm $lastdependsfile
exit