#!/usr/bin/perl

%title= (
  "libxml2" => "LIBXML2 The XML C parser and toolkit of Gnome",
);

%architecture= (
  "B.11.23" => "HP-UX_B.11.23",
  "B.11.11" => "HP-UX_B.11.11",
  "B.11.00" => "HP-UX_B.11.00",
);

%os_release= (
  "B.11.23" => "?.11.2?",
  "B.11.11" => "?.11.1?",
  "B.11.00" => "?.11.0?",
);

%machine_type= (
  "ia64" => "ia64*",
  "hppa2.0w" => "9000/800",
  "hppa2.0w" => "9000/700",
  "hppa2.0w" => "9000/*",
  "hppa2.0w" => "hppa",
);

$t=$ARGV[0];
$v=$ARGV[1];
$bit=$ARGV[2];
$prefix=$ARGV[3];
$tmp=$ARGV[4];
$arch=$ARGV[5];
$sourcedir=$ARGV[6];

open(UN,"uname -a|") or die "Unable to run uname";
$_ = <UN>;
close(UN);
($os, $nam, $a, $something, $m) = split(/ /);

if($bit eq "32") {
  $cpu64="";
  $machine="*";
} else {
  $cpu64="_$bit";
  $machine="*:*64";
}

if($m ne "ia64") {
  $m="hppa";
}

$target="$t-$v-$m-hpux$bit.depot";
$targetz="$t-$v-$m-hpux$bit.depot.Z";
print $target,"\n";

open (PSF,">$t.psf") or die "Unable to write PSF file ($!)\n";

print PSF <<EOF;
depot
	layout_version	1.0
vendor
	tag	MHSL
	title	March Hare Software Ltd
	description	The XML C parser and toolkit of Gnome
category
	tag	xml_parser
	title	LIBXML2 The XML C parser and toolkit of Gnome
	description	The XML C parser and toolkit of Gnome
	revision	$v
end
product
        tag	$t-$bit
        number	$t
        vendor_tag	MHSL
        title	LIBXML2-$bit The XML C parser and toolkit of Gnome
        description	< $sourcedir/README
        revision	$v
	category_tag	xml_parser
	copyright	"Copyright (C) March Hare Software Ltd"
	readme	< $sourcedir/README

        architecture 	HP-UX_B.11_32/64
        machine_type	$machine
        os_name	HP-UX
        os_release	?.1?.*
        directory	$prefix
	is_locatable	false

	subproduct
		tag	$t-$bit-base
		title	"LIBXML2-$bit base tools"
		contents	base
	end
        fileset
                tag	base
		title	Base
                revision	$v
                directory	$tmp$prefix = $prefix
                file_permissions	-u 222 -g bin -o bin
                file	*
        end
end
EOF

close(PSF); 

system("/usr/sbin/swpackage -vv -s $t.psf -x target_type=tape @ $target");
system("rm -f $targetz");
system("compress $target");
system("rm $t.psf");
