megastep / makeself

A self-extracting archiving tool for Unix systems, in 100% shell script.
https://makeself.io
GNU General Public License v2.0
2.3k stars 370 forks source link

tar: Cannot update compressed archives error #155

Open HarithaRamesh opened 5 years ago

HarithaRamesh commented 5 years ago

Ever since this PR (https://github.com/megastep/makeself/pull/149), I've been unable to build my self-extractable archive, I'm running into this error:

About to compress 7079540 KB of data...
Adding files to archive named "./output/artifact.up"...
tar: Cannot update compressed archives
Try 'tar --help' or 'tar --usage' for more information.
ERROR: failed to create temporary archive: /tmp/mkself28978.tar

Here is how I'm building it:

XZ_OPT="-1 --threads=0" ./makeself/makeself.sh \
     --needroot \
     --complevel 1 \
     --tar-extra "--use-compress-program=xz" \
     --untar-extra "-J" "./output/release" \
     "./output/artifact.up" "Self-Extractable Package Title" \
     "./install.sh" # my personal install script

Has anyone else seen this behaviour before? I was unable to find a workaround.

realtime-neil commented 5 years ago

Yep, that's on me since I changed the fundamental tar operation from create to append. I can think of a couple fixes, including but not limited to the following:

Alternatively, we could punt and say that flags related to compression are simply unsupported when given as --tar-extra.

realtime-neil commented 5 years ago

Possibly related: I've had my eye on the failing appendtest for a few weeks, now, and I think they way to solve it is to double-down on tar append. That is, we adopt the convention that all makeself operations proceed via the tar append operation and --- pointedly --- a fresh creation is a special case thereof since it appends to an empty precursor.

Refactoring as such would require that, in the case of a non-empty precursor, we implicitly decompress before attempting to append.

realtime-neil commented 5 years ago

@HarithaRamesh I should probably mention the workaround you want is to lose the --tar-extra and --untar-extra options (and arguments thereto); add the --xz option.

Moreover, the --complevel 1 option obviates the XZ_OPT=-1 variable assignment; I recommend keeping the former and losing the latter.

HarithaRamesh commented 5 years ago

@realtime-neil thank you for the response. I've tried the workaround and was able to get it working again. :)

Was there a decision made on fixing this? Or are you leaving flags related to compression when given as --tar-extra as unsupported?

EDIT: just for clarity, this is my new usage of makeself that worked

./makeself/makeself.sh \
     --needroot \
     --complevel 1 \
     --xz \
     "./output/release" \
     "./output/artifact.up" "Self-Extractable Package Title" \
     "./install.sh" # my personal install script
realtime-neil commented 5 years ago

@HarithaRamesh, I can't speak to others' intentions, but the very presence of the --gzip, --bzip2, --xz, etc options on makeself.sh gives me the impression that makeself.sh wants to take complete responsibility for compression/decompression. Speaking completely for myself, I prefer this subsumption of responsibilities because it allows makeself.sh to handle error conditions (e.g., missing decompression programs) that I would be forced to handle myself otherwise.

@megastep could you clarify where you want makeself.sh responsibilities to begin (and end) with regard to user-supplied tar flags?

realtime-neil commented 5 years ago

EDIT: just for clarity, this is my new usage of makeself that worked

./makeself/makeself.sh \
     --needroot \
     --complevel 1 \
     --xz \
     "./output/release" \
     "./output/artifact.up" "Self-Extractable Package Title" \
     "./install.sh" # my personal install script

Thank you for amending your post with the complete workaround in shell. IMHO, working example code is always in short supply and always welcome.