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