LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 02-12-2004, 09:47 AM   #1
linuxdev
Member
 
Registered: Feb 2004
Posts: 34

Rep: Reputation: 15
Patches for .spec file


I want to add 4 patches to my .spec file.....

I have one .spec file for reference (to see how patches are added in .spec file)
but that file is not using the patches
which I need to have ...at the same time those patches have certain number
assigned to them in declaration like....

Patch5000: linux-2.4.9-addon.patch .........................and down in .spec file
the patch is applied as %patch5000 -p1

How can I figure out these attached numbers with my patches...as ALL I know
is name of patches I need to add to my .spec file.....

Pls make it clear as I am lost.......
 
Old 02-12-2004, 12:26 PM   #2
Demonbane
Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
The first number after the patch (5000 in your example) is for determining the order which the patches are to be applied. Therefore unless a patch needs to be applied first before your one, you don't have to worry about it, just put any number.

As for the digit after -p, it depends on the prefix of the patch, since I don't know a better way to explain this I'll give you an example:
Suppose you have a source tar ball myprogram.tar.gz with the following content:

myprogram/README
myprogram/src/main.c
myprogram/Makefile

and you need to apply a patch to src/main.c in your spec file in order to build an RPM, first you'd open the patch with a text editor, on the first few lines you should see something like this:
[code]
--- src/main.c Fri Feb 13 00:00:00 2004
+++ src/main.c Sat Feb 14 00:00:00 2004
[code]
this tells you which file its going to patch, since the rpmbuild procedure applie patches relative to the root build directory (in this case "myprogram/"), and the path to the file is correct, we use -p0.

Suppose the patch has the following header instead:
Code:
--- myprogram/src/main.c Fri  Feb 13 00:00:00 2004
+++ myprogram/src/main.c  Sat Feb 14 00:00:00 2004
Then we need to use -p1, which will make it ignore the "myprogram/" part. If we have "whatever/myprogram/src/main.c" then we need to use -p2, so on and so forth.
It all comes down to the current working directory, with rpmbuild its the build directory (/usr/src/<distro>/BUILD/whatever)
To demonstrate this further I'll give you another quick example, if you're going to apply the patch in the first example manually, and your current working directory is something like "/home/user1/myprogram", then you use -p0 to apply the patch. But if its "home/user1/myprogram/src" then you can still apply the same patch with -p1.

Hope this helps
 
Old 02-12-2004, 12:53 PM   #3
linuxdev
Member
 
Registered: Feb 2004
Posts: 34

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by Demonbane
The first number after the patch (5000 in your example) is for determining the order which the patches are to be applied. Therefore unless a patch needs to be applied first before your one, you don't have to worry about it, just put any number.

As for the digit after -p, it depends on the prefix of the patch, since I don't know a better way to explain this I'll give you an example:
Suppose you have a source tar ball myprogram.tar.gz with the following content:

myprogram/README
myprogram/src/main.c
myprogram/Makefile

and you need to apply a patch to src/main.c in your spec file in order to build an RPM, first you'd open the patch with a text editor, on the first few lines you should see something like this:
[code]
--- src/main.c Fri Feb 13 00:00:00 2004
+++ src/main.c Sat Feb 14 00:00:00 2004
[code]
this tells you which file its going to patch, since the rpmbuild procedure applie patches relative to the root build directory (in this case "myprogram/"), and the path to the file is correct, we use -p0.

Suppose the patch has the following header instead:
Code:
--- myprogram/src/main.c Fri  Feb 13 00:00:00 2004
+++ myprogram/src/main.c  Sat Feb 14 00:00:00 2004
Then we need to use -p1, which will make it ignore the "myprogram/" part. If we have "whatever/myprogram/src/main.c" then we need to use -p2, so on and so forth.
It all comes down to the current working directory, with rpmbuild its the build directory (/usr/src/<distro>/BUILD/whatever)
To demonstrate this further I'll give you another quick example, if you're going to apply the patch in the first example manually, and your current working directory is something like "/home/user1/myprogram", then you use -p0 to apply the patch. But if its "home/user1/myprogram/src" then you can still apply the same patch with -p1.

Hope this helps


Thank you for your insight......
I added the patchs as described but when I gave rpmbuild command.....
I got following error messge for the Patch declaration line....

error: line 205: Tag takes single token only: Patch2: ase_ipqueue.patch

I am not sure what is wrong????
 
Old 02-12-2004, 01:18 PM   #4
Demonbane
Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
hmm not exactly sure, but here's one thing you can do, instead of using the spec file to patch, extract the source tarball, apply your patch then recreate it.

Last edited by Demonbane; 02-12-2004 at 01:26 PM.
 
Old 02-12-2004, 01:22 PM   #5
linuxdev
Member
 
Registered: Feb 2004
Posts: 34

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by Demonbane
hmm not exactly sure, but here's one thing you can do, instead of usnig the spec file to patch, extract the source tarball, apply your patch then recreate it.
--------------->>
The reason I was doing patch stuff here is that ...I think when I give rpmbuild it should do the patching stuff at the same time and avoid doing rpm alone for patching????

NOt sure........
 
Old 02-12-2004, 01:32 PM   #6
Demonbane
Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
Quote:
The reason I was doing patch stuff here is that ...I think when I give rpmbuild it should do the patching stuff at the same time and avoid doing rpm alone for patching????
Not exactly sure what you meant but doing it manually on the source tarball is the same as doing it on the spec file, the result RPM will be built with your patch applied.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
questions on writing own rpm .spec file adrianmak Linux - Software 0 08-18-2005 06:03 AM
creating the file list for the .spec files ingerul Linux - Software 0 11-01-2004 03:06 AM
%file attribute for RPM SPEC files Brian of Gep Linux - Software 3 06-18-2004 04:51 AM
%file attribute for RPM SPEC files Brian of Gep Fedora 0 06-15-2004 07:12 PM
RPM Spec file creation: %file section question davidas Linux - Newbie 0 03-16-2004 10:36 PM


All times are GMT -5. The time now is 04:28 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration