CTS 2322 (Unix/Linux Administration II) Project #4
Building and Installing Software From Source Code

 

Due: by the start of class on the date shown on the syllabus

Description:

In this project you will download and install a source code RPM package.  Next you will download and install a (standard) tar-ball.  You will then build binary packages from both and install them.

The version of the package used (version 4.64) won't install by default on a vanilla Fedora system.  You will have to trouble-shoot the install to make this work!

Requirements:

Answer the following questions and perform the following tasks:

Part I — Installing pine from a source RPM:

  1. Fedora currently doesn't include the pine MUA (email program).  What is the home URL for pine?  (Hint:  pine is maintained by the University of Washington.)
  2. While binary packages exist for pine for Fedora, locate a source RPM from the home website of pine and download it.  What is the version of pine you downloaded?

    Note that pine is a discontinued project.  The replacement for pine is alpine but for this project you must use pine and not alpine!

  3. If you don't have the rpmbuild command on your system, use what you have learned to locate the package for it and install that.  (You may need to install packages if you need to use some command that isn't currently installed on your system.)  Once installed you need to create a build environment in your home directory (your non-root login).  You do this by running the command rpmdev-setuptreeWhat files and directories were created in your home directory?
  4. Install the source package (as you, not as root) using the rpm -U command.  This will create a source tar-ball and a spec file under ~/rpmbuild/).  What is the exact command you used for this?  What files were installed?  (List the complete pathnames.)
  5. Next attempt to build a binary RPM from the installed source using the command rpmbuild -bb spec-file.  For the current version of the pine source RPM (version 4.64) this won't work on Fedora!  Now troubleshoot the problems and fix them:
    1. What error message is produced?  The error message includes the line number from the spec file that rpmbuild didn't like.  Before making any changes to the spec file, make a copy of it.
    2. Try to fix this problem by editing the spec file and commenting out the offending line.  Do this by pre-pending (adding to the front of the line) the # character, which is the start of comment character.
    3. Now try the rpmbuild command again.  What is the error this time?
    4. Run the rpmlint command on the spec file and note the error(s) it shows.  You can figure out what is wrong only by knowing the spec file syntax.  This can be found at www.rpm.org.  However in the interest of saving you some time I will provide these hints:  Older versions of RPM required a Copyright: line in the spec file, but modern versions have replaced that with a License: line.  In addition, the list of RPM package groups has changed.  You can find the current list of groups in the file /usr/share/doc/rpm-*/GROUPS.
    5. Edit the spec file and eliminate all the errors shown with rpmlint.  (It is okay to ignore warnings.)  What change(s) did you make to the spec file?  (Show the output of diff with the original and modified versions.)
    6. Try building the pine binary RPM.  You may discover missing development tools and libraries.  These can be solved one at a time, or you could use the groupinstall feature of yum, to install all the tools and development libraries at once.  What (if anything) did you need to install?
    7. You may find a warning about how OpenSSL can't be found.  You can continue the build anyway without SSL, or (if time permits) attempt to modify the spec file to eliminate the error.  (See the hints section below.)  If the build is successful, the result is a binary RPM.
    8. If the build fails, examine the output in reverse order, to see the error that caused the failure.  What was the error?  On my Fedora 14 system, the error was an undefined symbol.  Furthermore, the error included a helpful message about which library does include the missing stuff.  To include that library during the build, you should export the environment variable LDFLAGS, set to the name of the missing library.  For example, if the missing library is /usr/lib/libfoo-3.5.so.1, then set and export LDFLAGS='-lfoo'.  Once you set this correctly, you should be able to successfully build the binary pine RPMWhat was the environment variable setting required to successfully build the pine RPM?
  6. As root, install the binary RPM you built for pineWhat is the exact command(s) used?  Check to see if the install worked, by running pine, pico, and viewing the man pages.
  7. By default pine and Alpine use MBOX format.  However there is an available patch to pine and for alpine to enable support Maildir format as well.  Locate this patch on the Internet, download, and apply it to either the pine source or the alpine source (your choice), and then rebuild.  Where did you locate the patch?  What commands did you use to apply the patch?

Part II — Building from source:

  1. Download the tar-ball hello-1.0.tgz from this website.  (This is a simplified version of Gnu hello.)  Now unpack, compile, and install this tar-ball:
    1. What is the MD5 checksum for this tar-ball?  Does it agree with the one posted at Gnu Project Demo?
    2. Unpack the tar-ball using tarWhat is the exact command you used?
    3. Change your current working directory to hello-1.0 and read the various installation documentation provided.  What files did you (or should you) look at before installing?
    4. Compile and install the software.  (Hint:  As this is a standard Gnu package you use the standard steps to configure, compile, and install the software.) Which one of these commands is the only one that should be run as root?  What are the exact commands you used?
  2. Check your installation by running the command hello and reading the hello(1) man page.  What files were installed (and where)?  What would you have needed to do to have the files install under /opt/ instead?
  3. Now clean up the build files.  One way is to simply delete the entire build directory.  However the makefile generated usually has targets to clean up the files while leaving the configuration files.  What make command can you use to delete the build files but not the configuration files?
  4. Change to your home directory, and delete the entire build directory (hello-1.0/).  As root, delete all other files installed.  When you install from source, there is no record (except in your system journal) of what files were installed.  If you didn't have an accurate system journal, what could you do to determine what files were installed by some source (tar-ball) installation?

Part III — Building a binary RPM from a tar-ball:

  1. Next build a binary RPM package from this tar-ball.  If you are lucky, a tar-ball will include the spec file required.  Sadly for you this is not the case here, so you will need to create a spec file.
  2. Set up the rpm build system.  You should have done this previously in part I of this assignment.  You should also edit (or create if missing) the file ~/.rpmmacros to contain information that is needed by the rpmbuild tool.  Here is a copy of the one I use:
    %_topdir      /home/wpollock/rpmbuild
    %packager       Wayne Pollock <pollock@acm.org>
    %__arch_install_post   /usr/lib/rpm/check-rpaths   /usr/lib/rpm/check-buildroot
    %_smp_mflags  -j3
    %_signature     gpg
    %_gpg_name      779190A0

    (Only the first three lines are needed, the last three are some optional settings I use to speed the compiles and to sign the resulting packages using my GPG key.)  Be sure to edit this file, changing the information to your own name and home directory.  You should delete the last two lines unless you have a published GPG key others can use to verify your package.  What are the contents of your .rpmmacros file?

  3. Copy the tar-ball to ~/rpmbuild/SOURCES/hello-1.0.tgz.
  4. Next cd into the ~/rpmbuild/SPECS directory and create a spec file here, named hello-1.0.spec.  This is the hard part!  You could create a template spec file with the command rpmdev-newspec.  An interesting feature of vim is that when you create a file of name-version.spec it will create a template you can easily edit.  Try this now and look through the result.
  5. While a cruel instructor would make you read the tutorial and create your own spec file, you can just use this one:
    Name:      hello
    Version:   1.0
    Release:   1%{?dist}
    Summary:   Gnu hello
    Group:     Applications/System
    License:   GPL
    URL:       http://www.gnu.org/software/hello/
    Source:    hello-1.0.tgz
    Prefix:    /usr/local
    BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
    
    %description
    Gnu hello is a sample project showing the Gnu build tool-chain.
    
    %prep
    %setup -q
    
    %build
    %configure
    make %{?_smp_mflags}
    
    %install
    rm -rf $RPM_BUILD_ROOT
    make install DESTDIR=$RPM_BUILD_ROOT
    
    %clean
    rm -rf $RPM_BUILD_ROOT
    
    %files
    %defattr(-,root,root)
    %doc %{_mandir}/man1/hello.1.gz
    %{_bindir}/hello

    The parts that need to be filled in are: Name, Version, Summary, URL (which is optional), and Source.  Then you need to add a description (can be multiple lines) after the %description line.  The last part you would need to edit is the list of files to be installed by this package (the lines following the %defattr(-,root,root) line).  These are the ones created when you did the make install step previously.  Note how documentation is marked with %doc tag.  What is the tag you would use to mark configuration files?  (You will probably need to do a bit of searching in the tutorials to find this.)

  6. Now build a binary RPM package using the rpmbuild command.  What is the exact command you used? If this failed to work, you can use the rpmlint command on your spec file to see what might be the problem.  (You may need to install an additional package for this tool.)
  7. Locate the resulting RPM package.  Where did the system put the resulting RPM?  What is the exact name of the created package?  You should be able to query your package.  Use the rpm command to list the package information, and the list of files provided by this package.  (Note you will need to add the -p option in addition to the normal query options, to specify an un-installed .rpm file to query.)  What (two) commands did you use?
  8. As root, attempt to install this package using the command rpm -Uvh.  If you have SE Linux set to enforcing this may not work.  Troubleshoot the problem.  What change(s) did you make, if any?
  9. Update your system journal showing all changes made to your system.

Hints:

Trouble-shooting Compiles

To Be Turned In:

Answers to the above questions and the relevant system journal entries.  You can send as email to (preferred).  If email is a problem for some reason, you may turn in a hard-copy.  In this case the pages should be readable, dated, and stapled together.  Your name should appear on the first page. 

Please see your syllabus for more information about submitting projects.