You are on page 1of 8

7/29/13

Dragora

Dragora
Creating packages
Introduction Questions Let's get to it! Configuring the sources Building the source Aditional steps Building the package Package naming scheme Summary of the steps Final notes

Introduction
To create a package we need to understand "What's a package?", besides the basic needed skills in a Unix-like system: managing and editing files, directories, permissions, the concept of source code, compilation process, etc. Some of the mentioned skills won't be explained and we'll assume that the user is already familiar with them.

Questions
Below, there will be a series of questions and answers. There also will be some explanations and things to take into account. Source code or binary?
www.dragora.org/en/files/2x/makepkg.html 1/8

7/29/13

Dragora

The source code is a collection of instructions given by programmers through a computer language that can be read and written by people. Computers are capable of understanding this code or list of instructions if it is "interpreted", so they can use it directly. The way to interpret code by computers is to translate or "compile" the source code into a "binary" they can understand. What is a package? It is a piece of software that gets packed, distributed and it is then ready to be used. Usually software is packaged in binary form, distributed in a specific format according to the operating system or the GNU/Linux distribution. In Dragora GNU/Linux-Libre the format of the packages is a simple tar archive compressed with lzip. Just a standard, portable compressed archive (according to the usage tools). Why use or create a package? Simply, because it allows easier distribution. It allows the tools of the package manager to install, uninstall and upgrade as well as keep track of what files are in the system.

Let's get to it!


Let's suppose we have downloaded the sources of the application "foo" and we would like to create the package (after compiling, of course). To do that, we decompress the source:
#t a rx v ff o o 1 . 2 . 3 . t a r . g z

We enter the directory of the decompressed source so we can later configure and install it:
#c df o o 1 . 2 . 3

It is necessary to fix or correct the permissions of the files, group and sub-directories for our package, since many sources come with different owner, group and permissions.
#c h o w nR0 : 0. #c h m o dRu + w , g o w , a + r X s.

The -R flag of `chown' is recursive, which means that the owner and group of the id "0" (traditionally "root") will be
www.dragora.org/en/files/2x/makepkg.html 2/8

7/29/13

Dragora

applied for all the files and directories of the source. `chmod' takes care of looking for the wrong permissions and corrects them.

Configuring the sources


Now we shall use the `configure' application of the source to prepare and configure the package according to our needs. We need to clarify that `configure' may have many flags that are beyond the scope of this guide. The idea is to point out the more common flags: --prefix=/usr This flag tells `configure' in which directory we want to install the program, usually in /usr. --sysconfdir=/etc This flag tells `configure' in which directory we want to put the configuration files of the program, traditionally /etc. --infodir=/usr/info With this flag we configure where we want to install the info documents. --mandir=/usr/man With this flag we configure where we want to install the manuals. For a detailed description of the options we can type:
#. / c o n f i g u r eh e l p

In the end, we have something like this:


#. / c o n f i g u r ep r e f i x = / u s rs y s c o n f d i r = / e t ci n f o d i r = / u s r / i n f om a n d i r = / u s r / m a n

Building the source


www.dragora.org/en/files/2x/makepkg.html 3/8

7/29/13

Dragora

The next step is building / compiling the program itself with `make'; we type:
#m a k e

The next step is installing the binary program(s) generated by `make'. By tradition, that is accomplished by `make install', but that would install the files on the root of the file system, making it impossible to create the package. Instead, what we do is fake the path and install on a different directory that we shall create for this: Package's temporary directory:
#m k d i rp/ t m p / s o u r c e s / p a c k a g e f o o

Now we install the application:


#m a k ei n s t a l lD E S T D I R = / t m p / s o u r c e s / p a c k a g e f o o

Enter the directory and list the files to see the resulting structure:
#c d/ t m p / s o u r c e s / p a c k a g e f o o #l sl

Aditional steps
Removing debugging information in binaries: Removing this information might be useful because we would obtain a leaner binary. Identify in which directories are the binaries. The `strip' command is going to help us with this:
#s t r i ps t r i p u n n e e d e du s r / b i n / *u s r / l i b / * . s o *

An implementation by Matias A. Fonzo that uses scalable awk and combines `find', `file', `cut' and `strip' to scan files removing debugging symbols, from programs and libraries:
www.dragora.org/en/files/2x/makepkg.html 4/8

7/29/13

Dragora

#f i n d.t y p ef|x a r g sf i l e|a w k' / E L F /& &/ e x e c u t a b l e /| |/ s h a r e do b j e c t / '|\ c u tf1d:|x a r g ss t r i ps t r i p u n n e e d e d

GNU information documents: We remove a redundancy:


#r mfu s r / i n f o / d i r

We compress with the best compression method (-9), maintaining the original date and time of the files:
#g z i p9 Nu s r / i n f o / *

Man pages:
#g z i p9 Nu s r / m a n / * / * . ?

The info documents and the man pages are only a part of the documentation of the program. It is important to identify and include the rest of the documentation: Creating the directory to copy the documents to
#m k d i rpu s r / d o c / f o o 1 . 2 . 3

We enter the directory and we decompress the source to copy the documents to the directory of the future package:
#c paA U T H O R SC O P Y I N GR E A D M ET O D OF A Q/ t m p / s o u r c e s / p a c k a g e f o o / u s r / d o c / f o o 1 . 2 . 3

The -a flag of `cp' keeps the date and time of the latest modification of the files. The description file: By default Dragora provides two description files: en and es. Each prefix corresponds to a language, in this case: English / Spanish. The next step is creating the "description" directory where the description file will be saved:

www.dragora.org/en/files/2x/makepkg.html

5/8

7/29/13

Dragora

#c d/ t m p / s o u r c e s / p a c k a g e f o o #m k d i rd e s c r i p t i o n

Using a text editor, we create the file that will contain the description of the program. For example, for the description in English:
#m o ed e s c r i p t i o n / e n

The file is composed as:


p r o g r a m _ n a m e-B r i e fd e s c r i p t i o n . D e s c r i p t i o n . < n e wl i n e >

An example looks like:


u d e v-D y n a m i cd e v i c em a n a g e m e n t . U d e vi st h ed e v i c em a n a g e rf o rt h eL i n u x2 . 6k e r n e ls e r i e s . I t sp r i m a r yf u n c t i o ni sm a n a g i n gd e v i c en o d e si n/ d e v . I ti st h es u c c e s s o ro fd e v f sa n dh o t p l u g ,w h i c hm e a n st h a t i th a n d l e st h e/ d e vd i r e c t o r ya n da l lu s e rs p a c ea c t i o n s w h e na d d i n g / r e m o v i n gd e v i c e s ,i n c l u d i n gf i r m w a r el o a d .

Building the package


From within the temporary directory of the package we type:
#m a k e p k gl/ t m p / f o o 1 . 2 . 3 i 4 8 6 1 . t l z

The -l flag in `makepkg' is an indication to include the post-install file (post-install/post-install) the links found may or may not be present and may be created at the time of installing the package.
www.dragora.org/en/files/2x/makepkg.html 6/8

7/29/13

Dragora

/tmp is used by convention for the target path of "foo-1.2.3-i486-1.tlz". ".tlz" is the extension that the package gets. Since the changes for Dragora 1.1, a new feature was introduced to use lzip as the default format for the package system. lzip uses the LZMA compression algorithm providing a higher compression rate than bzip2. You can find more information regarding lzip visiting http://www.nongnu.org/lzip/lzip.html

Package naming scheme


Let's analyze how to name a package: name-version-architecture-build.extension Section name version The application's name The version of the program It represents the build number. If in the future you modify the package adding any significant change then you increment the build number Extension supported by `makepkg'. Description

architecture The architecture of the program. It might not be required to specify it, in which case it is noarch. build extension

Example: foo-1.2.3-i486-1.tlz Try to keep the name lower-case.

Summary of the steps


1 .t a rx v ff o o 1 . 2 . 3 . t a r . g z 2 .c df o o 1 . 2 . 3 3 .c h o w nR0 : 0. 4 .c h m o dRu + w , g o w , a + r X s. 5 .. / c o n f i g u r ep r e f i x = / u s rs y s c o n f d i r = / e t ci n f o d i r = / u s r / i n f om a n d i r = / u s r / m a n
www.dragora.org/en/files/2x/makepkg.html 7/8

7/29/13

Dragora

6 .m a k e 7 .m k d i rp/ t m p / s o u r c e s / p a c k a g e f o o 8 .m a k ei n s t a l lD E S T D I R = / t m p / s o u r c e s / p a c k a g e f o o 9 .c d/ t m p / s o u r c e s / p a c k a g e f o o 1 0 .l sl 1 1 .s t r i ps t r i p u n n e e d e du s r / b i n / *u s r / l i b / * . s o * 1 2 .r mfu s r / i n f o / d i r 1 3 .g z i p9 Nu s r / i n f o / * 1 4 .g z i p9 Nu s r / m a n / * / * . ? 1 5 .m k d i rpu s r / d o c / f o o 1 . 2 . 3 1 6 .c d/ d i r e c t o r y w h e r e s o u r c e w a s d e c o m p r e s s e d / f o o 1 . 2 . 3 1 7 .c paA U T H O R SC O P Y I N GR E A D M ET O D OF A Q/ t m p / s o u r c e s / p a c k a g e f o o / u s r / d o c / f o o 1 . 2 . 3 1 8 .c d/ t m p / s o u r c e s / p a c k a g e f o o 1 9 .m k d i rd e s c r i p t i o n 2 0 .m o ed e s c r i p t i o n / e n 2 1 .m a k e p k gl/ t m p / f o o 1 . 2 . 3 i 4 8 6 1 . t l z

All the steps are executed by the super user (system's administrator).

Final notes
It is worth noting that the flags explained here and the steps followed in this guide are a general explanation and they may or may not be present. It would depend on the sources you are dealing with since some do not have info files or man pages or configuration files, etc. Thus, it is the decision of the user how to handle those things. 11 June 2013, 16:37 | (GNU Free Documentation License | Validate HTML)

www.dragora.org/en/files/2x/makepkg.html

8/8

You might also like