#!/usr/bin/perl -w use strict; #use CGI qw(param); my %packages; my $pkgdir="spkg/unstable"; my $package_file = "Packages"; # get md5sum of a file sub packages_load { my $thispkg = {}; $thispkg->{depends} = []; open(PACKAGES, "$pkgdir/$package_file") or die("Cant open packages file"); while () { chomp; if ($_ eq '' && $thispkg->{name}) { bless $thispkg; $packages{$thispkg->{name}} = $thispkg; $thispkg = {}; $thispkg->{depends} = []; } elsif (/^\w+\:/) { my ($var, $val) = /^(\w+)\:\s*(.*)/; if ($var eq 'Package') { $thispkg->{name} = $val; } elsif ($var eq 'Filename') { $thispkg->{file} = $val; } elsif ($var eq 'Version') { $thispkg->{version} = $val; } elsif ($var eq 'MD5sum') { $thispkg->{md5} = $val; } elsif ($var eq 'Size') { $thispkg->{filesize} = $val; } elsif ($var eq 'Description') { if ($thispkg->{description}) { $thispkg->{longdesc} .= "$val\n"; } else { $thispkg->{description} = $val; } } elsif ($var eq 'Depend') { my $deppkg = $packages{$val}; my $depends = $thispkg->{depends}; if (!$deppkg) { die "package not found: $val\n"; } push @$depends, $deppkg; } else { die "Invalid field: $var\n"; } } } if ($thispkg->{name}) { $packages{$thispkg->{name}} = $thispkg; } close(PACKAGES); } sub pkg_param { my ($desc, $name, $pkg) = @_; return if !$pkg->{$name}; print "$desc: $pkg->{$name}
\n"; } sub param { my ($var) = @_; return $ENV{$var}; } packages_load; if (param('pkg')) { my $pkg = $packages{param('pkg')}; die "package not found" if !$pkg; print "

$pkg->{name}

\n"; pkg_param('Version', 'version', $pkg); if ($pkg->{file}) { print "File: "; print "{file}\">$pkg->{file}"; print "
\n"; } pkg_param('File Size', 'filesize', $pkg); pkg_param('File MD5SUM', 'md5', $pkg); pkg_param('Description', 'description', $pkg); print $pkg->{longdesc} if $pkg->{longdesc}; my $depends = $pkg->{depends}; if (scalar @$depends > 0) { print "

Dependencies

\n"; print "\n"; } print "

back\n"; } else { print "

Packages

\n"; print "Version 2.0 of Revol is package based, using "; print "spkg to build filesystems automatically. "; print "This is a list of packages currently available in the "; print "repository."; print "\n"; }