blob: 850d03b940f7665920ad8fe4feebf076a84b589a (
plain)
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
|
#!/bin/bash
function assert_eq() {
local expected="$1"
local actual="$2"
local message="$3"
if [ "$1" -ne "$2" ] ; then
if [ ! -z "$message" ]; then
echo "$message"
fi
die_usage
fi
}
function assert_le() {
local expected="$1"
local actual="$2"
local message="$3"
if [ "$1" -gt "$2" ] ; then
if [ ! -z "$message" ]; then
echo "$message"
fi
die_usage
fi
}
function get_pkginfo() {
local file="$1"
# FIXME remove dep on GNU tar
tar --to-stdout -xf "$file" .PKGINFO
}
function get_pkginfo_field() {
local file="$1"
local field="$2"
get_pkginfo "$file" | grep '^'"$field"'' | awk -F' = ' '{print $2}'
}
function die_usage() {
echo "Syntax: introspect.sh <action> [options]"
echo ""
echo "Valid actions:"
echo "all <package>"
echo "field <package> <field_name>"
echo "files <package>"
exit 1
}
assert_le 2 $# "Not enough arguments"
case "$1" in
"all")
assert_eq 2 $#
get_pkginfo $2
;;
"field")
assert_eq 3 $#
get_pkginfo_field $2 $3
;;
"files")
assert_eq 2 $#
echo Files not implemented
exit 1
;;
*)
echo "Unknown action \"$1\""
die_usage
;;
esac
|