public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH (pushed)] docs: create sources tarball
@ 2022-11-09 18:37 Martin Liška
  0 siblings, 0 replies; only message in thread
From: Martin Liška @ 2022-11-09 18:37 UTC (permalink / raw)
  To: gcc-patches

maintainer-scripts/ChangeLog:

	* update_web_docs_git.py: Create sources tarball.
---
 maintainer-scripts/update_web_docs_git.py | 29 +++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/maintainer-scripts/update_web_docs_git.py b/maintainer-scripts/update_web_docs_git.py
index 18c8bbb8324..d9cf9b70968 100755
--- a/maintainer-scripts/update_web_docs_git.py
+++ b/maintainer-scripts/update_web_docs_git.py
@@ -37,6 +37,32 @@ def find_configs():
                 yield (Path(root).resolve(), docname)
 
 
+def create_source_tarball(output, configs):
+    pwd = Path('.').resolve()
+    subfolders = {'doc'}
+    explicit_files = {'gcc/BASE-VER', 'gcc/DEV-PHASE', 'gcc/DATESTAMP'}
+
+    for location, _ in configs:
+        location = location.relative_to(pwd)
+        while not location.name == 'doc':
+            location = location.parent
+        subfolders.add(location)
+
+    sources = Path('sources')
+    sources.mkdir()
+
+    # Copy all subfolders and files
+    for subfolder in subfolders:
+        shutil.copytree(subfolder, sources / subfolder)
+
+    for filename in explicit_files:
+        shutil.copy(filename, sources / filename)
+
+    shutil.make_archive(Path(output, 'docs-sources'), 'gztar',
+                        sources)
+    print('sources tarball has been created')
+
+
 with tempfile.TemporaryDirectory() as folder:
     print(f'Using {folder} as temporary directory')
     os.chdir(folder)
@@ -49,6 +75,9 @@ with tempfile.TemporaryDirectory() as folder:
     if not output.exists():
         output.mkdir()
 
+    # Create source tarball
+    create_source_tarball(output, configs)
+
     temp = Path('tmp').resolve()
     temp.mkdir()
 
-- 
2.38.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-09 18:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09 18:37 [PATCH (pushed)] docs: create sources tarball Martin Liška

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).