Suggestion for unpack tag

Bryan Dumm bdumm at
Tue Jan 9 16:51:50 PST 2001

let me guess it was bzip2 that failed right?

> There could be other solutions, I'm all ears.  I'm also willing to code
> this mod and submit/commit the changes.

More than happy to accept submissions..... :)

btw here is the current sub... what can we do differently???

sub tag_unpack
	my $elt = shift;
	my $archive = $elt->att('archive');
	my $destination = fix_text($elt->text);

	print "Unpacking   : $archive\n";
	print "Destination : $destination\n";

	return if (! &to_continue);

	if (! chdir $destination) {
		if error("Unable to change directory to $destination: $!\n", $elt);

	if (! -f $archive) {
		return if error("Archive $archive does not exist.\n", $elt);

	if ($archive =~ /\.tar\.gz$/) {
		system_return(system "tar xzf $archive");

	} elsif ($archive =~ /\.tar\.bz2$/) {

		system_return(system "bzcat $archive | tar x");

	} elsif ($archive =~ /\.gz$/) {
		if (! copy ($archive, $destination)) {
			if error("Unable to copy $archive to $destination.\n");

		my $basename = $archive;
		$basename =~ s/.*\///;

		system_return(system "gunzip $destination/$basename");

		unlink "$destination/$basename" 
		|| print "Unable to delete $destination/$basename: $!\n";

	} else {
		print "Not supported file type ($archive).\n";

	print "Done unpacking $archive.\n";

More information about the alfs-discuss mailing list