Mercurial > vanilla
comparison Scripts/lint-deps.sh @ 659:9e199f8590e3
scripts: add lint-deps.sh
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 30 Jul 2019 20:30:00 +0200 |
parents | |
children | aa3c1de1780a |
comparison
equal
deleted
inserted
replaced
658:936f40a89c99 | 659:9e199f8590e3 |
---|---|
1 #!/bin/sh | |
2 # | |
3 # lint-deps.sh -- ensure that dependencies listed in PKGDEPENDS exist | |
4 # | |
5 # Copyright (c) 2019 David Demelier <markand@malikania.fr> | |
6 # | |
7 # Permission to use, copy, modify, and/or distribute this software for any | |
8 # purpose with or without fee is hereby granted, provided that the above | |
9 # copyright notice and this permission notice appear in all copies. | |
10 # | |
11 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
12 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
13 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
14 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
15 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
16 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
17 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
18 # | |
19 | |
20 alias basename="busybox basename" | |
21 alias dirname="busybox dirname" | |
22 alias echo="busybox echo" | |
23 alias find="busybox find" | |
24 alias grep="busybox grep" | |
25 alias realpath="busybox realpath" | |
26 | |
27 TOP=$(realpath $(dirname $0)/../) | |
28 PROGNAME=$(basename $0) | |
29 | |
30 usage() | |
31 { | |
32 echo "usage: $PROGNAME [category/package]" 1>&2 | |
33 exit 1 | |
34 } | |
35 | |
36 scriptfile() | |
37 { | |
38 echo $1/$(basename $1).sh | |
39 } | |
40 | |
41 list() | |
42 { | |
43 if [ $# -eq 0 ]; then | |
44 find $TOP -mindepth 2 -maxdepth 2 -type d | grep -v '\.hg' | |
45 else | |
46 file=$(scriptfile $1) | |
47 | |
48 if [ ! -f $file ]; then | |
49 echo "abort: invalid package specified '$1'" 1>&2 | |
50 exit 1 | |
51 fi | |
52 | |
53 echo $1 | |
54 fi | |
55 } | |
56 | |
57 check() | |
58 { | |
59 file=$(scriptfile $1) | |
60 failed=0 | |
61 | |
62 echo -n "checking dependencies for $1: " | |
63 | |
64 # Reset PKGDEPENDS in case script is broken. | |
65 PKGDEPENDS="" | |
66 | |
67 . $file | |
68 | |
69 for d in $PKGDEPENDS; do | |
70 file=$TOP/$(scriptfile ${d%:*}) | |
71 | |
72 if [ ! -f $file ]; then | |
73 # Only print "error" once. | |
74 if [ $failed -eq 0 ]; then | |
75 failed=1 | |
76 echo "error" | |
77 fi | |
78 | |
79 echo "missing ${d%:*}" 1>&2 | |
80 fi | |
81 done | |
82 | |
83 if [ $failed -eq 0 ]; then | |
84 echo "ok" | |
85 fi | |
86 } | |
87 | |
88 process() | |
89 { | |
90 list $@ | while read pkg; do | |
91 check $pkg | |
92 done | |
93 } | |
94 | |
95 process "$@" |