diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 14:14:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 14:14:39 +0000 |
commit | ee17e45964b786b48b455959dfe68715971893fb (patch) | |
tree | 118f40aa65dc838499053413b05adfd00f839c62 /proxysolver | |
parent | Initial commit. (diff) | |
download | mmdebstrap-ee17e45964b786b48b455959dfe68715971893fb.tar.xz mmdebstrap-ee17e45964b786b48b455959dfe68715971893fb.zip |
Adding upstream version 1.4.3.upstream/1.4.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'proxysolver')
-rwxr-xr-x | proxysolver | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/proxysolver b/proxysolver new file mode 100755 index 0000000..5cd51fa --- /dev/null +++ b/proxysolver @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +# +# This script is in the public domain +# +# Author: Johannes Schauer Marin Rodrigues <josch@mister-muffin.de> +# +# thin layer around /usr/lib/apt/solvers/apt, so that we can capture the solver +# result +# +# we set Debug::EDSP::WriteSolution=yes so that Install stanzas also come with +# Package and Version fields. That way, we do not also have to parse the EDSP +# request and spend time matching ID numbers + +import subprocess +import sys +import os +import getpass + +if not os.path.exists("/usr/lib/apt/solvers/apt"): + print( + """Error: ERR_NO_SOLVER +Message: The external apt solver doesn't exist. You must install the apt-utils package. +""" + ) + exit() + +fname = os.environ.get("APT_EDSP_DUMP_FILENAME") +if fname is None: + print( + """Error: ERR_NO_FILENAME +Message: You have to set the environment variable APT_EDSP_DUMP_FILENAME + to a valid filename to store the dump of EDSP solver input in. + For example with: export APT_EDSP_DUMP_FILENAME=/tmp/dump.edsp +""" + ) + exit() + +try: + with open(fname, "w") as f: + with subprocess.Popen( + ["/usr/lib/apt/solvers/apt", "-oDebug::EDSP::WriteSolution=yes"], + stdin=sys.stdin.fileno(), + stdout=subprocess.PIPE, + bufsize=0, # unbuffered + text=True, # open in text mode + ) as p: + for line in p.stdout: + print(line, end="") + f.write(line) +except (FileNotFoundError, PermissionError) as e: + print( + """Error: ERR_CREATE_FILE +Message: Writing EDSP solver input to file '%s' failed as it couldn't be created! +""" + % fname + ) |