diff options
| author | svn svn@31f1291d-b8d6-0310-a050-a5561fc1590b <svn svn@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2004-03-28 21:59:56 +0000 |
|---|---|---|
| committer | svn svn@31f1291d-b8d6-0310-a050-a5561fc1590b <svn svn@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2004-03-28 21:59:56 +0000 |
| commit | 55bf4dbcabf378e9472b7d31d6edf87f6ac853e9 (patch) | |
| tree | 7a9454ea6b8750256e242cf6d5fba3ca7a4b5044 /bin | |
Initial Anope Import
git-svn-id: svn://svn.anope.org/anope/trunk@1 31f1291d-b8d6-0310-a050-a5561fc1590b
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/checklang | 16 | ||||
| -rwxr-xr-x | bin/cp-recursive | 21 | ||||
| -rwxr-xr-x | bin/fixlang | 17 | ||||
| -rwxr-xr-x | bin/getanope | 42 | ||||
| -rwxr-xr-x | bin/langtool.pl | 239 | ||||
| -rwxr-xr-x | bin/makepatch | 83 | ||||
| -rwxr-xr-x | bin/mydbgen | 194 | ||||
| -rwxr-xr-x | bin/putanope | 104 |
8 files changed, 716 insertions, 0 deletions
diff --git a/bin/checklang b/bin/checklang new file mode 100755 index 000000000..bcabe0d88 --- /dev/null +++ b/bin/checklang @@ -0,0 +1,16 @@ +#!/bin/bash +# +# $Id: checklang,v 1.1 2003/07/16 04:34:04 dane Exp $ +# + +if [ ! -f en_us.l ]; then + echo "*** You must run this script on the lang directory." + echo "" + exit 1 +fi + +for lang in $(ls *.l) +do + echo "*** CHECKING $lang ***" + ./obs.pl $lang +done diff --git a/bin/cp-recursive b/bin/cp-recursive new file mode 100755 index 000000000..e51230db7 --- /dev/null +++ b/bin/cp-recursive @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ $1 = "-t" ] ; then + shift +fi +if [ ! "$2" ] ; then + echo >&2 Usage: $0 '<sourcedir> <targetdir>' + exit 1 +fi +if [ -d "$1" ] ; then + dir="$1" +else + dir="`echo $1 | sed 's#\(.*\)/.*#\1#'`" +fi +while [ "$2" ] ; do + shift +done +if [ ! -d $1 ] ; then + mkdir -p $1 || exit 1 +fi +/bin/tar -Ccf $dir - . | /bin/tar -Cxf $1 - diff --git a/bin/fixlang b/bin/fixlang new file mode 100755 index 000000000..1a1ea875a --- /dev/null +++ b/bin/fixlang @@ -0,0 +1,17 @@ +#!/bin/bash +# +# $Id: fixlang,v 1.1 2003/07/16 04:34:04 dane Exp $ +# + +if [ ! -f en_us.l ]; then + echo "*** You must run this script on the lang directory." + echo "" + exit 1 +fi + +for lang in $(ls *.l) +do + echo "*** CHECKING $lang ***" + ./fixlang.pl $lang + mv fixed.l $lang +done diff --git a/bin/getanope b/bin/getanope new file mode 100755 index 000000000..58f4c0dc7 --- /dev/null +++ b/bin/getanope @@ -0,0 +1,42 @@ +#!/bin/bash +# +# $Id: getanope,v 1.2 2003/11/24 20:23:28 dane Exp $ +# + +MODULE="anope-dev" +BRANCH="" + +if [ "$1" == "" ]; then + DST="$MODULE" +else + DST="$1" +fi + +let cnt="$(echo $CVSROOT | grep anope | wc -l)" +if [ $cnt -eq 0 ]; then + echo "*** Environment variable CVSROOT is not set. Please set it" + echo "*** if you have a developer account with write access." + echo "" + echo "*** Assuming anonymous access. If prompted for a password," + echo "*** just press RETURN to continue." + echo "" + export CVSROOT=":pserver:pubcvs@zero.org:/home/cvs/anope" + + let login="$(grep "pubcvs@zero.org" ~/.cvspass 2> /dev/null | grep anope | wc -l)" + + if [ $login -eq 0 ]; then + cvs -d$CVSROOT login + fi +fi + +echo "Checking out $MODULE" + +if [ "$BRANCH" == "" ]; then + cvs -z3 -d$CVSROOT checkout -d$DST $MODULE +else + cvs -z3 -d$CVSROOT checkout -r$BRANCH -d$DST $MODULE +fi + +echo "*** All done!" + +exit 0 diff --git a/bin/langtool.pl b/bin/langtool.pl new file mode 100755 index 000000000..c1072760c --- /dev/null +++ b/bin/langtool.pl @@ -0,0 +1,239 @@ +#!/usr/bin/perl +# +# Ribosome's all in one language tool +# 1) Compares to check for missing lines +# 2) Compares to check for equal lines +# 3) Fixes (on request) missing lines +# 4) Checks for errors in lines +# 5) Checks for long lines (>60 characters) +# + +# Check to see if we have received arguments +if (!$ARGV[0]) { +print "Usage: $0 [language file]\n"; +exit; +} + +# If yes, set $sourcefile to the language filename +$testagainst = $ARGV[0]; + +# Set $sourcefile to en_us language file +$sourcefile = "en_us.l"; + +# Number of Keys in File, Number of Equal Lines, Number of Missing Lines +# Fixed Lines (optional) and Number of Format Error Lines, Number of Long Lines +my $numberlines = 0; +my $equallines = 0; +my $missinglines = 0; +my $fixedlines = 0; +my $errorline = 0; +my $longlines = 0; + +# Array to hold the lines from the source file and explosion array for long line check + +my @sourcearray; +my @explosion; + +# Create associative arrays which will contain keys and definitions +# One for the control source and one for what is being tested against + +my %sourcehash= (); +my %testhash= (); + +# Check if Files Exist + +if (! -f $sourcefile) { +print "Critical Error: The source file does not exist or is unreadable.\nNote: This tool must be run from the language directory.\n"; +exit; +} + +if (! -f $testagainst) { +print "Critical Error: The language file does not exist or is unreadable\n"; +exit; +} +########################################### +# Function to load sourcefile into memory # +########################################### + +sub load_sourcefile { + + my $_key; # This variable will hold the key + my $_def; # This variable will hold the definition + my $line; # This variable will hold the current line + + open (SOURCEFILE, "< $sourcefile"); # Open the source file + while (<SOURCEFILE>) { # For each line the source file + $line = $_; # $line is set to the line in the source file + + # Skip comments + if (/^#/) { # This checks for # which indicates comment + next; # If detected, the next line is skipped to + } + + # Start of a key + if (/^[A-Z]/) { # Checks to see if the line is a key + chomp($line); # Removes things that shouldn't be at the end + push (@sourcearray, $line); # Puts the line into the source array + # If a key is defined, load definition into the hash + if ($_key ne undef) { # If the key is defined + $sourcehash{$_key} = $_def; # Add the definition to the associative array + } + $_key=$line; # Set the key to the line + $_def=""; # Reset the definition + next; # Move onto the next line + } + + if ($_key ne undef) { # If the key is set already + $_def.=$line; # The definition is the current line + } + + $sourcehash{$_key} = $_def; # Load the definition into the associative array + } # End of while which reads lines + + close (SOURCEFILE); # Close the source file + +} # End of load_sourcefile function + +################################################# +# Function to load testagainst file into memory # +################################################# + +sub load_testagainst { + + my $_key; # This variable will hold the key + my $_def; # This variable will hold the definition + my $line; # This variable will hold the current line + + open (TESTAGAINSTFILE, "< $testagainst"); # Open the file containing the control lines + while (<TESTAGAINSTFILE>) { # For each line in the file + $line = $_; # $line is set to the lines value + + + # Skip comments + if (/^#/) { # This checks for # which indicates comment + next; # If detected, the next line is skipped to + } + + # Start of a key + if (/^[A-Z]/) { # Checks to see if the line is a key + chomp($line); # Removes things that shouldn't be at the end + + + if ($_key ne undef) { # If the key is defined + $testhash{$_key} = $_def; # Add the definition to the associative array + } + $_key=$line; # Set the key to the line + $_def=""; # Reset the definition + next; # Move onto the next line + } + + if ($_key ne undef) { # If the key is set already + $_def.=$line; # The definition is the current line + } + + $testhash{$_key} = $_def; # Load the definition into the associative array + } # End of while which reads lines + close (TESTAGAINSTFILE); # Close the source file + +} + + +sub get_format { # Function to get the formatting from a string + my $fmt=""; + my $str=shift; # Get the input + + while ($str =~ m/%\w/g) { + $fmt .= $&; + } + + return $fmt; # Return the formatting +} + + +load_sourcefile; # Call function to load the source file +load_testagainst; # Call function to load the test file + +if (!grep(/^LANG_NAME/,%testhash)) { +print "Critical Error: $ARGV[0] is not a valid language file!\n"; +exit; +} + +open (LOG,"> langcheck.log"); # Open logfile for writing + +foreach $sourcearray (@sourcearray) { # For each key stored in the source array + my $_key=$_; # Store key from source array in $_key + + if ((get_format($sourcehash{$sourcearray})) ne (get_format($testhash{$sourcearray}))) { + if ($sourcearray !~ STRFTIME ) { + $errorline++; + print LOG "FORMAT: $sourcearray - (expecting '".get_format($sourcehash{$sourcearray})."' and got '".get_format($testhash{$sourcearray})."')\n"; + } } + + if ($testhash{$sourcearray} eq $sourcehash{$sourcearray} ) { + # If the definitions between the source and the test are equal + $equallines++; # Number of equal lines increases + print LOG "EQUAL: $sourcearray\n"; # Line is written to logfile + } + + if (!grep(/^$sourcearray/,%testhash)) { # If the key is found in the testhash associative array + $missinglines++; # Increase missing lines + print LOG "MISSING: $sourcearray\n"; # Line is written to logfile + } + + @explosion = split(/\n/, $testhash{$sourcearray}); + foreach $explosion (@explosion) { + $explosion =~ s/\002//g; + $explosion =~ s/\037//g; + if (length($explosion) > 61) { + print LOG "LONGLINE: $sourcearray (".substr($explosion,1,30)."...)\n"; + $longlines++; + } + } + +$numberlines++; # Increase the number of lines tested by 1 +} +close (LOG); # Close the logfile + + +######################### +# Show the test results # +######################### + +print "Calculation Results:\n"; +print "----------------------------------\n"; +print "[$numberlines] line(s) were compared\n"; +print "[$equallines] line(s) were found to equal their $sourcefile counterpart(s)\n"; +print "[$missinglines] line(s) were found to be missing\n"; +print "[$longlines] line(s) were found to be long (>60 chars)\n"; +print "[$errorline] line(s) were found to have formatting errors\n"; +print "The specific details of the test have been saved in langcheck.log\n"; + +if ($missinglines) { # If missing lines exist +print "----------------------------------\n"; +print "Missing line(s) have been detected in this test, would you like to fix the file?\n"; +print "This automatically inserts values from the control file ($sourcefile) for the missing values\n"; +print "y/N? (Default: No) "; + +my $input = <STDIN>; # Ask if the file should be fixed +if ((substr($input,0,1) eq "y") || (substr($input,0,1) eq "Y")) { # If Yes... + +open (FIX, ">> $testagainst"); # Open the file and append changes + +foreach $sourcearray (@sourcearray) { # For each key stored in the source array + my $_key=$_; # Store key from source array in $_key + + if (!grep(/^$sourcearray/,%testhash)) { # If the key is not found in the testhash associative array + print FIX "$sourcearray\n$sourcehash{$sourcearray}"; # Add the line(s) to the language file + $fixedlines++; # Increase the fixed line count + } +} + +close (FIX); # Close file after fixing + +print "Fixing Compete. [$fixedlines] line(s) fixed.\n"; +exit; # And Exit! +} + # Otherwise, quit without fixing +print "Exiting. The language file has NOT been fixed.\n"; + +} diff --git a/bin/makepatch b/bin/makepatch new file mode 100755 index 000000000..ed01d1b1b --- /dev/null +++ b/bin/makepatch @@ -0,0 +1,83 @@ +#!/bin/bash +# Daniel Engel (dane@zero.org) +# +# Creates a patch from any version of Anope to another within the +# same CVS module (in this case, anope-rel). Usage: +# +# ./anope-mkpatch 1.5.1 1.5.5 +# +# The earliest version you can use is 1.5.1 (the first CVS tag) +# +# Feel free to improve this script at will. +# +CVSROOT=":pserver:pubcvs@zero.org:/home/cvs/anope" +MODULE="anope-dev" +OLD="$1" +NEW="$2" +NAME="$1-$2.diff" + +echo "*** Note: This script is able to create patches from one version of 1.5.x" +echo "*** to anoter. The earliest valid version is 1.5.1, and you can only make" +echo "*** a patch between two released versions (i.e. no -rnum versions)" +echo "" + +if [[ $OLD == "" ]]; then + echo "*** Usage: $0 [OLD] [NEW]" + exit 0 +fi + + +if [[ $NEW == "" ]]; then + echo "*** Usage: $0 [OLD] [NEW]" + exit 0 +fi + +OLD="anope-$OLD" +NEW="anope-$NEW" + +if [[ -d $OLD ]]; then + echo "*** Directory $OLD already exists... aborting." + exit 0 +fi + +if [[ -d $NEW ]]; then + echo "*** Directory $OLD already exists... aborting." + exit 0 +fi + +echo "*** Issuing the CVS login, when prompted for a password, just press RETURN..." +cvs -d $CVSROOT login + +if [[ $? -ne 0 ]]; then + echo "*** ERROR: CVS login failed... aborting." + exit 0 +fi + +TOLD="$(echo $OLD | sed 's/\./_/g')" +TNEW="$(echo $NEW | sed 's/\./_/g')" + +echo "*** Cheking out $MODULE ($TOLD)" +cvs -d $CVSROOT checkout -r $TOLD -d $OLD $MODULE > /dev/null 2>&1 +if [[ $? -ne 0 ]]; then + echo "*** ERROR: Unable to checkout $MODULE ($TNEW)... aborting." + exit 0 +fi + +echo "*** Cheking out $MODULE ($TNEW)" +cvs -d $CVSROOT checkout -r $TNEW -d $NEW $MODULE > /dev/null 2>&1 +if [[ $? -ne 0 ]]; then + echo "*** ERROR: Unable to checkout $MODULE ($TNEW)... aborting." + exit 0 +fi + +# I wish i could use cvsrmadm here, but not everybody has it :( +echo "*** Removing CVS control files" +find $OLD -name CVS -exec rm -rf {} \; > /dev/null 2>&1 +find $NEW -name CVS -exec rm -rf {} \; > /dev/null 2>&1 + +echo "*** Creating the patch..." +diff -urN $OLD $NEW > $NAME + +echo "*** Done! The patch is $NAME"; +echo "*** You might want to clean things up with:" +echo "*** rm -rf $OLD $NEW" diff --git a/bin/mydbgen b/bin/mydbgen new file mode 100755 index 000000000..e78b025c9 --- /dev/null +++ b/bin/mydbgen @@ -0,0 +1,194 @@ +#!/bin/sh +# + +# Location of the .sql file with the schema +DBFILE="data/tables.sql" + +# Schema Version +SVER="1" + +# Local Version, defaults to 0 +LVER="0" + +TFILE="/tmp/.anopedb.$$" + +if [ "`eval echo -n 'a'`" = "-n a" ] ; then + c="\c" +else + n="-n" +fi + +if [ ! -f $DBFILE ] ; then + echo "Error: Required file $DBFILE is inaccessible!"; + exit +fi + +echo "" +echo "This script will guide you through the process of configuring your Anope" +echo "installation to make use of MySQL support. This script must be used for both" +echo "new installs as well as for upgrading for users who have a previous version" +echo "of Anope installed" + +while [ -z "$SQLHOST" ] ; do + echo "" + echo "What is the hostname of your MySQL server?" + echo $n "-> $c" + read cc + if [ ! -z "$cc" ] ; then + SQLHOST=$cc + fi +done + +while [ -z "$SQLUSER" ] ; do + echo "" + echo "What is your MySQL username?" + echo $n "-> $c" + read cc + if [ ! -z "$cc" ] ; then + SQLUSER=$cc + fi +done + +OLD_TTY=`stty -g` + +echo "" +echo "What is your MySQL password?" +echo $n "-> $c" +stty -echo echonl +read cc +if [ ! -z "$cc" ] ; then + SQLPASS=$cc +fi +stty $OLD_TTY + +mysqlshow -h$SQLHOST -u$SQLUSER -p$SQLPASS >/dev/null 2>&1 +if test "$?" = "1" ; then + echo "Error: Unable to login, verify your login/password and hostname" + exit +fi + +while [ -z "$SQLDB" ] ; do + echo "" + echo "What is the name of the Anope SQL database?" + echo $n "-> $c" + read cc + if [ ! -z "$cc" ] ; then + SQLDB=$cc + fi +done + +MYSQLSHOW="mysqlshow -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB" +MYSQL="mysql -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB" + +echo "" + +$MYSQLHOW >/dev/null 2>&1 +if test "$?" = "1" ; then + echo "It appears that database does not exist. Or that you don't have the" + echo "correct credentials to access it. Please verify that you have entered" + echo "the correct values." + exit +fi + + +res="$($MYSQL -Bs -e "show tables like 'anope_os_core'" | wc -l)" +if test "$res" = "0" ; then + echo -n "Unable to find Anope schema, creating... " + mysql -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB < $DBFILE + if test "$?" = "0" ; then + echo "done!" + else + echo "failed!" + FAILED="$FAILED 'schema creation'" + fi +else + # Introduced on Anope 1.6.0 -> Table anope_info + res="$($MYSQL -Bs -e "show tables like 'anope_info'" | wc -l)" + if test "$res" = "0" ; then + echo -n "Unable to find Anope info table, creating... " + echo "CREATE TABLE anope_info (version int, date datetime) TYPE=MyISAM" > $TFILE + mysql -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB < $TFILE >/dev/null 2>&1 + if test "$?" = "0" ; then + echo "done!" + + else + echo "failed!" + FAILED="$FAILED 'anope_info table'" + fi + else + LVER="$($MYSQL -sB -e "select version from anope_info")" + if test "x$LVER" = "x" ; then + LVER=0 + fi + fi + + # Introduced on Anope 1.5.14.5 -> anope_cs_info.memomax + res="$($MYSQL -Bs -e "describe anope_cs_info memomax" 2> /dev/null | wc -l)" + if test "$res" = "0" ; then + echo -n "Unable to find anope_cs_info.memomax, altering... " + echo "ALTER TABLE anope_cs_info ADD memomax smallint unsigned NOT NULL default 0" > $TFILE + mysql -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB < $TFILE >/dev/null 2>&1 + if test "$?" = "0" ; then + echo "done!" + + else + echo "failed!" + FAILED="$FAILED 'anope_cs_info.ttb alter'" + fi + fi + + # Introduced on Anope 1.5.14.5 -> anope_cs_info.ttb + res="$($MYSQL -Bs -e "describe anope_cs_info ttb" | wc -l)" + if test "$res" = "0" ; then + echo -n "Unable to find anope_cs_info.ttb, altering... " + echo "ALTER TABLE anope_cs_info ADD ttb smallint NOT NULL default 0" > $TFILE + mysql -h$SQLHOST -u$SQLUSER -p$SQLPASS $SQLDB < $TFILE >/dev/null 2>&1 + if test "$?" = "0" ; then + echo "done!" + + else + echo "failed!" + FAILED="$FAILED 'anope_cs_info.ttb alter'" + fi + fi + + +fi + +# Insert initial version number. This will have to be redesigned for 1.7 +if [ $LVER -ne $SVER ]; then +echo -n "Inserting initial version number... " +$MYSQL -Bs -e "delete from anope_info" +echo "INSERT INTO anope_info (version, date) VALUES ($SVER, now())" > $TFILE +$MYSQL < $TFILE >/dev/null 2>&1 +if test "$?" = "0" ; then + echo "done!" +else + echo "failed!" + FAILED="$FAILED 'version insert'" +fi +fi + +rm -f $TFILE +if test "x$FAILED" = "x" ; then + # Try to find out more about this installation + SQLSOCK="$(mysql_config --socket 2> /dev/null)" + SQLPORT="$(mysql_config --port 2> /dev/null)" + echo "" + echo "Your MySQL setup is complete and your Anope schema is up to date. Make" + echo "sure you configure MySQL on your services.conf file prior to launching" + echo "Anope with MySQL support. Your configuration values are:" + echo "" + echo "MysqlHost \"$SQLHOST\"" + echo "MysqlUser \"$SQLUSER\"" + echo "MysqlPass \"$SQLPASS\"" + echo "MysqlName \"$SQLDB\"" + echo "MysqlSock \"$SQLSOCK\"" + echo "MysqlPort \"$SQLPORT\"" + echo "" +else + echo "The following operations failed:" + echo "$FAILED" +fi + +exit diff --git a/bin/putanope b/bin/putanope new file mode 100755 index 000000000..d07017dc3 --- /dev/null +++ b/bin/putanope @@ -0,0 +1,104 @@ +#!/bin/sh +# +# $Id: putanope,v 1.14 2003/12/02 23:02:28 joris Exp $ +# + +CTRL="version.log" +MODULE="anope-dev" +TMP="/tmp/putanope.$$" +TMP2="/tmp/putanope2.$$" + +# We need an editor for the log entry +if [ "$EDITOR" == "" ]; then + EDITOR="vi" +fi + +# Use default target, or provided? +if [ "$1" == "" ]; then + DST="$MODULE" +else + DST="$1" +fi + +# Find where to run the rest of the script from. +if [ ! -d $DST ]; then + cd .. + if [ ! -d $DST ]; then + cd .. + if [ ! -d $DST ]; then + echo "*** Directory $DST does not exist, what's going on?" + echo "" + exit 1 + fi + fi +fi + +# CVSROOT dosnt need to be set, just read it form the CVS file :-) +CVSROOT=`cat ${DST}/CVS/Root` + +cd $DST + +# source control file +. $CTRL + +# Version arithmetics +CVER="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_BUILD}" +let minor="$(echo $VERSION_BUILD)" +let new="$minor + 1" +NVER="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${new}" + +# Greet the developer +echo "" +echo "*** Using CVSROOT: $CVSROOT" +echo "*** Using module : $MODULE" +echo "*** Current ver : $CVER" +echo "*** Updated ver : $NVER" +echo "" +echo "*** Make sure you have updated Changes, Changes.conf, and" +echo "*** Changes.lang acordingly before you proceed." +echo -n "*** Ready to continue? (RETURN if so, CTRL-C otherwise) " +read FOO + +cat > $TMP2 <<EOF +# Anope commit utility. Please use this template for your commits. +# Add Mantis bugs separated by spaces. The note part is free form. +BUILD : $NVER +BUGS : +NOTES : +EOF + +$EDITOR $TMP2 + +echo "*** Ready to commit, please verify:" +echo "" +grep -v "^#" $TMP2 +echo "" +echo -n "*** Perform commit? (RETURN if so, CTRL-C otherwise) " +read FOO + +echo "*** Running indent..." +for source in *.c +do + indent -kr -nut $source +done + +# Clean up indent backup files +rm -f *~ + +echo "*** Bumping the version number..." +sed "s/VERSION_BUILD=\"$VERSION_BUILD\"/VERSION_BUILD=\"$new\"/" $CTRL > $TMP +cat $TMP > $CTRL + +TS="$(date '+%F %R')" +grep -v "^#" $TMP2 > $TMP +echo "VTAG : cvs checkout -D \"$TS\" $MODULE" >> $TMP + +cd .. + +cvs -d$CVSROOT commit -F $TMP $DST + +rm -f $TMP $TMP2 + +echo "*** Done!" + +exit 0 |
