"""
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
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)
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))