From: Michael Trimarchi <michael@amarulasolutions.com>
To: buildroot@buildroot.org
Cc: Michael Trimarchi <michael@amarulasolutions.com>
Subject: [Buildroot] [PATCH 2/2] scripts/cve: Restart the clone if the pull generate an exception
Date: Mon, 2 Sep 2024 09:41:09 +0200 [thread overview]
Message-ID: <20240902074109.50173-2-michael@amarulasolutions.com> (raw)
In-Reply-To: <20240902074109.50173-1-michael@amarulasolutions.com>
If we are not able to pull from the directory, restart from a clean
clone
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
support/scripts/cve.py | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/support/scripts/cve.py b/support/scripts/cve.py
index 7d115a28b5..b205b72e65 100755
--- a/support/scripts/cve.py
+++ b/support/scripts/cve.py
@@ -21,6 +21,7 @@ import datetime
import os
import distutils.version
import json
+import shutil
import subprocess
import sys
import operator
@@ -69,15 +70,21 @@ class CVE:
@staticmethod
def download_nvd(nvd_git_dir):
+ done = False
print(f"Updating from {NVD_BASE_URL}")
if os.path.exists(nvd_git_dir):
- subprocess.check_call(
- ["git", "pull"],
- cwd=nvd_git_dir,
- stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL,
- )
- else:
+ try:
+ subprocess.check_call(
+ ["git", "pull"],
+ cwd=nvd_git_dir,
+ stdout=subprocess.DEVNULL,
+ stderr=subprocess.DEVNULL,
+ )
+ done = True
+ except:
+ shutil.rmtree(nvd_git_dir)
+
+ if (not done):
# Create the directory and its parents; git
# happily clones into an empty directory.
os.makedirs(nvd_git_dir)
--
2.43.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next prev parent reply other threads:[~2024-09-02 7:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-02 7:41 [Buildroot] [PATCH 1/2] scripts/cve: Avoid to do a complete clone of cve git repository Michael Trimarchi
2024-09-02 7:41 ` Michael Trimarchi [this message]
2024-09-02 16:41 ` [Buildroot] [PATCH 2/2] scripts/cve: Restart the clone if the pull generate an exception Yann E. MORIN
2024-09-02 16:44 ` Michael Nazzareno Trimarchi
2024-09-02 16:39 ` [Buildroot] [PATCH 1/2] scripts/cve: Avoid to do a complete clone of cve git repository Yann E. MORIN
2024-09-02 16:43 ` Michael Nazzareno Trimarchi
2024-09-02 16:53 ` Michael Nazzareno Trimarchi
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=20240902074109.50173-2-michael@amarulasolutions.com \
--to=michael@amarulasolutions.com \
--cc=buildroot@buildroot.org \
/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