summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/README6
-rwxr-xr-xscripts/astyle.sh3
-rwxr-xr-xscripts/buildnr.pl26
-rwxr-xr-xscripts/checkperl.sh13
-rwxr-xr-xscripts/config.pl144
-rwxr-xr-xscripts/makedist.sh27
-rwxr-xr-xscripts/makeyhttpd.pl198
-rwxr-xr-xscripts/screen.sh3
-rwxr-xr-xscripts/setglobvals.pl32
-rwxr-xr-xscripts/version.sh9
10 files changed, 457 insertions, 4 deletions
diff --git a/scripts/README b/scripts/README
new file mode 100644
index 0000000..189b169
--- /dev/null
+++ b/scripts/README
@@ -0,0 +1,6 @@
+All scripts should be run from the yChat main directory, example:
+
+./scripts/makeyhttpd.pl
+
+
+A ./makeyhttpd.pl WILL NOT work :)
diff --git a/scripts/astyle.sh b/scripts/astyle.sh
index 757364e..b9dbc45 100755
--- a/scripts/astyle.sh
+++ b/scripts/astyle.sh
@@ -1,6 +1,5 @@
#!/bin/sh
-
-# The yChat Project (2004, 2005)
+# The yChat Project (2004)
#
# This uses "astyle" to format C++ code into a specific code style!
diff --git a/scripts/buildnr.pl b/scripts/buildnr.pl
new file mode 100755
index 0000000..ee3d3e2
--- /dev/null
+++ b/scripts/buildnr.pl
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+
+# The yChat Project (2003)
+#
+# This script increases the BUILNR of msgs,h each time the yChat
+# gets recompiled!
+
+use strict;
+
+open MSGS, "src/msgs.h";
+my @msgs = <MSGS>;
+close MSGS;
+
+foreach (@msgs)
+{
+ if ( /define BUILDNR/ )
+ {
+ s/(BUILDNR )(.+)$/$1.($2+1)/e;
+ print;
+ next;
+ }
+}
+
+open MSGS, ">src/msgs.h";
+print MSGS @msgs;
+close MSGS;
diff --git a/scripts/checkperl.sh b/scripts/checkperl.sh
new file mode 100755
index 0000000..fa5e98f
--- /dev/null
+++ b/scripts/checkperl.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+# The yChat Project (2005)
+#
+# This scripts checks for a perl installation
+
+if ! which perl >/dev/null
+then
+ echo You need to have Perl in your PATH!
+ exit 1
+fi
+
+echo Using `which perl`
+exit 0
diff --git a/scripts/config.pl b/scripts/config.pl
new file mode 100755
index 0000000..79b1c49
--- /dev/null
+++ b/scripts/config.pl
@@ -0,0 +1,144 @@
+#!/usr/bin/perl
+
+# The yChat Project (2004, 2005)
+#
+# This script modifues the src/glob.h file.
+
+use strict;
+use scripts::modules::file;
+
+print <<END;
+Welcome to the yChat configurator!
+You may also edit the src/glob.h file manually instead of using
+this configurator option. Please also notice that this are only
+before-compile options. All setups which can be made after com-
+iling are placed in the yChat configuration file.
+END
+
+my $sep = "================================================================\n";
+my $stdin;
+
+for (;;)
+{
+ print "$sep Do you want to use the default before-compile options?\n";
+ print " (yes/no) [default is NO] ";
+ $stdin = <STDIN>;
+ chomp $stdin;
+ prove_if_default(\$stdin);
+ print "\n";
+
+ if ( $stdin eq "yes")
+ {
+ print " You chose to use all the default before-compile options. Exiti-\n";
+ print " ng the configurator now!\n";
+ print $sep;
+ exit(0);
+ }
+
+ last if $stdin eq "no" or $stdin eq "";
+ print " Wrong input: You need to specify yes or no!\n";
+} # for
+
+`cp src/glob.h src/glob.h.org` unless -f "src/glob.h.org";
+
+my @glob = fopen("src/glob.h.org");
+my $flag = 0;
+
+for (@glob)
+{
+ if ( $flag == 0 && /- CONFIG -/ )
+ {
+ print $sep;
+ $flag = 1;
+ next;
+ }
+
+ elsif ( $flag == 1 )
+ {
+ if ( /\*\// )
+ {
+ $flag = 2;
+ }
+
+ else
+ {
+ print;
+ }
+
+ next;
+ }
+
+ elsif ( $flag == 2 )
+ {
+ if ( /#define (.+) (.+)/ )
+ {
+ my $def = $1;
+ my $val = $2;
+ my $flg = 0;
+
+ $flg = 1 if $val =~ s/"//g;
+
+ print " [Press enter to use default value: $val] ";
+ $stdin = <STDIN>;
+ chomp $stdin;
+
+ unless ( prove_if_default(\$stdin) )
+ {
+ $stdin = "\"$stdin\"" if $flg == 1;
+ $_ = "#define $def $stdin\n";
+ }
+
+ print "\n";
+ $flag = 0;
+ next;
+ }
+
+ elsif ( /#define .+/ )
+ {
+ my $default = "true";
+ my $stdin;
+
+ for (;;)
+ {
+ $default = "false" if /\/\/#define/;
+
+ print " [Press enter to use default value: $default] ";
+ $stdin = <STDIN>;
+ chomp $stdin;
+
+ last if $stdin eq "" || $stdin eq "true" || $stdin eq "false";
+ print " Wrong input: You need to specify true or false!\n";
+ }
+
+ if ( $default eq "true" )
+ {
+ $_ = "//$_"
+ unless prove_if_default(\$stdin);
+ }
+
+ else
+ {
+ s/^\/\///
+ unless prove_if_default(\$stdin);
+ }
+
+ print "\n";
+ $flag = 0;
+ next;
+ }
+ }
+} // for
+
+ fwrite("src/glob.h", @glob);
+
+sub prove_if_default
+{
+ my $val = shift;
+ if ( $$val eq "" )
+ {
+ print " -> Using default option!\n";
+ return 1;
+ }
+ print " -> Using new option $$val!\n";
+ return 0;
+}
diff --git a/scripts/makedist.sh b/scripts/makedist.sh
new file mode 100755
index 0000000..6c51a07
--- /dev/null
+++ b/scripts/makedist.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# The yChat Project (2005)
+#
+# This script creates a .tar.bz2 ball.
+
+pwd=`pwd` && base=`basename $pwd` && cd .. &&
+version=`grep VERSION $base/src/msgs.h | head -n 1 | cut -d'"' -f2` &&
+prefix="$base-$version"
+package="$prefix.tar.bz2"
+
+echo Copying files... &&
+rm -Rf $prefix 2>/dev/null >/dev/null
+cp -Rp $base $prefix && cd $prefix &&
+
+echo Cleaning... &&
+gmake mrproper 2>/dev/null >/dev/null
+find . -name CVS | xargs rm -Rf
+cd .. &&
+
+echo Compressing... &&
+if test -f $package; then rm -f $package; fi &&
+tar cjf $package $prefix &&
+
+echo Finishing... &&
+rm -Rf $prefix 2>/dev/null >/dev/null
+cd $base &&
+du -h ../$package
diff --git a/scripts/makeyhttpd.pl b/scripts/makeyhttpd.pl
new file mode 100755
index 0000000..7dd0345
--- /dev/null
+++ b/scripts/makeyhttpd.pl
@@ -0,0 +1,198 @@
+#!/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 = (
+ 'CHANGES',
+ 'g++.version',
+ 'TODO',
+ 'NEWS',
+ 'docs',
+ 'src/chat',
+ 'src/memb',
+ 'src/data',
+ 'src/irc',
+ 'src/contrib/crypt',
+ 'src/modl.h',
+ 'src/modl.cpp',
+ 'src/mods',
+ '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',
+ 'yhttpd.org' => 'yChat.org',
+ '//>>' => ''
+);
+
+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 "Editing etc/yhttpd.conf\n";
+&edit_yhttpd_conf();
+print "Removing marked lines of code\n->";
+&remove_marked_lines('.');
+print "\nEdit version numbers\n->";
+&edit_version_numbers('yhttpd/src/msgs.h','yhttpd/README');
+
+sub remove_marked_lines {
+ my $dir = shift;
+ chdir($dir);
+
+ for (&dopen("."))
+ {
+ next if /^\.+$/;
+ print " $_";
+
+ if ( -f $_ )
+ {
+ my @newfile;
+ my $flag = 0;
+
+ for my $line (fopen($_))
+ {
+ $flag = 1 if $line =~ /\/\/<<\*/;
+ if ($flag == 0 && $line !~ /\/\/<</) {
+ for ( @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 $_ )
+ {
+ # Recursive
+ &remove_marked_lines($_);
+ }
+ }
+
+ chdir('..');
+}
+
+sub edit_yhttpd_conf
+{
+ my @old = fopen("etc/yhttpd.conf");
+ my @new = @old[0..1];
+
+ my $flag = 0;
+ for (@old)
+ {
+ if ($flag == 0)
+ {
+ if (/<category name="httpd">/)
+ {
+ $flag = 1;
+ push @new, $_;
+ }
+ }
+
+ else
+ {
+ push @new, $_;
+ }
+ }
+
+ fwrite("etc/yhttpd.conf", @new);
+}
+
+sub edit_version_numbers
+{
+ for (@_)
+ {
+ print " $_";
+ my @file = fopen $_;
+ for (@file)
+ {
+ s/([0-9]+\.[0-9]+)\.[0-9]+(-*)/$1$2/g for @file;
+ s/RELEASE/DEVEL/g;
+ }
+ fwrite($_,@file);
+ }
+}
+
+print "\n";
diff --git a/scripts/screen.sh b/scripts/screen.sh
new file mode 100755
index 0000000..6d5b7aa
--- /dev/null
+++ b/scripts/screen.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+screen -S ychat ./bin/ychat
diff --git a/scripts/setglobvals.pl b/scripts/setglobvals.pl
new file mode 100755
index 0000000..13288a5
--- /dev/null
+++ b/scripts/setglobvals.pl
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+
+# The yChat Project (2003)
+#
+# This script sets up some variables in src/glob.h
+
+use strict;
+
+use scripts::modules::file;
+
+my $file = 'src/glob.h';
+my $gmake = `which gmake`;
+my @glob = fopen($file);
+chomp($gmake);
+
+print "-> Setting values in $file\n";
+
+my $modified = 0;
+foreach (@glob)
+{
+ if (/^(#define GMAKE) "(.*)"/)
+ {
+ if ($2 ne "$gmake \\0")
+ {
+ s/^$1 "$2"/#define GMAKE "$gmake \\0"/;
+ print " -> Set $gmake\n";
+ fwrite($file,@glob);
+ last;
+ }
+ }
+}
+
diff --git a/scripts/version.sh b/scripts/version.sh
index be1b351..46b9fc5 100755
--- a/scripts/version.sh
+++ b/scripts/version.sh
@@ -1,6 +1,11 @@
#!/bin/sh
# The yChat Project (2005)
#
-# This script shows yChat VERSION-BRANCH
+# This script shows yChat VERSION-BRANCH Build BUILDNUMBER
+
+version=`grep VERSION src/msgs.h | head -n 1 | cut -d'"' -f2`
+branch=`grep BRANCH src/msgs.h | head -n 1 | cut -d'"' -f2`
+build=`grep BUILD src/msgs.h | tail -n 1 | cut -d' ' -f3`
+echo "yChat $version-$branch Build $build"
+
-sed -n 's/.*VERSION.*: \(.*\)".*/\1/p' src/msgs.h