Preparing a Pisi package is a step-by-step procedure which is easy to learn but difficult to apply and solve possible problems. I have followed how to manuals and examples on Pardus Wiki about preparing a Pisi package. To see the document on making a package for the beginners, you can visit “http://tr.pardus-wiki.org/NASIL:Yeni_ba%C5%9Flayanlar_i%C3%A7in_paket_yap%C4%B1m_rehberi”. Adding package to pisi system is more than just making a Pisi package. It is a process including gathering information about the package you want to make Pisi package of, testing and debugging your Pisi package, keeping up with newer versions. I also learned the underlying mechanism to move on. Packaging mechanism makes binary packages that Pisi uses by using source codes. The process is like following: Source codes get downloaded by processing source part of the pspec.xml file and after it gets verified, it gets extracted to /var/pisi/package_name/work. Then, to obtain binary data action.py gets processes and installation is made to /var/pisi/package_name/install using source code. If there is any additional file they get coppied to /install directory as it defined at pspec.xml. After that, Pisi makes index file for the files in the /install directory. This index is compatible with pisi database and in XML format. Then, index and binary get combined with datas obtained from pspec.xml and archived as .pisi package. As we can see, pisi installs package to /var/pisi/paket_adi/install while it produces .pisi file. By examining this directory, we can see which files go to which directory. Understanding this mechanism was important for me before I start making a package.
In order to make a Pisi package, I have to prepare at least two files: pspec.xml and actions.py. As I mentioned before, pspec.xml file is about definition and content of package and packaging progress. The general structure is shown here: "http://en.pardus-wiki.org/Making_Pisi_Packages#pspec.xml"
The source part gives basic information about package to Pisi. Also, which category and part that package belongs in Pardus system structure, which packages need to exist while compiling, which patches need to applied before compiling process are all stated in the source part. The general structure is shown here: "http://en.pardus-wiki.org/Making_Pisi_Packages#Source_part".
IsA tag is required to determine which category that package belongs and this tag can be defined more than once. It can take values as app:gui, app:console, library, daemon, service etc. I will explain how to fill each part by examples later. Before moving further, the concept of dependency is important to learn. As I have learned, dependecy means the packages that are required for a package to be built and installed. There are two types of dependencies as build dependency (required for a package to be built by pisi bi...) and run-time dependency (required for a package to be installed later by pisi it...).
IsA tag is required to determine which category that package belongs and this tag can be defined more than once. It can take values as app:gui, app:console, library, daemon, service etc. I will explain how to fill each part by examples later. Before moving further, the concept of dependency is important to learn. As I have learned, dependecy means the packages that are required for a package to be built and installed. There are two types of dependencies as build dependency (required for a package to be built by pisi bi...) and run-time dependency (required for a package to be installed later by pisi it...).
Package part keeps definitions about pisi files that will be created after packaging. If it is necessary to create more than one pisi file from a package, every one of them should be written in the same pspec.xml file, but into different Package part for each. The general struture is shown here: "http://en.pardus-wiki.org/Making_Pisi_Packages#Package_part"
Files node here is important, since source file is installed to /var/pisi/package_name/install. Directories that Path tag uses should be these directories. Contents of directories will be added to pisi file by pisi. While these files are added to directories, they are added according to their "fileType" property.
Lastly, History part keeps the information about updates and updaters by update nodes that every updater adds. The general structure is shown here: "http://en.pardus-wiki.org/Making_Pisi_Packages#History_part"
You can check the most recent and correct specification of pspec.xml file from here: “http://svn.pardus.org.tr/uludag/trunk/pisi/pisi-spec.rng”. After preparing pspec.xml file, it is time to prepare actions.py file written in Python. This file uses different Actions API and has a general or example structure as follows:
#!/usr/bin/python ... def setup(): #Preparation processes def build(): #Compile processes def install(): #Installation processes
We know that when we install a program from the source code, we use configure + make + install commands in this order. Similarly in acitons.py, when setup() is run by pisi we need to do configure, when build() is run we need to do make, and when install() is run we need to do install processes. However, it is not that much simple for most of the time. We need to use correct actions APIs with proper parameters. To learn how to write actions.py file, we need to learn configure and make parameters from the documents of the program on which we want to prepare a package. Then we need to look for proper Actions API functions for necessary processes we learned from these documents. From that point on, trial-error will be our guide. We can add new functions to fix the problems and check the result by viewing /var/pisi/package_name/install directory. Thus, there is no fixed action.py file anc each package may have its own setup(), build() and install() parts. For the beginners like me, it was a good idea to examine many actions.py files in SVN repository. Moreover, “http://tr.pardus-wiki.org/Pardus:ActionsAPI” will always be my guide to find the necessary API usage and parameters that will do my intended task.
In addition to pspec.xml and action.py files, we can wirte a translations.xml file. We can write multi-lingual description and summary sections at this file. This file must be located at same folder with pspec.xml file. In this file, I generally provide Turkish versions of the description and summary parts in pspec.xml file. In addition, we can also add files/ directory while making a package. If there is a patch for source file, it must be placed at this directory. Also some files which source package does not contain but application needs for running are put here, like icons etc. Patches could be needed to solve some external problems without changing the actual source code. I will explain how to prepare each of these files by examples later.
Finally I have prepared my first-example package called merhaba-pisi (Pisi Hello World). It is a simple program that when you type “merhaba-pisi” from console, it responds “sana da merhaba username/root”. The source code is written in Python and put into an online source page in a compressed format. This is the starting condition for preparing a new package that has a source code available online. You can find how to fill in pspec.xml and actions.py files for this example from Pardus Wiki manual: “http://tr.pardus-wiki.org/NASIL:PiSi_Hello_World”. It was a good example for me to learn how to fill these files, by searching program's/application's website and documents that come out from tar.gz source files etc. By following this tutorial, finally I prepared a new package, then built it by pisi bi command, and finally installed by pisi it command. After these steps, now it was available in my system and whenever I type “merhaba-pisi” from console, it writes back “sana da merhaba root/pars”, thus it works fine.