3

I get this error tar: Archive is compressed. Use -z option when trying to build my docker image:

RUN wget https://github.com/wal-g/wal-g/releases/download/v2.0.1/wal-g-pg-ubuntu-20.04-amd64.tar.gz -O - | \
  tar -xvf - -O > "${APP}/bin/wal-g"

But why this error happen when -z option is ignored in extract mode?

-z, --gunzip, --gzip
(c mode only) Compress the resulting archive with gzip(1). In extract or list modes, this
option is ignored. Note that this tar implementation recognizes gzip compression automatically when reading archives.

When I add -z option, I get another error:

Cannot write to ‘-’ (Success).
Eugen Konkov
  • 238
  • 1
  • 3
  • 14

1 Answers1

2

The command should be:

wget https://github.com/wal-g/wal-g/releases/download/v2.0.1/wal-g-pg-ubuntu-20.04-amd64.tar.gz -O - |   tar zxvf - -O > "${APP}/bin/wal-g"

The z needs to be added somewhere not between -f and -. The option -f requires an argument, which in this case is -.

Here is how -f aka --file option is defined in the tar source code:

  {"file", 'f', N_("ARCHIVE"), 0,
   N_("use archive file or device ARCHIVE"), GRID_DEVICE },

You can see from the code that -f needs to be followed by a file name, in this case the special name - which means stdout(3).

It seems that tar is using GNU argp for parsing the CLI arguments instead of getopt(3).