Hello folks, i have been going around a lot on Google actually do this but turns out the method listed are either incomplete or too confusing for a person to actually take an SRPM and then modify it accordingly to his needs and then extract a deploy-able RPM.
Therefore, i decided to blog it myself so that folks who find it hard can do this and will benefit anybody around. So here goes nothing : ( i will consider u as a root user at all time )
Prepare the build environment :
# yum install rpm-build
For example sake i will use the asterisk SRPM from Elastix repo, there first we get the SRPM of asterisk :
# wget http://repo.elastix.org/elastix/2/updates/SRPMS/asterisk-11.12.0-0.src.rpm
# ls
asterisk-11.12.0-0.src.rpm
# mv asterisk-11.12.0-0.src.rpm /usr/src
# mkdir -p /usr/src/redhat
# cd /usr/src/
# rpm -ivh asterisk-11.12.0-0.src.rpm
# cd /usr/src/redhat
This will result in five folders in the redhat folder.
BUILD RPMS SOURCES SPECS SRPMS
Now the patches and everything else is in the SOURCES folder, we will go to SPECS folder and prepare our package initially.
# cd /usr/src/redhat/SPECS
Now prepare for building the package :
# rpmbuild -bp asterisk.spec
NOTE: This cud stop as u will be asked for dependencies, install them all and then execute the above stated command.
This will build and patch the file. this is where our patch is gonna come up, move to BUILD folder.
# cd /usr/src/redhat/BUILD
You will see a package file like this one :
# ls
asterisk-11.12.0
Now make a backup of this file as we will be needing it to generate our own patch.
# cp -r asterisk-11.12.0/ asterisk-11.12.0-orig
This will result in two file in the BUILD folder, like this :
# ls
asterisk-11.12.0 asterisk-11.12.0-orig
Now move into ur package file
# cd /asterisk-11.12.0
Once inside do the modification to the source of ur need, any type of customization that u require and then pull out of the folder upto BUILD, listed as follows :
# cd /usr/src/redhat/BUILD
Now we make our own patch :
# diff -Naur asterisk-11.12.0-orig/ asterisk-11.12.0 > my.patch
This will generate our patch file now move it to the SOURCES folder,
# mv my.patch /usr/src/redhat/SOURCES
Now we edit the spec file again and tell the spec file of our patch,
# cd /usr/src/redhat/SPECS
# nano asterisk.spec
You will find two point at which editing will be required, for example in this case scenario the first one will be like :
....../.../.../.....
Patch65: asterisk-11.3.0-xorcom-busydetect-05-cap-limit-threshold.patch
Patch66: asterisk-11.3.0-xorcom-busydetect-06-dahdi-config-options-busydetect.patch
Patch68: asterisk-11.5.1-chan_allogsm-2.0.7-v2.patch
Patch69: asterisk-11.11.0-srtp-lifetime.patch
Patch70: my.patch
Notice how i placed the patch number 70, this is what we will be adding to spec file. ( indicated in red). One more entry is required to tell how to apply patch which we will put in like this :
....../.../.../.....
%patch64 -p1
%patch65 -p1
%patch66 -p1
%patch68 -p1
%patch69 -p1
%patch70 -p1
Again indicated in red is the entry which i did to the spec file, now save the spec file and quit it. Now comes the best part :
# rpmbuild -bp asterisk.spec
This will apply your patch and your modded source is now available, now we build our source so that we can install it, this can be done very easily,
# rpmbuild -ba asterisk.spec
This will generate your rpm which will be located in the RPMS folder under your architecture, according to my case it was in :
# cd /usr/src/redhat/RPMS/i386
Now to install it we just do this :
# rpm -Uvh asterisk*.rpm
If you get conflicting errors try this :
# rpm -Uvh -force asterisk*.rpm
This marks the end of our tutorial.
Thank You, Comments and suggestion are more then welcome!
Therefore, i decided to blog it myself so that folks who find it hard can do this and will benefit anybody around. So here goes nothing : ( i will consider u as a root user at all time )
Prepare the build environment :
# yum install rpm-build
For example sake i will use the asterisk SRPM from Elastix repo, there first we get the SRPM of asterisk :
# wget http://repo.elastix.org/elastix/2/updates/SRPMS/asterisk-11.12.0-0.src.rpm
# ls
asterisk-11.12.0-0.src.rpm
# mv asterisk-11.12.0-0.src.rpm /usr/src
# mkdir -p /usr/src/redhat
# cd /usr/src/
# rpm -ivh asterisk-11.12.0-0.src.rpm
# cd /usr/src/redhat
This will result in five folders in the redhat folder.
BUILD RPMS SOURCES SPECS SRPMS
Now the patches and everything else is in the SOURCES folder, we will go to SPECS folder and prepare our package initially.
# cd /usr/src/redhat/SPECS
Now prepare for building the package :
# rpmbuild -bp asterisk.spec
NOTE: This cud stop as u will be asked for dependencies, install them all and then execute the above stated command.
This will build and patch the file. this is where our patch is gonna come up, move to BUILD folder.
# cd /usr/src/redhat/BUILD
You will see a package file like this one :
# ls
asterisk-11.12.0
Now make a backup of this file as we will be needing it to generate our own patch.
# cp -r asterisk-11.12.0/ asterisk-11.12.0-orig
This will result in two file in the BUILD folder, like this :
# ls
asterisk-11.12.0 asterisk-11.12.0-orig
Now move into ur package file
# cd /asterisk-11.12.0
Once inside do the modification to the source of ur need, any type of customization that u require and then pull out of the folder upto BUILD, listed as follows :
# cd /usr/src/redhat/BUILD
Now we make our own patch :
# diff -Naur asterisk-11.12.0-orig/ asterisk-11.12.0 > my.patch
This will generate our patch file now move it to the SOURCES folder,
# mv my.patch /usr/src/redhat/SOURCES
Now we edit the spec file again and tell the spec file of our patch,
# cd /usr/src/redhat/SPECS
# nano asterisk.spec
You will find two point at which editing will be required, for example in this case scenario the first one will be like :
....../.../.../.....
Patch65: asterisk-11.3.0-xorcom-busydetect-05-cap-limit-threshold.patch
Patch66: asterisk-11.3.0-xorcom-busydetect-06-dahdi-config-options-busydetect.patch
Patch68: asterisk-11.5.1-chan_allogsm-2.0.7-v2.patch
Patch69: asterisk-11.11.0-srtp-lifetime.patch
Patch70: my.patch
Notice how i placed the patch number 70, this is what we will be adding to spec file. ( indicated in red). One more entry is required to tell how to apply patch which we will put in like this :
....../.../.../.....
%patch64 -p1
%patch65 -p1
%patch66 -p1
%patch68 -p1
%patch69 -p1
%patch70 -p1
Again indicated in red is the entry which i did to the spec file, now save the spec file and quit it. Now comes the best part :
# rpmbuild -bp asterisk.spec
This will apply your patch and your modded source is now available, now we build our source so that we can install it, this can be done very easily,
# rpmbuild -ba asterisk.spec
This will generate your rpm which will be located in the RPMS folder under your architecture, according to my case it was in :
# cd /usr/src/redhat/RPMS/i386
Now to install it we just do this :
# rpm -Uvh asterisk*.rpm
If you get conflicting errors try this :
# rpm -Uvh -force asterisk*.rpm
This marks the end of our tutorial.
Thank You, Comments and suggestion are more then welcome!
No comments:
Post a Comment