Difference between revisions of "Simple Package Modification"

From SME Server
Jump to navigationJump to search
Line 28: Line 28:
  
 
== Retrieve code ==
 
== Retrieve code ==
==== Getting the right module ====
+
==== Getting the source code ====
 
In this How-To we want to work on the package 'e-smith-base'. We first need to download (with CVS this is called retrieving) the code for 'e-smith-base' from the SME Server CVS repository. For this issue the following command:
 
In this How-To we want to work on the package 'e-smith-base'. We first need to download (with CVS this is called retrieving) the code for 'e-smith-base' from the SME Server CVS repository. For this issue the following command:
 
  cvs -z3 -d:pserver:anonymous@smeserver.cvs.sourceforge.net:/cvsroot/smeserver checkout -P e-smith-base
 
  cvs -z3 -d:pserver:anonymous@smeserver.cvs.sourceforge.net:/cvsroot/smeserver checkout -P e-smith-base
Line 35: Line 35:
 
  cd ~/home/smeserver
 
  cd ~/home/smeserver
 
  cvs -z3 -d:pserver:anonymous@smeserver.cvs.sourceforge.net:/cvsroot/smeserver co -P rpms  
 
  cvs -z3 -d:pserver:anonymous@smeserver.cvs.sourceforge.net:/cvsroot/smeserver co -P rpms  
 
WIP Up to here [HF]
 
  
 
You can now retrieve one of the packages from SourceForge. In this case, we want to modify the e-smith-base package for SME8, so let's retrieve it from SourceForge:
 
You can now retrieve one of the packages from SourceForge. In this case, we want to modify the e-smith-base package for SME8, so let's retrieve it from SourceForge:
 +
First change to the work directory:
 +
cd ~/home/smeserver/rpms/e-smith-base/sme8
  
* Change to work directory
+
Then we have to prepare a tree. Issue the following commands:
 
+
cvs  update -dPA
cd ~/home/smeserver/rpms/e-smith-base/sme8
+
make clean         
 
+
make prep
To prepare a tree
 
 
 
cvs  update -dPA
 
 
 
make clean         
 
 
 
make prep
 
  
* Save a copy of the original files
+
We want to save a copy of the original files:
 +
cp -R e-smith-base-5.2.0 e-smith-base-5.2.0.old
  
cp -R e-smith-base-5.2.0 e-smith-base-5.2.0.old
 
  
<Now make the changes needed to the files in e-smith-base-5.2.0>
+
== Make changes ==
 +
==== Edit the source code ====
 +
Now make the changes needed to the files in e-smith-base-5.2.0.
  
* Create a patch
+
We need to have an example!
  
diff -urN smeserver-foo-2.0.0.old smeserver-yum-2.0.0 > smeserver-yum-2.0.0-importKeys.patch
 
  
 +
== Create the RPM ==
 +
==== Create a patch ====
 +
When we have finished our editing the source code (see above example), we can create a patch. (a file that contains the differences between the original file and the file we have been working on). To create the patch issue the following command:
 +
diff -urN smeserver-foo-2.0.0.old smeserver-yum-2.0.0 > smeserver-yum-2.0.0-importKeys.patch
  
* Now to make a build to test if it works:
+
==== Test the patch ====
 +
To see if our changes work correctly as intended, we will make a build of the new package to test.
 +
First we will update the spec file (explain spec file in 1 line)
 +
<pre>#increase the release
 +
%define release 15
  
* Update the spec file
+
Then we apply our patch to the code:
<pre>#increase the release
+
Patch2: smeserver-foo-1.2-widget.patch
%define release 15
 
  
#add the patch
+
Then we need to update the changelog, including the bug number
Patch2: smeserver-foo-1.2-widget.patch
+
* Fri Jan 11 2008 John Smith <smith@foo.net> 1.2-15
 +
- fixed foo to create bar [SME 3470]
  
#update the changelog, include the bug number
+
Then we need to apply the patch in %setup (explain %setup in 1 line)
* Fri Jan 11 2008 John Smith <smith@foo.net> 1.2-15
+
%patch2 -p1
- fixed foo to create bar [SME 3470]
+
</pre>
  
#apply the patch in %setup
+
[Reformatted upto here]
%patch2 -p1
 
</pre>
 
  
 
CHECK: that the changelog version really matches the RPM version.
 
CHECK: that the changelog version really matches the RPM version.

Revision as of 12:16, 23 January 2013

The simplest package modification is for someone to access the code via anonymous CVS and produce a patch to put into Bugzilla. This can be done on SME 8 by installing only cvs as follows.

Setting up your build server

This How-to is primarily based on SME8, and that you have your development SME8 server up and running. This can be a dedicated machine or a virtual machine

Create a new 'builder' user

We will create a new user account that we use for our building purposes. The new user account can be created, as usual, through the server-manager, In this How-To we will have named our new user account 'builder'

Grant shell access

The 'builder' account needs to be able to login and have shell access. For this you will need to grant permissions. Type the following commands from the root account:

chsh -s /bin/bash builder
db accounts setprop builder Shell /bin/bash

After issuing the above commands, the user 'builder' should be able to login on the console. Please login as user 'builder', for the the rest of the instructions assume you are loged in as user 'builder'

Install CVS

SME Server uses CVS for maintaining code and packages. By default, CVS is not installed on SME8 (not required for normal SME Server operation). To install CVS on SME8 issue the following command:

yum install cvs

Create a development directory

The user 'builder needs a dedicated development directory. In this How-To we will use ~/home/smeserver. To create the directory ~/home/smeserver please issue the following command as user 'builder':

mkdir ~/home/smeserver
cd ~/home/smeserver

This is all what is required to setup your server to be able to start working on patches and packages


Retrieve code

Getting the source code

In this How-To we want to work on the package 'e-smith-base'. We first need to download (with CVS this is called retrieving) the code for 'e-smith-base' from the SME Server CVS repository. For this issue the following command:

cvs -z3 -d:pserver:anonymous@smeserver.cvs.sourceforge.net:/cvsroot/smeserver checkout -P e-smith-base

Next to a selective retrieve as per above, you can also retrieve the whole CVS tree.

cd ~/home/smeserver
cvs -z3 -d:pserver:anonymous@smeserver.cvs.sourceforge.net:/cvsroot/smeserver co -P rpms 

You can now retrieve one of the packages from SourceForge. In this case, we want to modify the e-smith-base package for SME8, so let's retrieve it from SourceForge: First change to the work directory:

cd ~/home/smeserver/rpms/e-smith-base/sme8

Then we have to prepare a tree. Issue the following commands:

cvs  update -dPA
make clean        
make prep

We want to save a copy of the original files:

cp -R e-smith-base-5.2.0 e-smith-base-5.2.0.old


Make changes

Edit the source code

Now make the changes needed to the files in e-smith-base-5.2.0.

We need to have an example!


Create the RPM

Create a patch

When we have finished our editing the source code (see above example), we can create a patch. (a file that contains the differences between the original file and the file we have been working on). To create the patch issue the following command:

diff -urN smeserver-foo-2.0.0.old smeserver-yum-2.0.0 > smeserver-yum-2.0.0-importKeys.patch

Test the patch

To see if our changes work correctly as intended, we will make a build of the new package to test. First we will update the spec file (explain spec file in 1 line)

#increase the release
 %define release 15

Then we apply our patch to the code:
 Patch2: smeserver-foo-1.2-widget.patch

Then we need to update the changelog, including the bug number
 * Fri Jan 11 2008 John Smith <smith@foo.net> 1.2-15
 - fixed foo to create bar [SME 3470]

Then we need to apply the patch in %setup (explain %setup in 1 line)
 %patch2 -p1
 

[Reformatted upto here]

CHECK: that the changelog version really matches the RPM version.

CHECK: Is the spec file correct, look at the changes

cvs diff e-smith-base.spec

  Have you updated the release? Is that new release in the changelog?
  Have you included the patch, Patch1: e-smith-proftpd-2.2.0-persistent_passwd.patch
  Is the changelog correct
* Tue Jan 22 2013 Ian Wells <esmith@wellsi.com> 2.2.0-4.sme
- Remove previous change [SME: 7129]
    There must be a bugzilla number in this format [SME: 7129]
    Is the date really correct? Both day and date.
    The version should follow after the email address

CHECK: what would be committed

cvs update

   * M modified, will be committed
   * U file has been updated since you last checked it out
   * A added, will be added on commit
   * D deleted, will be deleted on commit
   * ? egregious file not part of CVS record for this dir

CHECK: has the patch files been added? cvs add e-smith-quota-2.0.0-badlyformattedie8.patch

CHECK: are the files UNIX or do they have DOS endings (bad)

Build the rpm locally to test, (note, this deletes the working tree!)

make local


Once the patch works, attach the patch to the bugzilla entry.


--- this simple package modification ends here ---

      • If you have CVS access then

Once you are satisfied and want to submit the package to the build server commit your changes. (Please use descriptive comments so that other developers are aware of what is happening. Comments will appear on the subject line of the commit email that get send to the other developers.) cvs commit -m 'your descriptive commit message here' cvs commit -m <-- copy this then add changelog line

      • If you have build access then

Build it (from either the sme7 or sme8 dir):

make tag make build