mdist: Don't delete builddir on dist failure
Closes
@@ -177,6 +177,22 @@ def create_dist_hg(dist_name, archives, src_root, bld_root, dist_sub, dist_scrip
output_names.append(zipname)
return output_names
+def run_dist_steps(meson_command, unpacked_src_dir, builddir, installdir, ninja_bin):
+ if subprocess.call(meson_command + ['--backend=ninja', unpacked_src_dir, builddir]) != 0:
+ print('Running Meson on distribution package failed')
+ return 1
+ if subprocess.call([ninja_bin], cwd=builddir) != 0:
+ print('Compiling the distribution package failed')
+ return 1
+ if subprocess.call([ninja_bin, 'test'], cwd=builddir) != 0:
+ print('Running unit tests on the distribution package failed')
+ return 1
+ myenv = os.environ.copy()
+ myenv['DESTDIR'] = installdir
+ if subprocess.call([ninja_bin, 'install'], cwd=builddir, env=myenv) != 0:
+ print('Installing the distribution package failed')
+ return 1
+ return 0
def check_dist(packagename, meson_command, extra_meson_args, bld_root, privdir):
print('Testing distribution package %s' % packagename)
@@ -188,7 +204,6 @@ def check_dist(packagename, meson_command, extra_meson_args, bld_root, privdir):
shutil.rmtree(p)
os.mkdir(p)
ninja_bin = detect_ninja()
- try:
shutil.unpack_archive(packagename, unpackdir)
unpacked_files = glob(os.path.join(unpackdir, '*'))
assert(len(unpacked_files) == 1)
@@ -197,26 +212,16 @@ def check_dist(packagename, meson_command, extra_meson_args, bld_root, privdir):
meson_command += ['-D{name}={value}'.format(**o) for o in json.load(boptions)
if o['name'] not in ['backend', 'install_umask']]
meson_command += extra_meson_args
- if subprocess.call(meson_command + ['--backend=ninja', unpacked_src_dir, builddir]) != 0:
- print('Running Meson on distribution package failed')
- return 1
- if subprocess.call([ninja_bin], cwd=builddir) != 0:
- print('Compiling the distribution package failed')
- return 1
- if subprocess.call([ninja_bin, 'test'], cwd=builddir) != 0:
- print('Running unit tests on the distribution package failed')
- return 1
- myenv = os.environ.copy()
- myenv['DESTDIR'] = installdir
- if subprocess.call([ninja_bin, 'install'], cwd=builddir, env=myenv) != 0:
- print('Installing the distribution package failed')
- return 1
- finally:
+
+ ret = run_dist_steps(meson_command, unpacked_src_dir, builddir, installdir, ninja_bin)
+ if ret > 0:
+ print('Dist check build directory was {}'.format(builddir))
+ else:
shutil.rmtree(unpackdir)
shutil.rmtree(builddir)
shutil.rmtree(installdir)
print('Distribution package %s tested' % packagename)
- return 0
+ return ret
def determine_archives_to_generate(options):
result = []
