Saturday, October 21, 2006

Build your own RPM

Many a times while installing packages in linux , we have two options
either a rpm package or a tar file which needs to be uncompressed and
running commands like configure, make , make install.

I had just downloaded a Linux Flash Plugin which was in a tar format.

I followed the below steps to pack it as RPM :
1) cd /usr/src/redhat/SOURCES and copy
your tar(Flash-7.tar.gz) file here,
make sure
while copying the tar file is in Name-Version format.


2) create a flash.spec file on the above path.

3) run rpmbuild -ba and the spec file

Step 1 :
cd /usr/src/redhat/SOURCES and I copied the tar file
as Flash-7.tar.gz

Step 2: Flash.spec file

Summary: GNU Srirams Flash
Name: Flash
Version: 7
Release: 1
Source0: %{name}-%{version}.tar.gz
License: GPL
Group: Multimedia
%description
Allows you to run Flash based programs in Linux
%prep
%setup -q
%build
./flashplayer-installer
%install
%files
%defattr(-,root,root)

Step 3 : Building the RPM
[root@sriram SOURCES]# rpmbuild -ba flash.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.31439
+ umask 022
+ cd /usr/src/redhat/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /usr/src/redhat/BUILD
+ rm -rf Flash-7
+ tar -xf /usr/src/redhat/SOURCES/Flash-7.tar.gz
+ cd Flash-7
++ /usr/bin/id -u
+ '[' 0 = 0 ']'
+ /bin/chown -Rhf root .
++ /usr/bin/id -u
+ '[' 0 = 0 ']'
+ /bin/chgrp -Rhf root .
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.31439
+ umask 022
+ cd /usr/src/redhat/BUILD
+ cd Flash-7
+ LANG=C
+ export LANG
+ unset DISPLAY
+ ./flashplayer-installer

Copyright(C) 2002-2003 Macromedia, Inc. All rights reserved.

Macromedia Flash Player 7 for Linux

This will run the flashplayer-installer

The Macromedia Flash Player installation is complete.

+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.17690
+ umask 022
+ cd /usr/src/redhat/BUILD
+ cd Flash-7
+ LANG=C
+ export LANG
+ unset DISPLAY
+ /usr/lib/rpm/find-debuginfo.sh /usr/src/redhat/BUILD/Flash-7
0 blocks
find: /usr/lib/debug: No such file or directory
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-python-bytecompile
Processing files: Flash-7-1
Processing files: Flash-debuginfo-7-1
Checking for unpackaged file(s): /usr/lib/rpm/check-files %{buildroot}
Wrote: /usr/src/redhat/SRPMS/Flash-7-1.src.rpm
Wrote: /usr/src/redhat/RPMS/i386/Flash-7-1.i386.rpm
Wrote: /usr/src/redhat/RPMS/i386/Flash-debuginfo-7-1.i386.rpm

[root@sriram SOURCES]# rpm -ivh Flash-7-1.i386.rpm
Preparing... ############################## [100%]
1:Flash ############################## [100%]
[root@sriram SOURCES]# rpm -qa |grep Flash
Flash-7-1

Monday, October 16, 2006

Subversion Quick Reference

Subversion Quick reference


Check out code from a remote web repository


svn checkout http://svn.collab.net/repos/svn/trunk subversion

OR
svn co http://svn.collab.net/repos/svn/trunk subversion

This command will check out a working copy of the subversion
source code into a new subdirectory called subversion.
Note, this is just an example, checking out the subversion source
could take a while, so don’t do it. You would generally substitute
the URL with the one you are trying to access, and change the
working directory to something different.

svn checkout –username myuser –password ……

On the majority of the commands you can set the –username
parameter and the –pasword to help automate things,
instead of being prompted for them. Once you create a
local working copy, your client should really cache that
information, however.

Basic Subversion Commands

svn update
Run this in your project directory to get the latest
changes from the source control server.

svn update -r 123
Run this in your project directory to update to the specific revision 123

svn stat
OR
svn st

Run this in your project directory, gives you the status of all the
files and directories. If it returns nothing, then you are in sync.
M before a file means modified, and ? means the file is not in source control.

svn revert

This will show the differences between filename.cpp and the
working copy. This is most useful after running an svn stat
and seeing that the file is modified. You can then run this command
to see what the differences are.

svn revert filename.cpp

This will revert all changes you have made to filename.cpp
back to the copy in the repository.

svn revert -R *

This will revert all changes you have made to the entire
project back to the repository version.


svn -v list

This will list the files in source control for the current
workspace directory.

svn -v list http://svn.collab.net/repos/svn/trunk

This will list all files in source control at the particular subversion
repository URL. Fairly useful if you want to see what the
structure is before doing a checkout.


svn info

Gives you info about the current working copy,
including the URL of the repository it points to, and the last changed date/author.

svn commit -m “Adding new function” filename.cpp

Commit the changes in filename.cpp, and give it a useful message.
Using the messages is highly important down the road when
you want to figure out what a particular change did. Make sure you use them.

svn commit -m “Adding lots of new functions”

Use this function without the filename to commit all changes to all files.
This is useful when you have a set of changes spanning
multiple files. (common)

svn log
svn log filename.cpp
svn log –limit 5 http://svn.collab.net/repos/svn/trunk

Use this function to take a look at the log messages.
The first one is for the entire working copy,
the last one shows just the last 5 log messages on a web repository.

svn add newfile.cpp

Add a file or directory to version control. Note that you still
have to commit to actually send the file to the source control server.
You also can only use this command from within a working
copy directory, meaning if you haven’t used source control
on that directory you will need to import it first.


svn move filename.cpp newfilename.cpp

Allows you to rename or move files within source control.
You can either use filenames in your local repository,
or you can even pass in two URL locations to have it
be moved/renamed on the server side.

svn copy MySource MyNewSource

Allows you to copy a file or directory, either with local files,
or on the repository using the URL syntax.

svn delete filename.cpp

Deletes the filename from source control.
Note that the filename will still exist in older revisions,
but will be deleted from the current revision

svn blame filename.cpp

This is one of my favorite commands in subversion.
This lists out the file, giving the revision and person
who changed every single line in the file. Very useful

Import Code into Subversion

svn import -m “Importing the files” MySource
http://svn.theserver.net/svnroot/mysource

mports the directory MySource and all files contained
within into the subversion server. The URL can be several levels deep or more.

Note: once you import a source code directory, you should
remove the directory and then checkout the directory so that
you can have a proper working copy. Oh, and back up your
files before you delete them. I don’t want any nasty emails
about how you lost source code.

For Administrators

svnadmin create /svnroot/RepositoryName

Creates a new repository at RepositoryName.
If you are using the URL model for accessing your site,
make sure that the location you create it at is accessible
via your local web server.

svnadmin hotcopy /svnroot/reponame /backups/reponame

Makes a “Hot Copy” of the repository, which means a copy of
the repository that can be instantly reusable. This method seems
to work pretty well for full backups.


svn copy -m “Making a new branch for that new feature”
http://svn.server.com/svnroot/trunk
http://svn.server.com/branches/johnnysbranch

Make a branch copy of the trunk into a seperate branch.
This should only be used by power users or people that
know what they are doing.

svn copy -m “Tagging version 1.0″ http://svn.server.com/svnroot/trunk http://svn.server.com/svnroot/versions/version_1.0

Tag a version of the application. This uses the same copy
command that the branching does, and it’s really the same
underlying operation. Copying in subversion does not actually
make a new copy of the file, it just tags the current version.
Once changes are made, then the changes would be stored
to the file seperately.

Saturday, October 14, 2006

Linux boot script

Some days back I had written a script to stop/start
application as linux boots.

Instead of adding the script manually , you could try this :

On Debian
update-rc.d
is the debian utility to install and remove
System-V style init script links.

#Create the script
Like this

# make it executable
chmod a+x

# copy the script to /etc/init.d and run the below command
update-rc.d script defaults

# To Erase:
update-rc.d -f script remove

http://wiki.linuxquestions.org/wiki/Update-rc.d

On Redhat
chkconfig
on RedHat Linux Systems:
Add this 2 lines at the beginning of script
# chkconfig: 345 85 15
# description: Description of program
This will add to runlevel 3,4 and 5 , Start order priority
will be set to 85 while Stop/Shutdown order will be set to 15

Set execute permission to script ===> chmod +x script name
Copy the script to /etc/rc.d/init.d/

When added to the boot process using the "chkconfig --add script-name"
command the start order/priority will be set to 80 while the stop/shutdown
order will be set to 15. The process will be added to runlevels 3, 4 and 5.
This is enabled by generating links from the location of the script
(/etc/rc.d/init.d/) to the directory for the appropriate run level:
/etc/rc.d/rc#.d/. The file name in the run level directory will reflect if it
is used for boot (starts with an "S") or shutdown (starts with a "K")