Sapere On Line - basic courses, professional and advanced

LINUX

     Is Linux Really FREE?
     Getting Linux
     So What Do I Gain?
     What Do I Lose?
     Getting a Free Copy
     Dual Booting
Preserving Your Data
Windows on Linux
Getting Ready for Your Installation
Hardware Considerations
Dual Booting Revisited
An Installation Comparison
A Mandrake Linux Install
Putting On The Red Hat
An Easy Start
GNU General Public License
Security Revisited
Take Me out to the Arcade
Deal those Cards, Ace
B-4. Miss. E-7. Hit!
Educational Games
3D Accelerated Fun
Rambler's 

Top100

 

Linux

Customize RPMs with rpmrebuild

Building packages is usually hard work, and best left to distro developers who have the time and patience to work the appropriate magic. However, if you're an admin or user with a need to rebuild existing packages, rpmrebuild takes the pain out of creating new RPMs from installed packages.

What's rpmrebuild useful for? A couple of scenarios come to mind. The first is when an RPM isn't available from the original source for some reason -- for example, if you built a custom RPM, or if you got an RPM from a third party and it's no longer available online and you want to be able to use it on other systems.

It's also useful if you want to distribute customized packages. For instance, if you wanted to distribute the OpenSSH daemon with customized configuration files, you could repackage the openssh-server package with rpmrebuild and use it instead of the stock package.

Getting started

The rpmrebuild utility should work on any recent RPM-based distro that has rpmbuild installed. If you don't have rpmbuild, you'll need to get it. I tested rpmrebuild on CentOS 5, so I used yum to grab the rpm-build package:

yum install rpm-build

After that, I grabbed the rpmrebuild RPM from the SourceForge.net download page and installed it with rpm -ivh rpmrebuild-2.1.0-1rpm4.noarch.rpm. Of course, the version number of the RPM may change over time.

We can rebuild it, we have the technology...

Now that the utility is installed, you can start rebuilding packages. The syntax for rpmrebuild is simple: rpmrebuild options packagename , or rpm --rebuild options packagename .

So, if you wanted to rebuild the openssh-server package using some customized files, you'd use:

rpmrebuild openssh-server

You'll want to run it as root, unless all of the files are accessible to non-root users. Once you run the command you'll see something similar to Figure 1:

The utility will ask a few questions -- whether you want to continue and whether you want to change the version number -- then tell you where it put the modified RPM. On CentOS 5, my packages were written to /usr/src/redhat/RPMS/i386/packagename.rpm. You can specify an alternate directory location for the new RPM by passing it with the -d option to rpmrebuild.

It's a little more complex if you want to add new files to a package, but only a little. Add the edit (-e) option, and you'll be given the opportunity to edit the specfile:

rpmrebuild -e packagename

You'll be dropped into the default editor, with the specfile for the package. Look for the section that starts with %files:

%files
%config(noreplace) %attr(0644 root root) "/etc/pam.d/ssh"
%attr(0755 root root) "/etc/rc.d/init.d/sshd"
%dir %attr(0755 root root) "/etc/ssh"
%config(noreplace) %attr(0600 root root) "/etc/ssh/sshd_config"
%attr(0755 root root) "/usr/libexec/openssh/sftp-server"
%attr(0755 root root) "/usr/sbin/sshd"
%doc %attr(0644 root root) "/usr/share/man/man5/sshd_config.5.gz"

Each line has information about the type of file if necessary -- such as %dir for directory, or %doc for man pages. Regular files don't require a directive. Each line also has file permissions and ownership info, and the path of the file to be packaged. See the RPM docs for more on the file directives.

If I wanted to add a README with site-specific information, I might add a line like this:

%doc %attr(0644 root root) "/usr/local/packagename/README.local"

You can use the -e option to make other changes to the specfile; if you want to change package requirements or anything else, this would be the option to use.

If you're after a quick way to rebuild packages, rpmrebuild is the way to go. Be sure to read the manpage for additional options.

 

 

 


ORACLE

Oracle Data Dictionary
Installing Oracle
Introduction to SQL
Extended SQL
Indexes
Constraints
Other Database Structures
Functions
Distributed Queries, Transactions, and Databases
PL/SQL Basics
PL/SQL and SQL
PL/SQL Packages
Introduction to Java Database Programming
Triggers
Regular Expressions and Expression Filter
Object Relational Interactions with Oracle
Oracle XML DB
HTML-DB
High-Speed Data Movement
Data Loading and Management
Business Intelligence Query
Business Intelligence Analysis
Optimization
© 2008 The Company, Inc. All rights reserved. Terms of Use and Disclaimer