diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/README | 17 | ||||
| -rwxr-xr-x | scripts/astyle.sh | 14 | ||||
| -rwxr-xr-x | scripts/buildnr.pl | 26 | ||||
| -rwxr-xr-x | scripts/checkperl.sh | 13 | ||||
| -rwxr-xr-x | scripts/config.pl | 133 | ||||
| -rwxr-xr-x | scripts/makedist.sh | 27 | ||||
| -rwxr-xr-x | scripts/makeyhttpd.pl | 198 | ||||
| -rw-r--r-- | scripts/modules/file.pm | 28 | ||||
| -rwxr-xr-x | scripts/screen.sh | 3 | ||||
| -rwxr-xr-x | scripts/setglobvals.pl | 32 | ||||
| -rwxr-xr-x | scripts/stats.pl | 95 | ||||
| -rwxr-xr-x | scripts/version.sh | 11 |
12 files changed, 597 insertions, 0 deletions
diff --git a/scripts/README b/scripts/README new file mode 100644 index 0000000..f2040ae --- /dev/null +++ b/scripts/README @@ -0,0 +1,17 @@ +All scripts should be run from the yChat main directory, example: + +./scripts/makeyhttpd.pl + +A ./makeyhttpd.pl WILL NOT work :) + +astyle.sh - Uses the astyle tool for source code formatting +buildnr.pl - Increments the yChat build number by one +checkperl.sh - Checks which perl to use [obsolete] +config.pl - yChat configurator [obsolete] +makedist.sh - Creates a yChat destribution package [broken] +makeyhttpd.pl - Generates yhttpd sourcecode [broken] +modules/ - Contains perl subroutines +screen.sh - Starts yChat inside of a screen session +setglobvals.pl - Sets some variables inside of the ./src/glob.h file +stats.pl - Generates and prints out some source code statistics +version.sh - Prints out the current yChat version diff --git a/scripts/astyle.sh b/scripts/astyle.sh new file mode 100755 index 0000000..b9dbc45 --- /dev/null +++ b/scripts/astyle.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# The yChat Project (2004) +# +# This uses "astyle" to format C++ code into a specific code style! + +for f in h cpp tmpl +do + for i in `find . -name "*.$f"` + do + echo $i + astyle --style=ansi -s2 $i + rm -f $i.orig + done +done 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..73b3ae5 --- /dev/null +++ b/scripts/config.pl @@ -0,0 +1,133 @@ +#!/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; + 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 or q to quit] "; + $stdin = <STDIN>; + chomp $stdin; + + finish() if $stdin eq "q" or $stdin eq "quit"; + + unless ( parse_input_value(\$stdin,\$val) ) { + $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 or q to quit] "; + $stdin = <STDIN>; + chomp $stdin; + + finish() if $stdin eq "q" or $stdin eq "quit"; + 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 parse_input_value(\$stdin,\$default); + } + + else { + s/^\/\/// unless parse_input_value(\$stdin,\$default); + } + + print "\n"; + $flag = 0; + next; + } + } +} // for + +finish(); + +sub finish() { + fwrite("src/glob.h", @glob); + exit 0; +} + +sub parse_input_value { + my $val = shift; + my $def = shift; + + if ( $$val eq "" || $$val eq $$def) { + 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..4f1c6e9 --- /dev/null +++ b/scripts/makedist.sh @@ -0,0 +1,27 @@ +#!/bin/sh -x +# 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..5a44462 --- /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/[PRE]{0,3}RELEASE/DEVEL/g; + } + fwrite($_,@file); + } +} + +print "\n"; diff --git a/scripts/modules/file.pm b/scripts/modules/file.pm new file mode 100644 index 0000000..b11e2b3 --- /dev/null +++ b/scripts/modules/file.pm @@ -0,0 +1,28 @@ +sub dopen +{ + my $shift = shift; + opendir DIR, $shift or die "$shift: $!\n"; + my @dir = readdir(DIR); + closedir DIR; + return @dir; +} + +sub fopen +{ + my $shift = shift; + open FILE, $shift or die "$shift: $!\n"; + my @file = <FILE>; + close FILE; + return @file; +} + +sub fwrite +{ + my $shift = shift; + my @file = @_; + open FILE, ">$shift" or die "$shift: $!\n"; + print FILE @file; + close FILE; +} + +1; 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/stats.pl b/scripts/stats.pl new file mode 100755 index 0000000..0eea04d --- /dev/null +++ b/scripts/stats.pl @@ -0,0 +1,95 @@ +#!/usr/bin/perl + +# The yChat Project (2003 - 2005) +# +# This script generates source code and project statistics + +use strict; + +use scripts::modules::file; + +my %stats; +my $param = shift; + +&recursive("."); + +$stats{"Lines total"} = $stats{"Lines of source"} + + $stats{"Lines of scripts"} + + $stats{"Lines of text"} + + $stats{"Lines of HTML"}; + +unless (defined $param) { + + print "$_ = " . $stats{$_} . "\n" + for ( sort keys %stats ); + +} else { + + print $stats{$_} . " " + for sort keys %stats; + +} + +print "\n"; + +sub recursive +{ + my $shift = shift; + my @dir = &dopen($shift); + + foreach (@dir) + { + next if /^\.$/ or /^\.{2}$/; + + if ( -f "$shift/$_" ) + { + $stats{"Number of files total"}++; + &filestats("$shift/$_"); + } + elsif ( -d "$shift/$_" ) + { + $stats{"Number of dirs total"}++; + &recursive("$shift/$_"); + } + } +} + +sub filestats +{ + my $shift = shift; + if ( $shift =~ /\.(cpp|h|tmpl)$/ ) + { + $stats{"Number of source files"}++; + $stats{"Lines of source"} += countlines($shift); + } + elsif ( $shift =~ /\.(html|css)$/ ) + { + $stats{"Number of HTML files"}++; + $stats{"Lines of HTML"} += countlines($shift); + } + elsif ( $shift =~ /\.(gif|png|jpg)$/ ) + { + $stats{"Number of gfx files"}++; + } + elsif ( $shift =~ /(\.pl|\.pm|\.sh|configure.*|Makefile.*)$/ ) + { + $stats{"Number of script files"}++; + $stats{"Lines of scripts"} += countlines($shift); + } + elsif ( $shift =~ /(\.txt|[A-Z]+)$/ ) + { + $stats{"Number of text files"}++; + $stats{"Lines of text"} += countlines($shift); + } + elsif ( $shift =~ /\.so$/ ) + { + $stats{"Number of compiled module files"}++; + } +} + +sub countlines +{ + my $shift = shift; + my @file = fopen($shift); + return $#file; +} diff --git a/scripts/version.sh b/scripts/version.sh new file mode 100755 index 0000000..2f919ba --- /dev/null +++ b/scripts/version.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# The yChat Project (2005) +# +# This script shows yChat VERSION-BRANCH Build BUILDNUMBER + +version=`grep VERSION src/build.h | head -n 1 | cut -d'"' -f2` +branch=`grep BRANCH src/build.h | head -n 1 | cut -d'"' -f2` +build=`grep BUILD src/build.h | tail -n 1 | cut -d' ' -f3` +echo "yChat $version-$branch Build $build" + + |
