Recent

Author Topic: Creating .deb packages for Lazarus applications?  (Read 13482 times)

vrull

  • Full Member
  • ***
  • Posts: 111
Creating .deb packages for Lazarus applications?
« on: February 20, 2008, 01:46:50 am »
Does anybody have any experience in making Debian packages for Lazarus programs?

I read some tutorial about the topic I found in the Internet, but seems it related somehow to C++ and its folder structure. Would be nice if someone explained, how to make proper binary and source .deb packages.

Another option is to point to the existing package for Lazarus app, so I could examine how it works and what it contains.

Thank you in advance.

Almindor

  • Sr. Member
  • ****
  • Posts: 411
    • http://www.astarot.tk
RE: Creating .deb packages for Lazarus applications?
« Reply #1 on: February 20, 2008, 11:04:54 am »
You will not be able to make -src packages for fpc/lazarus programs easily. I usually just reverse-engineer binary .deb packages of "similar sized,styled" packages and change the CONTROL file and data accordingly.

It's relatively easy. You first use dpkg to unpack the original .deb package, and then put your data into "packname/usr/..." as you need them. Then you create a new md5sums file (use find with md5sum) and put it in "packname/DEBIAN/" (overriding the old one). Lastly you need to find out the size of the data dir (use du -c packname/usr) and change the "packname/DEBIAN/CONTROL" file accordingly (package data size, dependencies, package name, version etc.)

It sounds complicated but is actually easier than setting up a -src based building. Once you got it done once it's easy to update. The only downside is that your packages won't be elligable to be included in official debian/ubuntu etc.

vrull

  • Full Member
  • ***
  • Posts: 111
Creating .deb packages for Lazarus applications?
« Reply #2 on: February 20, 2008, 11:15:46 pm »
Thank you! Will try.

vrull

  • Full Member
  • ***
  • Posts: 111
Here is my steps:
« Reply #3 on: February 27, 2008, 04:26:35 am »
The explanation below is based on my experience in making my first debian package. I use the name of my package, you should change it appropriately. You need a terminal window open and your favourite file manager, I used Nautilus. When I say "current folder", that means the current folder in the terminal.

1. make a folder with any name you like, for example as your intended package will have, say
gpfind-0.1

2. create a folder tree inside this folder, representing the part of Linux directory structure, like
usr
usr/bin - here is place of the executable file(s) (recommended) or it might be usr/local/bin
usr/share
usr/share/applications - the gpfind.desktop file is here (or usr/local/share/applications - see below how to make it)
usr/share/doc
usr/share/doc/gpfind - the place for your documentation, like README, LICENCE, copyright, changelog.gz and help files
usr/share/pixmaps - your program's icon
usr/share/gpfind - other files,if any, used internally by gpfind (the program cannot modify them while working)

Debian Policy Manual also requires a man file for every executable, but so far I have no idea, how to create man pages

3. put all necessary files to the appropriate folders in the above tree

4. make a text file, called gpfind.desktop inside usr/share/applications
Its contents should be like this:

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=Gnome Package Finder
Categories=Application;Utility;
Exec=gpfind
Hidden=false
Icon=gpfind.png
Terminal=false
Type=Application

This file is necessary, if you want your program appeared in the Application menu under Accessories category, you may change the category, obviously. Note: Version=1.0 is NOT your program's version.

5. create a folder called DEBIAN inside the package folder (gpfind-0.1)

6. create a text file, called "control" (without quotes) inside the above folder and fill it in with the following information (my comments are in [square brackets]) :

Package: gpfind [without version number]
Version: 0.1.1  [put your version here]
Section: utils  [put the appropriate section here]
Priority: optional [most likely]
Architecture: i386
Depends: libgtk2.0-0 (>= 2.0), libgtk2.0-bin (>= 2.0), apt, apt-file
Installed-Size: 832 [in kilobytes, see below how to get it]
Maintainer: Victor Rull <victorrull@gmail.com>
Description: Debian Package finder for Gnome [Short description in one line]
 A GUI wrapper for apt-cache and apt-file commands, [Long description, may contain many lines]
 allowing quick search for debian packages and files inside packages.
 .
 gpfind is pretty fast and does not require root privileges.
 It shows common package information, its dependencies and list of files.

[more fields can be added, if you know their meanings]

See Debian Policy Manual for details:
http://www.debian.org/doc/debian-policy/ch-binary.html

7. to calculate the size of installed files use the following command, assuming that the package folder is your current directory:
du -ac --apparent-size --block-size=1024 usr

The last line of its output looks like this
832   total
and this is what you need - write it down to the "control" file, the field Installed-Size.

8. Calculate md5 sums of all files and save them into the file, called "md5sums" (without quotes) and located in DEBIAN folder.
I struggled to find the appropriate command for this and eventually found an excellent Nautilus script, which makes the trick (thanks to ofir):
http://www.gnome-look.org/content/show.php/show.php?content=69749&vote=good&tan=7008025

md5sums should look like this:

cba62c9c10d006d8d9123de47bb11b0d  usr/local/bin/gpfind
93bfdba24a19f2f7836e8b6ef17d82bb  usr/share/doc/gpfind/copyright
6215b995598a1b77094f1f8d5984d2ed  usr/share/doc/gpfind/gpfind.html
6b743ba6c790f3814d29d3e04ce0b400  usr/share/doc/gpfind/changelog.gz
377bffff1eee0a330e8cbdf8e629f186  usr/share/pixmaps/gpfind.png

9. make sure you removed all backup files (they may be hidden) from your working folders.

10. change the current folder to its parent (cd ..), right above your package folder.

11. type the command:

fakeroot dpkg --build gpfind-0.1 gpfind-0.1.1-i386.deb

If all the above steps were correct, this creates a new package, called gpfind-0.1.1-i386.deb in your current folder.

12. check, what you've got:

linda gpfind-0.1.1-i386.deb

"Linda is a Debian package checker, much like lintian, that runs some rudimentary checks over source and binary packages to see, if they comply to Policy" (extracted from linda's package long description).

13. TODO
  a. removing configuration files, when your package is being uninstalled

Sources:
http://tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO/
http://www.debian.org/doc/debian-policy/index.html#contents
the above post

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 918
    • Burdjia
RE: Here is my steps:
« Reply #4 on: March 03, 2008, 01:43:22 pm »
vrull: Thanks. I must remember this.
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

Bandbaz

  • New Member
  • *
  • Posts: 40
Re: Creating .deb packages for Lazarus applications?
« Reply #5 on: September 15, 2011, 01:50:04 pm »
Thanks

Quote
Depends: libgtk2.0-0 (>= 2.0), libgtk2.0-bin (>= 2.0), apt, apt-file

How you find Dependencies?
Is it always the same for Lazarus applications?

This link is also very useful to get professional on it and making high quality packages:
http://www.debian.org/doc/maint-guide/

Troodon

  • Sr. Member
  • ****
  • Posts: 484
Re: Creating .deb packages for Lazarus applications?
« Reply #6 on: September 15, 2011, 04:58:33 pm »
How you find Dependencies?
Is it always the same for Lazarus applications?

Not necessarily, it depends on the libraries that your application uses. Finding the dependencies is not obvious and creating a .deb package "the Debian way" is (I would say) unnecessarily complicated, particularly if all you need is to package some binaries and data files for distribution. Unless you can find a good tutorial on the Web, I will explain this soon, perhaps next month. Writing that book takes longer than I thought... ;)
« Last Edit: September 15, 2011, 08:10:36 pm by Troodon »
Lazarus/FPC on Linux

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Creating .deb packages for Lazarus applications?
« Reply #7 on: September 15, 2011, 05:04:13 pm »
How you find Dependencies?

If you wrote the application, you should know. It is any LCL dependencies + anything you added yourself.

It also depends on the LCL widgetset which you are using. For LCL-Gtk2 you should depend on .... gtk2, gdk2 and cairo (no idea about the exact Debian package names)

You can use the command line tool ldd to find all libraries which your app uses, but note that almost all of them are added by gtk2, so you can simply depend on just gtk2 most of the time.

Bandbaz

  • New Member
  • *
  • Posts: 40
Re: Creating .deb packages for Lazarus applications?
« Reply #8 on: September 16, 2011, 12:24:19 am »
Quote
If you wrote the application, you should know.

well.. I wrote the application, but I just know which units I used in uses parts!  %)
if everything is in gtk2, it should be libgtk2.0-0 debian package. but how can I be sure?

ldd gives me a long list of .so files. not the name of packages.
I can search one by one in debian website (packages.debian.org) and see which package it belongs to.
but is this really the right way?

flames

  • New member
  • *
  • Posts: 5
Re: Creating .deb packages for Lazarus applications?
« Reply #9 on: September 16, 2011, 03:28:36 am »
ldd output:

Code: [Select]
linux-gate.so.1 =>  (0x006ad000)
libpthread.so.0 => /lib/libpthread.so.0 (0x4e351000)
libdl.so.2 => /lib/libdl.so.2 (0x4e36d000)
libX11.so.6 => /usr/lib/libX11.so.6 (0x4e6cc000)
libgdk_pixbuf-2.0.so.0 => /usr/lib/libgdk_pixbuf-2.0.so.0 (0x41ad2000)
libgtk-x11-2.0.so.0 => /usr/lib/libgtk-x11-2.0.so.0 (0x42310000)
libgdk-x11-2.0.so.0 => /usr/lib/libgdk-x11-2.0.so.0 (0x428ea000)
libgobject-2.0.so.0 => /lib/libgobject-2.0.so.0 (0x41c4f000)
libglib-2.0.so.0 => /lib/libglib-2.0.so.0 (0x4e403000)
libgthread-2.0.so.0 => /lib/libgthread-2.0.so.0 (0x4e51e000)
libgmodule-2.0.so.0 => /lib/libgmodule-2.0.so.0 (0x4e591000)
libpango-1.0.so.0 => /usr/lib/libpango-1.0.so.0 (0x41d5d000)
libatk-1.0.so.0 => /usr/lib/libatk-1.0.so.0 (0x41da8000)
libcairo.so.2 => /usr/lib/libcairo.so.2 (0x4eaf5000)
libc.so.6 => /lib/libc.so.6 (0x4e1c3000)
/lib/ld-linux.so.2 (0x4e1a2000)
libxcb.so.1 => /usr/lib/libxcb.so.1 (0x4e807000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x4e3c3000)
libgio-2.0.so.0 => /lib/libgio-2.0.so.0 (0x427ba000)
librt.so.1 => /lib/librt.so.1 (0x4e374000)
libpng12.so.0 => /usr/lib/libpng12.so.0 (0x4e864000)
libm.so.6 => /lib/libm.so.6 (0x4e37f000)
libpangocairo-1.0.so.0 => /usr/lib/libpangocairo-1.0.so.0 (0x42110000)
libXfixes.so.3 => /usr/lib/libXfixes.so.3 (0x4eae0000)
libpangoft2-1.0.so.0 => /usr/lib/libpangoft2-1.0.so.0 (0x420e1000)
libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x4e948000)
libXext.so.6 => /usr/lib/libXext.so.6 (0x4e851000)
libXrender.so.1 => /usr/lib/libXrender.so.1 (0x4e93c000)
libXinerama.so.1 => /usr/lib/libXinerama.so.1 (0x4e9dc000)
libXi.so.6 => /usr/lib/libXi.so.6 (0x41c9f000)
libXrandr.so.2 => /usr/lib/libXrandr.so.2 (0x4eaa9000)
libXcursor.so.1 => /usr/lib/libXcursor.so.1 (0x4ead4000)
libXcomposite.so.1 => /usr/lib/libXcomposite.so.1 (0x4e9d7000)
libXdamage.so.1 => /usr/lib/libXdamage.so.1 (0x4e9d2000)
libpixman-1.so.0 => /usr/lib/libpixman-1.so.0 (0x4ea2c000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x4e88f000)
libz.so.1 => /lib/libz.so.1 (0x4e3ab000)
libXau.so.6 => /usr/lib/libXau.so.6 (0x4e6c7000)
libresolv.so.2 => /lib/libresolv.so.2 (0x4e525000)
libselinux.so.1 => /lib/libselinux.so.1 (0x4e3e2000)
libexpat.so.1 => /lib/libexpat.so.1 (0x4e827000)

I would add following to Depends:
Code: [Select]
libc6, libgdk-pixbuf2.0-0, libglib2.0-0, libgtk2.0-0, libatk1.0-0, libcairo2, libfreetype6, libpango1.0-0, libssl0.9.8

This app. uses synapse  "openssl_lib" unit for optional SSL, so i know i need to add "libssl0.9.8" to "Depends" or "Recommends" aswell.

You can add more or less, most packages are likely to be already present on the system, because they are common.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Creating .deb packages for Lazarus applications?
« Reply #10 on: September 16, 2011, 07:16:04 am »
You can add more or less, most packages are likely to be already present on the system, because they are common.
Thanks flames for the clear and helpful post, but adding "less" because packages are probably already present on a system seems a bit... optimistic to me.
If you switch from, say, Ubuntu to Debian, the list of default installed packages will change (probably decrease in this case), and it never hurts to explicitly state dependencies, I think...
Also, the user will get in trouble if deinstalling the last application that makes use of a shared lib/trimming stuff

After all, if a lot of the required dependencies are already installed on your system, the package manager will just have less to do  :)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Bandbaz

  • New Member
  • *
  • Posts: 40
Re: Creating .deb packages for Lazarus applications?
« Reply #11 on: September 16, 2011, 08:44:33 am »
Thanks   :)