I'm trying to generate a self extracting script using the method discussed here: http://www.linuxjournal.com/node/1005818
Using ANT (on win开发者_如何学JAVAdows) I create the payload archive using TAR task(gzip compression), and concat the script and the tar using the following CONCAT task.
<concat destfile="${output}/selfextract.bsx"
append="true"
eol="lf">
<fileset file="${installer}/decompress"/>
<fileset file="${output}/payload.tar.gz"/>
</concat>
The file is being created, and appears to contain the archive data, but when run on our Red Hat machine gzip complains "invalid compressed data --format violated".
Has anyone succeeded in this before?
Unless you use the fixlastline
argument (off by default) then eol
isn't used.
Likely guess: you have an extra line at the end of your "decompress" script after the __ARCHIVE_BELOW__
line. You can't have any extra (even empty) lines there or you'll pipe those bytes into the tar. This could be caused, as Dennis said, by eol problems, but you'd have to have an awk
that isn't GNU to have this problem I think.
Easy way to confirm is change your tail
to redirect to a file instead of tar, then hexdump the first few bytes of the original tar and the output tar to see what extra (or missing) bytes are getting in there.
A final thing to check is do you need to set the binary
option in your concat
.
Solved.
Higher in the ANT script, I was using the FixCRLF
task with eol="unix"
on decompress.sh. By default this task adds an extra newline to the end of the file unless you add fixlast="false"
.
I also added the binary="yes"
attribute to concat.
My mistake for not including the rest of the script, and thanks for the help.
Final Code:
<concat destfile="${output}/selfextract.bsx"
binary="yes">
<fileset file="${installer}/decompress"/>
<fileset file="${output}/payload.tar.gz"/>
</concat>
精彩评论