e-mail   
 Menu
  Home
  Download
  Top 10 Downloads
  Last 15 New Files
  Web Links
  Tips
  Last 15 New Tips
  NLM Programming
  Admins Club





Installation and Administration






Polish Forum SUSE




Novell Connection Magazine


 
Who's Online

 There are currently,
5 guest(s)
that is (are) online.
 


Technical Information

Back to List of Categories

Technical Information about
  A Little YaST Magic
  A Slideshow for Your KDE Wallpaper
  Add Novell Support to Your Firefox Search Engine
  Adding To The Panels In Gnome.
  Akregator - RSS News Reader
  An Introduction to WBEM and OpenWBEM in SUSE LINUX
  Authenticating SUSE LINUX to eDirectory via LDAP
  Basic Mounting Differences between Windows and Linux
  Beginner's Guide to Using Novell SUSE LINUX's Build Utility
  Browsing Files
  Card Readers on SUSE LINUX 9.2 Professional?
  Changing the Default Browser in Gnome
  Developing Perl CGI scripts on SUSE LINUX
  Do I Have Permission?
  Double SYNC -- Using RSYNC Simultaneously With and Without Branch Office for Data Backup
  Dumb Question: Mounting Linux CDs
  Easy Command-Line Introduction
  Easy Way to Debug SSL Connections
  Enabling an Interactive Startup in Novell/SUSE LINUX
  Exploring MySQL 4.1 and PHP 5 on SUSE LINUX
  Extend Your Panels Using Gnome Drawers.
  Firefox Speed Tip
  Fix Java Errors With ConsoleOne On Linux
  Fix Your Mouse Wheel...
  Gimp -- Closing In on Photoshop...
  Gimp Tips Part 1: Resizing Images
  Gimp Tips Part 2: Rounding Corners
  Gimp Tips Part 3: Fading Photography Edges
  Gimp Tips Part 4: Selective Colorization
  Gimp Tips Part 5: Plugins a Plenty - Adding Light
  Gimp Tips Part 6: Using The Clone Tool
  Google Auto-fill Replica for Linux
  How a Corrupted USB Drive Was Saved by GNU/Linux
  How to Implement Login Scripts into a Pure Linux Environment
  How to install and connect an External Modem on a Linux PC
  How to Install the Novell Client for Linux on SUSE Linux 10.0
  How to launch applications at login in Gnome
  How to Remote Control Linux
  How to setup a Linux application to automatically startup when you login.
  How to share Files and Printers Between Linux and MS Windows with Samba
  How to uninstall the Novell Client for Linux
  How to upgrade the Novell Client for Linux
  How to use SMB without turning off the firewall
  How's the Weather?
  HTML Development Tools in Linux
  Informative Bash Prompt
  Install and Use QEMU on SUSE 9.2
  Install Linux Frequently, Without the Hassle
  Installing Apache, PHP, and MySQL on SUSE LINUX Professional
  Installing RPM Files
  Integrating Novell Linux Desktop into a Novell NetWare network
  Introduction to Oracle 10g R1 (10.1.0.3) on SUSE LINUX Professional 9.3
  iPrint Printers on Novell Linux Desktop
  Linux Scheduling Priorities Explained
  Make a Misbehaving Program Quit
  Manually Mounting a USB Flash Drive in Linux
  Migrating To Linux, Advantages Over Windows 9.x And XP
  Minimize Your Maximizing with Multiple Desktops
  Mounting NetWare Volumes On NLD Illustrated
  Move Your /home to Another Computer
  Mozilla Mail Review
  Need a Backup?
  Novell Client Settings with Windows Terminal Server
  Novell Linux Desktop Equivalents of Windows Software - New and Improved
  Novell Linux Desktop System Upgrade How-To
  Partitioning Hard Drive for Linux Install
  Perform Remote SuSE Installations With Virtual Network Computing
  Quick Intro to Klipper
  Quick Shortcuts in The Gimp
  Reset Your Lost Root Password
  Resizing Your Gnome / KDE Panels
  Runlevels in SUSE LINUX
  Running Existing Win32 Applications on SUSE LINUX
  Service Command in /etc/init.d/
  Setting Shortcut Keys
  Setting up a Linux NFS Install Source for Your LAN
  Should I choose Novell Linux Desktop or SUSE LINUX Professional as my desktop?
  Starting Services From the Command Line On SuSE LINUX
  Sticky Notes for Gnome
  SUSE LINUX 9.3 Professional Review
  Sync Up The Taskbar and the Desktop in Gnome
  System Upgrade How-To
  Taking Screenshots in Linux
  The Basics of Messaging in the Cross-Platform GroupWise Client
  The Novell Client for Linux (beta).
  Transparent Panels in Gnome
  Trick Out Your KDE Desktop
  Understanding the YAST Software Module Options
  Updating Your Software with Red Carpet
  Using dsbk on Linux and Unix
  Using iFolder to Synchronize Firefox Bookmarks
  Using Multiple Swap Partitions In 2.4
  Using openSSH to Securely Access Remote Systems
  What FTP client should I use on Linux?
  What Is Logical Volume Management?
  What is so great about Firefox?
  Which Graphic Formats For What?
  Windows Shortcuts for Firefox Tabs on Linux
  Windows to Linux: A Beginner's Guide
  Windows Users Can Feel at Home Exploring Files in Linux
  WLAN interface as the Default
  Work With User Selection Icons In KDM
  YAST Online Update De-Mystified

Technical Information
 Beginner's Guide to Using Novell SUSE LINUX's Build Utility

Printer-friendly version

Posted: 23 Mar 2005

Introduction

"The RPM Package Manager (RPM) is a powerful command line driven package management system capable of installing, uninstalling, verifying, querying, and updating computer software packages."1

RPM is now considered the 'standard' for application and system packaging by most Linux distributions. Novell SUSE LINUX is one of those distributions that has standardized on RPM.

The design goals for RPM are to:

  1. make it easy to get packages on and off the system
  2. make it easy to verify that a package was installed correctly
  3. make it easy for the package builder
  4. make the build process start with the original source code
  5. make it work on different computer architectures

There are many "How-to's" and tutorials describing how to create RPMs (see Resources). However, creating RPMs in a clean build environment and in a consistent reproducible way, requires more effort than should be necessary.

Novell SUSE LINUX provides a utility called build that streamlines the RPM creation process and ensures configuration and system uniformity. It does this in an isolated chroot environment containing only the required packages necessary to create your RPM.

This tutorial describes how to use the build utility to easily create RPMs for Novell SUSE LINUX.

Where to Begin

To use build you must first install build.rpm. The build.rpm package is available via YaST or from Novell SUSE LINUX's download site (see Resources for download information).

The build.rpm package includes the following files:

/usr/bin/build
/usr/bin/unrpm
/usr/lib/build/init_buildsystem
/usr/lib/build/pac_unpack
/usr/share/doc/packages/build
/usr/share/doc/packages/build/README
/usr/share/man/man1/build.1.gz

In addition to the “/usr/bin/build” utility, build.rpm contains a useful RPM-related command called “/usr/bin/unrpm.” The unrpm command is a simple script to “expand” the contents of an RPM in the current directory (using rpm2cpio etc.).

Once you have installed build.rpm you will need either to mount a Novell SUSE LINUX DVD (or DVD ISO image) or create a directory containing the contents of the DVD. If you only have CDs, then copy all of the contents of the CDs into a directory.

Creating a local directory containing the contents of the DVD is highly recommended since it is far easier to update RPMs in a local directory than it is on a DVD:)

To create such a directory, copy everything under the DVD's top level directory using the following command:

cp -a /media/dvd/* <desired-directory>

The RPMs are used to create a reproducible build environment. The DVD or the directory containing the RPMs must also include any additional RPMs needed to satisfy your packages' build requirements that are not part of a standard Novell SUSE LINUX release.

By default, the RPMs are assumed to be located on a DVD that is mounted in the following directory:

/media/dvd

To override this default location, you need to set an environment variable named BUILD_RPMS to point to the directory containing the RPMs. Another way to specify where the RPMs are located is by using the --rpms option when invoking the build command.

build –rpms /work/9.2

How to Use the build Utility

To use build you must be root (root is required to use the chroot command). The chroot environment, by default, is created in the following location:

/var/tmp/build-root

The build utility takes as an argument an RPM spec file or a source RPM file (if no argument is specified, build assumes that the current directory contains a spec file and a source tar ball). If an RPM spec file is specified, a tar ball containing the source files is expected to be in the current directory. For those new to RPMs and RPM spec files, please look at the references at the end of this tutorial.

The key to creating an RPM spec file that build can use is to add one extra tag to the spec file. The special tag is BuildRequires, which lists all of the RPMs that are required to be installed in order for the source package to compile.

The build command initializes the build environment by installing all of the required packages necessary to compile the given RPM package. build then copies all of the source files, patch files and the rpm spec file into the chroot build area. The new build area becomes the "new" root in which build will operate.

The successful result of executing build is a binary RPM (a repackage source rpm is also generated) created in:

/var/tmp/build-root/usr/src/packages/RPMS

Enabling your application to be built using build ensures a reproducible build environment that doesn't get corrupted by the host's environment and vice-a-versa.

To test your newly created RPM, simply chroot into the build environment and install your RPM package using the standard rpm command.

Example Using build

A simple way to see how to use the build utility is to use build to create the GNU hello world RPM binary package.

  1. Get the appropriate hello--.src.rpm (for the purposes of this example I will use hello-2.1.1-311.src.rpm) by downloading it from the source directory for the Novell SUSE LINUX version (e.g. 9.1, 9.2, SLES9, NLD9) you are using for RPMs referenced by build.rpm.

  2. Create a directory called hello and change into it:
    mkdir hello cd hello
  3. Use the unrpm command to look at the contents of the source RPM:
    unrpm hello-2.1.1-311.src.rpm
  4. The directory will now contain the following files:
    hello-1.3.dif hello-2.1.1-311.src.rpm hello-2.1.1.tar.gz hello.spec
  5. If you look in the hello.spec file you will see the BuildRequires tag that build.rpm uses to install all specified RPMs into a build environment:

    ... BuildRequires: aaa_base acl attr bash bind-utils bison bzip2 coreutils cpio cppcracklib cvs cyrus-sasl db devs diffutils e2fsprogs file filesystem fillup findutils flex gawk gdbm-devel glibc glibc-devel glibc-locale gpm grep groff gzip info insserv less libacl libattr libgcc libnscd libselinux libstdc++ libxcrypt libzio m4 make man mktemp module-init-tools ncurses ncurses-devel net-tools netcfg openldap2-client openssl pam pam-modules patch permissions popt procinfo procps psmisc pwdutils rcs readline sed strace syslogd sysvinit tar tcpd texinfo timezone unzip util-linux vim zlib zlib-devel autoconf automake binutils gcc gdbm gettext libtool perl rpm ...

  6. Now switch user to root (su command)

  7. Issue the following command:
    build –rpms /work/dvd/9.2
  8. The build command will create, by default, an isolated build environment in
    /var/tmp/build-root
  9. If all goes well you will see the following message after build has completed:
    Wrote:
    /usr/src/packages/SRPMS/hello-2.1.1-311.src.rpm
    Wrote: /usr/src/packages/RPMS/i586/hello-2.1.1-311.i586.rpm
    Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.2137
    + umask 022
    + cd /usr/src/packages/BUILD
    + cd hello-2.1.1
    + '[' /var/tmp/hello-2.1.1-build '!=' / ']'
    + '[' -d /var/tmp/hello-2.1.1-build ']'
    + rm -rf /var/tmp/hello-2.1.1-build
    + exit 0
  10. The created binary and source RPMs are found in:
    /var/tmp/build-root/usr/src/packages/RPMS/i586/hello-2.1.1-311.i586.rpm
    /var/tmp/build-root/usr/src/packages/SRPMS/hello-2.1.1-311/src/rpm
  11. If you want to check the installation of your binary RPM you can chroot into the build area and use the rpm command:
chroot /var/tmp/build-root
rpm -ivh /usr/src/packages/RPMS/i586/hello-2.1.1-311.i586.rpm

The RPM should install without any issues.

Conclusion

This tutorial has given a brief overview of Novell SUSE LINUX's build utility. Please consult the build man page for addition information and a description of other beneficial command line options.

Using build.rpm is an easy and reproducible way to create binary and source RPMs for Novell SUSE LINUX in an isolated build environment. As a side benefit, the isolated environment can also be used to test the installation of your RPMs.

The build.rpm utility can also be used to create RPMs for multiple versions of Novell SUSE LINUX on a single system. How to do this is the topic of another tutorial on build.rpm.






Portal posiada akceptację firmy Novell Polska
Wszystkie materiały dotyczące produktów firmy Novell umieszczono za zgodą Novell Polska
Portal has been accepted by the Novell Polska
All materials concerning products of Novell firm are placed with Novell Polska consent.
NetWare is a registered trademark of Novell Inc. in the United States and other countries.
Windows is a trademark or a registered trademark of Microsoft Corporation in the United States and other countries.
Sybase is a registered trademark of Sybase Inc. in the United States of America.
Other company and product names are trademarks or registered trademarks of their respective owners.