summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TLPDB.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/TeXLive/TLPDB.pm')
-rw-r--r--Master/tlpkg/TeXLive/TLPDB.pm80
1 files changed, 66 insertions, 14 deletions
diff --git a/Master/tlpkg/TeXLive/TLPDB.pm b/Master/tlpkg/TeXLive/TLPDB.pm
index 3c392242a45..3c16d540402 100644
--- a/Master/tlpkg/TeXLive/TLPDB.pm
+++ b/Master/tlpkg/TeXLive/TLPDB.pm
@@ -10,7 +10,7 @@ package TeXLive::TLPDB;
=pod
=head1 NAME
-TeXLive::TLPDB - a database of TeX Live Packages
+C<TeXLive::TLPDB> -- A database of TeXLive Packages
=head1 SYNOPSIS
@@ -43,8 +43,17 @@ my $_listdir;
=pod
-C<TeXLive::TLPDB->new> creates a new C<TLPDB> object. If the argument
-location is given it will be initialized from this locations.
+=over 6
+
+=item C<< TeXLive::TLPDB->new >>
+
+=item C<< TeXLive::TLPDB->new(location => "$filename") >>
+
+C<< TeXLive::TLPDB->new >> creates a new C<TLPDB> object. If the
+argument C<location> is given it will be initialized from this
+location. C<$filename> is usually C</path/to/texlive.tlpdb>. If
+C<$filename> begins with C<http://> or C<ftp://>, the program C<wget>
+is used to download the file.
=cut
@@ -65,9 +74,12 @@ sub new {
=pod
+=item C<< $tlpdb->add_tlpobj($tlpobj) >>
+
The C<add_tlpobj> adds an object of the type TLPOBJ to the TLPDB.
=cut
+
sub add_tlpobj {
my ($self,$tlp) = @_;
$self->{'tlps'}{$tlp->name} = $tlp;
@@ -75,10 +87,15 @@ sub add_tlpobj {
=pod
-The C<from_file> function initializes the C<TLPDB> in case the location
-was not given at generation time.
+=item C<< $tlpdb->from_file($filename) >>
+
+The C<from_file> function initializes the C<TLPDB> in case the
+location was not given at generation time. If C<$filename> begins
+with C<http://> or C<ftp://>, the program C<wget> is used to download
+the file.
=cut
+
sub from_file {
my $self = shift;
if (@_ != 1) {
@@ -90,7 +107,12 @@ sub from_file {
}
}
$self->location($_[0]);
- open(TMP,"<$_[0]") || die("Cannot open tlpdb file: $_[0]");
+ if ($_[0]=~/^(http|ftp):\/\//) {
+ open(TMP, "wget -nv --output-document=- $_[0]|")
+ || die("Cannot open tlpdb file: $_[0]");
+ } else {
+ open(TMP,"<$_[0]") || die("Cannot open tlpdb file: $_[0]");
+ }
my $found = 0;
do {
my $tlp = TeXLive::TLPOBJ->new;
@@ -104,10 +126,15 @@ sub from_file {
=pod
-The C<writeout> function writes the whole TLPDB to STDOUT, or to the file
-handle given as argument.
+=item C<< $tlpdb->writeout >>
+
+=item C<< $tlpdb->writeout(FILEHANDLE) >>
+
+The C<writeout> function writes the whole C<TLPDB> to C<STDOUT>, or to
+the file handle given as argument.
=cut
+
sub writeout {
my $self = shift;
my $fd = (@_ ? $_[0] : STDOUT);
@@ -121,10 +148,13 @@ sub writeout {
=pod
-The C<save> functions saves the TLPDB to the file which has been set
+=item C<< $tlpdb->save >>
+
+The C<save> functions saves the C<TLPDB> to the file which has been set
as location. If the location is undefined, die.
=cut
+
sub save {
my $self = shift;
open(FOO,">$self->{'location'}") || die("Cannot open $self->{'location'} for writing: $!");
@@ -134,10 +164,13 @@ sub save {
=pod
-The C<get_package> function returns a reference to an TLPOBJ object in case
-its name the the argument name coincide.
+=item C<< $tlpdb->get_package("packagename") >>
+
+The C<get_package> function returns a reference to a C<TLPOBJ> object
+in case its name the the argument name coincide.
=cut
+
sub get_package {
my ($self,$pkg) = @_;
if (defined($self->{'tlps'}{$pkg})) {
@@ -149,9 +182,12 @@ sub get_package {
=pod
+=item C<< $tlpdb->list_packages >>
+
The C<list_packages> function returns the list of all included packages.
=cut
+
sub list_packages {
my $self = shift;
return (sort keys %{$self->{'tlps'}});
@@ -159,10 +195,13 @@ sub list_packages {
=pod
-The C<package_revision> function returns the the revision of the
+=item C<< $tlpdb->package_revision("packagename") >>
+
+The C<package_revision> function returns the revision number of the
package named in the first argument.
=cut
+
sub package_revision {
my ($self,$pkg) = @_;
if (defined($self->{'tlps'}{$pkg})) {
@@ -174,10 +213,13 @@ sub package_revision {
=pod
+=item C<< $tlpdb->generate_packagelist >>
+
The C<generate_packagelist> lists all available TL Packages together
with their revisions.
=cut
+
sub generate_packagelist {
my $self = shift;
my $fd = (@_ ? $_[0] : STDOUT);
@@ -188,10 +230,15 @@ sub generate_packagelist {
=pod
+=item C<< $tlpdb->generate_listfiles >>
+
+=item C<< $tlpdb->generate_listfiles($destdir) >>
+
The C<generate_listfiles> generates the list files for the old
installers. This function will probably go away.
=cut
+
sub generate_listfiles {
my ($self,$destdir) = @_;
if (not(defined($destdir))) {
@@ -313,10 +360,13 @@ sub _generate_listfile {
=pod
+=item C<< $tlpdb->location("/path/to/texlive.tlpdb") >>
+
The function C<location> allows to read and set the location of the
-text file of the TeX Live Database.
+text file of the TeXLive database.
=cut
+
sub location {
my $self = shift;
if (@_) { $self->{'location'} = shift }
@@ -325,6 +375,8 @@ sub location {
=pod
+=item C<< $tlpdb->listdir >>
+
The function C<listdir> allows to read and set the packages variable
specifiying where generated list files are created.
@@ -335,9 +387,9 @@ sub listdir {
return $_listdir;
}
+=back
=pod
-
=head1 SEE ALSO
The modules L<TeXLive::TLPSRC>, L<TeXLive::TLPOBJ>,