#!/usr/bin/env perl # # updater.pl # test implementation of an update program # Copyright 2007 Norbert Preining # # This file is licensed under the GNU General Public Licence version 2 # or any later version $^W = 1; use strict; use TLP; use TLDB; my $TEXLIVEROOT = "."; my $tldblocation = "$TEXLIVEROOT/local.tldb"; # setting the location at new time also initializes the tldb! my $tldb = TLDB->new ( location => $tldblocation ); # read package/revision list from stdin # format: package revision # later on this should be read from the tug.org server to get the # information which packages/revisions are available on the net. my %netavailable; while (<>) { chomp; next if m/^\s*#/; if (m/^(\w+)\s+(\d+)$/) { $netavailable{$1} = $2; } else { die "Wrong format of package list: $_!"; } } foreach (keys %netavailable) { my $localrev = $tldb->package_revision($_); if ($localrev) { # the package is installed if ($localrev < $netavailable{$_}) { update_one_package($_,$localrev,$netavailable{$_}); } } } sub update_one_package { my ($pkgname,$localrev,$netrev) = @_; print "update local/$localrev -> net/$netrev\n"; return 1; # ideas on implementation # - make temporary directory # - cd there # - get package to be updated # - unpack it there # - check the included tlp/$package.tlp for NOT satisfied dependencies my $newtlp = TLP->new; $newtlp->from_file("tlp/$pkgname.tlp"); my @deps = $newtlp->depends; # - if there are unsatisfied deps # . for each unsatisfied dep do # update_one_package (in the same dir should work) # - collect all actions to be carried out from the tlps # - cp -a * TEXLIVEROOT (this installs all updated packages) # - update mktexlsr # - call actions # - update tldb $tldb->add_tlp($newtlp); $tldb->save; # - remove temporary directory } ### Local Variables: ### perl-indent-level: 4 ### tab-width: 4 ### indent-tabs-mode: t ### End: # vim:set tabstop=4: #