summaryrefslogtreecommitdiff
path: root/Master/tlpkg/etc/updater.pl
blob: 305e035a7254353b1b896d8d33fdfd52a3fd4991 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/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: #