From 4236e8021b180b909edf86a030acd1a5901b1a10 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Adrian=20M=C3=BCller?= Date: Mon, 2 Mar 2026 10:03:09 +0100 Subject: [PATCH] Create directories required for make_dist.py if non-existent --- make_dist.py | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/make_dist.py b/make_dist.py index a505124..17de73b 100755 --- a/make_dist.py +++ b/make_dist.py @@ -10,7 +10,8 @@ run rpmbuild on it to create an installable rpm. """ import sys -from os.path import join, basename, dirname, expanduser +from os.path import join, basename, dirname, expanduser, isdir +from os import makedirs from re import compile as re_compile import tarfile from shutil import copy @@ -81,12 +82,21 @@ def tar_add_filter(tarinfo): return tarinfo +def ensure_dir_exists(dir_path): + """ + Create the directory under the specified path, if it doesn't already exist. + """ + if not isdir(dir_path): + makedirs(dir_path) + + def create_tarball(): """Create tarball, return its full path.""" name, version, tarball_file = get_spec_info() tarball_path = join(DIST_DIR, tarball_file) print(f'Creating {tarball_path}') dir_name = f'{name}-{version}' + ensure_dir_exists(DIST_DIR) with tarfile.open(tarball_path, 'w:gz') as tarball: for entry in DATA: tarball.add(entry, join(dir_name, entry), filter=tar_add_filter) @@ -95,6 +105,7 @@ def create_tarball(): def build_rpm(tarball_path): """Create rpm using rpmbuild with spec file and newly created tarball.""" + ensure_dir_exists(RPM_SOURCE_DIR) copy(tarball_path, RPM_SOURCE_DIR) run(('rpmbuild', '-bb', SPEC_FILE)) -- 1.7.1