From e5882e9d4b8e86afead4989c66ad21253f1704d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Luttringer?= Date: Fri, 16 Oct 2015 23:37:01 +0200 Subject: [PATCH] Install in a row Packages install must be done in a row in order to support packages dependencies --- agetpkg | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/agetpkg b/agetpkg index 7cefe69..021952e 100755 --- a/agetpkg +++ b/agetpkg @@ -162,15 +162,6 @@ class Package(Url): if sign and self.sigurl.exists: self.sigurl.download(self.sigfilename) - def install(self, sign=True): - """Download and install a package""" - with TemporaryDirectory() as tmpdir: - cwd = getcwd() - chdir(tmpdir) - self.get(sign) - pacman(["-U", self.filename]) - chdir(cwd) - class Archive(object): """Abstract access to the package Archive""" @@ -269,6 +260,7 @@ def pacman(args, asroot=True): cmd = ["su", "root", "-c=%s" % " ".join(cmd) ] else: error("Unable to execute as root: %s" % " ".join(cmd)) + debug("calling: %s" % cmd) call(cmd, close_fds=True) def list_packages(packages, long=False): @@ -315,9 +307,15 @@ def get_packages(packages): pkg.get() def install_packages(packages): - """install packages""" - for pkg in select_packages(packages): - pkg.install() + """install packages in one shot to allow deps to work""" + packages = list(select_packages(packages)) + with TemporaryDirectory() as tmpdir: + cwd = getcwd() + chdir(tmpdir) + for pkg in packages: + pkg.get() + pacman(["-U"] + [ pkg.filename for pkg in packages ]) + chdir(cwd) def parse_argv(): '''Parse command line arguments''' -- GitLab