PDA

View Full Version : Patch files (*.diff) for patching under FreeBSD



Makc666
Wed 12th Sep '07, 10:47am
A little question for vBulletin team.
What soft you are using to create patch files (*.diff) to generate patch(*.diff) files?

Today I meet with a problem under FreeBSD using

patch -u < ./23050.diff
http://www.vbulletin.com/forum/project.php?issueid=23050
http://www.vbulletin.com/forum/project.php?do=patch&attachmentid=283

and geting error:


Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Index: /admincp/blog_admin.php
|================================================= ==================
|--- /admincp/blog_admin.php (revision 17990)
|+++ /admincp/blog_admin.php (revision 17996)
--------------------------
Patching file blog_admin.php using Plan A...
patch: **** malformed patch at line 6:
Press any key to continue...

So I took old blog_admin.php made a new one manually and run

diff -crbBNu blog_admin_old.php blog_admin.php >23050_new.diff

Then I copmared the problem line and found out that your diff has:

@@ -245,6 +245,9 @@

// rebuild category counters
+ $tablename = 'blog_category_count' . $vbulletin->userinfo['userid'];
+
+ $vbulletin->db->query_write("DROP TABLE IF EXISTS " . TABLE_PREFIX . "$tablename");
$db->query_write("
- CREATE TEMPORARY TABLE " . TABLE_PREFIX . "blog_category_count
+ CREATE TABLE " . TABLE_PREFIX . "$tablename
(
blogcategoryid INT UNSIGNED NOT NULL DEFAULT '0',

And my new has:

@@ -244,8 +244,11 @@
$tabletype = (version_compare(MYSQL_VERSION, '4.1', '<')) ? 'HEAP' : 'MEMORY';

// rebuild category counters
+ $tablename = 'blog_category_count' . $vbulletin->userinfo['userid'];
+
+ $vbulletin->db->query_write("DROP TABLE IF EXISTS " . TABLE_PREFIX . "$tablename");
$db->query_write("
- CREATE TEMPORARY TABLE " . TABLE_PREFIX . "blog_category_count
+ CREATE TABLE " . TABLE_PREFIX . "$tablename
(
blogcategoryid INT UNSIGNED NOT NULL DEFAULT '0',
total INT UNSIGNED NOT NULL DEFAULT '0',

As you can notice your diff starts from 245 line.
And that line is empty...

My diff starts from 244 line.
And that line has information.

So I came to conclusion that diff blocks
@@ -245,6 +245,9 @@
must not start from the empty lines...

P.S. I also tried a software from this thread:
How to use Patch files (*.diff) for patching your vBulletin installation (http://www.vbulletin.com/forum/showthread.php?t=239778)
But it also gives me an error...

Patch I used:
/usr/bin/patch -v
Patch version 2.1

So then I go to
/usr/ports/devel/patch
and run 'make'

Copied patch from
/usr/ports/devel/patch/work/patch-2.5.4/
directory to
/usr/local/bin/

/usr/local/bin/patch -v
patch 2.5.4

When I used this patch it patched the file OK.
/usr/local/bin/patch -u /www/blog_admin.php /www/23050.diff

Hope this one can help anyone.

FreeBSD 6.1-RELEASE #2

Mike Sullivan
Wed 12th Sep '07, 11:22am
Actually, it has to do with line 6 being "" (empty) instead of " " (a space), which was the expected value. This has to do with the fact that most of us use a text editor that trims trailing spaces on save.

Clearly, newer versions of patch just handle this case better.