From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 02023429C4; Fri, 28 Apr 2023 21:39:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C3EB410DD; Fri, 28 Apr 2023 21:39:00 +0200 (CEST) Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by mails.dpdk.org (Postfix) with ESMTP id 820A3406B5 for ; Fri, 28 Apr 2023 21:38:59 +0200 (CEST) Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-63b4a64c72bso329404b3a.0 for ; Fri, 28 Apr 2023 12:38:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1682710738; x=1685302738; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=4DFLHjPuYplecSYyhtg6EWBT7MYAO/TRB9YyCeDllHQ=; b=C8Knpu/85SqjdqUlyh+5oMlBIVV6+1qoKYFthoj/DfO8iI7YhYtjziqOubib6yVjhY Bemf+KiyqTGKEySDRfezLaMoBG+S4L/5qIjjTLhovgQUJW4SkhYSJSZOt270ylslZWQC 8rHXfGmnloVKK15tlexAMvfU9ijuOGbyg99O0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682710738; x=1685302738; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4DFLHjPuYplecSYyhtg6EWBT7MYAO/TRB9YyCeDllHQ=; b=EWbpSQrjLVFeWEI3rXivUkNONFLbI/STZMY7URXGSM0VYOgKuUBHeLje7zsX7DF7/6 uJjZI5UR8BSaziZFVIovZ+dzpg6dF8kOkzOR2Mfpep9r2ix8BCBSJnFmjpI3VryLgWf1 cbqIt4wg7QKT7TMLAHhlkY80pnxgrn8CiKzPgvJ4A8KViUG0t5uDmuKMgGuTvGoUpJhR lUj9uFhzHiQckJbLhxlrJZ2X4PFwuupOHN2vJavLwPkkwEkNQTuTDn1dsUkTGcE/1h1C D9k9+5n0RM01PNTY/yDN8urYkB2HKoTGm906fqDEJ46AiDvKwte1SMNTDxA/Gx9FZV2m /kdg== X-Gm-Message-State: AC+VfDwWIwc4XoVOSFcIQOfRcx3NX6cyIk/I5W7KjVPBVaoKmYi45dYB kge59uWKBaDyKqP6K0slkb+J7bqLKK+raWCQ187yOQ== X-Google-Smtp-Source: ACHHUZ7NDPhiSMcGqB68HBj8nP/tbyQu4pIGfL0AzvkoYkdoIntWETLvuMkLQg82dM1PHpwJjBQnBqzi62/8PIHkKY4= X-Received: by 2002:a17:90b:19d5:b0:246:818c:d8e4 with SMTP id nm21-20020a17090b19d500b00246818cd8e4mr6499444pjb.11.1682710738693; Fri, 28 Apr 2023 12:38:58 -0700 (PDT) MIME-Version: 1.0 References: <20230420140244.701467-1-juraj.linkes@pantheon.tech> In-Reply-To: <20230420140244.701467-1-juraj.linkes@pantheon.tech> From: Jeremy Spewock Date: Fri, 28 Apr 2023 15:38:47 -0400 Message-ID: Subject: Re: [PATCH v1] dts: create tarball from git ref To: =?UTF-8?Q?Juraj_Linke=C5=A1?= Cc: thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, lijuan.tu@intel.com, wathsala.vithanage@arm.com, probb@iol.unh.edu, dev@dpdk.org Content-Type: multipart/alternative; boundary="000000000000d709fe05fa6a9fd9" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org --000000000000d709fe05fa6a9fd9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Acked-by: Jeremy Spweock On Thu, Apr 20, 2023 at 10:16=E2=80=AFAM Juraj Linke=C5=A1 wrote: > Add additional convenience options for specifying what DPDK version to > test. > > Signed-off-by: Juraj Linke=C5=A1 > --- > dts/framework/config/__init__.py | 11 +-- > dts/framework/settings.py | 20 ++--- > dts/framework/utils.py | 140 +++++++++++++++++++++++++++++++ > 3 files changed, 152 insertions(+), 19 deletions(-) > > diff --git a/dts/framework/config/__init__.py > b/dts/framework/config/__init__.py > index ebb0823ff5..a4b73483e6 100644 > --- a/dts/framework/config/__init__.py > +++ b/dts/framework/config/__init__.py > @@ -11,21 +11,14 @@ > import os.path > import pathlib > from dataclasses import dataclass > -from enum import Enum, auto, unique > +from enum import auto, unique > from typing import Any, TypedDict > > import warlock # type: ignore > import yaml > > from framework.settings import SETTINGS > - > - > -class StrEnum(Enum): > - @staticmethod > - def _generate_next_value_( > - name: str, start: int, count: int, last_values: object > - ) -> str: > - return name > +from framework.utils import StrEnum > > > @unique > diff --git a/dts/framework/settings.py b/dts/framework/settings.py > index 71955f4581..cfa39d011b 100644 > --- a/dts/framework/settings.py > +++ b/dts/framework/settings.py > @@ -10,7 +10,7 @@ > from pathlib import Path > from typing import Any, TypeVar > > -from .exception import ConfigurationError > +from .utils import DPDKGitTarball > > _T =3D TypeVar("_T") > > @@ -124,11 +124,13 @@ def _get_parser() -> argparse.ArgumentParser: > parser.add_argument( > "--tarball", > "--snapshot", > + "--git-ref", > action=3D_env_arg("DTS_DPDK_TARBALL"), > default=3D"dpdk.tar.xz", > type=3DPath, > - help=3D"[DTS_DPDK_TARBALL] Path to DPDK source code tarball " > - "which will be used in testing.", > + help=3D"[DTS_DPDK_TARBALL] Path to DPDK source code tarball or a > git commit ID, " > + "tag ID or tree ID to test. To test local changes, first commit > them, " > + "then use the commit ID with this option.", > ) > > parser.add_argument( > @@ -160,21 +162,19 @@ def _get_parser() -> argparse.ArgumentParser: > return parser > > > -def _check_tarball_path(parsed_args: argparse.Namespace) -> None: > - if not os.path.exists(parsed_args.tarball): > - raise ConfigurationError(f"DPDK tarball '{parsed_args.tarball}' > doesn't exist.") > - > - > def _get_settings() -> _Settings: > parsed_args =3D _get_parser().parse_args() > - _check_tarball_path(parsed_args) > return _Settings( > config_file_path=3Dparsed_args.config_file, > output_dir=3Dparsed_args.output_dir, > timeout=3Dparsed_args.timeout, > verbose=3D(parsed_args.verbose =3D=3D "Y"), > skip_setup=3D(parsed_args.skip_setup =3D=3D "Y"), > - dpdk_tarball_path=3Dparsed_args.tarball, > + dpdk_tarball_path=3DPath( > + DPDKGitTarball(parsed_args.tarball, parsed_args.output_dir) > + ) > + if not os.path.exists(parsed_args.tarball) > + else Path(parsed_args.tarball), > compile_timeout=3Dparsed_args.compile_timeout, > test_cases=3Dparsed_args.test_cases.split(",") if > parsed_args.test_cases else [], > re_run=3Dparsed_args.re_run, > diff --git a/dts/framework/utils.py b/dts/framework/utils.py > index 55e0b0ef0e..0623106b78 100644 > --- a/dts/framework/utils.py > +++ b/dts/framework/utils.py > @@ -3,7 +3,26 @@ > # Copyright(c) 2022-2023 PANTHEON.tech s.r.o. > # Copyright(c) 2022-2023 University of New Hampshire > > +import atexit > +import os > +import subprocess > import sys > +from enum import Enum > +from pathlib import Path > +from subprocess import SubprocessError > + > +from .exception import ConfigurationError > + > + > +class StrEnum(Enum): > + @staticmethod > + def _generate_next_value_( > + name: str, start: int, count: int, last_values: object > + ) -> str: > + return name > + > + def __str__(self) -> str: > + return self.name > > > def check_dts_python_version() -> None: > @@ -80,3 +99,124 @@ def __init__(self, default_library: str | None =3D No= ne, > **dpdk_args: str | bool): > > def __str__(self) -> str: > return " ".join(f"{self._default_library} > {self._dpdk_args}".split()) > + > + > +class _TarCompressionFormat(StrEnum): > + """Compression formats that tar can use. > + > + Enum names are the shell compression commands > + and Enum values are the associated file extensions. > + """ > + > + gzip =3D "gz" > + compress =3D "Z" > + bzip2 =3D "bz2" > + lzip =3D "lz" > + lzma =3D "lzma" > + lzop =3D "lzo" > + xz =3D "xz" > + zstd =3D "zst" > + > + > +class DPDKGitTarball(object): > + """Create a compressed tarball of DPDK from the repository. > + > + The DPDK version is specified with git object git_ref. > + The tarball will be compressed with _TarCompressionFormat, > + which must be supported by the DTS execution environment. > + The resulting tarball will be put into output_dir. > + > + The class supports the os.PathLike protocol, > + which is used to get the Path of the tarball:: > + > + from pathlib import Path > + tarball =3D DPDKGitTarball("HEAD", "output") > + tarball_path =3D Path(tarball) > + > + Arguments: > + git_ref: A git commit ID, tag ID or tree ID. > + output_dir: The directory where to put the resulting tarball. > + tar_compression_format: The compression format to use. > + """ > + > + _git_ref: str > + _tar_compression_format: _TarCompressionFormat > + _tarball_dir: Path > + _tarball_name: str > + _tarball_path: Path | None > + > + def __init__( > + self, > + git_ref: str, > + output_dir: str, > + tar_compression_format: _TarCompressionFormat =3D > _TarCompressionFormat.xz, > + ): > + self._git_ref =3D git_ref > + self._tar_compression_format =3D tar_compression_format > + > + self._tarball_dir =3D Path(output_dir, "tarball") > + > + self._get_commit_id() > + self._create_tarball_dir() > + > + self._tarball_name =3D ( > + > f"dpdk-tarball-{self._git_ref}.tar.{self._tar_compression_format.value}" > + ) > + self._tarball_path =3D self._check_tarball_path() > + if not self._tarball_path: > + self._create_tarball() > + > + def _get_commit_id(self) -> None: > + result =3D subprocess.run( > + ["git", "rev-parse", "--verify", self._git_ref], > + text=3DTrue, > + capture_output=3DTrue, > + ) > + if result.returncode !=3D 0: > + raise ConfigurationError( > + f"{self._git_ref} is neither a path to an existing DPDK = " > + "archive nor a valid git reference.\n" > + f"Command: {result.args}\n" > + f"Stdout: {result.stdout}\n" > + f"Stderr: {result.stderr}" > + ) > + self._git_ref =3D result.stdout.strip() > + > + def _create_tarball_dir(self) -> None: > + os.makedirs(self._tarball_dir, exist_ok=3DTrue) > + > + def _check_tarball_path(self) -> Path | None: > + if self._tarball_name in os.listdir(self._tarball_dir): > + return Path(self._tarball_dir, self._tarball_name) > + return None > + > + def _create_tarball(self) -> None: > + self._tarball_path =3D Path(self._tarball_dir, self._tarball_nam= e) > + > + atexit.register(self._delete_tarball) > + > + result =3D subprocess.run( > + 'git -C "$(git rev-parse --show-toplevel)" archive ' > + f'{self._git_ref} --prefix=3D"dpdk-tarball-{self._git_ref + > os.sep}" | ' > + f"{self._tar_compression_format} > > {Path(self._tarball_path.absolute())}", > + shell=3DTrue, > + text=3DTrue, > + capture_output=3DTrue, > + ) > + > + if result.returncode !=3D 0: > + raise SubprocessError( > + f"Git archive creation failed with exit code > {result.returncode}.\n" > + f"Command: {result.args}\n" > + f"Stdout: {result.stdout}\n" > + f"Stderr: {result.stderr}" > + ) > + > + atexit.unregister(self._delete_tarball) > + > + def _delete_tarball(self) -> None: > + if self._tarball_path and os.path.exists(self._tarball_path): > + os.remove(self._tarball_path) > + > + def __fspath__(self): > + return str(self._tarball_path) > -- > 2.30.2 > > --000000000000d709fe05fa6a9fd9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Acked-by: Jeremy Spweock <jspweock@iol.unh.edu>

On Thu, Apr 20= , 2023 at 10:16=E2=80=AFAM Juraj Linke=C5=A1 <juraj.linkes@pantheon.tech= > wrote:
Add = additional convenience options for specifying what DPDK version to
test.

Signed-off-by: Juraj Linke=C5=A1 <juraj.linkes@pantheon.tech>
---
=C2=A0dts/framework/config/__init__.py |=C2=A0 11 +--
=C2=A0dts/framework/settings.py=C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 20 ++---=
=C2=A0dts/framework/utils.py=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 140 = +++++++++++++++++++++++++++++++
=C2=A03 files changed, 152 insertions(+), 19 deletions(-)

diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init= __.py
index ebb0823ff5..a4b73483e6 100644
--- a/dts/framework/config/__init__.py
+++ b/dts/framework/config/__init__.py
@@ -11,21 +11,14 @@
=C2=A0import os.path
=C2=A0import pathlib
=C2=A0from dataclasses import dataclass
-from enum import Enum, auto, unique
+from enum import auto, unique
=C2=A0from typing import Any, TypedDict

=C2=A0import warlock=C2=A0 # type: ignore
=C2=A0import yaml

=C2=A0from framework.settings import SETTINGS
-
-
-class StrEnum(Enum):
-=C2=A0 =C2=A0 @staticmethod
-=C2=A0 =C2=A0 def _generate_next_value_(
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 name: str, start: int, count: int, last_values= : object
-=C2=A0 =C2=A0 ) -> str:
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 return name
+from framework.utils import StrEnum


=C2=A0@unique
diff --git a/dts/framework/settings.py b/dts/framework/settings.py
index 71955f4581..cfa39d011b 100644
--- a/dts/framework/settings.py
+++ b/dts/framework/settings.py
@@ -10,7 +10,7 @@
=C2=A0from pathlib import Path
=C2=A0from typing import Any, TypeVar

-from .exception import ConfigurationError
+from .utils import DPDKGitTarball

=C2=A0_T =3D TypeVar("_T")

@@ -124,11 +124,13 @@ def _get_parser() -> argparse.ArgumentParser:
=C2=A0 =C2=A0 =C2=A0parser.add_argument(
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"--tarball",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"--snapshot",
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 "--git-ref",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0action=3D_env_arg("DTS_DPDK_TARBALL&= quot;),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0default=3D"dpdk.tar.xz",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0type=3DPath,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 help=3D"[DTS_DPDK_TARBALL] Path to DPDK s= ource code tarball "
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 "which will be used in testing.", +=C2=A0 =C2=A0 =C2=A0 =C2=A0 help=3D"[DTS_DPDK_TARBALL] Path to DPDK s= ource code tarball or a git commit ID, "
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 "tag ID or tree ID to test. To test local= changes, first commit them, "
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 "then use the commit ID with this option.= ",
=C2=A0 =C2=A0 =C2=A0)

=C2=A0 =C2=A0 =C2=A0parser.add_argument(
@@ -160,21 +162,19 @@ def _get_parser() -> argparse.ArgumentParser:
=C2=A0 =C2=A0 =C2=A0return parser


-def _check_tarball_path(parsed_args: argparse.Namespace) -> None:
-=C2=A0 =C2=A0 if not os.path.exists(parsed_args.tarball):
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 raise ConfigurationError(f"DPDK tarball &= #39;{parsed_args.tarball}' doesn't exist.")
-
-
=C2=A0def _get_settings() -> _Settings:
=C2=A0 =C2=A0 =C2=A0parsed_args =3D _get_parser().parse_args()
-=C2=A0 =C2=A0 _check_tarball_path(parsed_args)
=C2=A0 =C2=A0 =C2=A0return _Settings(
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0config_file_path=3Dparsed_args.config_fil= e,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0output_dir=3Dparsed_args.output_dir,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0timeout=3Dparsed_args.timeout,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0verbose=3D(parsed_args.verbose =3D=3D &qu= ot;Y"),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0skip_setup=3D(parsed_args.skip_setup =3D= =3D "Y"),
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 dpdk_tarball_path=3Dparsed_args.tarball,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 dpdk_tarball_path=3DPath(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 DPDKGitTarball(parsed_args.tarba= ll, parsed_args.output_dir)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if not os.path.exists(parsed_args.tarball)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 else Path(parsed_args.tarball),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0compile_timeout=3Dparsed_args.compile_tim= eout,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0test_cases=3Dparsed_args.test_cases.split= (",") if parsed_args.test_cases else [],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0re_run=3Dparsed_args.re_run,
diff --git a/dts/framework/utils.py b/dts/framework/utils.py
index 55e0b0ef0e..0623106b78 100644
--- a/dts/framework/utils.py
+++ b/dts/framework/utils.py
@@ -3,7 +3,26 @@
=C2=A0# Copyright(c) 2022-2023 PANTHEON.tech s.r.o.
=C2=A0# Copyright(c) 2022-2023 University of New Hampshire

+import atexit
+import os
+import subprocess
=C2=A0import sys
+from enum import Enum
+from pathlib import Path
+from subprocess import SubprocessError
+
+from .exception import ConfigurationError
+
+
+class StrEnum(Enum):
+=C2=A0 =C2=A0 @staticmethod
+=C2=A0 =C2=A0 def _generate_next_value_(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 name: str, start: int, count: int, last_values= : object
+=C2=A0 =C2=A0 ) -> str:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 return name
+
+=C2=A0 =C2=A0 def __str__(self) -> str:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 return self.name


=C2=A0def check_dts_python_version() -> None:
@@ -80,3 +99,124 @@ def __init__(self, default_library: str | None =3D None= , **dpdk_args: str | bool):

=C2=A0 =C2=A0 =C2=A0def __str__(self) -> str:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return " ".join(f"{self._d= efault_library} {self._dpdk_args}".split())
+
+
+class _TarCompressionFormat(StrEnum):
+=C2=A0 =C2=A0 """Compression formats that tar can use.
+
+=C2=A0 =C2=A0 Enum names are the shell compression commands
+=C2=A0 =C2=A0 and Enum values are the associated file extensions.
+=C2=A0 =C2=A0 """
+
+=C2=A0 =C2=A0 gzip =3D "gz"
+=C2=A0 =C2=A0 compress =3D "Z"
+=C2=A0 =C2=A0 bzip2 =3D "bz2"
+=C2=A0 =C2=A0 lzip =3D "lz"
+=C2=A0 =C2=A0 lzma =3D "lzma"
+=C2=A0 =C2=A0 lzop =3D "lzo"
+=C2=A0 =C2=A0 xz =3D "xz"
+=C2=A0 =C2=A0 zstd =3D "zst"
+
+
+class DPDKGitTarball(object):
+=C2=A0 =C2=A0 """Create a compressed tarball of DPDK from t= he repository.
+
+=C2=A0 =C2=A0 The DPDK version is specified with git object git_ref.
+=C2=A0 =C2=A0 The tarball will be compressed with _TarCompressionFormat, +=C2=A0 =C2=A0 which must be supported by the DTS execution environment. +=C2=A0 =C2=A0 The resulting tarball will be put into output_dir.
+
+=C2=A0 =C2=A0 The class supports the os.PathLike protocol,
+=C2=A0 =C2=A0 which is used to get the Path of the tarball::
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 from pathlib import Path
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 tarball =3D DPDKGitTarball("HEAD", &= quot;output")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 tarball_path =3D Path(tarball)
+
+=C2=A0 =C2=A0 Arguments:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 git_ref: A git commit ID, tag ID or tree ID. +=C2=A0 =C2=A0 =C2=A0 =C2=A0 output_dir: The directory where to put the res= ulting tarball.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 tar_compression_format: The compression format= to use.
+=C2=A0 =C2=A0 """
+
+=C2=A0 =C2=A0 _git_ref: str
+=C2=A0 =C2=A0 _tar_compression_format: _TarCompressionFormat
+=C2=A0 =C2=A0 _tarball_dir: Path
+=C2=A0 =C2=A0 _tarball_name: str
+=C2=A0 =C2=A0 _tarball_path: Path | None
+
+=C2=A0 =C2=A0 def __init__(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 git_ref: str,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 output_dir: str,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 tar_compression_format: _TarCompressionFormat = =3D _TarCompressionFormat.xz,
+=C2=A0 =C2=A0 ):
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self._git_ref =3D git_ref
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self._tar_compression_format =3D tar_compressi= on_format
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self._tarball_dir =3D Path(output_dir, "t= arball")
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self._get_commit_id()
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self._create_tarball_dir()
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self._tarball_name =3D (
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f"dpdk-tarball-{self._git_r= ef}.tar.{self._tar_compression_format.value}"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self._tarball_path =3D self._check_tarball_pat= h()
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if not self._tarball_path:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self._create_tarball()
+
+=C2=A0 =C2=A0 def _get_commit_id(self) -> None:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 result =3D subprocess.run(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ["git", "rev-pars= e", "--verify", self._git_ref],
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 text=3DTrue,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 capture_output=3DTrue,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if result.returncode !=3D 0:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise ConfigurationError(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f"{self._git_= ref} is neither a path to an existing DPDK "
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "archive nor = a valid git reference.\n"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f"Command: {r= esult.args}\n"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f"Stdout: {re= sult.stdout}\n"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f"Stderr: {re= sult.stderr}"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self._git_ref =3D result.stdout.strip()
+
+=C2=A0 =C2=A0 def _create_tarball_dir(self) -> None:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 os.makedirs(self._tarball_dir, exist_ok=3DTrue= )
+
+=C2=A0 =C2=A0 def _check_tarball_path(self) -> Path | None:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if self._tarball_name in os.listdir(self._tarb= all_dir):
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return Path(self._tarball_dir, s= elf._tarball_name)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 return None
+
+=C2=A0 =C2=A0 def _create_tarball(self) -> None:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self._tarball_path =3D Path(self._tarball_dir,= self._tarball_name)
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 atexit.register(self._delete_tarball)
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 result =3D subprocess.run(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 'git -C "$(git rev-pars= e --show-toplevel)" archive '
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f'{self._git_ref} --prefix= =3D"dpdk-tarball-{self._git_ref + os.sep}" | '
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f"{self._tar_compression_fo= rmat} > {Path(self._tarball_path.absolute())}",
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 shell=3DTrue,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 text=3DTrue,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 capture_output=3DTrue,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if result.returncode !=3D 0:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise SubprocessError(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f"Git archive= creation failed with exit code {result.returncode}.\n"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f"Command: {r= esult.args}\n"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f"Stdout: {re= sult.stdout}\n"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f"Stderr: {re= sult.stderr}"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 atexit.unregister(self._delete_tarball)
+
+=C2=A0 =C2=A0 def _delete_tarball(self) -> None:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if self._tarball_path and os.path.exists(self.= _tarball_path):
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 os.remove(self._tarball_path) +
+=C2=A0 =C2=A0 def __fspath__(self):
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 return str(self._tarball_path)
--
2.30.2

--000000000000d709fe05fa6a9fd9--