How to patch?

Please tell me how to patch. I cannot patch anything :frowning:

For example:

anixx@anixx-desktop:~> diff -u ‘/home/anixx/Загрузки/kalgebra/src/qexp.cpp.orig’ ‘/home/anixx/Загрузки/kalgebra/src/qexp.cpp’ > ‘/home/anixx/Desktop/cpppatch.diff’
anixx@anixx-desktop:~> patch /home/anixx/Загрузки/kalgebra/src/qexp.cpp.orig ‘/home/anixx/Desktop/cpppatch.diff’
patch: **** Only garbage was found in the patch input.

--- /home/anixx/Загрузки/kalgebra/src/qexp.cpp.orig	2006-04-29 19:23:29.000000000 +0400
+++ /home/anixx/Загрузки/kalgebra/src/qexp.cpp	2010-09-19 15:50:50.486781883 +0400
@@ -114,7 +114,7 @@
 			err += i18n("Too much comma in %1<br />
").arg(ret.val);
 		}
 		
-		ret.val = QString::QString("<cn>%1</cn>").arg(ret.val);
+		ret.val = QString("<cn>%1</cn>").arg(ret.val);
 		ret.tipus= tVal;
 	} else if(a[0].isLetter()) {//es una variable o func
 		ret.val += a[0];
@@ -124,7 +124,7 @@
 		if(a*=='('){
 			ret.tipus=tFunc;
 		} else {
-			ret.val = QString::QString("<ci>%1</ci>").arg(ret.val);
+			ret.val = QString("<ci>%1</ci>").arg(ret.val);
 			ret.tipus= tVal;
 		}
 	} else if(a[0]=='-' && a[1] == '>') {

Also sometimes a patch works well in OBS for 11.1 but does not for 11.2 (with macro %patch). If to use patch utility (without macro) then all works. Why?*

I’m not sure I understand your question. Is it about diff/patch usage ?

For example :

diff -u /kalgebra/src/qexp.cpp.orig /kalgebra/src/qexp.cpp > /home/anixx/qexp.ccp.diff

and :

patch -p0 < /home/anixx/qexp.cpp.diff

--- /home/anixx/Загрузки/kalgebra/src/qexp.cpp.orig	2006-04-29 19:23:29.000000000 +0400
+++ /home/anixx/Загрузки/kalgebra/src/qexp.cpp	2010-09-19 15:50:50.486781883 +0400

Having my screen set to iso-8859-1 (latin1) charset I see some strange characters including a comma in your path. Perhaps patch doesn’t like this.

Hi
I use diff -Naur somefile somefile.orig hasn’t failed me yet…


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.32.19-0.2-default
up 3 days 1:55, 3 users, load average: 0.33, 0.45, 0.25
GPU GeForce 8600 GTS Silent - Driver Version: 256.53

Once I started using quilt I never looked back. I think there was a good post in planetsuse, but now I can only find openSUSE:Junior jobs - openSUSE

Also, in newer RPM versions you can’t

Patch0: XXX
...
%patch

You need to use also “%patch0”.

This does not work either. Only direct use of the patch utility works. For example, in this package:

https://build.opensuse.org/package/files?package=kde3-kalgebra&project=KDE%3AKDE3

In the %prep section this should be:

%patch0 -p0
%patch1 -p0
...

and the paths in the patchfiles should be relative to the kalgebra directory:

--- src/kfunctionedit.cpp.orig    2006-05-01 15:56:59.000000000 +0400  
+++ src/kfunctionedit.cpp 2010-09-19 16:44:32.780780999 +0400
@@ -30,7 +30,7 @@
    topLayout->addWidget(raro);
      
    m_graph = new QGraph(raro);
-   m_graph->setViewPort(QRect::QRect(QPoint::QPoint(-9, 5), QPoint::QPoint(9, -5)));
+   m_graph->setViewPort(QRect(QPoint(-9, 5), QPoint(9, -5)));
    m_graph->setResolution(400);
    m_graph->setMouseTracking(false);
    m_graph->setFocusPolicy(NoFocus);

Hi
That’s because of your patches??? Your patches start at the source tree
when it’s unpacked. In your cpppatch1.diff it should be src/<somefile>

For each patch you use %patch(n), you also better to combine all your
patches if their similar… (just my preference) using > and >> to
append.


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.32.19-0.2-default
up 3 days 7:21, 2 users, load average: 0.13, 0.22, 0.25
GPU GeForce 8600 GTS Silent - Driver Version: 256.53

No, the initial patch from Fedora also did not work through %patch macro in 11.2 and 11.3. Only in 11.1 it worked well. So I changed it to the call to patch utility directly (and after this it worked). Other patches which I made myself I even did not try to call with %patch.

In the %prep section this should be:
and the paths in the patchfiles should be relative to the kalgebra directory:

Yes, this is what exacty was with the first patch. But it worked only for 11.1

Hi
That to me would indicate either a) the source was changed (ie not
original) or b) it’s an old patch used on a later source. Best to review
the patches and redo so the work how they should…


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.32.19-0.2-default
up 3 days 10:42, 2 users, load average: 0.40, 0.42, 0.27
GPU GeForce 8600 GTS Silent - Driver Version: 256.53

The same source. And I very often face it: the same source but for later SUSE version the patch fails.

I have just changed the spec to use %patch script. Now for 11.2 builds, for 11.3 fails:
https://build.opensuse.org/package/show?package=kalgebra&project=home%3AAnsus%3AKDE3

That’s because newer RPMs run patch with a lower fuzz level. Just fix the patch (I still recommend quilt for such tasks).

So it is like a lottery - will your patch work or not.

As RedDwarf said, quilt is the best tool. It can refresh the patch to fuzz=0.

The patch is wrong, that’s the only problem and not related to lottery.
In openSUSE < 11.3 the patch works because RPM is making you a favor and accepting that patch even knowing it has problems. But to make you that favor patch has to make some guesses and sometimes ends applying the patch in the wrong position. After years of problems because packagers didn’t noticed those guessing problems it was decided that RPM should stop making favors… if a patch needs to be updated the packager must manually update it verifying everything is ok.

The only lottery is knowing if patch is applying that patch correctly in the openSUSE versions that “works”.

The patch is wrong, that’s the only problem and not related to lottery.

Why is it wrong?

A patch says “this is what there is now, it must be changed by this other thing”. And your patch is wrong in the “this is what there is now”. The patch program looks at the file to be patched, looks at the patch file… and sees they don’t match.

It is like if I say you to repaint the green wall in red… and all walls are yellow.

Your are trying to apply a patch for kalgebra 0.4 to kalgreba 0.5… it just doesnt works. Recreate the patch for kalgebra 0.5 and everything will work just fine.

Also if the patch has been pushed upstream the new version may already
include the patch. As a packager you need to look at the patch and
check the code to see what has changed, there may be more lines of
code, but the patch is still needed.


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.32.19-0.2-default
up 4 days 4:37, 2 users, load average: 0.08, 0.07, 0.09
GPU GeForce 8600 GTS Silent - Driver Version: 256.53