1
2
3 """
4 Display information about package(s) (suite, version, etc.)
5
6 @contact: Debian FTP Master <ftpmaster@debian.org>
7 @copyright: 2000, 2001, 2002, 2003, 2004, 2005, 2006 James Troup <james@nocrew.org>
8 @license: GNU General Public License version 2 or later
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 import sys
35
36 import apt_pkg
37
38 from daklib import utils
39 from daklib.config import Config
40 from daklib.ls import list_packages
41
42
43
44
46 print(
47 """Usage: dak ls [OPTION] PACKAGE[...]
48 Display information about PACKAGE(s).
49
50 -a, --architecture=ARCH only show info for ARCH(s)
51 -b, --binary-type=TYPE only show info for binary TYPE
52 -c, --component=COMPONENT only show info for COMPONENT(s)
53 -g, --greaterorequal show buildd 'dep-wait pkg >= {highest version}' info
54 -G, --greaterthan show buildd 'dep-wait pkg >> {highest version}' info
55 -h, --help show this help and exit
56 -r, --regex treat PACKAGE as a regex
57 -s, --suite=SUITE only show info for this suite
58 -S, --source-and-binary show info for the binary children of source pkgs
59 -f, --format=control-suite use same format as control-suite for output
60
61 ARCH, COMPONENT and SUITE can be comma (or space) separated lists, e.g.
62 --architecture=amd64,i386"""
63 )
64 sys.exit(exit_code)
65
66
67
68
69
71 cnf = Config()
72
73 Arguments = [
74 ("a", "architecture", "Ls::Options::Architecture", "HasArg"),
75 ("b", "binarytype", "Ls::Options::BinaryType", "HasArg"),
76 ("c", "component", "Ls::Options::Component", "HasArg"),
77 ("f", "format", "Ls::Options::Format", "HasArg"),
78 ("g", "greaterorequal", "Ls::Options::GreaterOrEqual"),
79 ("G", "greaterthan", "Ls::Options::GreaterThan"),
80 ("r", "regex", "Ls::Options::Regex"),
81 ("s", "suite", "Ls::Options::Suite", "HasArg"),
82 ("S", "source-and-binary", "Ls::Options::Source-And-Binary"),
83 ("h", "help", "Ls::Options::Help"),
84 ]
85 for i in [
86 "architecture",
87 "binarytype",
88 "component",
89 "format",
90 "greaterorequal",
91 "greaterthan",
92 "regex",
93 "suite",
94 "source-and-binary",
95 "help",
96 ]:
97 key = "Ls::Options::%s" % i
98 if key not in cnf:
99 cnf[key] = ""
100
101 packages = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv)
102 Options = cnf.subtree("Ls::Options")
103
104 if Options["Help"]:
105 usage()
106 if not packages:
107 utils.fubar("need at least one package name as an argument.")
108
109
110 if Options["GreaterOrEqual"] or Options["GreaterThan"]:
111 if Options["GreaterOrEqual"] and Options["GreaterThan"]:
112 utils.fubar(
113 "-g/--greaterorequal and -G/--greaterthan are mutually exclusive."
114 )
115 if not Options["Suite"]:
116 Options["Suite"] = "unstable"
117
118 kwargs = dict()
119
120 if Options["Regex"]:
121 kwargs["regex"] = True
122 if Options["Source-And-Binary"]:
123 kwargs["source_and_binary"] = True
124 if Options["Suite"]:
125 kwargs["suites"] = utils.split_args(Options["Suite"])
126 if Options["Architecture"]:
127 kwargs["architectures"] = utils.split_args(Options["Architecture"])
128 if Options["BinaryType"]:
129 kwargs["binary_types"] = utils.split_args(Options["BinaryType"])
130 if Options["Component"]:
131 kwargs["components"] = utils.split_args(Options["Component"])
132
133 if Options["Format"]:
134 kwargs["format"] = Options["Format"]
135 if Options["GreaterOrEqual"]:
136 kwargs["highest"] = ">="
137 elif Options["GreaterThan"]:
138 kwargs["highest"] = ">>"
139
140 for line in list_packages(packages, **kwargs):
141 print(line)
142
143
144
145
146
147 if __name__ == "__main__":
148 main()
149