From 570fd0a05d525dd72ff7e47ac26250ad06b8017a Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Tue, 31 Aug 2021 09:03:34 -0400 Subject: [PATCH] Use `ar` & `tar` instead of `dpkg -x` --- src/datalad_installer.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/datalad_installer.py b/src/datalad_installer.py index adddb4b..0363efa 100755 --- a/src/datalad_installer.py +++ b/src/datalad_installer.py @@ -2076,20 +2076,26 @@ def install_deb( install_dir: Optional[Path] = None, extra_args: Optional[List[str]] = None, ) -> Path: - cmd: List[Union[str, os.PathLike]] = ["dpkg"] - if extra_args is not None: - cmd.extend(extra_args) if install_dir is None: + cmd: List[Union[str, os.PathLike]] = ["dpkg"] + if extra_args is not None: + cmd.extend(extra_args) cmd.append("-i") cmd.append(debpath) manager.sudo(*cmd) return Path("/usr/bin") else: + if extra_args: + log.warning("Not using dpkg; ignoring --extra-args") + assert os.path.isabs(debpath) install_dir.mkdir(parents=True, exist_ok=True) - cmd.append("-x") - cmd.append(debpath) - cmd.append(install_dir) - runcmd(*cmd) + install_dir = install_dir.resolve() + with tempfile.TemporaryDirectory() as tmpdir: + oldpwd = os.getcwd() + os.chdir(tmpdir) + runcmd("ar", "-x", debpath) + runcmd("tar", "-C", install_dir, "-xzf", "data.tar.gz") + os.chdir(oldpwd) manager.addpath(install_dir / bin_path) return install_dir / bin_path