Ubuntu 20.04 compile zstd error

Seems tar in ubuntu 20.04 LTS do not know zstd format, need add a host build of last version tar?

make[3]: Entering directory '/build/feeds/packages/utils/zstd'
touch /build/build_dir/target-mipsel_24kc_musl/zstd-1.4.5/.prepared_a0852ce41381e360020701a92b99e7e9_6664517399ebbbc92a37c5bb081b5c53_check
. /build/include/shell.sh;  /build/dl/zstd-1.4.5.tar.zst | tar -C /build/build_dir/target-mipsel_24kc_musl/zstd-1.4.5/.. -xf -
bash: /build/dl/zstd-1.4.5.tar.zst: Permission denied
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
make[3]: *** [Makefile:105: /build/build_dir/target-mipsel_24kc_musl/zstd-1.4.5/.prepared_a0852ce41381e360020701a92b99e7e9_6664517399ebbbc92a37c5bb081b5c53] Error 2
make[3]: Leaving directory '/build/feeds/packages/utils/zstd'
time: package/feeds/packages/zstd/compile#0.13#0.00#0.13
make[2]: *** [package/Makefile:113: package/feeds/packages/zstd/compile] Error 2
make[2]: Leaving directory '/build'
make[1]: *** [package/Makefile:107: /build/staging_dir/target-mipsel_24kc_musl/stamp/.package_compile] Error 2
make[1]: Leaving directory '/build'
make: *** [/build/include/toplevel.mk:227: world] Error 2
apt install zstd

You're getting the permission denied error since the archive should be preceded by the command zstdcat, which is blank because the binary is not installed on your host. As a result, instead of zstdcat the file, the shell is trying to execute it.

Ofcause I have zstd installed. When this error occur.

make package/zstd/compile -j1 V=s
make[1]: Entering directory '/build'
make[2]: Entering directory '/build/feeds/packages/devel/ninja'
make[2]: Leaving directory '/build/feeds/packages/devel/ninja'
time: package/feeds/packages/ninja/host-compile#0.23#0.05#0.25
make[2]: Entering directory '/build/feeds/packages/devel/meson'
make[2]: Leaving directory '/build/feeds/packages/devel/meson'
time: package/feeds/packages/meson/host-compile#0.25#0.01#0.23
make[2]: Entering directory '/build/package/libs/toolchain'
echo "libc" >> /build/staging_dir/target-mipsel_24kc_musl/pkginfo/toolchain.default.install
echo "libgcc" >> /build/staging_dir/target-mipsel_24kc_musl/pkginfo/toolchain.default.install
echo "libstdcpp" >> /build/staging_dir/target-mipsel_24kc_musl/pkginfo/toolchain.default.install
echo "libpthread" >> /build/staging_dir/target-mipsel_24kc_musl/pkginfo/toolchain.default.install
echo "librt" >> /build/staging_dir/target-mipsel_24kc_musl/pkginfo/toolchain.default.install
make[2]: Leaving directory '/build/package/libs/toolchain'
time: package/libs/toolchain/compile#0.24#0.02#0.25
make[2]: Entering directory '/build/feeds/packages/utils/zstd'
touch /build/build_dir/target-mipsel_24kc_musl/zstd-1.4.5/.prepared_a0852ce41381e360020701a92b99e7e9_6664517399ebbbc92a37c5bb081b5c53_check
. /build/include/shell.sh;  /build/dl/zstd-1.4.5.tar.zst | tar -C /build/build_dir/target-mipsel_24kc_musl/zstd-1.4.5/.. -xf -
bash: /build/dl/zstd-1.4.5.tar.zst: Permission denied
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
make[2]: *** [Makefile:105: /build/build_dir/target-mipsel_24kc_musl/zstd-1.4.5/.prepared_a0852ce41381e360020701a92b99e7e9_6664517399ebbbc92a37c5bb081b5c53] Error 2
make[2]: Leaving directory '/build/feeds/packages/utils/zstd'
time: package/feeds/packages/zstd/compile#0.15#0.03#0.17
make[1]: *** [package/Makefile:113: package/feeds/packages/zstd/compile] Error 2
make[1]: Leaving directory '/build'
make: *** [/build/include/toplevel.mk:227: package/zstd/compile] Error 2
apt list|grep zstd
golang-github-datadog-zstd-dev/focal 1.3.5-1 all
libzstd-dev/focal,now 1.4.4+dfsg-3 amd64 [installed]
libzstd1/focal,now 1.4.4+dfsg-3 amd64 [installed]
zstd/focal,now 1.4.4+dfsg-3 amd64 [installed]
zstdcat --help
*** zstd command line interface 64-bits v1.4.4, by Yann Collet ***
Usage :
      zstdcat [args] [FILE(s)] [-o file]

FILE    : a filename
          with no FILE, or when FILE is - , read standard input
Arguments :
 -#     : # compression level (1-19, default: 3)
 -d     : decompression
 -D file: use `file` as Dictionary
 -o file: result stored into `file` (only if 1 input file)
 -f     : overwrite output without prompting and (de)compress links
--rm    : remove source file(s) after successful de/compression
 -k     : preserve source file(s) (default)
 -h/-H  : display help/long help and exit

Advanced arguments :
 -V     : display Version number and exit
 -v     : verbose mode; specify multiple times to increase verbosity
 -q     : suppress warnings; specify twice to suppress errors too
 -c     : force write to standard output, even if it is the console
 -l     : print information about zstd compressed files
--exclude-compressed:  only compress files that are not previously compressed
--ultra : enable levels beyond 19, up to 22 (requires more memory)
--long[=#]: enable long distance matching with given window log (default: 27)
--fast[=#]: switch to very fast compression levels (default: 1)
--adapt : dynamically adapt compression level to I/O conditions
--stream-size=# : optimize compression parameters for streaming input of given number of bytes
--size-hint=# optimize compression parameters for streaming input of approximately this size
--target-compressed-block-size=# : make compressed block near targeted size
 -T#    : spawns # compression threads (default: 1, 0==# cores)
 -B#    : select size of each job (default: 0==automatic)
--rsyncable : compress using a rsync-friendly method (-B sets block size)
--no-dictID : don't write dictID into header (dictionary compression)
--[no-]check : integrity check (default: enabled)
--[no-]compress-literals : force (un)compressed literals
 -r     : operate recursively on directories
--output-dir-flat[=directory]: all resulting files stored into `directory`.
--format=zstd : compress files to the .zst format (default)
--format=gzip : compress files to the .gz format
--format=xz : compress files to the .xz format
--format=lzma : compress files to the .lzma format
--format=lz4 : compress files to the .lz4 format
--test  : test compressed file integrity
--[no-]sparse : sparse mode (default: enabled on file, disabled on stdout)
 -M#    : Set a memory usage limit for decompression
--no-progress : do not display the progress bar
--      : All arguments after "--" are treated as files

Dictionary builder :
--train ## : create a dictionary from a training set of files
--train-cover[=k=#,d=#,steps=#,split=#,shrink[=#]] : use the cover algorithm with optional args
--train-fastcover[=k=#,d=#,f=#,steps=#,split=#,accel=#,shrink[=#]] : use the fast cover algorithm with optional args
--train-legacy[=s=#] : use the legacy algorithm with selectivity (default: 9)
 -o file : `file` is dictionary name (default: dictionary)
--maxdict=# : limit dictionary to specified size (default: 112640)
--dictID=# : force dictionary ID to specified value (default: random)

Benchmark arguments :
 -b#    : benchmark file(s), using # compression level (default: 3)
 -e#    : test all compression levels from -bX to # (default: 1)
 -i#    : minimum evaluation time in seconds (default: 3s)
 -B#    : cut file into independent blocks of size # (default: no block)
--priority=rt : set process priority to real-time

This is the line causing the error

. /build/include/shell.sh;  /build/dl/zstd-1.4.5.tar.zst | tar -C /build/build_dir/target-mipsel_24kc_musl/zstd-1.4.5/.. -xf -
bash: /build/dl/zstd-1.4.5.tar.zst: Permission denied
tar: This does not look like a tar archive

it should read

. /build/include/shell.sh;  zstdcat /build/dl/zstd-1.4.5.tar.zst | tar -C /build/build_dir/target-mipsel_24kc_musl/zstd-1.4.5/.. -xf -

If it is still not working for you and you've installed zstdcat, then the problem is your build tree is not merged with the latest commits from master. There is a recent update to include/unpack.mk which adds the zstd method.

4696112ea28 (Matthias Schiffer  2020-05-17 13:18:10 +0200 33)     endif
4696112ea28 (Matthias Schiffer  2020-05-17 13:18:10 +0200 34)     ifeq (zst,$(EXT))
4696112ea28 (Matthias Schiffer  2020-05-17 13:18:10 +0200 35)       EXT:=$(call ext,$(PKG_SOURCE:.$(EXT)=))
4696112ea28 (Matthias Schiffer  2020-05-17 13:18:10 +0200 36)       DECOMPRESS_CMD:=zstdcat $(DL_DIR)/$(PKG_SOURCE) |
fa802af399d (Jo-Philipp Wich    2010-08-06 21:29:23 +0000 37)     endif

Yes my openwrt git branch is 19.07 not master, script maybe not up to date.

So then you must be using packages from master with a 19.07 branch of openwrt....

I stay in 19.07 because master make my device not working, MT7621 switch and LAN disconnect with kernel v5.4.x.

You should also use 19.07 branches for package feeds as well then, otherwise you're likely to get issues like this as well as potentially erroneous behaviour from packages at runtime.