diff options
author | Helmut Grohne <helmut@subdivi.de> | 2021-06-24 13:53:31 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2021-06-24 13:53:31 +0200 |
commit | 312342b3e5eeee88dc47f555f11defc80d3d02e9 (patch) | |
tree | c8f4b3c8497446caef73ce54394b72663965a582 | |
parent | c03690f53941e03a6f1f400da4d7313f36902426 (diff) | |
download | mdbp-312342b3e5eeee88dc47f555f11defc80d3d02e9.tar.gz |
rename a number of fields to become similar to debusine
debusine describes a PackageBuildTask in docs/devel/ontology.rst.
Changes performed herein:
* dscpath -> source_package_path
* dscuri -> source_package_url
* buildarch -> build_architecture
* hostarch -> host_architecture
* options -> build_options
* profiles -> build_profiles
* buildpath -> build_path
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | mdbp/build_schema.json | 18 | ||||
-rw-r--r-- | mdbp/common.py | 17 | ||||
-rwxr-xr-x | mdbp/debspawn.py | 13 | ||||
-rw-r--r-- | mdbp/mmdebstrap.py | 24 | ||||
-rw-r--r-- | mdbp/pbuilder.py | 8 | ||||
-rw-r--r-- | mdbp/sbuild.py | 8 | ||||
-rw-r--r-- | mdbp/ssh.py | 4 | ||||
-rw-r--r-- | mdbp/streamapi.py | 4 |
9 files changed, 51 insertions, 47 deletions
@@ -14,7 +14,7 @@ is a schema describing the available parameters in `mdbp/build_schema.json`. An example build request could be: { - "input": {"dscpath": "./hello_2.10-2.dsc"}, + "input": {"source_package_path": "./hello_2.10-2.dsc"}, "distribution": "unstable", "output": {"directory": "out"} } diff --git a/mdbp/build_schema.json b/mdbp/build_schema.json index c908fb6..0f7e9bc 100644 --- a/mdbp/build_schema.json +++ b/mdbp/build_schema.json @@ -7,19 +7,19 @@ "input": { "type": "object", "oneOf": [ { - "required": [ "dscpath" ], + "required": [ "source_package_path" ], "additionalProperties": false, "properties": { - "dscpath": { + "source_package_path": { "type": "string", "description": "path to the .dsc file that is to be built, can be relative to the location of this json file" } } }, { - "required": [ "dscuri" ], + "required": [ "source_package_url" ], "additionalProperties": false, "properties": { - "dscuri": { + "source_package_url": { "type": "string", "format": "uri", "description": "uri for downloading the .dsc file" @@ -68,26 +68,26 @@ "default": "binary", "description": "select an arch-only, indep-only or full build" }, - "buildarch": { + "build_architecture": { "type": "string", "minLength": 2, "pattern": "^[a-z0-9-]+$", "description": "build architecture, defaults to the native architecure" }, - "hostarch": { + "host_architecture": { "type": "string", "minLength": 2, "pattern": "^[a-z0-9-]+$", "description": "host architecture, defaults to the build architecture" }, - "profiles": { + "build_profiles": { "type": "array", "items": { "type": "string", "pattern": "^[a-z0-9.-]+$" }, "uniqueItems": true, "default": [], "description": "select build profiles to enabled" }, - "options": { + "build_options": { "type": "array", "items": { "type": "string", "pattern": "^[a-z0-9.,+=_-]+$" }, "uniqueItems": true, @@ -110,7 +110,7 @@ "default": [], "description": "extra environment variables" }, - "buildpath": { + "build_path": { "type": "string", "description": "the path inside the chroot to peform the build" }, diff --git a/mdbp/common.py b/mdbp/common.py index 7a528bc..719a8b6 100644 --- a/mdbp/common.py +++ b/mdbp/common.py @@ -42,11 +42,11 @@ def buildjson_validate(buildobj: JsonObject) -> None: def buildjson_patch_relative(buildobj: JsonObject, basedir: pathlib.PurePath) -> None: """Resolve relative paths used in the buildobj using the given basedir: - * .input.dscpath + * .input.source_package_path * .output.directory The operation is performed in-place and modifes the given buildobj. """ - for attrs in (("input", "dscpath"), ("output", "directory")): + for attrs in (("input", "source_package_path"), ("output", "directory")): obj = buildobj for attr in attrs[:-1]: try: @@ -73,7 +73,7 @@ def compute_env(build: JsonObject) -> typing.Dict[str, str]: parallel = build.get("parallel") if parallel == "auto": parallel = "%d" % multiprocessing.cpu_count() - options = build.get("options", []) + options = build.get("build_options", []) if parallel: options.append("parallel=" + str(parallel)) if options: @@ -120,10 +120,11 @@ def download(uri: str, checksums: typing.Dict[str, str], def download_dsc(buildinput: JsonObject, destdir: pathlib.Path) -> pathlib.Path: - """Download the .input.dscuri including referenced components to the given - destination directory and return the path to the contained .dsc file. + """Download the .input.source_package_url including referenced components + to the given destination directory and return the path to the contained + .dsc file. """ - dscuri = buildinput["dscuri"] + dscuri = buildinput["source_package_url"] dscpath = destdir / dscuri.split("/")[-1] # mypy doesn't grok this: assert isinstance(dscpath, pathlib.Path) @@ -147,7 +148,7 @@ def get_dsc(build: JsonObject) -> typing.Iterator[pathlib.Path]: downloaded to a temporary location. """ try: - dscpath = build["input"]["dscpath"] + dscpath = build["input"]["source_package_path"] except KeyError: with tempfile.TemporaryDirectory() as tdir: yield download_dsc(build["input"], pathlib.Path(tdir)) @@ -170,7 +171,7 @@ def make_option(optname: str, value: typing.Optional[str]) -> typing.List[str]: def profile_option(build: JsonObject, optname: str) -> typing.List[str]: """Construct the option for specifying build profiles if required.""" - return make_option(optname, ",".join(build.get("profiles", ()))) + return make_option(optname, ",".join(build.get("build_profiles", ()))) def tar_add(tarobj: tarfile.TarFile, path: pathlib.Path) -> None: """Add the given file as its basename to the tarobj retaining its diff --git a/mdbp/debspawn.py b/mdbp/debspawn.py index e98605c..a84bba0 100755 --- a/mdbp/debspawn.py +++ b/mdbp/debspawn.py @@ -23,9 +23,10 @@ def main() -> None: if "bd-uninstallable-explainer" in build: raise ValueError("bd-uninstallable-explainer %r not supported" % build["bd-uinstallable-explainer"]) - if build.get("buildpath"): - raise ValueError("buildpath not supported") - if build.get("hostarch") not in (None, build.get("buildarch")): + if build.get("build_path"): + raise ValueError("build_path not supported") + if build.get("host_architecture") not in (None, + build.get("build_architecture")): raise ValueError("cross building is not supported") if build.get("lintian", {}).get("run", False) and \ build["lintian"].get("options"): @@ -34,14 +35,14 @@ def main() -> None: raise ValueError("disabling network is not supported") env = compute_env(build) - if build.get("profiles"): - env["DEB_BUILD_PROFILES"] = " ".join(build["profiles"]) + if build.get("build_profiles"): + env["DEB_BUILD_PROFILES"] = " ".join(build["build_profiles"]) enablelog = build["output"].get("log", True) cmd = [ *(["sudo", "--"] if os.getuid() != 0 else ()), "debspawn", "build", "--no-buildlog", - *make_option("--arch", build.get("buildarch")), + *make_option("--arch", build.get("build_architecture")), "--only", dict( any="arch", diff --git a/mdbp/mmdebstrap.py b/mdbp/mmdebstrap.py index aa1f461..c864bce 100644 --- a/mdbp/mmdebstrap.py +++ b/mdbp/mmdebstrap.py @@ -63,12 +63,12 @@ def hook_main(buildjsonfilename: str, chrootname: str) -> None: """The entry point for the --hook-helper invocation run from mmdebstrap.""" build = json_load(pathlib.Path(buildjsonfilename).open("r")) chroot = pathlib.Path(chrootname) - buildpath = pathlib.PurePath(build.get("buildpath", "/build/build")) + buildpath = pathlib.PurePath(build.get("build_path", "/build/build")) fullbuildpath = chroot / buildpath.relative_to("/") - if "dscpath" in build["input"]: + if "source_package_path" in build["input"]: dscpath = fullbuildpath.parent / \ - pathlib.PurePath(build["input"]["dscpath"]).name - elif "dscuri" in build["input"]: + pathlib.PurePath(build["input"]["source_package_path"]).name + elif "source_package_url" in build["input"]: dscpath = download_dsc(build["input"], fullbuildpath.parent) priv_drop(["chown", "-R", "build:build", "."], chroot=chroot, chdir=buildpath.parent) @@ -87,7 +87,8 @@ def hook_main(buildjsonfilename: str, chrootname: str) -> None: setuid="build", chroot=chroot, chdir=buildpath.parent) for path in [*get_dsc_files(dscpath), dscpath]: path.unlink() - hostarch = build.get("hostarch") or build.get("buildarch") or \ + hostarch = build.get("host_architecture") or \ + build.get("build_architecture") or \ native_architecture() cmd = [*apt_get, "build-dep", "--host-architecture", hostarch, *dict(any=["--arch-only"], @@ -157,8 +158,8 @@ def main() -> None: raise ValueError("bd-uinstallable-explainer %r not supported" % build.get("bd-uinstallable-explainer")) - buildarch = build.get("buildarch") or native_architecture() - hostarch = build.get("hostarch") or buildarch + buildarch = build.get("build_architecture") or native_architecture() + hostarch = build.get("host_architecture") or buildarch if buildarch == hostarch: buildessential = set(("build-essential", "fakeroot")) @@ -167,7 +168,7 @@ def main() -> None: "libc-dev:" + hostarch, "libstdc++-dev:" + hostarch, "fakeroot")) - buildpath = pathlib.PurePath(build.get("buildpath", "/build/build")) + buildpath = pathlib.PurePath(build.get("build_path", "/build/build")) enablelog = build["output"].get("log", True) cmd = [ @@ -184,10 +185,11 @@ def main() -> None: '--home-dir %s build --skel /nonexistent' % shlex.quote(str(buildpath.parent)), *(["--customize-hook=copy-in " + shlex.join([ - build["input"]["dscpath"], - *map(str, get_dsc_files(pathlib.Path(build["input"]["dscpath"]))), + build["input"]["source_package_path"], + *map(str, get_dsc_files(pathlib.Path( + build["input"]["source_package_path"]))), str(buildpath.parent)])] - if "dscpath" in build["input"] else ()), + if "source_package_path" in build["input"] else ()), '--customize-hook=mdbp-mmdebstrap --hook-helper %s "$1"' % shlex.quote(args.raw_buildjson), *(["--customize-hook=sync-out " + diff --git a/mdbp/pbuilder.py b/mdbp/pbuilder.py index 09b6b59..fb5c4fe 100644 --- a/mdbp/pbuilder.py +++ b/mdbp/pbuilder.py @@ -43,8 +43,8 @@ def main() -> None: if "bd-uninstallable-explainer" in build: raise ValueError("bd-uninstallable-explainer %r not supported" % build["bd-uinstallable-explainer"]) - if build.get("buildpath"): - raise ValueError("buildpath not supported") + if build.get("build_path"): + raise ValueError("build_path not supported") if build["distribution"] in ("sid", "unstable"): basetgz = None else: @@ -62,8 +62,8 @@ def main() -> None: cmd.extend(["sudo", "-E", "--"]) cmd.extend(["/usr/sbin/pbuilder", "build", "--no-source-only-changes"]) cmd.extend(make_option("--basetgz", basetgz)) - cmd.extend(make_option("--architecture", build.get("buildarch"))) - cmd.extend(make_option("--host-arch", build.get("hostarch"))) + cmd.extend(make_option("--architecture", build.get("build_architecture"))) + cmd.extend(make_option("--host-arch", build.get("host_architecture"))) cmd.extend(make_option("--othermirror", "|".join(build.get("extrarepositories", ())))) cmd.extend(make_option("--use-network", diff --git a/mdbp/sbuild.py b/mdbp/sbuild.py index 02aa6cf..f1d4fe4 100644 --- a/mdbp/sbuild.py +++ b/mdbp/sbuild.py @@ -83,13 +83,13 @@ def main() -> None: with contextlib.suppress(KeyError): sbc["lintian_opts"] = build["lintian"]["options"] with contextlib.suppress(KeyError): - sbc["build_arch"] = build["buildarch"] + sbc["build_arch"] = build["build_architecture"] with contextlib.suppress(KeyError): - sbc["host_arch"] = build["hostarch"] + sbc["host_arch"] = build["host_architecture"] with contextlib.suppress(KeyError): - sbc["build_profiles"] = " ".join(build["profiles"]) + sbc["build_profiles"] = " ".join(build["build_profiles"]) with contextlib.suppress(KeyError): - sbc["build_path"] = build["buildpath"] + sbc["build_path"] = build["build_path"] if build.get("network") == "try-disable": sbc["external_commands"]["starting-build-commands"] = \ ["mv /etc/resolv.conf /etc/resolv.conf.disabled"] diff --git a/mdbp/ssh.py b/mdbp/ssh.py index 50b7d25..4cb64cd 100644 --- a/mdbp/ssh.py +++ b/mdbp/ssh.py @@ -26,12 +26,12 @@ def produce_request_tar(buildjsonobj: JsonObject, del sendjsonobj["output"]["directory"] dscpath: typing.Optional[pathlib.Path] try: - dscpath = pathlib.Path(buildjsonobj["input"]["dscpath"]) + dscpath = pathlib.Path(buildjsonobj["input"]["source_package_path"]) except KeyError: dscpath = None else: sendjsonobj["input"] = sendjsonobj["input"].copy() - sendjsonobj["input"]["dscpath"] = dscpath.name + sendjsonobj["input"]["source_package_path"] = dscpath.name tar = tarfile.open(mode="w|", fileobj=fileobj) info = tarfile.TarInfo("build.json") sendjsonfile = io.BytesIO() diff --git a/mdbp/streamapi.py b/mdbp/streamapi.py index f36208a..a32761b 100644 --- a/mdbp/streamapi.py +++ b/mdbp/streamapi.py @@ -5,8 +5,8 @@ backend and is used as frontend from the ssh backend on the remote side. Differences to the regular backend API: * It expects an uncompressed tar file on stdin. The first member must be named "build.json". Any other members must be regular files. The build.json file - should lack the .output.directory and if an .input.dscpath is given, it - should not contain any slashes. + should lack the .output.directory and if an .input.source_package_path is + given, it should not contain any slashes. * The build log is issued on stderr instead of stdout. * All the requested artifacts are emitted as a tar stream on stdout. """ |