[elbe-devel] [PATCH 17/19] elbepack: init: simplify devel packaging

Thomas Weißschuh thomas.weissschuh at linutronix.de
Tue Mar 19 08:47:46 CET 2024


Instead of starting with the full source directory and having to exclude
a everything unwanted only include the wanted things in the first place.

In the process get rid of another usage of elbe_dir.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/commands/init.py | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/elbepack/commands/init.py b/elbepack/commands/init.py
index fe936254fcd2..82fb6f7a8052 100644
--- a/elbepack/commands/init.py
+++ b/elbepack/commands/init.py
@@ -5,6 +5,7 @@
 import importlib.resources
 import logging
 import os
+import pathlib
 import shutil
 import subprocess
 import sys
@@ -13,10 +14,9 @@ from optparse import OptionParser
 import elbepack.init
 from elbepack.config import cfg
 from elbepack.debinstaller import NoKinitrdException, copy_kinitrd
-from elbepack.directories import elbe_dir
 from elbepack.filesystem import Filesystem
 from elbepack.log import elbe_logging
-from elbepack.shellhelper import do, system
+from elbepack.shellhelper import do
 from elbepack.templates import get_initvm_preseed, write_template
 from elbepack.treeutils import etree
 from elbepack.validate import validate_xml
@@ -241,18 +241,16 @@ def run_command(argv):
             env_add={'GNUPGHOME': out_path})
 
         if opt.devel:
-            out_real = os.path.realpath(out_path)
-            opts = []
-            if out_real.startswith(elbe_dir + os.sep):
-                opts.append(
-                    f'--exclude "{os.path.relpath(out_path, start=elbe_dir)}"')
-
-            opts.append('--exclude-vcs')
-            opts.append('--exclude-vcs-ignores')
-            opts.append("--exclude='elbe-build*'")
-            opts.append("--exclude='docs/*'")
+            opts = [
+                '--exclude-vcs',
+                '--exclude-vcs-ignores',
+            ]
+
             tar_fname = os.path.join(out_path, 'elbe-devel.tar.bz2')
-            system(f'tar cfj "{tar_fname}" {" ".join(opts)} -C "{elbe_dir}" .')
+            source_dir = pathlib.Path(__file__).parents[2]
+            subprocess.run([
+                'tar', 'cfj', tar_fname, *opts, '-C', source_dir, 'elbepack', 'elbe'
+            ], check=True)
 
         to_cpy = [('apt.conf', 'etc/apt'),
                   ('init-elbe.sh', ''),

-- 
2.44.0



More information about the elbe-devel mailing list