9fans archive / 2000 / 12 / 15 /    prev next

From: Scott Schwartz <schwartz@bio...>
Subject: Re: [9fans] unpacking plan9.9gz from unix 
Date: Sun, 03 Dec 2000 18:04:52 -0500

| apologies if this question has been asked before,
| but is there any easy way of unpacking plan9.9gz            
| from linux?

Steve Kotsopoulos and Fabricio Chalub produced this perl script
(from the archives of 16 June 2000).  

#!/usr/bin/perl
# unwrap gzipped Plan9 wrap(8) format packages
# usage: unwrap pkg.9gz
#
# unpack-plan9.pl, v 11062000
# (c) Fabricio Chalub, chalub@gnu.org

$pkg = $ARGV[0];

open F, "zcat $pkg |" or die "cannot open pipe: $!";

while (<F>)
{
    /(.*) (.*) (.*) (.*) (.*) (.*)/;
    $filename = $1;
    $filename = substr ($filename, 1);
    $length = $6;
    read F, $buffer, $length;
    print "$filename\n";
    if ($length == 0)
    {
        mkdir $filename, 0700;
    }
    else
    {
        open O, ">$filename";
        print O $buffer;
        close O;
    }
}