UnTGZ plug-in
Author: PerditionC (talk, contrib) |
Links
Download:
Untgz.zip (259 KB)
Untgz.1.0.18.zip (261 KB) (Mirror #1)
Untbgz.zip (249 KB) Older Untgz plugin with bz2 support, requires MSVCRT.DLL
Untgz.1.0.10.zip (158 KB) Older Untgz plugin with only gzip & LZMA support
Older releases may be found at http://www.fdos.org/win32/nsis/plugins/.
Description
Version: 1.0.18
UnTGZ plugin is similar to ExtractDLL and ZipDLL plugins, except it allows one to extract the files from a tarball. Only simple tarballs are supported, those with filenames longer than 100 characters or including special files may not be supported well (please send me information including where to obtain a sample tarball if better support is required for one of these).
(Basic support for longer than 100 char filenames added to 1.0.16, but does not yet support unicode or all methods of using long names.) Limited support for hard links.
Supports TAR files with no compression (*.tar), gzipped [zlib compatible] compression (*.tgz / *.tar.gz), lzma compression (*.tlz / *.tar.lzma), and bzip2 compression (*.tbz / *.tar.bz2).
For problems, corrections, etc. send email to PerditionC __at gmail.com (or jeremyd --at-- fdos.org)
Usage
- untgz::extract [-j] [-d basedir] [-h] [-k] [-z<type>] tarball.tgz
- extracts all files from tarball.tgz
- if -j is specified then ignore paths in tarball (junkpaths)
- if -d is specified will extract relative to basedir
- if -h is specified will return error if fails to create hard link
- if -k is specified will not overwrite existing files (keep)
- if -u is specified will only overwrite nonexisting or older files (update)
- if -z is specified determines compression used, see below
- untgz::extractV [-j] [-d basedir] [-h] [-k] [-z<type>] tarball.tgz [-i {iList}] [-x {xList}] --
- extracts files from tarball.tgz
- if -j is specified then ignore paths in tarball (junkpaths)
- if -d is specified will extract relative to basedir
- if -h is specified will return error if fails to create hard link
- if -k is specified will not overwrite existing files (keep)
- if -u is specified will only overwrite nonexisting or older files (update)
- if -z is specified determines compression used, see below
- if -i is specified will only extract files whose filename matches
- if -x is specified will NOT extract files whose filename matches
- the -- is required and marks the end of the file lists
- untgz::extractFile [-d basedir] [-z<type>] tarball.tgz file
- extracts just the file specified
- path information is ignored, implictly -j and -h are specified (may also be explicit)
- For compatibility with tar command, the following option specifiers may be used prior to tar file name (tarball.tgz), however, they are simply ignored.
- -x indicates action to perform is extraction (extract)
- -f archive-name indicates name of tarball (filename), note even when used, the filename must be last argument
- The -z<type> option may be specified to explicitly indicate how tar file is compressed.
- -z indicates gzip (.tgz/.tar.gz) compression, uses zlib,
- -zgz alias for -z
- -znone indicates uncompressed tar file (.tar), may be omitted (internally same as -z)
- -zlzma indicates lzma (.tlz/.tar.lzma) compression
- -zbz2 indicates bzip2 (.tbz/.tar.bz2) compression
- -zauto determines type based on content & extension this is the default if -z<type> option is omitted NOTE: prior to version 1.0.15 -z was the default so .tlz & .tbz required -zlzma & -zbz2 respectively if those compression methods used.
- NOTES
Without -j there is a security issue as no checking is done to paths, allowing untrusted tarballs to overwrite arbitrary files (e.g. /bin/*). Also no checking is done to directory or file names. In untar.c there is a hook so custom versions can modify/strip filepaths prior to opening. The -d option is currently implemented by a chdir to indicated directory prior to extraction; future versions may instead prepend to extracted path.
Example usage
This is a snippet from AbiWord's NSIS2 script (abi_dict_misc.nsh):
; Unzip $TEMP\$FILENAME into installation directory untgz::extract "-j" "-d" "$INSTDIR" "$TEMP\$FILENAME" StrCmp $R0 "success" +4 DetailPrint " Failed to extract ${DICT_FILENAME}" MessageBox MB_OK|MB_ICONEXCLAMATION|MB_DEFBUTTON1 " Failed to extract $FILENAME" Abort ; Delete temporary files Delete "$TEMP\$FILENAME"
Notes
Currently tested with NSIS 2.0x
Based on ExDLL/ExDLL.h and Zlib's untgz, all dependencies included, simply extract to your contrib directory and build with MSVC 6 (or later) or copy included untgz.dll to the plugins subdirectory of your NSIS installation. Some parts (such as extraction with paths, hard links, long names) not as well tested. See included README.TXT for more details.
Version 1.0.15 automatically determine compression type if not explicity indicated.
Version 1.0.16 is an update to 1.0.15 that supports the prefix in the tar header for file names longer than 100 characters. Compiled with MSVC6.
Version 1.0.17 adds support for Unicode NSIS; does NOT yet support Unicode file names. No functional changes from 1.0.16 for standard NSIS.
Version 1.0.18 has initial support for hard links. Will issue a warning if a hard link is found and unable to create. The option -h may be used to force failure if unable to create a hard link. Only works on NT5 or higher on NTFS; will fail to create hard link on all earlier versions of Windows, if file system is FAT or non NTFS, or if accessing NTFS file system via a share (mapped drive).