summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2008-12-25 23:36:18 +0000
committerNorbert Preining <preining@logic.at>2008-12-25 23:36:18 +0000
commitb0729282be04682a746efb389405c584fe6df35c (patch)
treea660a0f8fb69842d3686bcce2f64f03e59eb6eea
parentb26dd214751e7737d70dde4bb42ed6525f677a0c (diff)
TLPDB->add_symlinks: factor out the actual code from creating the links,
and do not check for $option_symlinks anymore git-svn-id: svn://tug.org/texlive/trunk@11717 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/tlpkg/TeXLive/TLPDB.pm100
1 files changed, 41 insertions, 59 deletions
diff --git a/Master/tlpkg/TeXLive/TLPDB.pm b/Master/tlpkg/TeXLive/TLPDB.pm
index e4ac88bf4ef..3d201b25224 100644
--- a/Master/tlpkg/TeXLive/TLPDB.pm
+++ b/Master/tlpkg/TeXLive/TLPDB.pm
@@ -931,74 +931,56 @@ On Windows it returns undefined.
=cut
+sub link_dir_dir {
+ my ($from, $to) = @_;
+ mkdirhier $to;
+ if (-w $to) {
+ debug("linking files from $from to $to\n");
+ chomp (@files = `ls "$from"`);
+ for my $f (@files) {
+ unlink("$to/$f");
+ system("ln -s \"$from/$f\" \"$to\"");
+ }
+ return 1;
+ } else {
+ tlwarn("destination $to not writable, no linking files in $from done.\n");
+ return 0;
+ }
+}
+
sub add_symlinks {
my $self = shift;
- my $ret = 0;
+ my $nrfailed = 0;
my $Master = $self->{'root'};
my $arch = $self->option_platform;
my $plat_bindir = "$Master/bin/$arch";
return if win32();
- if ($self->option_create_symlinks) {
- $sys_bin = $self->option_sys_bin;
- $sys_man = $self->option_sys_man;
- $sys_info= $self->option_sys_info;
- my @files;
- # bin files
- mkdirhier $sys_bin;
- if (-w $sys_bin) {
- debug("linking binaries to $sys_bin\n");
- chomp (@files = `ls $plat_bindir`);
- `cd "$sys_bin" && rm -f @files`;
- `ln -s "$plat_bindir/"* "$sys_bin"`;
- } else {
- tlwarn("destination of bin symlinks $sys_bin not writable, "
- . "no linking of bin files done.\n");
- $ret++;
+ $sys_bin = $self->option_sys_bin;
+ $sys_man = $self->option_sys_man;
+ $sys_info= $self->option_sys_info;
+ $nrfailed++ unless link_dir_dir($plat_bindir, $sys_bin);
+ $nrfailed++ unless link_dir_dir("$Master/texmf/doc/info", $sys_info);
+ mkdirhier $sys_man;
+ if (-w $sys_man) {
+ debug("linking man pages to $sys_man\n");
+ my $foo = `(cd "$Master/texmf/doc/man" && echo *)`;
+ chomp (my @mans = split (' ', $foo));
+ foreach my $m (@mans) {
+ my $mandir = "$Master/texmf/doc/man/$m";
+ next unless -d $mandir;
+ $nrfailed++ unless link_dir_dir($mandir, "$sys_man/$m");
}
- # for info and man files we do that only if the option_install_docfiles
- # is set
- if ($self->option_install_docfiles) {
- # info files
- mkdirhier $sys_info;
- if (-w $sys_info) {
- debug("linking info pages to $sys_info\n");
- chomp (@files = `ls "$Master/texmf/doc/info"`);
- `cd "$sys_info" && rm -f @files`;
- `ln -s "$Master/texmf/doc/info/"*info* "$sys_info"`;
- } else {
- tlwarn("destination of info symlink $sys_info not writable, "
- . "no linking of info files done.\n");
- $ret++;
- }
- # man files
- mkdirhier $sys_man;
- if (-w $sys_man) {
- debug("linking man pages to $sys_man\n");
- my $foo = `(cd "$Master/texmf/doc/man" && echo *)`;
- chomp (my @mans = split (' ', $foo));
- foreach my $m (@mans) {
- my $mandir = "$Master/texmf/doc/man/$m";
- next unless -d $mandir;
- mkdirhier "$sys_man/$m";
- next unless -w "$sys_man/$m";
- chomp (@files = `ls "$mandir"`);
- `cd "$sys_man/$m" && rm -f @files`;
- `ln -s "$mandir/"* "$sys_man/$m"`;
- }
- } else {
- tlwarn("destination of man symlink $sys_man not writable, "
- . "no linking of man files done.\n");
- $ret++;
- }
- } else {
- # doc files are not installed, so not linked, should we return an
- # error, or warn, or ???
- }
- # we collected errors in $ret, so return the negation of it
- return !$ret;
} else {
- tlwarn("Option to create symlinks is not set, please do that first.\n");
+ tlwarn("destination of man symlink $sys_man not writable, "
+ . "no linking of man files done.\n");
+ $nrfailed++;
+ }
+ # we collected errors in $ret, so return the negation of it
+ if ($nrfailed) {
+ info("linking failed $nrfailed times, please see above messages.\n");
return 0;
+ } else {
+ return 1;
}
}