SourceFiles.org - Use the Source, Luke
Home | Register | News | Forums | Guide | MyLinks | Bookmark

Related Sites

Latest News
  General News
  Reviews
  Press Releases
  Software
  Hardware
  Security
  Tutorials
  Off Topic


Back to files

Unarc version 0.2.8

INTRODUCTION

Sometimes when you unpack a .tar.gz file, it spills files all over your current directory, so you have to make a new directory to unpack in if you want to avoid a mess. But other .tar.gz files have their own top-level directory, so unpacking in a new directory is not necessary and creates a different kind of mess.

The answer is unarc, which unpacks an archive and creates a top-level directory if it's needed. Unarc works with lots of archives, not just tarballs - .tar.bz2, .zip and even .rpm are supported. It's a simple and tidy way to unpack most archives.

There is a companion program arcdir which provides a uniform way to archive directories into tarfiles, zipfiles and so on.

CHANGES IN THIS RELEASE

When a filename with the name of an archive's top-level directory already existed, some systems would get stuck in an infinite loop on unpacking. This should now be fixed. As long as your system's rename() will not overwrite directories or overwrite a non-directory with a directory, you know that unpacking will not overwrite any existing files.

See ChangeLog for a less readable list based on CVS commits.

USAGE

% unarc filename(s)

Unpack the archives specified, each into its own directory. The archiver to use is chosen based on the filename.

% arcdir directory(s)

Archive each directory individually, using the default archive type tar.bz2. Each directory will be archived into <dirname>.tar.bz2.

% arcdir -t type directory(s)

where type is one of zip, tar.gz, etc.

Archive directories into a type of archive you choose. For example, 'arcdir -t zip foo' will archive foo/ into foo.zip.

INSTALLING

Copy unarc and arcdir to somewhere in your PATH. They use the library archive_types.pl, which you need to copy to your Perl library directory. To find out where Perl looks for libraries, try this:

% perl -e 'print "$_\n" foreach @INC'

and copy archive_types.pl to one of the directories listed, /usr/lib/perl5/site_perl/5.x/ would be a good choice. Alternatively, create your own directory for Perl libraries and add it to PERL5LIB. (I'm still looking for a better way to do this, or at least a better way to explain it.)

To unpack some of the more esoteric archive types you will need to first install the program pip
<http://membled.com/work/apps/pip/> which works around the fact that some programs (like unzip) cannot read their input from stdin.

There is a test suite included. Try this (with archive_types.pl in the current directory):

% perl archive_types.pl --test-archivers | grep -E 'ok|fail|skip'

and check that nothing fails. You may get complaints from cpio about 'truncating inode number', they can be safely ignored.

The list of archivers supported (and these instructions) assume that you have the GNU utilities on your system, rather than the plain old Unix or BSD versions. However it shouldn't be too difficult to change things to support non-GNU archivers.

ADDING YOUR OWN ARCHIVERS

Take a look at archive_types.pl. You will need three commands:

  • a command which archives the directory given as its first argument, and prints the archive to stdout
  • a command which reads an archive from stdin, unpacks it, and prints filenames to stdout
  • (optional) a command which reads an archive from stdin and prints the filenames contained in it

The set of commands for 'tar' is a good example, some of the others go through horrible contortions.

COPYING

All the files are in the public domain. This means there are no copyright restrictions, you may do what you wish with them. Of course, giving credit would be appeciated (but not required).

They are offered as-is with no warranty whatsoever.

AUTHOR AND CREDITS

Written by Ed Avis, thanks to Seth Golub, Uwe Koloska, Bruce Gingery, Mads Villadsen, and Alistair Burt.

Please contact me with any suggestions, bug reports or if you would like to add a new archive type.

Ed Avis <ed@membled.com>

These programs have a web page at
<http://membled.com/work/apps/unarc/>.


Other Sites

Discussion Groups
  Beginners
  Distributions
  Networking / Security
  Software
  PDAs

About | FAQ | Privacy | Awards | Contact
Comments to the webmaster are welcome.
Copyright 2006 Sourcefiles.org All rights reserved.