[pacman-dev] [PATCH 1/3] pmpkg: add makepkg_bytes
Builds the package file in memory. Useful with the built-in server. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> --- test/pacman/pmpkg.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py index 8ff1ec1e..01ed4e0a 100644 --- a/test/pacman/pmpkg.py +++ b/test/pacman/pmpkg.py @@ -98,7 +98,12 @@ def parse_filename(name): filename, extra = filename.split("|") return filename - def makepkg(self, path): + def makepkg_bytes(self): + buf = BytesIO(); + self.makepkg(fileobj=buf) + return buf.getvalue() + + def makepkg(self, path=None, fileobj=None): """Creates an Arch Linux package archive. A package archive is generated in the location 'path', based on the data @@ -138,11 +143,12 @@ def makepkg(self, path): if any(self.install.values()): archive_files.append((".INSTALL", self.installfile())) - self.path = os.path.join(path, self.filename()) - util.mkdir(os.path.dirname(self.path)) + if path: + self.path = os.path.join(path, self.filename()) + util.mkdir(os.path.dirname(self.path)) # Generate package metadata - tar = tarfile.open(self.path, "w:gz", format=tarfile.GNU_FORMAT) + tar = tarfile.open(name=self.path, fileobj=fileobj, mode="w:gz", format=tarfile.GNU_FORMAT) for name, data in archive_files: info = tarfile.TarInfo(name) info.size = len(data) -- 2.31.1
Useful for serving in-memory package files. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> --- test/pacman/pmserve.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/pacman/pmserve.py b/test/pacman/pmserve.py index 47e041d0..b6de9797 100644 --- a/test/pacman/pmserve.py +++ b/test/pacman/pmserve.py @@ -78,6 +78,8 @@ def do_GET(self): response.get('body', ''), headers=response.get('headers', {}), code=response.get('code', 200)) + elif isinstance(response, bytes): + self.respond_bytes(response) else: self.respond_string(response) else: -- 2.31.1
An extra break causes _alpm_download to break out of the payload loop as soon as it sees a successful url download with XferCommand. Fixes: FS#70608 - -U fails to download all files with XferCommand Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> --- This fixes the issue I *think*. There appears to be a deeper issue between -U and XferCommand (FS#70607 - XferCommand breaks -U) that breaks things altogether. So the test doesn't actually pass, but the CACHE_EXISTS rules at least do. lib/libalpm/dload.c | 1 - test/pacman/meson.build | 1 + .../upgrade-download-with-xfercommand.py | 23 +++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/pacman/tests/upgrade-download-with-xfercommand.py diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index a4c42f8d..57d25383 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -879,7 +879,6 @@ int _alpm_download(alpm_handle_t *handle, if(payload->fileurl) { if (handle->fetchcb(payload->fileurl, localpath, payload->force) != -1) { success = 1; - break; } } else { for(s = payload->servers; s; s = s->next) { diff --git a/test/pacman/meson.build b/test/pacman/meson.build index 6c28bd7d..03649b47 100644 --- a/test/pacman/meson.build +++ b/test/pacman/meson.build @@ -333,6 +333,7 @@ pacman_tests = [ 'tests/upgrade-download-404.py', 'tests/upgrade-download-pkg-and-sig-with-filename.py', 'tests/upgrade-download-pkg-and-sig-without-filename.py', + 'tests/upgrade-download-with-xfercommand.py', ] xfail_tests = { diff --git a/test/pacman/tests/upgrade-download-with-xfercommand.py b/test/pacman/tests/upgrade-download-with-xfercommand.py new file mode 100644 index 00000000..63510e19 --- /dev/null +++ b/test/pacman/tests/upgrade-download-with-xfercommand.py @@ -0,0 +1,23 @@ +self.description = "--upgrade remote packages with XferCommand" + +#wget doesn't support file:// urls. curl does +self.option['XferCommand'] = ['/usr/bin/curl %u -o %o'] + +p1 = pmpkg('pkg1', '1.0-1') +self.addpkg(p1) + +p2 = pmpkg('pkg2', '2.0-2') +self.addpkg(p2) + +url = self.add_simple_http_server({ + '/{}'.format(p1.filename()): p1.makepkg_bytes(), + '/{}'.format(p2.filename()): p2.makepkg_bytes(), +}) + +self.args = '-U {url}/{} {url}/{}'.format(p1.filename(), p2.filename(), url=url) + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_EXIST=pkg1") +self.addrule("PKG_EXIST=pkg2") +self.addrule("CACHE_EXISTS=pkg1|1.0-1") +self.addrule("CACHE_EXISTS=pkg2|2.0-2") -- 2.31.1
participants (1)
-
Andrew Gregory