LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 10-21-2003, 04:42 PM   #1
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Rep: Reputation: 30
Question How to apply patches for application programs?


I think this is a question many newbies like me ask. A lot of times I checkout software on sourceforge which has a section called "patches" but I have never had the opportunity to discover what is a patch excatly, and how to apply it? Lately I came across XCHAT2 which has patches which ar every recommended to install (for security reasons). The patches are in .diff format... Can someone illuminate this argument? Thanks. Ganninu.
 
Old 10-22-2003, 08:05 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,454
Blog Entries: 54

Rep: Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896
//moderator.note: moved to Linux - General, because it isn't about security, but the process of patching. A patch is the output from diff ("diff -Naur oldfile newfile > oldfile.diff"), and to use it you could "cat patch.diff | patch --dry-run -p 1 -b /dir/with/xchat2/sourcecode". The "p 1" strips one directory level in the patch before applying, "-b" makes backups, and using "--dry-run" it won't apply the patch but test if it will work. Note any messages about rejects, because you're supposed to patch those parts manually. If satisfied it will work OK, remove the "--dry-run" switch and let it rip.
 
Old 10-22-2003, 08:20 AM   #3
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Original Poster
Rep: Reputation: 30
I don't understand why one has to strip one directory level in the patch though...
 
Old 10-22-2003, 01:04 PM   #4
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Original Poster
Rep: Reputation: 30
Ok got it... thanks a lot... I understood the -p1 concept. I applied all the patches except one... It made reference to more than one source file:

# fixes 64bit issues (where a pointer to int was given, instead of gsize).
--- xchat-2.0.5/src/common/server.c 2003-08-11 01:40:15.000000000 +1000
+++ xchat-2.0.6/src/common/server.c 2003-10-07 14:54:26.000000000 +1000
@@ -289,8 +289,8 @@
{
char *conv_line; /* holds a copy of the original string */
int conv_len; /* tells g_convert how much of line to convert */
- int utf_len;
- int read_len;
+ gsize utf_len;
+ gsize read_len;
GError *err;
gboolean retry;

--- xchat-2.0.5/src/common/text.c 2003-09-21 20:36:15.000000000 +1000
+++ xchat-2.0.6/src/common/text.c 2003-10-07 15:01:06.000000000 +1000
@@ -446,7 +446,7 @@
get_stamp_str (char *fmt, time_t tim, char **ret)
{
char dest[128];
- int len;
+ gsize len;

len = strftime (dest, sizeof (dest), fmt, localtime (&tim));
if (len)
--- xchat-2.0.5/src/fe-gtk/xtext.c 2003-09-18 15:26:52.000000000 +1000
+++ xchat-2.0.6/src/fe-gtk/xtext.c 2003-10-07 14:57:14.000000000 +1000
@@ -2126,6 +2126,7 @@
char *stripped;
guchar *new_text;
int len;
+ gsize glen;

stripped = gtk_xtext_selection_get_text (xtext, &len);
if (!stripped)
@@ -2158,9 +2159,9 @@
}
break;
default:
- new_text = g_locale_from_utf8 (stripped, len, NULL, &len, NULL);
+ new_text = g_locale_from_utf8 (stripped, len, NULL, &glen, NULL);
gtk_selection_data_set (selection_data_ptr, GDK_SELECTION_TYPE_STRING,
- 8, new_text, len);
+ 8, new_text, glen);
g_free (new_text);
}

How can I patch the source code then? I tried entering all the filenames after the patch command but it doesn't seem to accept more than 1 filename... Or should I edit the patch myself to split it in several diff files?
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to apply patches?? jadukor Slackware 4 12-02-2005 07:37 PM
How do you apply these WIFI patches? john_walsh54 Linux - Newbie 0 10-07-2003 06:49 AM
How do you apply those patches that are in text? KuRe Linux - Newbie 1 08-07-2003 04:20 PM
how to apply patches NGraphiX Linux - General 1 06-17-2003 06:04 AM
Can I apply ALL patches all the time? Dark_Helmet Linux From Scratch 2 06-08-2003 11:21 AM


All times are GMT -5. The time now is 05:12 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