summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2009-03-18 00:16:50 +0000
committerNorbert Preining <preining@logic.at>2009-03-18 00:16:50 +0000
commit3d282a45eceb99e5e239ee2be0f8fc54c30f8bbc (patch)
treee558ffeac48c6c2882b32cd0e9c7d8525b32835c
parent1a82a7b9ed1ef82d2087ac55a66e93149a0186a1 (diff)
work on import feature of settings from previous installation
git-svn-id: svn://tug.org/texlive/branches/branch2009-dev@12414 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-xMaster/install-tl116
-rw-r--r--Master/tlpkg/TeXLive/TLPDB.pm34
-rwxr-xr-xMaster/tlpkg/installer/install-menu-text.pl46
3 files changed, 143 insertions, 53 deletions
diff --git a/Master/install-tl b/Master/install-tl
index c8fcef0bd22..67718118f98 100755
--- a/Master/install-tl
+++ b/Master/install-tl
@@ -255,6 +255,7 @@ if ($opt_nonadmin and win32()) {
# media, while $localtlpdb is for the new installation
# $tlpdb must be our because it is used in install-menu-text.pl
our $tlpdb;
+our $previoustlpdb;
my $localtlpdb;
my $location;
@@ -451,17 +452,14 @@ if ($opt_profile eq "") {
if ($tlmgrwhich) {
my $dn = dirname($tlmgrwhich);
$dn = abs_path("$dn/../..");
- printf "dn=$dn\n";
my $tlpdboldpath = "$dn/$TeXLive::TLConfig::InfraLocation/$TeXLive::TLConfig::DatabaseName";
if (-r $tlpdboldpath) {
# we found an old installation, so read that one in and save
# the list installed collections into an array.
- print "tlpdboldpath = $tlpdboldpath\n";
- my $oldtlpdb=TeXLive::TLPDB->new(root => $dn);
- if ($oldtlpdb) {
- print "found old installation\n";
- my @colls = $oldtlpdb->collections;
- push @runargs, "-old-installation-collections", \@colls;
+ $previoustlpdb = TeXLive::TLPDB->new(root => $dn);
+ if ($previoustlpdb) {
+ debug ("found old installation in $dn\n");
+ push @runargs, "-old-installation-found";
}
}
}
@@ -958,18 +956,20 @@ sub calc_depends {
# initialize the %install hash with what should be installed
- # First look for packages in the selected scheme.
- my $scheme=$tlpdb->get_package($vars{'selected_scheme'});
- if (!defined($scheme)) {
- if ($vars{'selected_scheme'}) {
- # something is written in the selected scheme but not defined, that
- # is strange, so warn and die
- die ("Scheme $vars{'selected_scheme'} not defined, vars:\n");
- dump_vars(\*STDOUT);
- }
- } else {
- for my $scheme_content ($scheme->depends) {
- $install{"$scheme_content"}=1 unless ($scheme_content=~/^collection-/);
+ if ($vars{'selected_scheme'} ne "scheme-custom") {
+ # First look for packages in the selected scheme.
+ my $scheme=$tlpdb->get_package($vars{'selected_scheme'});
+ if (!defined($scheme)) {
+ if ($vars{'selected_scheme'}) {
+ # something is written in the selected scheme but not defined, that
+ # is strange, so warn and die
+ die ("Scheme $vars{'selected_scheme'} not defined, vars:\n");
+ dump_vars(\*STDOUT);
+ }
+ } else {
+ for my $scheme_content ($scheme->depends) {
+ $install{"$scheme_content"}=1 unless ($scheme_content=~/^collection-/);
+ }
}
}
@@ -1305,25 +1305,87 @@ sub save_options_into_tlpdb {
$localtlpdb->save() unless $vars{'from_dvd'};
}
-#
-# select a group of collection, maybe from an old isntallation
-#
-sub select_collections_from_list {
- $vars{'selected_scheme'} = "";
- $vars{'n_collections_selected'}=0;
+
+sub import_settings_from_old_tlpdb {
+ # first import the collections
+ # since the scheme is not the final word we select scheme-custom here
+ # and then set the single collections by hand
+ $vars{'selected_scheme'} = "scheme-custom";
+ $vars{'n_collections_selected'} = 0;
# remove the selection of all collections
foreach my $entry (keys %vars) {
if ($entry=~/^(collection-.*)/) {
$vars{"$1"}=0;
}
}
- for my $c (@_) {
+ for my $c ($previoustlpdb->collections) {
my $tlpobj = $tlpdb->get_package($c);
if ($tlpobj) {
$vars{$c} = 1;
++$vars{'n_collections_selected'};
}
}
+ # now take over the path
+ my $oldroot = $previoustlpdb->root;
+ my $newroot = abs_path("$oldroot/../$texlive_release");
+ $vars{'TEXDIR'} = $newroot;
+ $vars{'TEXDIRW'} = $newroot;
+ $vars{'TEXMFSYSVAR'} = "$newroot/texmf-var";
+ $vars{'TEXMFSYSCONFIG'} = "$newroot/texmf-config";
+ # only TEXMFLOCAL is treated differently, we use what is found by kpsewhich
+ # in 2008 and onward this is defined as
+ # TEXMFLOCAL = $SELFAUTOPARENT/../texmf-local
+ # so kpsewhich -var-value=TEXMFLOCAL returns
+ # ..../2008/../texmf-local
+ # TODO TODO TODO
+ chomp (my $tml = `kpsewhich -var-value=TEXMFLOCAL`);
+ $tml = abs_path($tml);
+ $vars{'TEXMFLOCAL'} = $tml;
+ #
+ # now for the settings
+ # set the defaults to what is specified in the tlpdb
+ $vars{'option_doc'} =
+ $previoustlpdb->option_pkg("00texlive-installation.config",
+ "opt_install_docfiles");
+ $vars{'option_src'} =
+ $previoustlpdb->option_pkg("00texlive-installation.config",
+ "opt_install_srcfiles");
+ $vars{'option_fmt'} =
+ $previoustlpdb->option_pkg("00texlive-installation.config",
+ "opt_create_formats");
+ my $tmp = $previoustlpdb->option_pkg("00texlive-installation.config",
+ "opt_paper");
+ $vars{'option_letter'} = defined($tmp) && ($tmp eq "letter" ? 1 : 0);
+ $vars{'option_desktop_integration'} = 1 if win32();
+ # option_path does not exist in older installation
+ $vars{'option_path'} =
+ $previoustlpdb->option_pkg("00texlive-installation.config",
+ "opt_create_symlinks");
+ $vars{'option_path'} = 1 if win32();
+ $vars{'sys_bin'} =
+ $previoustlpdb->option_pkg("00texlive-installation.config",
+ "opt_sys_bin");
+ $vars{'sys_man'} =
+ $previoustlpdb->option_pkg("00texlive-installation.config",
+ "opt_sys_man");
+ $vars{'sys_info'} =
+ $previoustlpdb->option_pkg("00texlive-installation.config",
+ "opt_sys_info");
+ #
+ # import the set of selected architectures
+ my $val = $previoustlpdb->option_pkg("00texlive-installation.config",
+ "available_architectures");
+ my @aar;
+ if (defined($val)) {
+ @aar = split(" ", $val);
+ for my $b ($tlpdb->available_architectures) {
+ $vars{"binary_$b"} = member( $b, @aar );
+ }
+ $vars{'n_systems_available'} = 0;
+ for my $key (keys %vars) {
+ ++$vars{'n_systems_available'} if ($key=~/^binary/);
+ }
+ }
}
# do everything to select a scheme
@@ -1332,6 +1394,8 @@ sub select_scheme {
my $s = shift;
# set the selected scheme to $s
$vars{'selected_scheme'} = $s;
+ # if we are working on scheme-custom simply return
+ return if ($s eq "scheme-custom");
# remove the selection of all collections
foreach my $entry (keys %vars) {
if ($entry=~/^(collection-.*)/) {
diff --git a/Master/tlpkg/TeXLive/TLPDB.pm b/Master/tlpkg/TeXLive/TLPDB.pm
index e55bb4f15f5..32a72b3ae10 100644
--- a/Master/tlpkg/TeXLive/TLPDB.pm
+++ b/Master/tlpkg/TeXLive/TLPDB.pm
@@ -1110,12 +1110,16 @@ Need to be documented
=cut
sub _set_option_value {
- my ($self,$key,$value) = @_;
- my $pkg = $self->{'tlps'}{'00texlive.installation'};
+ my $self = shift;
+ $self->_set_option_value_pkg('00texlive.installation', @_);
+}
+sub _set_option_value_pkg {
+ my ($self,$pkgname,$key,$value) = @_;
+ my $pkg = $self->{'tlps'}{$pkgname};
my @newdeps;
if (!defined($pkg)) {
$pkg = new TeXLive::TLPOBJ;
- $pkg->name("00texlive.installation");
+ $pkg->name($pkgname);
$pkg->category("TLCore");
push @newdeps, "$key:$value";
} else {
@@ -1133,20 +1137,25 @@ sub _set_option_value {
}
}
$pkg->depends(@newdeps);
- $self->{'tlps'}{'00texlive.installation'} = $pkg;
+ $self->{'tlps'}{$pkgname} = $pkg;
}
sub _option_value {
- my ($self,$key) = @_;
- if (defined($self->{'tlps'}{'00texlive.installation'})) {
- foreach my $d ($self->{'tlps'}{'00texlive.installation'}->depends) {
+ my $self = shift;
+ $self->_option_value_pkg('00texlive.installation', @_);
+}
+
+sub _option_value_pkg {
+ my ($self,$pkg,$key) = @_;
+ if (defined($self->{'tlps'}{$pkg})) {
+ foreach my $d ($self->{'tlps'}{$pkg}->depends) {
if ($d =~ m!^$key:(.*)$!) {
return "$1";
}
}
return;
}
- tlwarn("00texlive.installation not found, cannot read option $key.\n");
+ tlwarn("$pkg not found, cannot read option $key.\n");
return;
}
@@ -1156,6 +1165,15 @@ sub option {
if (@_) { $self->_set_option_value($key, shift); }
return $self->_option_value($key);
}
+
+sub option_pkg {
+ my $self = shift;
+ my $pkg = shift;
+ my $key = shift;
+ if (@_) { $self->_set_option_value_pkg($pkg, $key, shift); }
+ return $self->_option_value_pkg($pkg, $key);
+}
+
# TODO the above function should be used in the functions below as
# far as possible ...
diff --git a/Master/tlpkg/installer/install-menu-text.pl b/Master/tlpkg/installer/install-menu-text.pl
index e3733071a28..c8a5d0bdf57 100755
--- a/Master/tlpkg/installer/install-menu-text.pl
+++ b/Master/tlpkg/installer/install-menu-text.pl
@@ -13,6 +13,7 @@ use vars qw(@::end_install_hook $::opt_no_cls);
our %vars;
our $tlpdb;
+our $previoustlpdb;
our @collections_std;
our @collections_lang;
our @collections_lang_doc;
@@ -112,11 +113,21 @@ sub prompt {
sub run_menu_text {
my (@args) = @_;
# the text mode installer does not take interest in any argument
- # but the -old-installation-collections
+ # but the -old-installation-found
while (@args) {
my $f = shift @args;
- if ($f eq "-old-installation-collections") {
- select_collections_from_list(@{shift @args});
+ if ($f eq "-old-installation-found") {
+ print "\nAnd old installation of TeX Live has been found in ",
+ $previoustlpdb->root, "\n";
+ print "
+If you want the selection of collections and various options being taken
+over press `y', otherwise anything else.
+
+Import settings from previous TeX Live installation: (y/n): ";
+ chomp(my $yn = <STDIN>);
+ if ($yn =~ m/^y$/i) {
+ import_settings_from_old_tlpdb();
+ }
}
}
my $menu=\&main_menu;
@@ -207,30 +218,27 @@ sub scheme_menu {
menu_head 'Select a scheme:';
- foreach my $pkg ($tlpdb->list_packages) {
- my $tlpobj = $tlpdb->{'tlps'}{$pkg};
- if ($tlpobj->category eq "Scheme") {
- push @schemes, $pkg;
- $vars{"$pkg"}=($vars{'selected_scheme'} eq $pkg)? 1:0;
- }
+ foreach my $pkg ($tlpdb->schemes) {
+ push @schemes, $pkg;
+ $vars{"$pkg"}=($vars{'selected_scheme'} eq $pkg)? 1:0;
}
@schemes=sort @schemes;
+ push @schemes, "scheme-custom";
foreach my $scheme (@schemes) {
$keyval{$keys[$index]}="$scheme";
- my $tlpobj = $tlpdb->get_package("$scheme");
- printf " %s %s %s\n", $keys[$index], button($vars{"$scheme"}),
- $tlpobj->shortdesc;
- ++$index;
- }
-
- foreach my $entry (keys %vars) {
- if ($entry=~/^(collection-.*)/) {
- $vars{"$1"}=0;
+ if ($scheme ne "scheme-custom") {
+ my $tlpobj = $tlpdb->get_package("$scheme");
+ printf " %s %s %s\n", $keys[$index], button($vars{"$scheme"}),
+ $tlpobj->shortdesc;
+ } else {
+ printf " %s %s custom selection of collections\n",
+ $keys[$index], button($vars{'selected_scheme'} eq "scheme-custom");
}
+ ++$index;
}
- # select_scheme($vars{'selected_scheme'});
+ select_scheme($vars{'selected_scheme'});
if ($vars{"binary_win32"}) {
$vars{"collection-wintools"} = 1;