mirror of
https://github.com/clearlinux/autospec.git
synced 2026-08-26 18:35:57 +00:00
zstd support
This commit is contained in:
committed by
Brett T. Warden
parent
f9eab4897e
commit
5d6bcfe2f7
@@ -532,6 +532,7 @@ VERIFIER_TYPES = {
|
||||
'.bz2': GPGVerifier,
|
||||
'.xz': GPGVerifier,
|
||||
'.zip': GPGVerifier,
|
||||
'.zst': GPGVerifier,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -465,6 +465,11 @@ class Specfile(object):
|
||||
extract_cmd = 'unzip -q {}'
|
||||
if archive.endswith('.bz2') and not archive.endswith('.tar.bz2'):
|
||||
extract_cmd = 'bzcat {0} > $(basename "{0}" .bz2)'
|
||||
if archive.endswith('.zst'):
|
||||
if archive.endswith('.tar.zst'):
|
||||
extract_cmd = 'tar -I zstd xf {}'
|
||||
else:
|
||||
extract_cmd = 'zstd -dqc {0} > $(basename "{0}" .zst)'
|
||||
self._write_strip('cd %{_builddir}')
|
||||
archive_file = os.path.basename(archive)
|
||||
if self.config.archive_details.get(archive + "prefix"):
|
||||
|
||||
@@ -24,6 +24,7 @@ import re
|
||||
import sys
|
||||
import tarfile
|
||||
import zipfile
|
||||
import zstandard as zstd
|
||||
|
||||
import download
|
||||
from util import do_regex, get_sha1sum, print_fatal, write_out
|
||||
@@ -53,6 +54,8 @@ class Source():
|
||||
self.type = 'zip'
|
||||
elif self.url.lower().endswith(('.bz2')) and not self.url.lower().endswith(('.tar.bz2')):
|
||||
self.type = 'bz2'
|
||||
elif self.url.lower().endswith('.zst'):
|
||||
self.type = 'zst'
|
||||
else:
|
||||
self.type = 'tar'
|
||||
|
||||
@@ -80,6 +83,16 @@ class Source():
|
||||
else:
|
||||
print_fatal("Not a valid tar file.")
|
||||
sys.exit(1)
|
||||
|
||||
def set_zst_prefix(self):
|
||||
"""Determine prefix folder name of tar.zst file."""
|
||||
with tarfile.open(fileobj=zstd.open(self.path, 'rb'), mode='r|') as content:
|
||||
lines = content.getnames()
|
||||
if len(lines) == 0:
|
||||
print_fatal("Zstd compressed tar file doesn't appear to have any content")
|
||||
sys.exit(1)
|
||||
elif len(lines) > 1:
|
||||
self.prefix = os.path.commonpath(lines)
|
||||
|
||||
def set_bz2_prefix(self):
|
||||
"""No prefix for plain bz2 archives."""
|
||||
@@ -128,6 +141,10 @@ class Source():
|
||||
with zipfile.ZipFile(self.path, 'r') as content:
|
||||
content.extractall(path=extraction_path)
|
||||
|
||||
def extract_zst(self, extraction_path):
|
||||
"""Extract zst in path."""
|
||||
with tarfile.open(fileobj=zstd.open(self.path, 'rb'), mode='r|') as content:
|
||||
content.extractall(path=extraction_path)
|
||||
|
||||
def convert_version(ver_str, name):
|
||||
"""Remove disallowed characters from the version."""
|
||||
|
||||
Reference in New Issue
Block a user