Skip to main content
Topic: How to patch files in a PKGBUILD (Read 2088 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How to patch files in a PKGBUILD

Hello again everyone, I'm trying my best to learn as much as I can about creating PKGBUILDs but one part that always really confuses me to the point where I have absolutely no clue how to solve is how to patch a file.

https://github.com/mgba-emu/mgba/commit/7f41dd354176b720c8e3310553c6b772278b9dca

I need to apply these patches onto the right lines in specific files, how do I do this in a PKGBUILD?

And what does " @@ -10,6 +10,7 @@  " as well as  "@@ -5,6 +5,7 @@" mean?

Like, "10" and "5" I think mean lines 10 and lines 5... but.... what does the - + and the ,6 ,7 mean?

I learn best from seeing examples instead of reading pages upon pages of documentation, so if anyone could show me what a line would look like to modify specific lines in a specific text file that'd be awesome.

Re: How to patch files in a PKGBUILD

Reply #1
You should read up on the patch and diff programs.
Additionally, it won't do harm to get familiar with git, which makes use of diff.

Re: How to patch files in a PKGBUILD

Reply #2
Ok, but could anyone please provide me with an example of how this is done? I learn way more from examples than I do from reading documentation....

How am I supposed to patch a specific line in a specific file?? What is that supposed to look like? Does a patch file replace the entire file that needs to be patched or does it just change specific lines?

What is the ,6 ,7 mean in the link I provided? I am trying to understand all of this stuff, I don't have time to read pages upon pages of documentation especially when I am just trying to figure out only certain parts of this, a lot of it I can understand, but the numbers I don't understand... the first number is the line, but the second numbers 10,6 and 10,7, 5,6 and 5,7 confuse me. 

Re: How to patch files in a PKGBUILD

Reply #3
I'll explain this part for you which may not be clear in the docs.

And what does " @@ -10,6 +10,7 @@  " as well as  "@@ -5,6 +5,7 @@" mean?

Like, "10" and "5" I think mean lines 10 and lines 5... but.... what does the - + and the ,6 ,7 mean?

Not quite. The left hand side (-10, 6) designates the original code while the right hand side (+10,7) designates the modified code. In this case, "10" is the starting line of the chunk (aka line 10) and the second number designates how many lines are displayed in the chunk. So (-10, 6) means the original chunk starts at line 10 and shows six lines (10, 11, 12, 13, 14, and 15) while (+10, 7) means the modified/new chunk which starts at line 10 and shows seven lines (10, 11, 12, 13, 14, 15, and 16).

That being said, I don't think patching it during the build would be the desired approach. You linked to a specific commit, so why not just check out a version from source that includes that commit you want? What are you trying to build exactly? Could you post an example of what you have?

Re: How to patch files in a PKGBUILD

Reply #4
Quote
That being said, I don't think patching it during the build would be the desired approach. You linked to a specific commit, so why not just check out a version from source that includes that commit you want? What are you trying to build exactly? Could you post an example of what you have?

Because medusa-emu hasn't been updated to include this commit, only mgba-emu has been updated, so if I want medusa-emu to work then I have to patch it manually, that's what the mgba-emu repo owner told me.... Plus its good practice, I am doing this so I can learn how to make PKGBUILDs

Re: How to patch files in a PKGBUILD

Reply #5
Because medusa-emu hasn't been updated to include this commit, only mgba-emu has been updated, so if I want medusa-emu to work then I have to patch it manually, that's what the mgba-emu repo owner told me.... Plus its good practice, I am doing this so I can learn how to make PKGBUILDs

It's not clear to me why adding a couple of header files to a totally different piece of software would do anything. Could you point out to where the medusa-emu maintainer told you to put these includes?

Re: How to patch files in a PKGBUILD

Reply #6

How am I supposed to patch a specific line in a specific file?? What is that supposed to look like? Does a patch file replace the entire file that needs to be patched or does it just change specific lines?



I just told you to look at patch and diff and their man pages.
Generally, you need an understanding what a patch is,  a diff.

For examples, I would refer to the package tree, pick any build containing a patch.