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
|
#!/usr/bin/perl
# The yChat & yhttpd Project (2004, 2005)
#
# This scripts modifies the yChat sources to yhttpd sources.
use strict;
use scripts::modules::file;
my @delete = (
'ChangeLog',
'g++.version',
'TODO',
'NEWS',
'docs',
'src/chat',
'src/data',
'src/irc',
'src/contrib/crypt',
'src/modl.h',
'src/modl.cpp',
'src/mods',
'src/mods/commands',
'src/mods/irc',
'obj',
'mods',
'html',
'log/rooms',
'scripts/makeyhttpd.pl',
'scripts/mergeconf.pl',
'bin/ychat',
'bin/ychat.old',
);
my @createdir = (
'html'
);
my %substituate = (
'ychat' => 'yhttpd',
'yChat' => 'yhttpd',
'YCHAT' => 'YHTTPD',
'CHAT' => 'HTTPD',
'//>>' => ''
);
if ( -d "../yhttpd" ) {
print "Removing ../yhttpd\n";
system("rm -Rf ../yhttpd");
}
print "Creating new ../yhttpd\n";
system("cp -Rp ../ychat ../yhttpd");
chdir("../yhttpd");
system("gmake clean");
my @deletelines;
foreach (@delete) {
next unless -d $_;
foreach (dopen($_)) {
next unless /\.h$/;
push @deletelines, $_;
}
}
print "Moving html templates\n";
system("mv html/test.cgi .");
system("mv html/demo.html .");
system("mv html/style.css .");
system("mv html/notfound.html .");
print "Removing dirs and files\n->";
foreach (@delete) {
next unless -f $_ || -d $_;
print " $_";
system("rm -Rf $_");
}
print "\nDeleting CVS directories\n";
system("find . -name CVS | xargs rm -Rf");
print "Creating new dirs\n->";
foreach (@createdir) {
print " $_";
system("mkdir $_");
}
print "\nRenaming config file\n";
system("mv etc/ychat.conf etc/yhttpd.conf");
print "Moving html templates\n";
system("mv demo.html html/index.html");
system("mv test.cgi notfound.html style.css html");
print "Removing marked lines of code\n->";
&remove_marked_lines('.');
sub remove_marked_lines {
my $dir = shift;
chdir($dir);
foreach (&dopen(".")) {
next if /^\.+$/;
print " $_";
if ( -f $_ ) {
my @newfile;
my $flag = 0;
foreach my $line (fopen($_)) {
$flag = 1 if $line =~ /\/\/<<\*/;
if ($flag == 0 && $line !~ /\/\/<</) {
foreach ( @deletelines ) {
if ($line =~ /$_/) {
$flag = 3;
last;
}
}
if ($flag != 3 ) {
map { $line =~ s/$_/$substituate{$_}/eg } keys %substituate;
push @newfile, $line;
} else {
$flag = 0;
}
}
$flag = 0 if $line =~ /\/\/\*>>/;
}
&fwrite($_, @newfile);
} elsif ( -d $_ ) {
&remove_marked_lines($_);
}
}
chdir('..');
}
print "\n";
|