From nobody Mon Feb 9 09:22:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615570208; cv=none; d=zohomail.com; s=zohoarc; b=NZVCmaWLaiQ/egSiEBSCHcJMtEvKU74809AfY2JTDO6Jb75pwRI3etFJBU58bsJyabn3dCyI1EcS3XStc/Ymd6eIuhWAFV0/nxvMw60DX3pA9rxsmBXQClIv22oTmp6bgiROQJkoaGN2X5Rgds1Eao07uX9Ehzba0vhoYxXk/jA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615570208; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ObhNNVZ4sepBGoGepo06uPkb2b3u4pZq8t70aNKj69w=; b=Bm2HEAdS6YjWUmA2xtgsrVerheaLxwd5l474dwMMzzQqGthTWweVN5SddkDtk0EqIAXUWvOY9VL+M7MbqUi7SAPF4BzVOPxEZjMBYV6W4/1QGAQA52mzdGKEOnc4S3CQDrqW2y7FzqS3kxRgeXSGs4QcJAQQ7Ijdc5q+f1ALGO4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 161557020798276.93855987078973; Fri, 12 Mar 2021 09:30:07 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-525-y81pfs71MCKc-PXX0Usm7Q-1; Fri, 12 Mar 2021 12:28:49 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F27A51B2C98C; Fri, 12 Mar 2021 17:28:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C37371002388; Fri, 12 Mar 2021 17:28:42 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5C8B81800B99; Fri, 12 Mar 2021 17:28:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12CHSY5X031349 for ; Fri, 12 Mar 2021 12:28:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id 33EC85D6D7; Fri, 12 Mar 2021 17:28:34 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.194.186]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F2CC5D6BA for ; Fri, 12 Mar 2021 17:28:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615570206; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ObhNNVZ4sepBGoGepo06uPkb2b3u4pZq8t70aNKj69w=; b=VEzMvRO6G9UWaCtn2Omm5CpsF7ixhR+380tqupP8eVcq09I0MeMHiK2XUFXJNCPVZjOQxE jlv+l3+VJDqJzGaE7KDC6pUGwpeGl7pOlLfl3Fd7gLzRIcabToH6t8rcW2MEZCmPRbw9IA y+5rv5vm3OFldV1ayWD6atV0HM8cFfc= X-MC-Unique: y81pfs71MCKc-PXX0Usm7Q-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v3 04/10] ci: Implement 'refresh' helper action Date: Fri, 12 Mar 2021 18:28:16 +0100 Message-Id: <20210312172822.244833-5-abologna@redhat.com> In-Reply-To: <20210312172822.244833-1-abologna@redhat.com> References: <20210312172822.244833-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This provides the same functionality as the two refresh scripts that are currently in the repository, with the following advantages: * all files are refreshed with a single command; * if lcitool is present in the user's $PATH, it will be discovered and used automatically; * some output is produced, so the user can follow along with the progress of the operation. Signed-off-by: Andrea Bolognani --- ci/helper | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/ci/helper b/ci/helper index 2a59b8e5ab..05ecdcb426 100755 --- a/ci/helper +++ b/ci/helper @@ -18,10 +18,22 @@ =20 import argparse import pathlib +import shutil +import subprocess +import sys =20 =20 class Parser: def __init__(self): + # Options that are common to all actions that use lcitool + lcitoolparser =3D argparse.ArgumentParser(add_help=3DFalse) + lcitoolparser.add_argument( + "--lcitool", + metavar=3D"PATH", + default=3D"lcitool", + help=3D"path to lcitool binary", + ) + # Main parser self.parser =3D argparse.ArgumentParser() subparsers =3D self.parser.add_subparsers( @@ -30,6 +42,14 @@ class Parser: ) subparsers.required =3D True =20 + # refresh action + refreshparser =3D subparsers.add_parser( + "refresh", + help=3D"refresh data generated with lcitool", + parents=3D[lcitoolparser], + ) + refreshparser.set_defaults(func=3DApplication.action_refresh) + def parse(self): return self.parser.parse_args() =20 @@ -39,6 +59,88 @@ class Application: self.basedir =3D pathlib.Path(__file__).resolve().parent self.args =3D Parser().parse() =20 + if self.args.action =3D=3D "refresh": + if not shutil.which(self.args.lcitool): + sys.exit("error: 'lcitool' not installed") + + def lcitool_run(self, args): + output =3D subprocess.check_output([self.args.lcitool] + args) + return output.decode("utf-8") + + def lcitool_get_hosts(self): + output =3D self.lcitool_run(["hosts"]) + return output.splitlines() + + def generate_dockerfile(self, host, cross=3DNone): + args =3D ["dockerfile", host, "libvirt"] + outdir =3D self.basedir.joinpath("containers") + outfile =3D f"ci-{host}.Dockerfile" + + if cross: + args.extend(["--cross", cross]) + outfile =3D f"ci-{host}-cross-{cross}.Dockerfile" + + output =3D self.lcitool_run(args) + with open(outdir.joinpath(outfile), "w") as f: + f.write(output) + + def generate_vars(self, host): + args =3D ["variables", host, "libvirt"] + outdir =3D self.basedir.joinpath("cirrus") + outfile =3D f"{host}.vars" + + output =3D self.lcitool_run(args) + with open(outdir.joinpath(outfile), "w") as f: + f.write(output) + + def refresh_containers(self): + debian_cross =3D [ + "aarch64", + "armv6l", + "armv7l", + "i686", + "mips", + "mips64el", + "mipsel", + "ppc64le", + "s390x", + ] + fedora_cross =3D [ + "mingw32", + "mingw64", + ] + + for host in self.lcitool_get_hosts(): + if host.startswith("freebsd-") or host.startswith("macos-"): + continue + + print(f"containers/{host}") + self.generate_dockerfile(host) + + if host =3D=3D "fedora-rawhide": + for cross in fedora_cross: + print(f"containers/{host} ({cross})") + self.generate_dockerfile(host, cross) + + if host.startswith("debian-"): + for cross in debian_cross: + if host =3D=3D "debian-sid" and cross =3D=3D "mips": + continue + print(f"containers/{host} ({cross})") + self.generate_dockerfile(host, cross) + + def refresh_cirrus(self): + for host in self.lcitool_get_hosts(): + if not (host.startswith("freebsd-") or host.startswith("macos-= ")): + continue + + print(f"cirrus/{host}") + self.generate_vars(host) + + def action_refresh(self): + self.refresh_containers() + self.refresh_cirrus() + def run(self): self.args.func(self) =20 --=20 2.26.2