From 7b5d4d5145731c9ef393e3b89767bba3bb683bf9 Mon Sep 17 00:00:00 2001 From: Stephen Smoogen Date: Thu, 20 May 2021 15:37:09 -0400 Subject: [PATCH] This is a hack in order to make grobisplitter understand different compression types from pungi output. Basically determine if the file is ends with gz (oldstyle) or xz (newstyle) or neither. If it is gz assume it is a gzip (HA!) or if it is xz assume it is LZMA (double ha!) and bail if it is neither. A proper fix would be to determine the file type holistically and pull in the appropriate decompression as needed. However to quote Dante from Clerks: I'm not even supposed to be here today! Signed-off-by: Stephen Smoogen --- roles/grobisplitter/files/splitter.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/roles/grobisplitter/files/splitter.py b/roles/grobisplitter/files/splitter.py index d14cd1be39..f1159c1f16 100755 --- a/roles/grobisplitter/files/splitter.py +++ b/roles/grobisplitter/files/splitter.py @@ -7,6 +7,7 @@ import shutil import gi import gzip import librepo +import lzma import hawkey import tempfile import os @@ -104,7 +105,15 @@ def _parse_repository_modular(repo_info,package_sack): """ cts = {} idx = mmd.ModuleIndex() - with gzip.GzipFile(filename=repo_info['modules'], mode='r') as gzf: + myfile = repo_info['modules'] + if myfile.endswith(".gz"): + openfunc=gzip.GzipFile + elif myfile.endswith(".xz"): + openfunc=lzma.LZMAFile + else: + print("This file type is not fixed in this hack. Please fix code. (2021-05-20)"); + sys.exit(1) + with openfunc(filename=myfile, mode='r') as gzf: mmdcts = gzf.read().decode('utf-8') res, failures = idx.update_from_string(mmdcts, True) if len(failures) != 0: @@ -190,7 +199,15 @@ def get_default_modules(directory): if 'modules' not in repo_info: return contents idx = mmd.ModuleIndex() - with gzip.GzipFile(filename=repo_info['modules'], mode='r') as gzf: + myfile=repo_info['modules'] + if myfile.endswith(".gz"): + openfunc=gzip.GzipFile + elif myfile.endswith(".xz"): + openfunc=lzma.LZMAFile + else: + print("This file type is not fixed in this hack. Please fix code. (2021-05-20)"); + sys.exit(1) + with openfunc(filename=myfile, mode='r') as gzf: mmdcts = gzf.read().decode('utf-8') res, failures = idx.update_from_string(mmdcts, True) if len(failures) != 0: