diff options
author | biao716.wang <biao716.wang@samsung.com> | 2020-11-16 16:14:50 +0900 |
---|---|---|
committer | biao716.wang <biao716.wang@samsung.com> | 2020-11-16 16:19:22 +0900 |
commit | ae34b3e7059a42bdfeb7e81e745b1bcf07cce9ae (patch) | |
tree | 7b87fa7eb175111bc29e4d8c830182b434395818 | |
parent | 2f8398141cfca1a8c58d317357555fd61373ab6b (diff) | |
download | build-ae34b3e7059a42bdfeb7e81e745b1bcf07cce9ae.tar.gz build-ae34b3e7059a42bdfeb7e81e745b1bcf07cce9ae.tar.bz2 build-ae34b3e7059a42bdfeb7e81e745b1bcf07cce9ae.zip |
Support zstd arch for tar
Merge related pathches form github:
https://github.com/openSUSE/obs-build/commit/9adf3c45a9da802ca40eb2fa7a263407fb2509ac
https://github.com/openSUSE/obs-build/commit/99ace9e9af9227ef3d9b82ea64d2f22c766e225d
https://github.com/openSUSE/obs-build/commit/f207143703d53ce2bdfa3996d22de885734dbf2dX
Change-Id: I85e24df802a9aaab67c512609cf1471bb3f10d0f
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
-rw-r--r-- | Build.pm | 4 | ||||
-rw-r--r-- | Build/Arch.pm | 36 | ||||
-rw-r--r-- | debian/control | 2 | ||||
-rwxr-xr-x | init_buildsystem | 14 | ||||
-rw-r--r-- | packaging/build.spec | 1 |
5 files changed, 47 insertions, 10 deletions
@@ -1376,7 +1376,7 @@ sub query { return Build::Rpm::query($handle, %opts) if $do_rpm && $binname =~ /\.d?rpm$/; return Build::Deb::query($handle, %opts) if $do_deb && $binname =~ /\.deb$/; return Build::Kiwi::queryiso($handle, %opts) if $do_kiwi && $binname =~ /\.iso$/; - return Build::Arch::query($handle, %opts) if $do_arch && $binname =~ /\.pkg\.tar(?:\.gz|\.xz)?$/; + return Build::Arch::query($handle, %opts) if $do_arch && $binname =~ /\.pkg\.tar(?:\.gz|\.xz|\.zst)?$/; return Build::Arch::query($handle, %opts) if $do_arch && $binname =~ /\.arch$/; return undef; } @@ -1406,7 +1406,7 @@ sub queryhdrmd5 { return Build::Kiwi::queryhdrmd5(@_) if $do_kiwi && $binname =~ /\.iso$/; return Build::Kiwi::queryhdrmd5(@_) if $do_kiwi && $binname =~ /\.raw$/; return Build::Kiwi::queryhdrmd5(@_) if $do_kiwi && $binname =~ /\.raw.install$/; - return Build::Arch::queryhdrmd5(@_) if $do_arch && $binname =~ /\.pkg\.tar(?:\.gz|\.xz)?$/; + return Build::Arch::queryhdrmd5(@_) if $do_arch && $binname =~ /\.pkg\.tar(?:\.gz|\.xz|\.zst)?$/; return Build::Arch::queryhdrmd5(@_) if $do_arch && $binname =~ /\.arch$/; return undef; } diff --git a/Build/Arch.pm b/Build/Arch.pm index a100d9f..cb93ef9 100644 --- a/Build/Arch.pm +++ b/Build/Arch.pm @@ -107,6 +107,16 @@ sub islzma { return $h eq "\3757zXZ"; } +sub iszstd { + my ($fn) = @_; + local *F; + return 0 unless open(F, '<', $fn); + my $h; + return 0 unless read(F, $h, 4) == 4; + close F; + return $h eq "(\265\057\375"; +} + sub lzmadec { my ($fn) = @_; my $nh; @@ -120,13 +130,29 @@ sub lzmadec { return $nh; } +sub zstddec { + my ($fn) = @_; + my $nh; + my $pid = open($nh, '-|'); + return undef unless defined $pid; + if (!$pid) { + $SIG{'PIPE'} = 'DEFAULT'; + #zstd -dc is not accepting symlinks, but zstdcat does. + exec('zstdcat', $fn); + die("zstdcat $!\n"); + } + return $nh; +} + sub queryvars { my ($handle) = @_; if (ref($handle)) { die("arch pkg query not implemented for file handles\n"); } - if ($handle =~ /\.xz$/ || islzma($handle)) { + if ($handle =~ /\.zst$/ || iszstd($handle)) { + $handle = zstddec($handle); + } elsif ($handle =~ /\.xz$/ || islzma($handle)) { $handle = lzmadec($handle); } my $tar = Archive::Tar->new; @@ -148,7 +174,9 @@ sub queryfiles { if (ref($handle)) { die("arch pkg query not implemented for file handles\n"); } - if ($handle =~ /\.xz$/ || islzma($handle)) { + if ($handle =~ /\.zst$/ || iszstd($handle)) { + $handle = zstddec($handle); + } elsif ($handle =~ /\.xz$/ || islzma($handle)) { $handle = lzmadec($handle); } my @files; @@ -215,7 +243,9 @@ sub queryhdrmd5 { if (ref($handle)) { die("arch pkg query not implemented for file handles\n"); } - if ($handle =~ /\.xz$/ || islzma($handle)) { + if ($handle =~ /\.zst$/ || iszstd($handle)) { + $handle = zstddec($handle); + } elsif ($handle =~ /\.xz$/ || islzma($handle)) { $handle = lzmadec($handle); } my $tar = Archive::Tar->new; diff --git a/debian/control b/debian/control index f8d93d5..5fd7761 100644 --- a/debian/control +++ b/debian/control @@ -13,7 +13,7 @@ Depends: ${perl:Depends}, libcrypt-ssleay-perl (>= 0.64-tizen20130308), binfmt-support, tizen-qemu-arm-static-2020.06.17 -Recommends: rpm2cpio +Recommends: rpm2cpio, zstd Description: A script to build SUSE Linux RPMs This package provides a script for building RPMs for SUSE Linux in a chroot environment. diff --git a/init_buildsystem b/init_buildsystem index 721cd55..68be1b6 100755 --- a/init_buildsystem +++ b/init_buildsystem @@ -417,6 +417,7 @@ downloadpkg() { if test "${url:0:7}" == "zypp://" -o "${url:0:7}" == "http://" -o "${url:0:8}" == "https://" -o "${url:0:6}" == "ftp://" -o "${url:0:7}" == "ftps://" ; then cachedir="$(getcachedir "$url")" local name="$(basename "$url")" + name=${name/%.pkg.tar.zst/.arch} name=${name/%.pkg.tar.?z/.arch} SRC="$cachedir/$name" else @@ -745,7 +746,8 @@ else ;; esac fi - SRCSUF=${SRC/%.pkg.tar.?z/.arch} + SRCSUF=${SRC/%.pkg.tar.zst/.arch} + SRCSUF=${SRCSUF/%.pkg.tar.?z/.arch} ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}" done < $RPMLIST @@ -775,20 +777,23 @@ else rm -f "$BUILD_ROOT"/.init_b_cache/rpmlist.download2 while read PKG SRC ; do cachepkg="${SRC##*/}" + cachepkg="${cachepkg/%.pkg.tar.zst/.arch}" cachepkg="${cachepkg/%.pkg.tar.?z/.arch}" if test "$SRC" != "${SRC#zypp://}" ; then # for zypp packages also look in the zypp cache cachedir="/var/cache/zypp/packages/${SRC#zypp://}" cachedir="${cachedir%/*}" if can_reuse_cached_package "$cachedir/$cachepkg" ; then - SRCSUF=${SRC/%.pkg.tar.?z/.arch} + SRCSUF=${SRC/%.pkg.tar.zst/.arch} + SRCSUF=${SRCSUF/%.pkg.tar.?z/.arch} ln -s "$cachedir/$cachepkg" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}" continue fi fi cachedir="$(getcachedir "$SRC")" if can_reuse_cached_package "$cachedir/$cachepkg" ; then - SRCSUF=${SRC/%.pkg.tar.?z/.arch} + SRCSUF=${SRC/%.pkg.tar.zst/.arch} + SRCSUF=${SRCSUF/%.pkg.tar.?z/.arch} ln -s "$cachedir/$cachepkg" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}" continue fi @@ -808,7 +813,8 @@ else progress_step PACKAGES_TO_DOWNLOAD downloadpkg "$SRC" # downloadpkg modified $SRC, so it has a right name for use - SRCSUF=${SRC/%.pkg.tar.?z/.arch} + SRCSUF=${SRC/%.pkg.tar.zst/.arch} + SRCSUF=${SRCSUF/%.pkg.tar.?z/.arch} ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}" done < "$BUILD_ROOT"/.init_b_cache/rpmlist.download rm -f "$BUILD_ROOT"/.init_b_cache/rpmlist.download diff --git a/packaging/build.spec b/packaging/build.spec index 72a2583..09ee415 100644 --- a/packaging/build.spec +++ b/packaging/build.spec @@ -62,6 +62,7 @@ Recommends: perl(Pod::Usage) Recommends: perl(Time::Zone) Recommends: perl(URI) Recommends: bsdtar +Recommends: zstd %endif %if 0%{?suse_version} > 1120 || ! 0%{?suse_version} |