Thursday, April 30, 2009

CVS Enhancement

Code Freeze:

Following can be used to prevent developers check in any file by accident when the source tree is ready for a release.

First, create a new directory $CVSROOT/CVSROOT/Freeze to keep the files for tree freeze. Each file is for a either a HEAD (at trunk) or branch. Following function check if the current tree is under freeze policy before perform the commit or import commands. This cvs function can be part of profile, so once the user login the system, it is loaded right away.

cvs ()
{
# check for code freeze
if [ "$1" = commit -o "$1" = import ]; then
if [ ! -f "CVS/Repository" ]; then
echo "Cannot find CVS/Repository.Please check
you current directory."
return 1
fi
if [ -f CVS/Tag ]; then
CVSTAG=`cat CVS/Tag | sed -e 's/.//'`
if [ -f $CVSROOT/CVSROOT/Freeze/$CVSTAG ]; then
echo "Sorry. Code freeze for the branch
$CVSTAG."
return 2
fi
elif [ -f $CVSROOT/CVSROOT/Freeze/HEAD ]; then
echo "Sorry. Code freeze for the main trunk."
return 3
fi
fi
command cvs "$@"
}


Time Stamp for Tags or Branches

The "cvs log" command displays the tag and branch names with the revision of the file without date information.

To have a clear history for tags, create a tag history file in $CVSROOT/CVSROOT/logs/tags.history. Put following lines in the release script to append the tag to the history with the date information. To create new branch, a similar script can be created.

HISTORY=$CVSROOT/CVSROOT/logs/tags.history
cvs tag $1 source database document tools buildlogs
echo "Tagged $1 source, database, document, tools, and \
buildlogs at `date`" | tee -a $HISTORY

Thursday, April 23, 2009

Powerful Unix find command

List the files contain the word Unix in the current tree:

find . -type f -exec grep -l Unix {} \;

Set permission to 644 for all files in the current tree:

find . -type f -exec chmod 644 {} \;

The number of files in the current tree:

find . -type f -exec ls -l {} \; | wc -l

All the text type files in the current tree:

find . -type f -exec file {} \; | grep text

Wednesday, April 22, 2009

Power Schemes problem in Windows XP

If the Power Schemes of Power Options Properties in Windows XP is set to Portable/Laptop, The system will be switched to standby state say after 20 minutes. However, this is a problem for the systems that provide the services to others, one of the example is the build system. The scheduled build tasks won't be able to start to perform the builds. Once a system could not start up scheduled tasks and stay in standby state, make sure the power schemes is not set to Portable/Laptop.

Thursday, April 16, 2009

Extract files from DAA/UIF disc image file with PowerISO

After download a CD/DVD image file in DAA or UIF format instead of the popular ISO, it's a headache to find a converter to open such image file, or retrieve some files from the image. I have tried daa2iso, MagicISO, and Active@ISO Burner but found various problems.

PowerISO can convert CD/DVD image file formats from BIN, NRG, CDI, DAA, and UIF, etc. to ISO format, extract files from the image to the hard disk, and make image file in ISO, BIN, or DAA formats.

To find out more PowerISO's features, please check http://www.poweriso.com.

Wednesday, March 25, 2009

Use Expect script with Database and others

Expect is the tool for automated interactive programming, and it is available for Unix/Linux, Mac, and Windows.

If you are running a command line program and want to insert, modify, or retrieve data in and out with the database, expect is the choice.

It's simple and easy to learn and use. The basic commands are expect and send. Following is a piece of code to access MySQL database with Expect script.

set passwrd something
spawn mysql -u uid -p
expect "password:"
send "$passwrd\r"
expect "mysql>"
send "use CustomerDB\r"
expect "mysql>"
send "show tables;\r"
expect "mysql>"
send "select * from Customers where City = 'New York';\r"
expect "mysql>"
send "quit\r"

However, the expect script also can be used for Oracle but it is not limited to the database application. You can use it in other interactive applications such as ftp, telnet, and software installation, and software testing, etc.

Please check Don Libes' book Exploring Expect from O'Reilly for more details.

Use mkisofs to create data DVD for Unix file system

The popular DVD burning software for Windows like Nero and Easy Media Creator are not safe to burn the Unix file system directly on CD or DVD. If you burned a disc in this way, try to md5 files on disc and the original files. You may realize that some of the MD5 hashes are not identical!

The older version of mkisofs could not create the image file larger than 2GB. However, the current version fix this problem by using a new -UDF option. Following is the syntax to create a data DVD ISO image file for the entire dirname folder:

mkisofs -o file.iso -UDF -f -a -J -r -v -V "Volume ID" dirname

It's safe to burn the image file with mkisofs because all files on disc will be identical to the original files.

For more detailed options, please look at its man page or run "mkisofs -help".

Saturday, March 21, 2009

Unix sort command

The sort command has -u option for unique. Therefore, the command "sort file | uniq" can be simplified as "sort -u file".

To sort in arithmetic order, use -n option, and -r option is used for reverse order.