From 32a75c4f782a0292983a054336d7197e4c75a3a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 21 Apr 2016 02:26:16 +0200 Subject: [PATCH] lorax: fix SEGV in librpm during ISO build https://bugzilla.redhat.com/1208296 QubesOS/qubes-issues#1807 --- ...rocessing-for-do_transaction-1208296.patch | 159 ++++++++++++++++++ lorax/lorax.spec | 3 + 2 files changed, 162 insertions(+) create mode 100644 lorax/Drop-multiprocessing-for-do_transaction-1208296.patch diff --git a/lorax/Drop-multiprocessing-for-do_transaction-1208296.patch b/lorax/Drop-multiprocessing-for-do_transaction-1208296.patch new file mode 100644 index 0000000..5053e41 --- /dev/null +++ b/lorax/Drop-multiprocessing-for-do_transaction-1208296.patch @@ -0,0 +1,159 @@ +From b3bf61bfddf80bfa7f9b152eb17d9b7b5393ecc5 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Wed, 9 Sep 2015 15:58:57 -0700 +Subject: [PATCH] Drop multiprocessing for do_transaction (#1208296) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Organization: Invisible Things Lab +Cc: Marek Marczykowski-Górecki + +When running the transaction in a separate process it crashes if you use +a https repo source. There's really no need for threads or processes in +lorax so drop it. + +Also switched to using the DNF TransactionProgress API for progress +reporting. + +Signed-off-by: Marek Marczykowski-Górecki +--- + src/pylorax/dnfhelper.py | 26 +++++++++++------------ + src/pylorax/ltmpl.py | 55 ++++++------------------------------------------ + 2 files changed, 19 insertions(+), 62 deletions(-) + +diff --git a/src/pylorax/dnfhelper.py b/src/pylorax/dnfhelper.py +index 8e35776..a25d3f6 100644 +--- a/src/pylorax/dnfhelper.py ++++ b/src/pylorax/dnfhelper.py +@@ -85,23 +85,23 @@ class LoraxDownloadCallback(dnf.callback.DownloadProgress): + self.total_size = total_size + + +-class LoraxRpmCallback(dnf.callback.LoggingTransactionDisplay): +- def __init__(self, queue): ++class LoraxRpmCallback(dnf.callback.TransactionProgress): ++ def __init__(self): + super(LoraxRpmCallback, self).__init__() +- self._queue = queue + self._last_ts = None +- self.cnt = 0 + +- def event(self, package, action, te_current, te_total, ts_current, ts_total): +- if action == self.PKG_INSTALL and te_current == 0: ++ def progress(self, package, action, ti_done, ti_total, ts_done, ts_total): ++ if action == self.PKG_INSTALL: + # do not report same package twice +- if self._last_ts == ts_current: ++ if self._last_ts == ts_done: + return +- self._last_ts = ts_current ++ self._last_ts = ts_done + +- msg = '(%d/%d) %s.%s' % \ +- (ts_current, ts_total, package.name, package.arch) +- self.cnt += 1 +- self._queue.put(('install', msg)) ++ msg = '(%d/%d) %s.%s' % (ts_done, ts_total, package.name, package.arch) ++ logger.info(msg) + elif action == self.TRANS_POST: +- self._queue.put(('post', None)) ++ msg = "Performing post-installation setup tasks" ++ logger.info(msg) ++ ++ def error(self, err_msg): ++ logger.warning(err_msg) +diff --git a/src/pylorax/ltmpl.py b/src/pylorax/ltmpl.py +index 93ecd14..053dec4 100644 +--- a/src/pylorax/ltmpl.py ++++ b/src/pylorax/ltmpl.py +@@ -32,15 +32,12 @@ from pylorax.dnfhelper import LoraxDownloadCallback, LoraxRpmCallback + from pylorax.base import DataHolder + from pylorax.executils import runcmd, runcmd_output + from pylorax.imgutils import mkcpio +-import pylorax.output as output + + from mako.lookup import TemplateLookup + from mako.exceptions import text_error_template + import sys, traceback + import struct + import dnf +-import multiprocessing +-import queue + import collections + + class LoraxTemplate(object): +@@ -501,40 +498,12 @@ class LoraxTemplateRunner(object): + else: + logger.debug("removepkg %s: no files to remove!", p) + +- def get_token_checked(self, process, token_queue): +- """Try to get token from queue checking that process is still alive""" +- +- try: +- # wait at most a minute for the token +- (token, msg) = token_queue.get(timeout=60) +- except queue.Empty: +- if process.is_alive(): +- try: +- # process still alive, give it 2 minutes more +- (token, msg) = token_queue.get(timeout=120) +- except queue.Empty: +- # waited for 3 minutes and got nothing +- raise Exception("The transaction process got stuck somewhere (no message from it in 3 minutes)") +- else: +- raise Exception("The transaction process has ended abruptly") +- +- return (token, msg) +- + def run_pkg_transaction(self): + ''' + run_pkg_transaction + Actually install all the packages requested by previous 'installpkg' + commands. + ''' +- +- def do_transaction(base, token_queue): +- try: +- display = LoraxRpmCallback(token_queue) +- base.do_transaction(display=display) +- except BaseException as e: +- logger.error("The transaction process has ended abruptly: %s", e) +- token_queue.put(('quit', str(e))) +- + try: + logger.info("Checking dependencies") + self.dbo.resolve() +@@ -555,24 +524,12 @@ class LoraxTemplateRunner(object): + raise + + logger.info("Preparing transaction from installation source") +- token_queue = multiprocessing.Queue() +- msgout = output.LoraxOutput() +- process = multiprocessing.Process(target=do_transaction, args=(self.dbo, token_queue)) +- process.start() +- (token, msg) = self.get_token_checked(process, token_queue) +- +- while token not in ('post', 'quit'): +- if token == 'install': +- logging.info("%s", msg) +- msgout.writeline(msg) +- (token, msg) = self.get_token_checked(process, token_queue) +- +- if token == 'quit': +- logger.error("Transaction failed.") +- raise Exception("Transaction failed") +- +- logger.info("Performing post-installation setup tasks") +- process.join() ++ try: ++ display = LoraxRpmCallback() ++ self.dbo.do_transaction(display=display) ++ except BaseException as e: ++ logger.error("The transaction process has ended abruptly: %s", e) ++ raise + + # Reset the package sack to pick up the installed packages + self.dbo.reset(repos=False) +-- +2.1.0 + diff --git a/lorax/lorax.spec b/lorax/lorax.spec index ba5311c..2b4a114 100644 --- a/lorax/lorax.spec +++ b/lorax/lorax.spec @@ -17,6 +17,7 @@ URL: https://github.com/rhinstaller/lorax # git checkout -b archive-branch lorax-%%{version}-%%{release} # tito build --tgz Source0: %{name}-%{version}.tar.gz +Patch0: Drop-multiprocessing-for-do_transaction-1208296.patch BuildRequires: python3-devel BuildRequires: python3-pocketlint >= 0.5 @@ -108,6 +109,8 @@ to run Anaconda. %prep %setup -q -n %{name}-%{version} +%patch0 -p1 + %build %install