* rebased llvm/hotfix-sparcv9-not-64.diff
[t2sde.git] / misc / archive / showsorteddeps.sh
blob8a863e0fb6ba84ce71d5a826d6bb740f39a96c2a
1 #!/bin/sh
2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 #
5 # T2 SDE: misc/archive/showsorteddeps.sh
6 # Copyright (C) 2006 The T2 SDE Project
7 #
8 # More information can be found in the files COPYING and README.
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
16 cachefiles=
17 packages=
18 config=default
20 if [ "$1" == "-cfg" ]; then
21 config="$2"
22 shift; shift
25 echo_warning() {
26 echo "$@" | sed -e 's,^,!> ,g' >& 2
29 echo_error() {
30 echo "$@" | sed -e 's,^,!> ,g' >& 2
31 exit 1
34 if [ ! -f config/$config/packages ]; then
35 echo_error "config '$config' doesn't exist, sorry"
38 # get the list of cache files
40 for pkg; do
41 confdir=`echo package/*/$pkg/`
42 if [ -d $confdir ]; then
43 packages="$packages $pkg"
44 if [ -f ${confdir}$pkg.cache ]; then
45 cachefiles="$cachefiles ${confdir}$pkg.cache"
46 else
47 echo_warning "package '$pkg' doesn't have a .cache file"
49 else
50 echo_warning "package '$pkg' doesn't exist"
52 done
55 # get the list of interesting packages
56 # just one level of recursion
58 packages=$( {
59 echo "$packages" | tr ' ' '\n'
60 for cache in $cachefiles; do
61 grep '^\[DEP\]' $cache | cut -d' ' -f2
62 done } | sort -u | tr -s '\n' | tr '\n' ' ' )
64 # pattern to search at packages file of this config
66 pkgsexp=$( echo "$packages" | sed -e 's,^ ,,' -e 's, $,,' -e 's,\+,[+],' -e 's, ,\\\|,g' )
68 # catch interesting data from packages file
69 # (sorted by package name)
71 mkfifo $0.$$
72 ( sed -n -e "s,^\(.\) \([^ ]*\) \(...\)\.\(...\) [^ ]* \($pkgsexp\) .*,\5 \3\4 \2 \1,p" \
73 config/$config/packages | sort > $0.$$ ) &
75 sleep 1
76 packages_orig="$packages"
77 while read pkg prio stages status; do
78 packages_new="${packages/ $pkg / }"
79 if [ "$packages" != "$packages_new" ]; then
80 packages="$packages_new"
81 if [ "$status" != X ] ; then
82 status='*'
83 else
84 status=' '
86 echo "$prio $stages $status $pkg"
87 else
88 echo_warning "what is '$pkg' doing here?"
90 done < $0.$$
91 rm $0.$$
93 # and catch data from dependencies which were not found at packages list
95 for pkg in $packages; do
96 confdir=`echo package/*/$pkg/`
97 if [ -f $confdir/$pkg.desc ]; then
98 echo_warning "dependency '$pkg' is not available for this build."
99 sed -n -e 's,^\[P\] . \([^ ]*\) \([^ \.]*\)\.\([^ \.]*\).*,\2\3 \1 - '$pkg',p' $confdir/$pkg.desc
100 else
101 echo_warning "dependency '$pkg' doesn't exist!"
103 done
104 } | sort -n