Personal tools
     DOCUMENTATION

FAQ:Modify Packaged Software

From rPath Wiki

Jump to: navigation, search
FAQ
Question: How can I create a modified version of an existing Conary software packages?

Contents

Answer: The following sections describe creating local modifications to an existing Conary software package, and maintaining the changes through the entire package life-cycle, including:

  • Initial shadowing of the upstream package
  • Applying the local modifications to the shadow
  • Building and testing the resulting software
  • Committing and deploying the tested version

Shadow and Modify

Lets use the sudo package as an example. To patch the package so users in the wheel group are allowed sudo access by default, follow these steps:

[you@yourhost tmp]$cvc shadow foresight.rpath.org@fl:desktop sudo:source=conary.rpath.com@rpl:1
[you@yourhost tmp]$cvc co sudo
[you@yourhost tmp]$cd sudo
[you@yourhost sudo]$cvc cook --prep sudo.recipe

The last step above makes Conary download the source (in this case, a tarball) and prepare the build directory.

Continuing on:

[you@yourhost sudo]$cd ~/conary/cache/sudo
[you@yourhost sudo]$tar zxvf sudo-1.6.7p5.tar.gz
[you@yourhost sudo]$cp -rp sudo-1.6.7p5 sudo-1.6.7p5.orig

You now have two directories with the same sources. The sudo-1.6.7p5.orig directory will be used as our pristine source, and we will modify the contents of the sudo-1.6.7p5 directory.

Use a text editor to open the sudoers file. This is the file that gets installed in /etc/sudoers:

[you@yourhost sudo]$$EDITOR sudo-1.6.7p5/sudoers 

# Uncomment to allow people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL

Comment in the %wheel ... line and save the file. Then create a patch using diff on the two directories:

[you@yourhost sudo]$diff -Naur sudo-1.6.7p5.orig sudo-1.6.7p5 > wheel.patch

This creates a patch file that can be applied when you build sudo. Copy wheel.patch to your checkout of sudo.

Edit the sudo.recipe and add the following below r.addArchive:

        r.addPatch('wheel.patch')

Build and Test

Save the recipe, and issue the following commands to instruct Conary to add the wheel.patch file to the repository, and cook a local changeset:

[you@yourhost sudo]$cvc add wheel.patch
[you@yourhost sudo]$cvc cook sudo.recipe

This will create sudo-1.6.7p5.ccs file. To test, as the root user, or user with sudo access, execute the following command:

[root@yourhost sudo]#conary update sudo-1.6.7p5.ccs

Commit and Deploy

Examine the /etc/sudoers file to verify that the %wheel ... line is uncommented. If it is, you are now ready to commit your work and cook it into the repository:

[you@yourhost sudo]$cvc commit --message "Patched to allow members of the wheel group to use sudo"
[you@yourhost sudo]$cvc cook sudo

You are done, you have now patched the software, and placed it into the repository for others to use.

Further Directions

To take this one step further, say you want to change a compile time option. Like a configure argument. For example, the sudo package has the '--with-password-timeout=' configure option. Go ahead and set that option to 1 minute. In your sudo.recipe, you will see a line that starts with r.Configure. It looks like this:

 
        r.Configure('--with-logging=syslog --with-logfac=authpriv'
                    ' --with-editor=%(essentialbindir)s/vi'
                    ' --with-env-editor --with-ignore-dot'
                    ' --with-tty-tickets --without-interfaces'
                    ' --without-lecture')

You want to add '--with-password-timeout=1' so it looks like this:

 
        r.Configure('--with-logging=syslog --with-logfac=authpriv'
                    ' --with-editor=%(essentialbindir)s/vi'
                    ' --with-env-editor --with-ignore-dot'
                    ' --with-tty-tickets --without-interfaces'
                    ' --without-lecture --with-password-timeout=1')

You need to commit and cook this change as well:

[you@yourhost sudo]$cvc commit --message "Set password timeout to 1 minute instead of the default 5 minute"
[you@yourhost sudo]$cvc cook sudo

Now your version of sudo will allow users in the wheel group to use sudo and only save the cached password for 1 minute.