Difference between revisions of "Package Management"

From GlueXWiki
Jump to: navigation, search
 
Line 30: Line 30:
 
## Copy the new RPM file from where it was built to somewhere more convienient. For my system, it was left in ''/usr/src/redhat/RPMS/i386''.
 
## Copy the new RPM file from where it was built to somewhere more convienient. For my system, it was left in ''/usr/src/redhat/RPMS/i386''.
 
## Check that the install paths are correct using ''rpm -qlp file.rpm'' where you give it the name of your new RPM file.
 
## Check that the install paths are correct using ''rpm -qlp file.rpm'' where you give it the name of your new RPM file.
 +
 +
 +
==Creating a '''yum''' repository==
 +
 +
'''yum''' is a package management system built on top of RPM. It is used by several Linux distributions, most notably Fedora. Creating a yum repository is pretty easy. Since I have done this already, you probably don't need to. You just need to get the RPMs in the right place and re-run the "createrepo" program to rebuild the database. I document how I set up the repository here anyway.
 +
 +
# Prerequisites:
 +
#* Install the ''createrepo'' package (if not already). I did this using
 +
#*: ''yum install createrepo''
 +
#:
 +
# Create a directory to hold the yum repository. I did this in /group/12gev_phys/www/yum on the JLab CUE. This is because I wanted the repository to be accessible via http. Note that in order for this to work, directory listing must be enabled. I did this by creating a .htaccess file in the /group/12gev_phys/www directory that contained the following:
 +
#: Options +Indexes
 +
#: LayoutHeaderOff
 +
#:
 +
# Put all of your RPMs in the yum repository directory. I believe they can be placed inside subdirectories if you desire. The directory tree will be traversed when the repository database is created.
 +
# Run the ''createrepo'' program giving the name of the directory holding the yum repository. This will generate a few files and place them in a directory called "repodata" at the top of your repository.
 +
#:
 +
# Create a configuration file with the location of you repository. Here's the one I set up called ''jlab-phys.repo":
 +
#:
 +
#: [jlab-phys]
 +
#: name=JLab - Physics
 +
#: baseurl=http://www.jlab.org/12gev_phys/yum/linux
 +
#: enabled=1
 +
#: gpgcheck=0
 +
#:
 +
# Now you have a choice, you can just post this file with instructions to install it into /etc/yum/yum.repos.d or you can put it in an RPM that installs it there automatically. I did the latter and created a file jlab-phys-0.0-0.i386.rpm.
 +
#:
 +
 +
Now you should be all set. You can use your favorite yum client to look at the repository (once you've installed the configuration file in /etc/yum/yum.repos.d). I've use ''kyum'' which provides a nice graphical interface that allows me to check that my repository is being recognized by yum as well as temporarily disable other repositories while testing.

Revision as of 12:15, 6 June 2007

HOWTO install and/or create Hall-D software packages

Creating an RPM

Here are instructions on how I created an RPM. There are other ways, but this one seemed to work easily enough so I'm documenting it here for myself and others. This was done on a Fedora Core 6 system running on a virtual machine on my MacBook Pro using Parallels.

  1. Prerequisites:
    • You must have root access on the machine you are building the RPM on. This is because the rpmbuild tools like to write things into /usr/src which usually only root has access to. I believe there are ways around this, but I have not explored them as of yet.
    • The rpm tools must be installed on your system. I believe this is done by default on FC6 if you install the developer tools. Otherwise, you can get them with
      yum install rpm-build
    • Install the "RPM Package Maker"" program. This provides a nice graphical interface to creating the RPM and it's what the instructions below refer to.
  2. Preparing the files for the package:
    1. Create a directory to hold the files you wish to be included in the RPM. The directory name should be the base name and version number of the RPM package. e.g. "xerces-c-2.7.0". This can be anywhere you want and does not need to be owned by root.
    2. Copy the files into this directory. Subdirectories should be created as necessary to include the full path of the final destination directory where the file(s) should be installed. For example, to get the include and lib directories to install into /usr/local, I created a usr/local directory inside my xerces-c-2.7.0 directory.
    3. Create any README, INSTALL, Changelog, or TODO files that you want to include in your package. Put them in the topmost directory and they will be found automatically.
  3. Run the /opt/kde/bin/rpmpm program as root.
    1. Click the "Dir..." button and select the directory that holds your files.
    2. Click the "New Spec File" button on the top left. (If you already tried creating an RPM, a spec file may already exist. In this case select it from the list on the left hand side and click the "Edit" button. If you want to get rid of the old spec file and start fresh, delete it from /usr/src/packages/SPECS/mini).
    3. Fill in the fields. Note that:
      • The "Release" field should contain the target platform for the RPM. For example, for Fedora Core 6, I put "fc6".
      • The "Distribution" field should contain something about the home repository where this RPM will be kept. I put "JLab".
      • The summary field is required to be filled out as well.
    4. In the main window, deselect the "Autodetect" checkbox and select the "RPM" radiobutton.
    5. Click "Start". The output window should appear and after several seconds it should complete with numerous informational messages.
    6. Copy the new RPM file from where it was built to somewhere more convienient. For my system, it was left in /usr/src/redhat/RPMS/i386.
    7. Check that the install paths are correct using rpm -qlp file.rpm where you give it the name of your new RPM file.


Creating a yum repository

yum is a package management system built on top of RPM. It is used by several Linux distributions, most notably Fedora. Creating a yum repository is pretty easy. Since I have done this already, you probably don't need to. You just need to get the RPMs in the right place and re-run the "createrepo" program to rebuild the database. I document how I set up the repository here anyway.

  1. Prerequisites:
    • Install the createrepo package (if not already). I did this using
      yum install createrepo
  2. Create a directory to hold the yum repository. I did this in /group/12gev_phys/www/yum on the JLab CUE. This is because I wanted the repository to be accessible via http. Note that in order for this to work, directory listing must be enabled. I did this by creating a .htaccess file in the /group/12gev_phys/www directory that contained the following:
    Options +Indexes
    LayoutHeaderOff
  3. Put all of your RPMs in the yum repository directory. I believe they can be placed inside subdirectories if you desire. The directory tree will be traversed when the repository database is created.
  4. Run the createrepo program giving the name of the directory holding the yum repository. This will generate a few files and place them in a directory called "repodata" at the top of your repository.
  5. Create a configuration file with the location of you repository. Here's the one I set up called jlab-phys.repo":
    [jlab-phys]
    name=JLab - Physics
    baseurl=http://www.jlab.org/12gev_phys/yum/linux
    enabled=1
    gpgcheck=0
  6. Now you have a choice, you can just post this file with instructions to install it into /etc/yum/yum.repos.d or you can put it in an RPM that installs it there automatically. I did the latter and created a file jlab-phys-0.0-0.i386.rpm.

Now you should be all set. You can use your favorite yum client to look at the repository (once you've installed the configuration file in /etc/yum/yum.repos.d). I've use kyum which provides a nice graphical interface that allows me to check that my repository is being recognized by yum as well as temporarily disable other repositories while testing.