From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 605F41382C5 for ; Mon, 18 Jan 2021 20:22:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id ABE58E085E; Mon, 18 Jan 2021 20:22:17 +0000 (UTC) Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A4ACBE085E for ; Mon, 18 Jan 2021 20:22:17 +0000 (UTC) Received: by mail-qt1-f171.google.com with SMTP id c1so12196745qtc.1 for ; Mon, 18 Jan 2021 12:22:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lLRetJYPIgnjWMMgD3L/Zsv3P5JmtbzHU9t1vC+P8xo=; b=RixA9jgF4a/8xIhyvKlkWe5iqJSTa/z/VCUMeIK9YCZM2OrXANPWRozVIDR4cN38Sm TOIKGzz86Stgxpc3IuVPxz7p8XvH6l7aIc/yN7C3BQuJI1xda8m33aIVVh+VYlOBji1N QK7f5cIXL/s9q5BO009SMS4XImHmKVrUrEZl4hc9dqXV+cJC5NzFI6Jv9WVj2WsKFeWe EX4nc3HALcaa0oaYy36FcFaTZXFYTxFYxrm9cC6oQ5JJe+hZyGGDpi4/6Jvn0z1Uxjks OKedt8viFnTyEQRHazeCX9qggn8TY7W2SBCF1F/rq1KzL+P85XSEUy5xfdih2fzUEvhD 6zYA== X-Gm-Message-State: AOAM530jleravT1qg4YA9HaPvJmR7N9I/zo4bORSF8oGwlCQbAWawB5L vIBr6j5pwCYVPojEgr/lvBpeLBJJc/E= X-Google-Smtp-Source: ABdhPJzhvDtSGTgt9h39ahTC9QUYPkWg+833q49XW5/qpiDJHwWlw7mWyexbyj/u4BgEcL3DlYVgKQ== X-Received: by 2002:ac8:5909:: with SMTP id 9mr1299853qty.39.1611001336676; Mon, 18 Jan 2021 12:22:16 -0800 (PST) Received: from localhost ([208.104.103.123]) by smtp.gmail.com with ESMTPSA id o56sm4455306qtb.0.2021.01.18.12.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jan 2021 12:22:16 -0800 (PST) From: Matt Turner To: gentoo-catalyst@lists.gentoo.org Cc: Matt Turner Subject: [gentoo-catalyst] [PATCH 10/11] catalyst: Add option to enter the chroot before building Date: Mon, 18 Jan 2021 15:21:51 -0500 Message-Id: <20210118202152.374078-10-mattst88@gentoo.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210118202152.374078-1-mattst88@gentoo.org> References: <20210118202152.374078-1-mattst88@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: fda10d5e-e992-4b53-bb3a-72ec8a0218f9 X-Archives-Hash: c5f1e3dc3c1bba544e7bc7b8642233e0 With --enter-chroot, after the mounts and environment are set up, catalyst will drop you into a shell inside the chroot. Useful for hacking or debugging. Signed-off-by: Matt Turner --- catalyst/base/stagebase.py | 17 ++++++++++++++++- catalyst/main.py | 4 ++++ doc/catalyst.1.txt | 3 +++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 40b60af3..02e202c1 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -20,7 +20,7 @@ from catalyst import log from catalyst.context import namespace from catalyst.defaults import (confdefaults, MOUNT_DEFAULTS, PORT_LOGDIR_CLEAN) from catalyst.support import (CatalystError, file_locate, normpath, - cmd, read_makeconf, get_repo_name, ismount, + cmd, command, read_makeconf, get_repo_name, file_check, sanitize_name) from catalyst.base.targetbase import TargetBase from catalyst.base.clearbase import ClearBase @@ -94,6 +94,7 @@ class StageBase(TargetBase, ClearBase, GenBase): self.bind, self.chroot_setup, self.setup_environment, + self.enter_chroot, ] self.finish_sequence = [] @@ -1326,6 +1327,20 @@ class StageBase(TargetBase, ClearBase, GenBase): log.debug('setup_environment(); env = %r', self.env) + def enter_chroot(self): + if 'enter-chroot' not in self.settings['options']: + return + + chroot = command('chroot') + bash = command('bash') + + log.notice("Entering chroot") + try: + cmd([chroot, self.settings['chroot_path'], bash, '-l'], + env=self.env) + except CatalystError: + pass + def run(self): self.chroot_lock.write_lock() diff --git a/catalyst/main.py b/catalyst/main.py index 48daf004..b0d9015f 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -120,6 +120,8 @@ def get_parser(): parser.add_argument('-V', '--version', action='version', version=get_version(), help='display version information') + parser.add_argument('--enter-chroot', default=False, action='store_true', + help='Enter chroot before starting the build') group = parser.add_argument_group('Program output options') group.add_argument('-d', '--debug', @@ -293,6 +295,8 @@ def _main(parser, opts): options.append('purgetmponly') if opts.clear_autoresume: options.append('clear-autoresume') + if opts.enter_chroot: + options.append('enter-chroot') # Make sure we have some work before moving further. if not myspecfile and not mycmdline: diff --git a/doc/catalyst.1.txt b/doc/catalyst.1.txt index 90d5a24b..217fc86a 100644 --- a/doc/catalyst.1.txt +++ b/doc/catalyst.1.txt @@ -39,6 +39,9 @@ configuration file is installed at '/etc/catalyst/catalyst.conf'. *-d*:: Enable debugging mode +*--enter-chroot*:: +Enter the chroot before starting the build. + *--fetchonly*:: *-F*:: This tells *catalyst* to only fetch distfiles for the given packages without -- 2.26.2