1#! /usr/bin/env python3
3"""
4Display information about files related to a specific source package/version
5Display information about package(s) (suite, version, etc.)
7@contact: Debian FTP Master <ftpmaster@debian.org>
8@copyright: 2000, 2001, 2002, 2003, 2004, 2005, 2006 James Troup <james@nocrew.org>
9@license: GNU General Public License version 2 or later
11"""
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, write to the Free Software
24# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26################################################################################
28# < mhy> whilst you're here, if you have time to look at and merge
29# https://salsa.debian.org/ftp-team/dak/-/merge_requests/281 , I'd be
30# nice to you for at least 5 minutes
31# < Ganneff> ...
32# < Ganneff> 10!
33# < mhy> Done
34# ...
35# < mhy> god I hate dak's argument parsing. One day far in the future
36# when I have lots of time, I'm going to rip it all out
37# < Ganneff> and replace it with rust
38# * Ganneff hides
39# < mhy> I'll replace *you* with rust
40# < mhy> oh blast, I didn't even make 10 minutes
42################################################################################
44import sys
46import apt_pkg
48from daklib import utils
49from daklib.config import Config
50from daklib.dbconn import DBConn, DBSource
52################################################################################
55def usage(exit_code=0):
56 print(
57 """Usage: dak find-files SOURCE_PACKAGE VERSION
58Display file paths for files related to SOURCE_PACKAGE at VERSION
59"""
60 )
61 sys.exit(exit_code)
64################################################################################
67def main():
68 cnf = Config()
70 Arguments = [("h", "help", "FindFiles::Options::Help")]
71 for i in ["help"]:
72 key = "FindFiles::Options::%s" % i
73 if key not in cnf:
74 cnf[key] = ""
76 package_details = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv)
77 Options = cnf.subtree("FindFiles::Options")
79 if Options["Help"]:
80 usage()
82 if len(package_details) != 2:
83 utils.fubar("require source package name and version")
85 source, version = package_details
87 session = DBConn().session()
89 q = session.query(DBSource).filter_by(source=source, version=version)
91 pkg = q.first()
93 if pkg is None:
94 utils.fubar(f"Source {source} at version {version} does not exist")
96 filenames = []
98 # Don't include pool otherwise we have to work out components (which may vary
99 # by archive). The partial path is enough for rsync to match it
100 for binary in pkg.binaries:
101 filenames.append(binary.poolfile.filename)
103 for filename in sorted(filenames):
104 print(filename)
107######################################################################################
110if __name__ == "__main__":
111 main()