Coverage for dak/find_files.py: 17%
33 statements
« prev ^ index » next coverage.py v7.6.0, created at 2026-08-03 16:46 +0000
« prev ^ index » next coverage.py v7.6.0, created at 2026-08-03 16:46 +0000
1"""
2Display information about files related to a specific source package/version
3Display information about package(s) (suite, version, etc.)
5@contact: Debian FTP Master <ftpmaster@debian.org>
6@copyright: 2000, 2001, 2002, 2003, 2004, 2005, 2006 James Troup <james@nocrew.org>
7@license: GNU General Public License version 2 or later
9"""
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# < mhy> whilst you're here, if you have time to look at and merge
28# https://salsa.debian.org/ftp-team/dak/-/merge_requests/281 , I'd be
29# nice to you for at least 5 minutes
30# < Ganneff> ...
31# < Ganneff> 10!
32# < mhy> Done
33# ...
34# < mhy> god I hate dak's argument parsing. One day far in the future
35# when I have lots of time, I'm going to rip it all out
36# < Ganneff> and replace it with rust
37# * Ganneff hides
38# < mhy> I'll replace *you* with rust
39# < mhy> oh blast, I didn't even make 10 minutes
41################################################################################
43import sys
45import apt_pkg
46from sqlalchemy import select
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) # type: ignore[attr-defined]
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 = select(DBSource).filter_by(source=source, version=version).limit(1)
91 pkg = session.scalars(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)