summaryrefslogtreecommitdiff
path: root/Build/source/mswin32/sync.pl
blob: d4d0342cf7c538d73786164e23700c867db1e15f (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
require "newgetopt.pl";
use lib ("c:/source/texlive/Master/Tools");
use Cwd;
use FileUtils qw(dirname basename normalize walk_dir cleandir sort_uniq
		 copy remove_list push_uniq newer sync_dir canon_dir
		 is_absolute build_path);
use File::Copy qw(copy);

my @ignore = ( 
	   "libs/gifreader",
	   "libs/geturl",
	   "libs/geturl-new",
	   "libs/freetype2",
	   "libs/expat",
	   "libs/libttf",
	   "libs/T1",
	   "libs/unzip",
	   "texk/kpathsea-fp",
	   "texk/kpsexx",
	   "texk/tth",
	   "texk/windvi-0.68",
	   "utils/l2h-orig",
	   "utils/l2h-orig-orig",
	   "utils/latex2html",
	   "utils/noweb",
	   "utils/src2tex",
	   "utils/texinfo/info",
	   "texk.stable",
	   "texk/kpse-shared*",
	   "texk/cwebk",
	   "texk/msvc/factory",
	   "texk/kpse.*",
	   "texk/web2c/eomegadir/.*",
	   "texk/web2c/eomegadir-1.15/.*",
	   "texk/web2c/eomegadir-1.23/.*",
	   "CVS"
	  );

# $ignore_regexp = "(" . join ( '|', map { s/^/.\\/ ; s/\//\\/g; $_ } @ignore) . ")";
my $ignore_regexp = "(" . join ( '|', @ignore) . ")";

&main;

1;

sub restrict_win {
  my ($dir, $dst, @files) = @_;
  # under the texk/msvc dir, we don't want to copy all the files
  $dir =~ s/^\.//;
  $dir = &getcwd . $dir;
  $dir =~ s@\\@/@g;
  if ($dir =~ m@/msvc$@) {
    @files = grep { /(\.h|\.mak|\.sed|\.pl|\.pm|\.bat|\.inc|\.version)$/ } @files;
  } 
  # only .mak and .rc files under most directories
  elsif ($dir eq '.' || ($dir =~ m@/(texk|libs|utils)@ && $dir !~ m@$ignore_regexp@xo)) {
#    map { if ($dir =~ m@[/\\]$_@) { @files = (); return @files; } } @ignore;
    @files = grep { (-d "$dir/$_") || ($_ =~ m/(\.mak|\.rc)$/) } @files;
  }
  # don't bother with other directories
  else {
    @files = ();
  }
  return @files;
}

sub restrict_unix {
  my ($dir, $dst, @files) = @_;
  $dir =~ s/^\.//;
  $dir = &getcwd . $dir;
  $dir =~ s@\\@/@g;
  # Unix autoconf files
  if ($dir eq '.' || $dir =~ m@[/\\](texk|libs|utils)@ && $dir !~ m@$ignore_regexp@xo) {
    @files = grep { /(Makefile\.in|config|configure|configure\.in|config\.guess|config\.sub|c-auto\.in|\.mk)$/ || (-d "$dir/$_") } @files;
  }
  # don't bother with other directories
  else {
    @files = ();
  }
  return @files;
}

sub restrict_mswin32 {
  my ($dir, $dst, @files) = @_;

  @files = grep /(README|\.exclude|\*.pm|\.pl|\.bat|\.txt)$/, @files;

}

sub restrict_standard {
  my ($dir, $dst, @files) = @_;
  $dir =~ s/^\.//;
  $dir = &getcwd . $dir;
  $dir =~ s@\\@/@g;

  if ($dir =~ m@/CVS$@) {
    @files = ();
  }
  else {
    @files = grep { $_ !~ /^(\.nosearch|\.cvsignore)$/ } @files ;
  }

  return @files;
}

sub main {
  
  unless (&NGetOpt ("dry", "mirror", "sources", "texmf", "restrict")) {
    print STDERR "Try `$0 --help'";
    exit 1;
  }

  $opt_verbose = 1;

  if ($opt_sources) {
    local ($f1, $f2);
    $f1 = "c:/source/fptex/libs";
    $f2 = "c:/source/texlive/Build/source/TeX/libs";
    &sync_dir($f1, $f2, \&restrict_win, "", $opt_dry != 0, $opt_mirror != 0, 1);
    &sync_dir($f2, $f1, \&restrict_unix, "", $opt_dry != 0, $opt_mirror != 0, 1);
    $f2 = "c:/source/texlive/Build/source.development/TeX/libs";
    &sync_dir($f1, $f2, \&restrict_win, "", $opt_dry != 0, $opt_mirror != 0, 1);
    &sync_dir($f2, $f1, \&restrict_unix, "", $opt_dry != 0, $opt_mirror != 0, 1);

    $f1 = "c:/source/fptex/utils";
    $f2 = "c:/source/texlive/Build/source/TeX/utils";
    &sync_dir($f1, $f2, \&restrict_win, "", $opt_dry != 0, $opt_mirror != 0, 1);
    &sync_dir($f2, $f1, \&restrict_unix, "", $opt_dry != 0, $opt_mirror != 0, 1);
    $f2 = "c:/source/texlive/Build/source.development/TeX/utils";
    &sync_dir($f1, $f2, \&restrict_win, "", $opt_dry != 0, $opt_mirror != 0, 1);
    &sync_dir($f2, $f1, \&restrict_unix, "", $opt_dry != 0, $opt_mirror != 0, 1);

    $f1 = "c:/source/fptex/texk";
    $f2 = "c:/source/texlive/Build/source/TeX/texk";
    &sync_dir($f1, $f2, \&restrict_win, "", $opt_dry != 0, $opt_mirror != 0, 1);
    &sync_dir($f2, $f1, \&restrict_unix, "", $opt_dry != 0, $opt_mirror != 0, 1);

    $f1 = "c:/source/fptex/texk.development";
    $f2 = "c:/source/texlive/Build/source.development/TeX/texk";
    &sync_dir($f1, $f2, \&restrict_win, "", $opt_dry != 0, $opt_mirror != 0, 1);
    &sync_dir($f2, $f1, \&restrict_unix, "", $opt_dry != 0, $opt_mirror != 0, 1);

    $f1 = "c:/source/fptex/mswin32";
    $f2 = "c:/source/texlive/Build/source/TeX/mswin32";
    &sync_dir($f1, $f2, \&restrict_mswin32, "", $opt_dry != 0, $opt_mirror != 0, 1);

    $f1 = "c:/source/fptex/mswin32";
    $f2 = "c:/source/texlive/Build/source.development/TeX/mswin32";
    &sync_dir($f1, $f2, \&restrict_mswin32, "", $opt_dry != 0, $opt_mirror != 0, 1);

  }
  elsif ($opt_texmf) {
    local ($f1, $f2) = ("c:/source/texlive/Master/texmf",
			"c:/Program Files/TeXLive/texmf");
    my $restrict = ($opt_restrict ? \&restrict_standard : "");
    &sync_dir($f1, $f2, $restrict , "", $opt_dry != 0, $opt_mirror != 0, 0);    
    ($f1, $f2) = ("c:/source/texlive/Master/texmf-dist",
		  "c:/Program Files/TeXLive/texmf-dist");
    &sync_dir($f1, $f2, $restrict, "", $opt_dry != 0, $opt_mirror != 0, 0);    
    ($f1, $f2) = ("c:/source/texlive/Master/texmf-doc",
		  "c:/Program Files/TeXLive/texmf-doc");
    &sync_dir($f1, $f2, $restrict, "", $opt_dry != 0, $opt_mirror != 0, 0);    
  }
  else {
    local ($f1, $f2) = @ARGV;

    die "$f1 is not a directory!\n" if (! -d $f1);
    die "$f2 is not a directory!\n" if (! -d $f2);

    $f1 = &canon_dir( &build_path(&getcwd, "$f1")) if (! &is_absolute($f1));
    $f2 = &canon_dir( &build_path(&getcwd, "$f2")) if (! &is_absolute($f2));
    
    if ($opt_restrict) {
      &sync_dir($f1, $f2, \&restrict_standard, "", $opt_dry != 0, $opt_mirror != 0, 0);
    }
    else {
      &sync_dir($f1, $f2, "", "", $opt_dry != 0, $opt_mirror != 0, 0);
    }
  }
}