Creating a patch file

To correct some things in a source or a .desktop file, it is possible to use a patch file. The patch must be included in the directory /file next to your pspec.xml.

To create a patch, simply copy the original file into the same folder and rename it (xxxx.orig). Then do your modifications in the new file. After that, start terminal and type the following command in the same directory.

diff -Naur /textfiles/test.txt.orig /textfiles/test.txt > test.patch

original file (/textfiles/test.txt.orig):

A
B
C
D

new file (/textfiles/test.txt):

A
A
BB
CCC
D

 

Patch (test.patch):

 

— /textfiles/test.txt.orig 2011-02-13 23:20:45.501000079 +0100

+++ /textfiles/test.txt 2011-02-13 23:21:15.841000080 +0100

@@ -1,4 +1,5 @@

A

-B

-C

+BB

+CCC

+

D

 

To use the patch, simply save the created patch file into the files folder of your build files, and add the following red line into the pspec.xml :

 

<BuildDependencies>

<Dependency>qt</Dependency>

<Dependency>gcc</Dependency>

</BuildDependencies>

<Patches>

<Patch level=”1″>test.patch</Patch>

</Patches>

</Source>

 

level indicates how much level will be cut out while patching.

In first example you would have to use level=”1″:

— qrencode/configure_org· 2010-02-03 00:43:16.000000000 +0100
+++ qrencode/configure· 2011-06-03 00:14:07.566744000 +0200

 

In second example You would have to use level=”2″:

— a/b/configure_org· 2010-02-03 00:43:16.000000000 +0100
+++ c/d/configure· 2011-06-03 00:14:07.566744000 +0200

 

Patching is not difficult

If during building package PiSi is removing some necessary files (e.g. *.pyc-files) then You can use a „Keepfile“ function in actions.py!

Here is an example:

from pisi.actionsapi import pisitoolsfrom pisi.actionsapi import shelltools

WorkDir = “.”

NoStrip = [“/”] # stripping disabled

KeepSpecial=[“python”] # do not remove .pyc files

content_of_rpmunpack = “xxxx.rpm”

def setup():

shelltools.system(“rpm2targz xxxx.rpm”)

shelltools.system(“tar -zxvf xxxx.tar.gz”)

def install():

pisitools.insinto(“/”, “usr”)

pisitools.insinto(“/”, “etc”)

 

If You have to detect the architecture of Your system by actions.py (ie.g. if only precompiled software is availabe), then You can use the „get.ARCH()“ function in actions.py!

Have a look:

if get.ARCH() == “x86_64”:
pisitools.dobin(“bin/amd64/xxxx”)
elif get.ARCH() == “i686”:
pisitools.dobin(“bin/i386/xxxx”)

 

Another way to do is that, You can hold the directory names in a dictionary.

bin_dirs = { “i686” : “i386”, “x86_64” : “amd64”}

 

and write a single line of code:

pisitools.dobin(“bin/%s/makemkvcon” % bin_dirs[get.ARCH()] )

 

You can search for examples of get.ARCH() usage in the main repository (say, 2011/devel)

grep -rHIn get.ARCH . –exclude-dir=.svn

So that was all Folks i wish you Happy packaging with Pisi Linux and it is a Joy to see you on the GitHub as Contributer for Pisi Linux

By this way this introducing is make from me with help from the original Pardus HowTo i have modify it for Pisi Linux and i hope this helps you much by building from Pisi Packages.

Happy reading and working with Pisi Linux

Advertisements