diff options
author | Helmut Grohne <helmut@subdivi.de> | 2021-07-06 13:51:41 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2021-07-06 13:51:41 +0200 |
commit | 58e77f47adf737c27e87e185adfe437dfebed6df (patch) | |
tree | 74ba8c2856e15dd210232e4cc4c4c2876810c80d /mdbp/common.py | |
parent | 2e9f3bddc0c9c7fd3411a2e41f49d048c93ba52e (diff) | |
download | mdbp-58e77f47adf737c27e87e185adfe437dfebed6df.tar.gz |
mmdebstrap and sbuild shall agree on what build_path means
While mmdebstrap would extract the package precisely to the build_path,
sbuild would create a subdirectory <source>-<upstream_version> inside
the build_path. Changing sbuild to do the mmdebstrap behaviour looks
next to impossible, so this commit changes mmdebstrap to behave like
sbuild.
pbuilder also allows changing the build_path in principle. The
documented BUILDDIR variable works quite similar to the sbuild option
--build-path. pbuilder also allows changing the sub directory using the
undocumented BUILDSUBDIR variable. That's another reason to do it like
sbuild.
Diffstat (limited to 'mdbp/common.py')
-rw-r--r-- | mdbp/common.py | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/mdbp/common.py b/mdbp/common.py index 719a8b6..5c67f58 100644 --- a/mdbp/common.py +++ b/mdbp/common.py @@ -118,6 +118,11 @@ def download(uri: str, checksums: typing.Dict[str, str], dest.unlink() raise +def parse_dsc(dscpath: pathlib.Path) -> debian.deb822.Dsc: + """Parse a dsc file.""" + with dscpath.open("r") as dscf: + return debian.deb822.Dsc(dscf) + def download_dsc(buildinput: JsonObject, destdir: pathlib.Path) -> pathlib.Path: """Download the .input.source_package_url including referenced components @@ -130,12 +135,11 @@ def download_dsc(buildinput: JsonObject, assert isinstance(dscpath, pathlib.Path) download(dscuri, buildinput.get("checksums", {}), dscpath) files: typing.Dict[str, typing.Dict[str, str]] = {} - with dscpath.open("r") as dscf: - for key, value in debian.deb822.Dsc(dscf).items(): - if key.lower().startswith("checksums-"): - for entry in value: - algo = key[10:].lower() - files.setdefault(entry["name"], dict())[algo] = entry[algo] + for key, value in parse_dsc(dscpath).items(): + if key.lower().startswith("checksums-"): + for entry in value: + algo = key[10:].lower() + files.setdefault(entry["name"], dict())[algo] = entry[algo] for name, checksums in files.items(): download(urllib.parse.urljoin(dscuri, name), checksums, destdir / name) return dscpath @@ -155,11 +159,12 @@ def get_dsc(build: JsonObject) -> typing.Iterator[pathlib.Path]: else: yield pathlib.Path(dscpath) -def get_dsc_files(dscpath: pathlib.Path) -> typing.List[pathlib.Path]: - """Get the component names referenced by the .dsc file.""" - with dscpath.open("r") as dscf: - dsc = debian.deb822.Dsc(dscf) - return [dscpath.parent / item["name"] for item in dsc["Files"]] +def get_dsc_files(dscpath: pathlib.Path, + dscobj: typing.Optional[debian.deb822.Dsc] = None) -> \ + typing.List[pathlib.Path]: + """Get the component names referenced by the .dsc.""" + return [dscpath.parent / item["name"] + for item in (dscobj or parse_dsc(dscpath))["Files"]] def make_option(optname: str, value: typing.Optional[str]) -> typing.List[str]: """Construct a valued option if a value is given.""" |