Ignore tesseract data when building DEB/RPM packages

This commit is contained in:
Alex Pyrgiotis 2024-10-08 18:51:22 +03:00
parent 477bdfcc2e
commit d1e119452e
No known key found for this signature in database
GPG key ID: B6C15EBA0357C9AA
2 changed files with 13 additions and 3 deletions

View file

@ -2,3 +2,6 @@ compression = "gzip"
tar-ignore = "dev_scripts"
tar-ignore = ".*"
tar-ignore = "__pycache__"
# Ignore the 'share/tessdata' dir, since it slows down the process, and we
# install Tesseract data via Debian packages anyway.
tar-ignore = "share/tessdata"

View file

@ -64,10 +64,15 @@ def build(build_dir, qubes=False):
os.symlink(dist_path, srpm_dir)
print("* Creating a Python sdist")
tessdata = root / "share" / "tessdata"
tessdata_bak = root / "tessdata.bak"
container_tar_gz = root / "share" / "container.tar.gz"
container_tar_gz_bak = root / "container.tar.gz.bak"
if tessdata.exists():
tessdata.rename(tessdata_bak)
stash_container = qubes and container_tar_gz.exists()
if stash_container:
if stash_container and container_tar_gz.exists():
container_tar_gz.rename(container_tar_gz_bak)
try:
subprocess.run(["poetry", "build", "-f", "sdist"], cwd=root, check=True)
@ -77,7 +82,9 @@ def build(build_dir, qubes=False):
shutil.copy2(sdist_path, build_dir / "SOURCES" / sdist_name)
sdist_path.unlink()
finally:
if stash_container:
if tessdata_bak.exists():
tessdata_bak.rename(tessdata)
if stash_container and container_tar_gz_bak.exists():
container_tar_gz_bak.rename(container_tar_gz)
print("* Building RPM package")