Difference between revisions of "Simple Package Modification"

From SME Server
Jump to navigationJump to search
(to be merged)
(Update CVS server details)
 
(70 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 +
{{Level|Developer}}
 +
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.
  
we can merge this page into the [[SME_Server:Documentation:Developers_Manual:Chapter14|devguide]] now, have two sections
+
== Setting up your build server ==
a. mezannine
+
This How-to is based on SME8, and that you have your development SME8 server fully updated and up and running. This can be a dedicated machine or a virtual machine.  
b. cvs
 
  
== My 2ct's on the new build architecture ==
+
==== 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 as root user.
 +
yum install cvs
  
# Is it normal behavior for 'make clean' to not remove the noarch folder and RPMS in there as it does remove the SRPM?
+
==== Create a new 'builder' user ====
# Is it normal for make to create a SRPM in the root of the branch (package-name/contribs7/) and the noarch RPM in a noarch folder? Shouldn't it be desired to build the SPRM in a seperate folder as well?
+
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'
  
Normally you shouldn't need to worry about the rpms produced. The build system needs packages in a specific place so it knows where to look for them. The single srpm is used to build multiple arch packages so it makes sense for it to be at the root.  All the packages that are created for each arch end up under that arch directory.  For a single noarch it doesn't look very clean but when you are build against 2-5 different archs and each arch produces 3-10 packages it makes it very nice to be organized in this fashion.  <small>— [[User:Slords|Slords]] ([[User talk:Slords|talk]] • [[Special:Contributions/Slords|contribs]]).</small> 10:05, 25 December 2007 (MST)
+
  useradd builder
 +
  passwd builder
  
Now off to learn cvs (as mezzanine was a very nice shell hiding my lack of cvs knowledge) - [[User:Cactus|Cactus]] 05:07, 25 December 2007 (MST)
+
==== 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
  
== Emphasize the need for the common folder ==
+
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'
  
I think we need to clearly document that you at least need to check out the common folder for the build system to work, am I right? - [[User:Cactus|Cactus]] 06:51, 25 December 2007 (MST)
+
==== 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 ~/smeserver
 +
cd ~/smeserver
  
The common folder doesn't need to be specifically checked outThe make file is smart enough to check for a common folder and if it doesn't find one then it will automatically check it outThe instructions for checking out the common folder in the rpms directory make it so that the make file won't check out a common folder for each and every package you work on.  <small>[[User:Slords|Slords]] ([[User talk:Slords|talk]] [[Special:Contributions/Slords|contribs]]).</small> 10:05, 25 December 2007 (MST)
+
To add the smecontribs cvs:
 +
mkdir ~/smecontribs
 +
cd ~/smecontribs
 +
 
 +
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 at koozali.org, we can also retrieve the CVS for the smecontribs tree. For this issue the following commands:
 +
cd ~/smeserver
 +
cvs -z3 -d:pserver:anonymous@shell.koozali.org:/cvs/smeserver checkout -P e-smith-base
 +
 
 +
For the 'smeserver-base' base from the contribs tree.
 +
cd ~/smecontribs
 +
cvs -z3 -d:pserver:anonymous@shell.koozali.org:/cvs/smecontribs checkout -P smeserver-base
 +
 
 +
Next to a selective retrieve as per above, you can also retrieve the whole CVS tree.
 +
cd ~/smeserver
 +
cvs -z3 -d:pserver:anonymous@shell.koozali.org:/cvs/smeserver co -P rpms
 +
 
 +
For the SME contribs tree.
 +
cd ~/smecontribs
 +
cvs -z3 -d:pserver:anonymous@shell.koozali.org:/cvs/smecontribs co -P rpms
 +
 
 +
If you want to update/refresh the whole CVS tree smeserver or smecontribs, run the following from the rpms directory, or any lower directory with a CVS dir , issue
 +
cvs update -dPA
 +
 
 +
To work on the e-smith-base smeserver tree, change to the e-smith-base SME8 directory:
 +
cd ~/smeserver/rpms/e-smith-base/sme8
 +
 
 +
Then we have to prepare a tree. Issue the following commands:
 +
cvs update -dPA
 +
make clean
 +
make prep
 +
Please ignore if 'make clean' returns an error about a missing *.tgz package
 +
 
 +
Our patch will be a done with the 'diff' tool which compares the edited files against the original files. So we need to 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 we can make the changes or edit the source code in e-smith-base-5.2.0.
 +
 
 +
For a simple test you can edit the SME8 'e-smith-base-5.2.0/root/sbin/e-smith/console' file and add something to the header.
 +
 
 +
cd ~/smeserver/rpms/e-smith-base/sme8
 +
nano -w e-smith-base-5.2.0/root/sbin/e-smith/console
 +
 
 +
<pre>
 +
#!/usr/bin/perl -w
 +
 
 +
#----------------------------------------------------------------------
 +
# copyright (C) 1999-2006 Mitel Corporation
 +
#
 +
# This program is free software; you can redistribute it and/or modify
 +
# it under the terms of the GNU General Public License as published by
 +
# the Free Software Foundation; either version 2 of the License, or
 +
# (at your option) any later version.
 +
#
 +
# This program is distributed in the hope that it will be useful,
 +
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 +
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSESee the
 +
# GNU General Public License for more details.
 +
#
 +
# You should have received a copy of the GNU General Public License
 +
# along with this program; if not, write to the Free Software
 +
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 +
#
 +
# Let's see if this new line pops up in my patch file and my new test RPM !!!    <----- Add this line
 +
#----------------------------------------------------------------------
 +
</pre>
 +
Save the file
 +
 
 +
== Create a patch ==
 +
When we have finished our editing of 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:
 +
 +
cd ~/smeserver/rpms/e-smith-base/sme8
 +
diff -urN e-smith-base-5.2.0.old e-smith-base-5.2.0 > e-smith-base-5.2.0-test.patch
 +
 
 +
==== Test the patch ====
 +
To see if our changes work correctly as intended, we will make a local RPM build to test, and before building the RPM it is necessary to update the spec file to increase the release number and to ensure your patch is included in the build.
 +
 
 +
===== Update the spec file =====
 +
First we will update the spec file. Spec files are text files that contain RPM directives and macro definitions, which are used to build an RPM package.
 +
 
 +
For our examle we will continue to use the e-smith-base-5.2.0
 +
 
 +
cd ~/smeserver/rpms/e-smith-base/sme8
 +
 
 +
Edit the file e-smith-base.spec
 +
 
 +
nano e-smith-base.spec
 +
 
 +
and change:
 +
 
 +
<pre>
 +
#increase the release version at the beginning of the spec file
 +
%define release 68
 +
 
 +
#add the patch to the existing patchlist section:
 +
Patch2: e-smith-base-5.2.0-test.patch
 +
 
 +
#update the changelog section, including the release version and bug number
 +
* Wed Jan 23 2013 John Doe <jdoe@foo.net> 5.2.0-68.sme
 +
- just a test to see if I can do this [SME: 7129]
 +
 
 +
#add patch version to the %setup section
 +
%patch2 -p1
 +
</pre>
 +
 
 +
Save the file
 +
 
 +
To check the changes issue the following command which compares your updated spec file with the original one in CVS. This is an optional step, but helps catch errors in the spec file.
 +
 
 +
cvs diff -u e-smith-base.spec
 +
 
 +
* Ensure that the changelog version really matches the RPM version.
 +
* Check if the spec file correct, look at the changes
 +
* 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
 +
 
 +
==== Build the test RPM ====
 +
Build the rpm locally to test, (note, this deletes the working tree!<-- Please explain)
 +
make local
 +
 
 +
A new RPM e-smith-base-5.2.0-68.el5.sme.x86_64.rpm will be created which you can test or explore to see if your changes are applied
 +
 
 +
Once the patch works, attach the patch to the bugzilla entry. That is all what it takes to create a patch.
 +
You can also, optionally, attach the updated spec file.
 +
 
 +
This simple package modification ends here. The next section is intended for developers who have CVS commit and build access. The developers will also check your patches and apply them to the CVS tree for you.
 +
 
 +
== Committing the patch ==
 +
==== If you have CVS commit access ====
 +
 
 +
CVS needs to be updated. To check what will be committed to CVS, issue the following command:
 +
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
 +
 
 +
* Ensure that the patch file has been added
 +
cvs add e-smith-base-5.2.0-test.patch
 +
* Ensure that your patch/files etc. are UNIX style and do not have DOS endings.
 +
 
 +
Once you are satisfied and want to submit the package to CVS 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'
 +
 
 +
for example
 +
cvs commit -m '* Wed Jan 23 2013 John Doe <jdoe@foo.net> 5.2.0-68.sme
 +
- just a test to see if I can do this [SME: 7129]'
 +
 
 +
==== If you have build access ====
 +
Build it (from either the sme7 or sme8 dir):
 +
make tag
 +
make build
 +
[[Category:SME9-Development]]
 +
[[Category:SME Server Development Framework]]
 +
[[Category:Development Tools]]

Latest revision as of 05:17, 18 November 2017

PythonIcon.png Skill level: Developer
Risk of inconsistencies with Koozali SME Server methodology, upgrades & functionality is high. One must be knowledgeable about how changes impact their Koozali SME Server. Significant risk of irreversible harm.


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 based on SME8, and that you have your development SME8 server fully updated and up and running. This can be a dedicated machine or a virtual machine.

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 as root user.

yum install cvs

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'

useradd builder
passwd 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'

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 ~/smeserver
cd ~/smeserver

To add the smecontribs cvs:

mkdir ~/smecontribs
cd ~/smecontribs 

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 at koozali.org, we can also retrieve the CVS for the smecontribs tree. For this issue the following commands:

cd ~/smeserver
cvs -z3 -d:pserver:anonymous@shell.koozali.org:/cvs/smeserver checkout -P e-smith-base

For the 'smeserver-base' base from the contribs tree.

cd ~/smecontribs
cvs -z3 -d:pserver:anonymous@shell.koozali.org:/cvs/smecontribs checkout -P smeserver-base

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

cd ~/smeserver
cvs -z3 -d:pserver:anonymous@shell.koozali.org:/cvs/smeserver co -P rpms 

For the SME contribs tree.

cd ~/smecontribs
cvs -z3 -d:pserver:anonymous@shell.koozali.org:/cvs/smecontribs co -P rpms 

If you want to update/refresh the whole CVS tree smeserver or smecontribs, run the following from the rpms directory, or any lower directory with a CVS dir , issue

cvs update -dPA

To work on the e-smith-base smeserver tree, change to the e-smith-base SME8 directory:

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

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

cvs update -dPA
make clean
make prep

Please ignore if 'make clean' returns an error about a missing *.tgz package

Our patch will be a done with the 'diff' tool which compares the edited files against the original files. So we need to 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 we can make the changes or edit the source code in e-smith-base-5.2.0.

For a simple test you can edit the SME8 'e-smith-base-5.2.0/root/sbin/e-smith/console' file and add something to the header.

cd ~/smeserver/rpms/e-smith-base/sme8
nano -w e-smith-base-5.2.0/root/sbin/e-smith/console
#!/usr/bin/perl -w

#----------------------------------------------------------------------
# copyright (C) 1999-2006 Mitel Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
#
# Let's see if this new line pops up in my patch file and my new test RPM !!!     <----- Add this line
#----------------------------------------------------------------------

Save the file

Create a patch

When we have finished our editing of 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:

cd ~/smeserver/rpms/e-smith-base/sme8 
diff -urN e-smith-base-5.2.0.old e-smith-base-5.2.0 > e-smith-base-5.2.0-test.patch

Test the patch

To see if our changes work correctly as intended, we will make a local RPM build to test, and before building the RPM it is necessary to update the spec file to increase the release number and to ensure your patch is included in the build.

Update the spec file

First we will update the spec file. Spec files are text files that contain RPM directives and macro definitions, which are used to build an RPM package.

For our examle we will continue to use the e-smith-base-5.2.0

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

Edit the file e-smith-base.spec

nano e-smith-base.spec

and change:

 #increase the release version at the beginning of the spec file
 %define release 68

 #add the patch to the existing patchlist section:
 Patch2: e-smith-base-5.2.0-test.patch

 #update the changelog section, including the release version and bug number
 * Wed Jan 23 2013 John Doe <jdoe@foo.net> 5.2.0-68.sme
 - just a test to see if I can do this [SME: 7129]

 #add patch version to the %setup section
 %patch2 -p1

Save the file

To check the changes issue the following command which compares your updated spec file with the original one in CVS. This is an optional step, but helps catch errors in the spec file.

cvs diff -u e-smith-base.spec
  • Ensure that the changelog version really matches the RPM version.
  • Check if the spec file correct, look at the changes
  • 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

Build the test RPM

Build the rpm locally to test, (note, this deletes the working tree!<-- Please explain)

make local

A new RPM e-smith-base-5.2.0-68.el5.sme.x86_64.rpm will be created which you can test or explore to see if your changes are applied

Once the patch works, attach the patch to the bugzilla entry. That is all what it takes to create a patch. You can also, optionally, attach the updated spec file.

This simple package modification ends here. The next section is intended for developers who have CVS commit and build access. The developers will also check your patches and apply them to the CVS tree for you.

Committing the patch

If you have CVS commit access

CVS needs to be updated. To check what will be committed to CVS, issue the following command:

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
  • Ensure that the patch file has been added
cvs add e-smith-base-5.2.0-test.patch
  • Ensure that your patch/files etc. are UNIX style and do not have DOS endings.

Once you are satisfied and want to submit the package to CVS 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'

for example

cvs commit -m '* Wed Jan 23 2013 John Doe <jdoe@foo.net> 5.2.0-68.sme
- just a test to see if I can do this [SME: 7129]'

If you have build access

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

make tag
make build