Making a patch

I usually fix the SlackBuilds I maintain by sed, as it makes things much more transparent. However, sed is not always an option, especially for some big fixes or fixes that contain “weird” characters, for example something like this:

unless (defined(@$slist) && defined($hlist_sel)) {

The above is an excerpt from perlprimer.pl, that had to be fixed. The problem in question has been discussed here. I wanted to provide a fix for my perlprimer.SlackBuild, therefore I decided to make a patch.

I have rarely done that and I do not remember the exact options for diff. I decided to follow a simple tutorial that I know from the time I used CRUX.

So… as stated there, it’s not good to alter the file names themselves, as that can confuse patch, so it’s better to change the directory name instead. Therefore, I downloaded the Perlprimer sources, created two folders orig and new. Note that the perlprimer.SlackBuild already applies a patch, called 01_sytaxerrors.patch. I applied it first, then I copied the patched perlprimer.pl in the orig and new folders. Now I made my own changes to new/perlprimer.pl. After that I got up one level where both orig and new folders are and issued the following command:

diff -pruN orig new

this will output the patch in the console. Of course it can be saved to a file:

diff -pruN orig new > 02_fix-defined-slist.patch

Here it is, the patch is ready:

--- orig/perlprimer.pl	2016-11-22 21:06:25.135978000 +0200
+++ new/perlprimer.pl	2016-11-22 21:08:09.001971413 +0200
@@ -5226,7 +5226,7 @@ sub generate_report {
 	}
 	
 	my ($hlist_sel) = $$hlist_ref->selectionGet;
-	unless (defined(@$slist) && defined($hlist_sel)) {
+	unless (@$slist && defined($hlist_sel)) {
 		dialogue("The Generate Report function saves the statistics and alignment of a particular primer pair - please select a primer pair first");
 		return;
 	}

To apply it, there’s the command that goes to perlprimer.SlackBuild:

patch -p1 -i $CWD/02_fix-defined-slist.patch

That’s it.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s