From: Anton Mikanovich <amikan@ilbers.de>
To: isar-users@googlegroups.com
Cc: Anton Mikanovich <amikan@ilbers.de>
Subject: [PATCH v2 4/4] events: Cleanup lost schroot sessions if any
Date: Fri, 30 Dec 2022 22:08:24 +0300 [thread overview]
Message-ID: <20221230190824.12256-5-amikan@ilbers.de> (raw)
In-Reply-To: <20221230190824.12256-1-amikan@ilbers.de>
In case the user will only open imager schroot session but not close it
we need to find and clean it up.
Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
meta/classes/isar-events.bbclass | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/meta/classes/isar-events.bbclass b/meta/classes/isar-events.bbclass
index f52b2349..5343d4b1 100644
--- a/meta/classes/isar-events.bbclass
+++ b/meta/classes/isar-events.bbclass
@@ -51,6 +51,22 @@ python build_completed() {
basepath = tmpdir + '/work/'
+ build_uuid = d.getVar('ISAR_BUILD_UUID', True)
+ sessions = subprocess.run('schroot -l --all-sessions | grep isar | grep %s' % build_uuid,
+ shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
+ for line in sessions.splitlines():
+ session_id = line.split(':', 1)[1]
+ bb.debug(1, 'Closing imager session %s' % session_id)
+ id = subprocess.run("schroot -d / -r -c %s -- printenv -0 SCHROOT_ALIAS_NAME" % session_id,
+ shell=True, check=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
+ if id:
+ subprocess.run('schroot --recover-session -c %s' % session_id, shell=True, check=True)
+ subprocess.run('schroot -e -c %s' % session_id, shell=True, check=True)
+ if 'id' in locals():
+ d.setVar('SBUILD_CHROOT', id)
+ bb.build.exec_func('remove_mounts', d)
+ bb.build.exec_func('schroot_delete_configs', d)
+
with open('/proc/mounts') as f:
for line in f.readlines():
if basepath in line:
--
2.17.1
next prev parent reply other threads:[~2022-12-30 19:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-30 19:08 [PATCH v2 0/4] Imager schroot migration Anton Mikanovich
2022-12-30 19:08 ` [PATCH v2 1/4] sbuild: Allow setting custom config paths Anton Mikanovich
2022-12-30 19:08 ` [PATCH v2 2/4] imager: Migrate from buildchroot to schroot Anton Mikanovich
2022-12-30 19:08 ` [PATCH v2 3/4] imager: Move image types " Anton Mikanovich
2022-12-30 19:08 ` Anton Mikanovich [this message]
2023-01-03 9:55 ` [PATCH v2 4/4] events: Cleanup lost schroot sessions if any Roberto A. Foglietta
2023-01-04 11:19 ` Roberto A. Foglietta
2022-12-30 19:13 ` [PATCH v2 0/4] Imager schroot migration Anton Mikanovich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221230190824.12256-5-amikan@ilbers.de \
--to=amikan@ilbers.de \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox