Extending deco
The generic deco extraction algorithm goes to great pains in order to simplify writing the specific extractor wrappers.
Let’s say you want to support foo archives, which can be composed of multiple parts—archive.foo, archive.f00, possibly up to archive.f99:
- In deco’s extractor wrappers directory, typically /usr/local/share/deco, add a new directory. This directory’s name needs to be a (case-insensitive, POSIX extended) regular expression that will match an archive file when anchored to the end its name. For our example, a good choice would be:
foo|f[0-9][0-9] - Inside your newly created directory, add an executable file called extract, maybe a small shell script.
- Whenever deco wants to extract a file some/where/archive.foo, it runs your script with the parameter
archive.foo. The archive will appear to reside in the current working directory. - If verbose operation was requested with -v, the environment variable
Verbosewill be set to the empty string. Otherwise, it will be unset. The same applies toKeepfor -k (“keep”) mode. - For your convenience, the environment variable
Namewill be set toarchive, but usually you won’t need to use it. - Your script should then extract the archive in whatever way is appropriate. It doesn’t matter whether or not the archive is removed during extraction.
Example:
#!/bin/sh exec unfoo ${Keep+-k} ${Verbose--q} "$1"
- Whenever deco wants to extract a file some/where/archive.foo, it runs your script with the parameter
- You can create additional files in the
foo|f[0-9][0-9]directory to influence deco’s behavior:- If the contents of archive.foo should always be put into a new directory generally called archive/, even if the archive only contains a single entry at its top level, add an empty file called subdirectory.
- In case your extractor is known to create files with weird permissions and you want them changed to the defaults implied by the current umask, add an empty file called permissions.
Hints
- The longest matching extension is used, unless the -e option is in effect.
- No need to use the option delimeter (
--) in your code. If an archive name starts with a dash, it is passed like this:./-archive.foo - Anything the extract program writes to stdout is redirected to stderr.