1#! /usr/bin/env python3
3"""
4Display information about package(s) (suite, version, etc.)
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
10"""
11# This program is free software; you can redistribute it and/or modify
12# it under the terms of the GNU General Public License as published by
13# the Free Software Foundation; either version 2 of the License, or
14# (at your option) any later version.
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
21# You should have received a copy of the GNU General Public License
22# along with this program; if not, write to the Free Software
23# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25################################################################################
27# <aj> ooo, elmo has "special powers"
28# <neuro> ooo, does he have lasers that shoot out of his eyes?
29# <aj> dunno
30# <aj> maybe he can turn invisible? that'd sure help with improved transparency!
32################################################################################
34import sys
35import apt_pkg
37from daklib.config import Config
38from daklib.ls import list_packages
39from daklib import utils
41################################################################################
44def usage(exit_code=0):
45 print("""Usage: dak ls [OPTION] PACKAGE[...]
46Display information about PACKAGE(s).
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
59ARCH, COMPONENT and SUITE can be comma (or space) separated lists, e.g.
60 --architecture=amd64,i386""")
61 sys.exit(exit_code)
63################################################################################
66def main():
67 cnf = Config()
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: 83 ↛ 79line 83 didn't jump to line 79, because the condition on line 83 was never false
84 cnf[key] = ""
86 packages = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv)
87 Options = cnf.subtree("Ls::Options")
89 if Options["Help"]:
90 usage()
91 if not packages: 91 ↛ 92line 91 didn't jump to line 92, because the condition on line 91 was never true
92 utils.fubar("need at least one package name as an argument.")
94 # Handle buildd maintenance helper options
95 if Options["GreaterOrEqual"] or Options["GreaterThan"]: 95 ↛ 96line 95 didn't jump to line 96, because the condition on line 95 was never true
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"
101 kwargs = dict()
103 if Options["Regex"]: 103 ↛ 104line 103 didn't jump to line 104, because the condition on line 103 was never true
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"]: 109 ↛ 110line 109 didn't jump to line 110, because the condition on line 109 was never true
110 kwargs['architectures'] = utils.split_args(Options['Architecture'])
111 if Options['BinaryType']: 111 ↛ 112line 111 didn't jump to line 112, because the condition on line 111 was never true
112 kwargs['binary_types'] = utils.split_args(Options['BinaryType'])
113 if Options['Component']: 113 ↛ 114line 113 didn't jump to line 114, because the condition on line 113 was never true
114 kwargs['components'] = utils.split_args(Options['Component'])
116 if Options['Format']: 116 ↛ 117line 116 didn't jump to line 117, because the condition on line 116 was never true
117 kwargs['format'] = Options['Format']
118 if Options['GreaterOrEqual']: 118 ↛ 119line 118 didn't jump to line 119, because the condition on line 118 was never true
119 kwargs['highest'] = '>='
120 elif Options['GreaterThan']: 120 ↛ 121line 120 didn't jump to line 121, because the condition on line 120 was never true
121 kwargs['highest'] = '>>'
123 for line in list_packages(packages, **kwargs):
124 print(line)
126######################################################################################
129if __name__ == '__main__':
130 main()