Lazarus

Programming => Operating Systems => Linux => Topic started by: vrull on February 20, 2008, 01:46:50 am

Title: Creating .deb packages for Lazarus applications?
Post by: vrull 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.
Title: RE: Creating .deb packages for Lazarus applications?
Post by: Almindor 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.
Title: Creating .deb packages for Lazarus applications?
Post by: vrull on February 20, 2008, 11:15:46 pm
Thank you! Will try.
Title: Here is my steps:
Post by: vrull 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
Title: RE: Here is my steps:
Post by: Ñuño_Martínez on March 03, 2008, 01:43:22 pm
vrull: Thanks. I must remember this.
Title: Re: Creating .deb packages for Lazarus applications?
Post by: Bandbaz 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/
Title: Re: Creating .deb packages for Lazarus applications?
Post by: Troodon 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... ;)
Title: Re: Creating .deb packages for Lazarus applications?
Post by: felipemdc 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.
Title: Re: Creating .deb packages for Lazarus applications?
Post by: Bandbaz 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?
Title: Re: Creating .deb packages for Lazarus applications?
Post by: flames 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.
Title: Re: Creating .deb packages for Lazarus applications?
Post by: BigChimp 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  :)
Title: Re: Creating .deb packages for Lazarus applications?
Post by: Bandbaz on September 16, 2011, 08:44:33 am
Thanks   :)
Title: Re: Creating .deb packages for Lazarus applications?
Post by: circular on May 19, 2020, 09:45:44 am
Here's how to determine som fields in the control file.

Architecture
If you build your application using the current architecture, you can get the architecture with the command:
Code: [Select]
dpkg --print-architecture
Which gives for example:
Code: [Select]
amd64
Depends
To get full field, i.e. the libraries and their minimal versions, you can use dpkg-shlibdeps command.

For it to work properly, you need to have a subdirectory called debian and inside it a control file. Note that this file can be completely empty. To set it up you can do for example:
Code: [Select]
mkdir debian
touch debian/control

Then determine dependencies with (here assuming the binary file is called project1):
Code: [Select]
dpkg-shlibdeps -O project1
It will display, for a simple application with just one window and a label, a few warnings and:
Code: [Select]
shlibs:Depends=libatk1.0-0 (>= 1.12.4), libc6 (>= 2.2.5), libcairo2 (>= 1.2.4), libgdk-pixbuf2.0-0 (>= 2.22.0), libglib2.0-0 (>= 2.12.0), libgtk2.0-0 (>= 2.24.0), libpango-1.0-0 (>= 1.18.0), libx11-6
So that would give the following fields in the control file:
Code: [Select]
Architecture: amd64
Depends: libatk1.0-0 (>= 1.12.4), libc6 (>= 2.2.5), libcairo2 (>= 1.2.4), libgdk-pixbuf2.0-0 (>= 2.22.0), libglib2.0-0 (>= 2.12.0), libgtk2.0-0 (>= 2.24.0), libpango-1.0-0 (>= 1.18.0), libx11-6
Title: Re: Creating .deb packages for Lazarus applications?
Post by: circular on May 19, 2020, 11:33:54 am
Here is a more general documentation I just wrote:
https://wiki.freepascal.org/Debian_package_structure

Also found two programs to make Debian packages. I haven't tested them.
https://github.com/prof7bit/LazPackager
https://forum.lazarus.freepascal.org/index.php/topic,30302.msg192746.html
Title: Re: Creating .deb packages for Lazarus applications?
Post by: Ñuño_Martínez on May 20, 2020, 11:42:02 am
Great.  Thank-you (again).
Title: Re: Creating .deb packages for Lazarus applications?
Post by: circular on May 20, 2020, 12:07:46 pm
You're welcome.  :)

As I have spent sometime struggling with those, I would prefer others not to have to go through that.
Title: Re: Creating .deb packages for Lazarus applications?
Post by: dbannon on May 20, 2020, 02:43:36 pm
You might like to look through this script, its very specific for my project, I build 32bit and 64bit linux and windows binaries and then make debs (and a few other packages as well).

https://github.com/tomboy-notes/tomboy-ng/blob/master/package/package.bash

Davo
Title: Re: Creating .deb packages for Lazarus applications?
Post by: circular on May 20, 2020, 09:36:42 pm
Interesting.

I learnt about the icon folders  :)
/usr/share/icons/hicolor/*/apps

If I understand correctly you add the files:
/usr/share/locale/*/LC_MESSAGES/lclstrconsts.mo
Wouldn't that may cause an interference with another program doing the same? When removing the other program, wouldn't that remove this file as well?

The Installed-Size seems to be fixed to 4096. Instead, you could compute it when all files are ready to be archived:
Code: [Select]
SIZE_IN_KB="$(du -s ${STAGING_DIR} | awk '{print $1;}')"
echo "Installed-Size: ${SIZE_IN_KB}" >> "${STAGING_DIR}/DEBIAN/control"
Title: Re: Creating .deb packages for Lazarus applications?
Post by: Gizmo on May 20, 2020, 11:00:56 pm
Also this (it used to deb package one of my tools)

https://github.com/darealshinji/debian-packaging
Title: Re: Creating .deb packages for Lazarus applications?
Post by: dbannon on May 21, 2020, 01:39:38 am
If I understand correctly you add the files:
/usr/share/locale/*/LC_MESSAGES/lclstrconsts.mo
Wouldn't that may cause an interference with another program doing the same? When removing the other program, wouldn't that remove this file as well?
Possibly, but the lclstrconsts.mo does not change with your application, its the same file for every application you make on one version of Lazarus, it may change in small ways between versions. I have not yet come across an end user with more than one Lazarus app installed - thats sad !
The Installed-Size seems to be fixed to 4096. Instead, you could compute it when all files are ready to be archived:
Code: [Select]
SIZE_IN_KB="$(du -s ${STAGING_DIR} | awk '{print $1;}')"
echo "Installed-Size: ${SIZE_IN_KB}" >> "${STAGING_DIR}/DEBIAN/control"
Indeed you are right. I put 4096 in because, when I started, my app was less than this, it has grown since then so its certainly wrong now !

Good hint !

Davo
Title: Re: Creating .deb packages for Lazarus applications?
Post by: circular on May 21, 2020, 10:23:42 am
Indeed there are not many installed Lazarus applications. To be fair, just making the Deb is a challenge.

You're welcome for the tip. Long live to peer review.
Title: Re: Creating .deb packages for Lazarus applications?
Post by: maurobio on May 27, 2020, 09:54:33 pm
Dear ALL,

I have been struggling with this for months now (https://forum.lazarus.freepascal.org/index.php?topic=48398.new;topicseen (https://forum.lazarus.freepascal.org/index.php?topic=48398.new;topicseen)), without much progress so far.

But this does not lead me to conclude that there is no way to achieve the goal of creating a fully working Debian package for a Lazarus application which can be installed in any Linux distribution (or at least on those based on the Debian system). There are indeed some excellent programs written in Lazarus (all of which I heavily use under both Linux and Windows) that are distributed in binary form as Debian packages, for example:

SkyChart: https://www.ap-i.net/skychart//pt/start (https://www.ap-i.net/skychart//pt/start)
DoubleCommander: https://doublecmd.sourceforge.io (https://doublecmd.sourceforge.io)
GreenFish Icon Editor: http://greenfishsoftware.org/gfie.php (http://greenfishsoftware.org/gfie.php)

It seems that at the heart of the matter is the question of finding all the correct dependencies of the binary, but unfortunately the output of either ldd or elf is not entirely helpful because is not obvious how to relate the names of the .so libraries to the real names of the packages which should be provided when creating the package. So, for example, this wiki page (https://wiki.freepascal.org/Deploying_Your_Application#Linux_Deployment (https://wiki.freepascal.org/Deploying_Your_Application#Linux_Deployment)) lists the "packages required for an very basic GUI Application in GTK+", but does not explain how to correlate those names with the names listed in the ldd output.

Once the dependencies are correctly found, a nice program like Debreate (https://antumdeluge.github.io/debreate-web/ (https://antumdeluge.github.io/debreate-web/)) could be used to create a Debian package under Linux as easily as Inno Setup (http://www.jrsoftware.org/isinfo.php (http://www.jrsoftware.org/isinfo.php)) is used to create binary installation packages for Windows.

As has already been mentioned, LazPackager (https://github.com/prof7bit/LazPackager (https://github.com/prof7bit/LazPackager)) can offer a good alternative for creating Debian packages for Lazarus applications - but do someone here has any experience using it? I have not been able to even install it, because it is a "Lazarus plugin (a package that you can install in your IDE)" and I could not found how to install such plugins (which do not seem to be installed in the same way as usual LCL packages).

Comments and suggestions are welcome!

With best wishes,
Title: Re: Creating .deb packages for Lazarus applications?
Post by: dbannon on May 28, 2020, 02:44:25 am
Maurobio, I release a new version of tomboy-ng every one to two months. Each release builds a 32bit and 64bit deb file and I subsequently make rpm files from them.  Once setup, its trivial. Scripts in my git repo.

Getting dependencies right is certainly necessary but not really that hard, you definitely need either the GTK2 or Qt5 libraries but there is a 'catch all' for both. Almost always works.  (I say 'almost' because in Ubuntu19.04 there was, apparently ?? a module left out that was necessary for a GTK2 app to communicate via the dbus approach that GtK3 likes  :( )

* QT5 - libqt5pas1, libc6 (>= 2.14), wmctrl
* Gtk2 - libgtk2.0-0 (>= 2.6), libc6 (>= 2.14), libcanberra-gtk-module, wmctrl

Note I add in wmctrl because I use it to bring forms to the active workspace and, with Gtk2, I include libcanberra-gtk-module because having it there suppresses otherwise harmless Gtk assertions. And, lib6 is pretty obvious.

If your app uses other, specialized libraries, I guess you would be aware of them when using them so should be easy to add them to the list.  If you are still missing libraries, and that would be surprising, run your binary on a newly installed VM and note the error messages !

Davo

Title: Re: Creating .deb packages for Lazarus applications?
Post by: circular on May 28, 2020, 11:38:34 am
@maurobio:

I explained there how to get the dependencies:
https://forum.lazarus.freepascal.org/index.php/topic,5032.msg362817.html#msg362817
https://wiki.freepascal.org/Debian_package_structure#DEBIAN_directory
Title: Re: Creating .deb packages for Lazarus applications?
Post by: maurobio on May 28, 2020, 01:11:28 pm
Hi, @dbannon, @circular!

Thanks for your suggestions.

I had already found @dbannon script, but I still prefer a more user-friendly tool like Debreate (in which case my real need is getting the correct list of dependencies).

The method provided by @circular for finding the dependencies is new to me (it looks like everyone just keep suggesting the use of either ldd or elf, which are not that helpful). I'll try it!

With best wishes,
Title: Re: Creating .deb packages for Lazarus applications?
Post by: dbannon on May 28, 2020, 01:52:15 pm
.....
The method provided by @circular for finding the dependencies is new to me (it looks like everyone just keep suggesting the use of either ldd or elf, which are not that helpful). I'll try it!

And the method described by circular is the official debian model, and a good one. But you must keep in mind that, for example, when it recommends we need -
Code: [Select]
shlibs:Depends=libatk1.0-0 (>= 1.12.4), libc6 (>= 2.2.5), libcairo2 (>= 1.2.4), libgdk-pixbuf2.0-0 (>= 2.22.0), libglib2.0-0 (>= 2.12.0), libgtk2.0-0 (>= 2.24.0), libpango-1.0-0 (>= 1.18.0), libx11-6
all the packages listed (except libgtk2.0-0) are, themselves dependencies of libgtk2.0-0.  And, given that gtk2 is pretty stable and has been so for some years, the version is quite unlikely to be an issue.  That rosie picture does not apply to Qt5, most, but not all systems around now have a suitable version of Qt5. See https://github.com/davidbannon/libqt5pas

Davo

Title: Re: Creating .deb packages for Lazarus applications?
Post by: circular on November 01, 2020, 04:04:20 pm
Here is a guide on how to make an upstream source for Debian:
https://wiki.freepascal.org/Debian_upstream

In principle, it is possible just to supply the source with the Makefile and request that someone would make the packaging for Debian distributions.
Title: Re: Creating .deb packages for Lazarus applications?
Post by: dbannon on November 02, 2020, 07:47:44 am
Here is a guide on how to make an upstream source for Debian:
https://wiki.freepascal.org/Debian_upstream
Really useful pair of pages Circular, I inteneded to do something similar for some time but, well, you know ! I have added a small section to Debian Package Structure to define the difference between Source and Binary packages. Hope you don't mind.

In principle, it is possible just to supply the source with the Makefile and request that someone would make the packaging for Debian distributions.

Indeed. But as there are far to many people wanting packages added and far too few people willing to do the packaging, I would suggest that what you say is true in principle but not practice.

As someone who has been negotiating with the Debian people for some months now, my advice is firstly, the copyright file is absolutely critical. Makes sure every scrap of your code is your own or carefully attributed to someone else who has stamped it with an acceptable license.  Its no use saying "'someone' posted a bit of code on the forum and they said I could use it".

Secondly, be prepared for some pushback about the way we do things here in the FreePascal world, what we consider perfectly sensible is not the way a C programmer does it and it makes them feel uncomfortable. While they are all very helpful, they have rules and processes that are not the way we think.

But keep at it ! The more FreePascal code in the Debian archives, the more they will take us seriously.

Davo

Title: Re: Creating .deb packages for Lazarus applications?
Post by: circular on November 02, 2020, 03:53:56 pm
Thanks for your input.

I have moved some of your text, because I have already created a Debian package source:
article:
https://wiki.freepascal.org/Debian_package_source

I have added that in practice one has to do its own source package.

What remains to write I suppose is how to use debuild or pbuilder with it.
Title: Re: Creating .deb packages for Lazarus applications?
Post by: dbannon on November 02, 2020, 11:24:39 pm
I use debuild, with that I can make a src package acceptable to Ubuntu in a PPA, https://launchpad.net/~d-bannon/+archive/ubuntu/ppa-tomboy-ng

 I am working on the legal aspects of Debian, if we can get over that, I hope to use the same model to make Debian SRC packages although I have seen hints they they might prefer pbuilder.

At present my model is that I have a script (prepare.bash) that takes a zip file downloaded from GitHub containg all my source and it builds the directory structure of a debian src package.   Inside that scr package the make file does much of the usual build and install things but to actually compile the Pascal source, it calls another script (buildit.bash) that uses both lazbuild (to build a dependency) and fpc to build the actual app.

Not a simple process !

The  Debian process is quite well documented in very many pages on the Debian website, I suggest that not be duplicated on our wiki. But how that official process needs to be fiddled to work with FPC/Lazarus would be useful indeed. Its a steep learning curve.

Davo
Title: Re: Creating .deb packages for Lazarus applications?
Post by: circular on November 03, 2020, 08:52:00 am
I use debuild, with that I can make a src package acceptable to Ubuntu in a PPA, https://launchpad.net/~d-bannon/+archive/ubuntu/ppa-tomboy-ng

 I am working on the legal aspects of Debian, if we can get over that, I hope to use the same model to make Debian SRC packages although I have seen hints they they might prefer pbuilder.
In fact, the main difference is that pbuilder does not assume that you have the packages installed on your system. So it can be useful to check that you have all the dependencies defined in control file. Apart from that, it seems debuild is fine and it is faster when building things over and over again.

Quote
At present my model is that I have a script (prepare.bash) that takes a zip file downloaded from GitHub containg all my source and it builds the directory structure of a debian src package.   Inside that scr package the make file does much of the usual build and install things but to actually compile the Pascal source, it calls another script (buildit.bash) that uses both lazbuild (to build a dependency) and fpc to build the actual app.

Not a simple process !
Yeah. Well as far as I understand it, whether it is a script or not, you need to provide a repository with all files necessary to build. Apparently they prefer it to be on https://salsa.debian.org. You can include the debian folder, so that (p)debuild can be run on top of it. You can use fpc and lazbuild as long as you add the build dependencies (fpc, lcl, lazarus and libqt5pas-dev).

After that, I am still a bit confused but I guess the next step is to sign the package with debsign, add your pgp key to https://mentors.debian.org and upload the generated files with dput command. You may discover new problems at this point and once you solved most of them, you need to get the attention of a Debian uploader.

Quote
The  Debian process is quite well documented in very many pages on the Debian website, I suggest that not be duplicated on our wiki. But how that official process needs to be fiddled to work with FPC/Lazarus would be useful indeed. Its a steep learning curve.
Well there is a lot of documentation, but it is not obvious to find what you are looking for. Also it is indeed not adapted to FreePascal. But yeah, it is better to make links to Debian documentation when possible.
Title: Re: Creating .deb packages for Lazarus applications?
Post by: devEric69 on November 12, 2020, 06:11:42 pm
But you must keep in mind that, for example, when it recommends we need
Code: [Select]
shlibs:Depends=libatk1.0-0 (>= 1.12.4), libc6 (>= 2.2.5), libcairo2 (>= 1.2.4), libgdk-pixbuf2.0-0 (>= 2.22.0), libglib2.0-0 (>= 2.12.0), libgtk2.0-0 (>= 2.24.0), libpango-1.0-0 (>= 1.18.0), libx11-6all the packages listed (except libgtk2.0-0) are, themselves dependencies of libgtk2.0-0.

@dbannon:

I've tried to redemonstrate your conclusions, with a Bash script, but I can't do it.
When I run the script below...

Code: Bash  [Select][+][-]
  1. ldd myAppli | awk '/=>/{print $(NF-1)}' | while read n; do dpkg -S $n; done | awk '{print $1}' | sed 's/:amd64://' | sort | uniq | while read n; do echo "------------> usefullness of package named *$n*...:"; apt-cache search ^$n; echo "...which installs the following files on the system:"; dpkg -L $n; echo "...and depends itself on the following packages on the system:"; apt-cache rdepends $n; done;

...it informs me that the libgtk2.0-0 package installs its own libraries, and depends on other packages. But I can't show that the installation of libgtk2.0-0 also installs (though dependencies?) libpango, libatk1, libpango, ...

How do you come to your conclusions?
Title: Re: Creating .deb packages for Lazarus applications?
Post by: dbannon on November 13, 2020, 04:39:54 am
How do you come to your conclusions?


* You need a clean distro that has not got gtk2 already, then install gtk2 and see what extra packages are listed as about to be installed.   For a while, Cannonical was shipping Ubuntu without gtk2 but they seem to have reversed that recently.

* Use synaptic, search for libgtk2.0-0 and right click, under properties the dependencies are displayed.

* Apt command ? apt-rdepends from memory.

Davo



Title: Re: Creating .deb packages for Lazarus applications?
Post by: lucamar on November 13, 2020, 05:31:20 am
* Apt command ? apt-rdepends from memory.

apt show libgtk2.0-0 will do it; or, if apt is not available (oldish distro), apt-cache showpkg or apt-cache show. Similar commands for aptitude will serve too.

Note that apt-cache showpkg will show first the reverse dependencies (packages which depend on libgtk2), quite a looong list; just ignore it and look only for the "normal" dependencies (packages on which libgtk2 depends).
Title: Re: Creating .deb packages for Lazarus applications?
Post by: circular on November 13, 2020, 09:34:08 am
Not sure why you would need to know all the dependencies. If you specify that you need gtk2, then all the rest will be installed. Or did I miss something?
Title: Re: Creating .deb packages for Lazarus applications?
Post by: devEric69 on November 13, 2020, 09:53:43 am
* You need a clean distro that has not got gtk2 already, then install gtk2 and see what extra packages are listed as about to be installed.
* Apt command ? apt-rdepends from memory.
Thanks for the advice: I'll look in a virtual machine.
In fact, I've already tested with apt-rdepends. But with this command, I didn't get a satisfactory result in my Bash script, hence my question.


apt show libgtk2.0-0 will do it;
"apt show" displays the dependencies very well, exactly what I want. I can "redemonstrate" the conclusions of dbannon with my script now:
Code: Bash  [Select][+][-]
  1. ldd myAppli | awk '/=>/{print $(NF-1)}' | while read n; do dpkg -S $n; done | awk '{print $1}' | sed 's/:amd64://' | sort | uniq | while read n; do echo "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --> Usefullness of package named $n*:"; apt-cache search ^$n; echo "...which installs the following libraries on the system:"; dpkg -L $n |grep .so; echo "...and which depends itself on the following packages on the system:"; apt show $n | grep Depends; done;
It returns this:
Code: Pascal  [Select][+][-]
  1. ...\...
  2. [snip]
  3. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --> Usefullness of package named libgtk2.0-0*:
  4. libgtk2.0-0 - GTK graphical user interface library - old version
  5. ...which installs the following libraries on the system:
  6. /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules/im-am-et.so
  7. /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules/im-cedilla.so
  8. /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules/im-cyrillic-translit.so
  9. /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules/im-inuktitut.so
  10. /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules/im-ipa.so
  11. /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules/im-multipress.so
  12. /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules/im-thai.so
  13. /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules/im-ti-er.so
  14. /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules/im-ti-et.so
  15. /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules/im-viqr.so
  16. /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules/im-xim.so
  17. /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/printbackends/libprintbackend-cups.so
  18. /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/printbackends/libprintbackend-file.so
  19. /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/printbackends/libprintbackend-lpr.so
  20. /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/printbackends/libprintbackend-test.so
  21. /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0.2400.32
  22. /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.32
  23. /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0
  24. /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
  25. ...and which depends itself on the following packages on the system:
  26. WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
  27. Depends: libgtk2.0-common, libatk1.0-0 (>= 1.32.0), libc6 (>= 2.29), libcairo2 (>= 1.6.4-6.1), libcups2 (>= 2.3~b6), libfontconfig1 (>= 2.12.6), libgdk-pixbuf2.0-0 (>= 2.22.1), libglib2.0-0 (>= 2.41.1), libpango-1.0-0 (>= 1.28.3), libpangocairo-1.0-0 (>= 1.28.3), libpangoft2-1.0-0 (>= 1.28.3), libx11-6 (>= 2:1.4.99.1), libxcomposite1 (>= 1:0.3-1), libxcursor1 (>> 1.1.2), libxdamage1 (>= 1:1.1), libxext6, libxfixes3, libxi6, libxinerama1, libxrandr2 (>= 2:1.5.0), libxrender1, adwaita-icon-theme | gnome-icon-theme, hicolor-icon-theme, shared-mime-info
  28. ...\...[/snip]


Not sure why you would need to know all the dependencies. If you specify that you need gtk2, then all the rest will be installed. Or did I miss something?
No, you didn't miss anything: I just wanted to automate - in a IT way - the series of commands (ldd, ...) described on the page https://wiki.freepascal.org/Deploying_Your_Application (https://wiki.freepascal.org/Deploying_Your_Application), to cross-check the results with the "official" Debian command dpkg-shlibdeps -O %s explained in https://wiki.freepascal.org/Debian_package_structure (https://wiki.freepascal.org/Debian_package_structure), and retrieve only the really necessary, needed packages.

Thanks a lot!
Title: Re: Creating .deb packages for Lazarus applications?
Post by: dbannon on November 14, 2020, 12:03:32 am
There is also a need to be careful about the difference between -

* The packages a particular package depends on and
* The packages that need to be installed to install a package on one machine at that point in time.

I suspect your script shows you what is missing right now.  Its quite possible you (or someone else) has already installed individual packages that also happen to be on (eg) gtk2.0's list. Obviously, in that case, they won't be reinstalled.

If you were to get really silly, you could argue that gtk2.0 depends on the kernel.....

And also remember that when you install something like gtk2.0 on an otherwise minimal system, it will install a lot of packages that your gtk2.0 app will not, in fact ever use.  But it is convenient to bundle a superset under the name gtk2.0

Davo 
Title: Re: Creating .deb packages for Lazarus applications?
Post by: devEric69 on November 19, 2020, 05:54:33 pm
Help!

I encounter a problem, with the user's /home directory (the /home directory of the user who is installing the package), creating a Debian package, with the following scenario:
- a user named user_1 wants to install an application packaged in an the_appli.deb file.
- he starts the installation (of the_appli.deb file).
- the package the_appli.deb is then launched under the user_1 account (no?).
- a dependency is found, and it must be installed (actually, I'm thinking of Firebird). So, the installer will ask you to log in as root in order to fetch and to install Firebird from PPAs.
- the installation continues.
Very good. But, at some point (which? where? how?), I need to install in the directory /home/user_1/.config/the_appli, a file named referential.xml.

Do you know if it's possible to do this, and possibly how to do it properly with a Debian package ( honestly, after researching on the internet, I have the feeling that this is not possible %) )?
Title: Re: Creating .deb packages for Lazarus applications?
Post by: circular on November 19, 2020, 07:34:59 pm
Oh I see. Indeed when you install, you are as root, and so you don't know the user folder.

One way to deal with it though is to install this file as a resource (in /usr/share/the_appli) and when your application starts, to check if the file exists in the .config directory. If not to copy it from the resource directory.
Title: Re: Creating .deb packages for Lazarus applications?
Post by: dbannon on November 19, 2020, 10:30:12 pm
Help!

I encounter a problem, with the user's /home directory (the /home directory of the user who is installing the package), creating a Debian package, with the following scenario:
- a user named user_1 wants to install an application packaged in an the_appli.deb file.
- he starts the installation (of the_appli.deb file).
.....

At this stage, the install should be running as root and if it has dependencies, apt installs them first.  Apt install never makes changes at the user level, if, for example, the user will need some config files or directories created, that should happen when, later, they run the application for the first time.

Don't forget linux/unix is a multiuser system, once installed, an application should be usable by every user, including ones who did not exist when the application was first installed.

Davo
Title: Re: Creating .deb packages for Lazarus applications?
Post by: dbannon on November 20, 2020, 07:38:45 am
Here is a more general documentation I just wrote:
https://wiki.freepascal.org/Debian_package_structure

And thank you, Thank You indeed!

You just solved my lintian "hardening-no-pie" message that has been plaguing me for months !  What a beautiful page !

Davo
Title: Re: Creating .deb packages for Lazarus applications?
Post by: circular on November 20, 2020, 09:22:00 am
I am happy that it is useful to you.  :)

It was suggested to me on mentors if I recall well.
Title: Re: Creating .deb packages for Lazarus applications?
Post by: devEric69 on November 20, 2020, 10:12:03 am
One way to deal with it though is to install this file as a resource (in /usr/share/the_appli) and when your application starts, to check if the file exists in the .config directory. If not to copy it from the resource directory.

Indeed, by rereading https://wiki.freepascal.org/Debian_package_structure (https://wiki.freepascal.org/Debian_package_structure), it is clear and certain that everything which is an external resource, in read-only mode for the application (excluding documentation) such as i18n, external images to link at run-time, and therefore also read-only referential, must be in /usr/share/$(TargetFile)/ (like /usr/share/$(TargetFile)/i18n, ...).



Don't forget linux/unix is a multiuser system, once installed, an application should be usable by every user, including ones who did not exist when the application was first installed.

It is certain that I am always too influenced by Windows installations :-[ .
I try to do the same thing again and again, more or less: ask where to install, then put everything in the same directory near the executable: database, configuration file, documentation and referentials where I can pick.



At this stage, the install should be running as root and if it has dependencies, apt installs them first.  Apt install never makes changes at the user level, if, for example, the user will need some config files or directories created, that should happen when, later, they run the application for the first time.

Yes: the installation system manager is root, and only root. Even if the "original double click" to install is done by a simple user. So, I'm gonna install in /usr/share/$(TargetFile)/.


[Aside on]
However, I found on the net a trick, less clean but which can be useful: it is possible to code Bash\Shell scripts in 4 events named preinst, postinst, prerm, and postrm (they are thrown, if they are coded, during a Debian installation).
In the postinst event during the installation, all files are unpacked and therefore accessible. And Linux seems to keep a track of the user that was active (who made the "original double click" to install) before running the root installer. From this information, some people code (copy-paste from https://unix.stackexchange.com/questions/23463/how-to-create-debian-package-to-install-files-to-home-user)https://unix.stackexchange.com/questions/23463/how-to-create-debian-package-to-install-files-to-home-user (https://unix.stackexchange.com/questions/23463/how-to-create-debian-package-to-install-files-to-home-user)https://unix.stackexchange.com/questions/23463/how-to-create-debian-package-to-install-files-to-home-user)) a script like this...:
Code: Bash  [Select][+][-]
  1. # For every user in /home/ ...
  2. for HOME_U in /home/*?; do
  3.  
  4. # Obtain the username
  5. USER=$( basename ${HOME_U} )
  6.  
  7. # In case the user is active (exists in /etc/shadow) ...
  8. if [ $( grep -c "${USER}:.*:.*:.*:.*:.*:::" /etc/shadow ) == 1 ] \
  9. && [ $( grep -c "${USER}:.*:.*:.*:.*:.*:/bin/.*sh" /etc/passwd ) == 1 ] \
  10. && [ -d ${HOME_U}/.config ] \
  11. && [ -d ${HOME_U} ]; then
  12.  
  13. # Making sure .config/your-package/ exists
  14. mkdir -p /home/${USER}/.config/your-package/
  15.  
  16. # with appropiate permissions
  17. chown ${USER}:${USER} /home/${USER}/.config/your-package/
  18.  
  19. # copy what we need
  20. cp /etc/skel/.config/your-package/x.conf /home/${USER}/.config/your-package/
  21. cp /etc/skel/.config/your-package/y.conf /home/${USER}/.config/your-package/
  22. cp ... /home/${USER}/.config/your-package/
  23.  
  24. # with appropiate permissions
  25. chown ${USER}:${USER} /home/${USER}/.config/your-package/x.conf
  26. chown ${USER}:${USER} /home/${USER}/.config/your-package/y.conf
  27. ...
  28. fi
  29. done
  30.  
...which - in theory - allows to install a *single-user* application (certainly, against the nature of Linux). Nevertheless, some create an installation by relocating (all paths in the executable must be relative) /usr, /usr/bin, /usr/share/, ... into $HOME/.local/$(TargetFile)/usr/... and in /home/${USER}/.config/your-package/$(TargetFile).conf, for example. This seems to be more and more in the spirit of some Linux Desktop editions (I'm thinking of new packaging formats such as snap, flatpack which are - caricaturally - somehow fractalization \ miniaturization of /usr notable directories and files into the /home/${USER}/snap_or_flatpack_or_appImage/a_package, with a level of confinement).
[Aside off]

Thanks to all!
Title: Re: Creating .deb packages for Lazarus applications?
Post by: circular on November 20, 2020, 10:26:37 am
Interesting. It seems to me though that. this scripts copy the config for all users.

Note: the URL is kind of duplicated
Title: Re: Creating .deb packages for Lazarus applications?
Post by: devEric69 on November 20, 2020, 11:28:21 am
this scripts copy the config for all users.
Indeed. So, not a real one  *single-user* application's installation :-\ .
==> I'm coming back to the lack of a record somewhere in Linux of who was actively logged in, before the root installation ("original double click"), if it wasn't already root. That's strange , because I think it could be useful...

Morover, a postrm script must also be written (and shipped inside the *.deb), in order to remove everything created in the postinst script.
Title: Re: Creating .deb packages for Lazarus applications?
Post by: dbannon on November 22, 2020, 08:23:49 am
I repeat -

Don't forget linux/unix is a multiuser system, once installed, an application should be usable by every user, including ones who did not exist when the application was first installed.

Packages such as debs should not mess around in user space !   Unix systems have all sorts of 'users' installed that are not real users and you risk the wrath of a leather winged dragon from hell if you mess around with their accounts. Its the wrong thing to do.

Its very, very easy to make your app prepare the end user env at first start up -

Does config file exist ?
Yes - read it and use it.
No - create a default config file

Davo
Title: Re: Creating .deb packages for Lazarus applications?
Post by: lucamar on November 22, 2020, 01:10:01 pm
==> I'm coming back to the lack of a record somewhere in Linux of who was actively logged in, before the root installation [...]

Calling fpGetuid() should give that, as fpGeteuid() should give you the "root" id. The installation runs as root but the real id should still be that of the user who launched it.

But Davo is right: normal user configuration should be deferred until first run and if you have assets that are the same for all users, like images, sounds, etc., they should be copied to the programs folder in /usr/share at install-time, which means your .deb file should reflect this.
Title: Re: Creating .deb packages for Lazarus applications?
Post by: circular on November 22, 2020, 01:19:57 pm
Unix systems have all sorts of 'users' installed that are not real users and you risk the wrath of a leather winged dragon from hell if you mess around with their accounts.
Isn't it a bit overdramatic?
Title: Re: Creating .deb packages for Lazarus applications?
Post by: PascalDragon on November 22, 2020, 01:22:19 pm
Unix systems have all sorts of 'users' installed that are not real users and you risk the wrath of a leather winged dragon from hell if you mess around with their accounts.
Isn't it a bit overdramatic?

I'd even go so far as to say that dbannon underestimated that...
Title: Re: Creating .deb packages for Lazarus applications?
Post by: circular on November 22, 2020, 01:24:58 pm
As a Dragon, I suspect that you opinion is biased.
Title: Re: Creating .deb packages for Lazarus applications?
Post by: devEric69 on February 03, 2021, 09:36:49 pm
Hello,

I'm trying to create a Linux installation, with a system user (adduser --system ...\... a_software_usr). a_software_usr represents the installed software (my_software's proxy, an abstraction of other real users). Then, I've created a single-user software group named a_software_grp containing a_software_usr. I've installed \ dispatched all the binaries released in /opt/my_software/... . Then, I've added the real users - detected during the installation - inside the group named a_software_grp. I'm using setfacl cmd to manage rights on /opt/my_software/... .

I've then said that the /opt/my_software directory belongs, is owned by a_software_usr:a_software_grp. I, i.e. user01, as a real user (not a system user), also belong to a_software_grp. In other words, I use a_software_grp as a proxy group to manage the rights dispatched into /opt/my_software. And real users who want to run a_software, must be added inside this group.

I've got the following problem: in summary, if the permissions given on /opt/a_software are [rwx rwx rwx] i.e. [777], I can launch a_software from a menu launching itself /usr/share/applications/a_software.desktop. But, if I grant /opt/a_software with a less permissive installation, i.e. if the permissions given on /opt/a_software are [rwx rwx ---] i.e. [770], then I get the message "Desktop file invalid: '/usr/share/applications/a_software.desktop'". Same thing: when I run a_software with [770] rights, from a terminal as @user01 or as @root, I get the message "Gtk-WARNING **: 21:02:36.872: cannot open display: ".

Does someone have a clue \ hint, where to look for the reason of this message?
Title: Re: Creating .deb packages for Lazarus applications?
Post by: devEric69 on February 04, 2021, 10:53:35 am
Okay, it's my fault:

I restarted the commands...

Code: Bash  [Select][+][-]
  1. find "${OPT_DIR_OF_A_APPLICATION}" -type d -exec chmod 0755 {} \; #set directory attributes
  2. find "${OPT_DIR_OF_A_APPLICATION}". -type f -exec chmod 0644 {} \; #set data file attributes
  3. find "${OPT_DIR_OF_A_APPLICATION}/usr/bin" -type f -exec chmod 0755 {} \; #set executable attributes

...in a post-install script embedded in the installation package, to give the same adhoc rights such as described in the paragraph § "Finalizing the staging directory" of the page https://wiki.lazarus.freepascal.org/Debian_package_structure (https://wiki.lazarus.freepascal.org/Debian_package_structure), and the application is launched again well, from a menu. So, the problem of mandating the installation by a system user and a representation group are transparent if I respect the same rights.

Nevertheless, even with the good rights, I always have the problem of launching in a terminal that persists, i.e. I get the message "Gtk-WARNING **: 10:26:05.756: cannot open display:". I can't launch, too, some utilities like xeyes, xclock from a terminal ("Error: Can't open display:"), on a new ghost image of Debian 10 Buster (for information). Of course, it's no longer really a problem of installation, but rather a problem of launching a visual application from a terminal. If anyone have a hint about Xorg \ X11...?
Title: Re: Creating .deb packages for Lazarus applications?
Post by: devEric69 on February 04, 2021, 12:26:21 pm
For information, found on the web: "Graphics applications must be launched by the user who opened the X session. So you should not launch (in a terminal) as root or any other user, but only with the connected one (without su or sudo).".

So...:
- I restarted a terminal as @user01, not as @root, like I used to do.
- I started the cmd: export DISPLAY=:0.0
- I ran the cmd: xclock
...and the small GUI clock, now starts and displays itself. Same thing for the application I'm trying to correctly install (more important, I now see in the terminal the notification messages, OS layer errors, etc).
Title: Re: Creating .deb packages for Lazarus applications?
Post by: circular on February 05, 2021, 02:59:16 am
Interesting to know that those rights can have such surprising side effects.
Title: Re: Creating .deb packages for Lazarus applications?
Post by: vladimirr on March 25, 2021, 05:39:33 pm
Does anybody have any experience in making Debian packages for Lazarus programs?

I use Debreate - Debian Package Builder.

https://antumdeluge.github.io/debreate-web/ (https://antumdeluge.github.io/debreate-web/)
Title: Re: Creating .deb packages for Lazarus applications?
Post by: MarkMLl on March 25, 2021, 07:46:33 pm
For information, found on the web: "Graphics applications must be launched by the user who opened the X session. So you should not launch (in a terminal) as root or any other user, but only with the connected one (without su or sudo).".

Somebody on the Internet is wrong https://xkcd.com/386/ You can generally run a command as root provided that you use sudo's -E option... which is unavoidable if you think about it since a complete ban on root logging in via ssh and on ordinary (but authenticated and authorised) users switching to root would result in a total inability to run graphics-based management tools remotely.

There might, of course, be other factors involved such as the ownership of FIFOs in /tmp or in the original user's ~ And there's ways round it like using POSIX capabilities. And the wisdom of running anything as complex as a GUI-based program with elevated permissions is moot. And so on.

MarkMLl
Title: Re: Creating .deb packages for Lazarus applications?
Post by: devEric69 on September 02, 2021, 04:14:04 pm
Hello,

I've created a Debian version 0 installation of a software, say named "softfoo". Everything is installed in the /opt/softfoo/* directory (a kind of miniature fractalized directory of a Linux). For a new installation, from scratch, the Debian installation softfoo_0.0.0.0_amd64.deb installs all very correctly. I'm happy.

Now, I'm creating a Debian version 1 installation. And of course, I'm now testing the "switch case" of maintainer scripts (prerm, preinst, postrm, postinst; Cf. https://wiki.debian.org/MaintainerScripts (https://wiki.debian.org/MaintainerScripts)) in oder to upgrade from version 1 over an already installed version 0. To be complete, in this case, my upgrade only needs to replace the old *.elf binary, and some *.htm online help files in situ, instead of the old ones [^]. For the rest, the new *.elf will update the old centralised database, the old *.conf files, ..., by itself.

Question number 1: I've a constraint which is that I want to preserve an old detected installation (number 0, here). So, I want to do a bash cmd "mv" from the old installation towards /opt/softfoo_old_historized_version_0/*. I was thinking of writing this in the script '1->preinst "switch case" upgrade) 0', and rollback\cancel on error in 'this->postrm "switch case" abort-upgrade) 0'. Is this correct?

Question number 2: for file replacements (Cf. [^*] above , i.e. in order to replace an existing old *.elf, and existing old *.htm online help files), my question is: where, in which maintainer script and with which event script "switch case" (upgrade, configure, ...), is it advisable to script (verify\validate\invalidate) such file to file replacement of a previous installation, and especially how to tell not to replace an old existing database (my installation and my database are in fact centralized: I install a software that can be launched by all users alternatively, but all using the same database)? I would like to code this as much as possible into a upgrade event script "switch case" (for semantic purpose).

Regards.
Title: Re: Creating .deb packages for Lazarus applications?
Post by: devEric69 on September 02, 2021, 05:58:17 pm
So, after having read, re-read the Debian events flowchart and its documentation several times, here is what I think is notable in my upgrade context:



       ...\...
'$old->prerm upgrade) $new'     nb: I should code the reverse if it fails in '$new->prerm failed-upgrade) $old'
          ↓
'$new->preinst upgrade) $old'     nb: I should code the reverse if it fails in '$new->postrm abort-upgrade) $old'
          ↓
The new package files are unpacked and they are written, overwriting the old ones that are still there (so, it seems that I should have to rename the database in one of the 2 scripts before, in order not to lose it, to backup it), as far as I understand.
          ↓
'$old->postrm upgrade) $new'     nb: I should code the reverse if it fails in '$new->postrm failed-upgrade) $old'
                                                           and 'postrm' means 'overwritten' here


So, in this event, I should be able to rename an existing backuped database in place of the newly comming one. Then, the Debian Installer says that it will remove all the files that were in the listing of the old installation, but are not present in this new installation.
       ...\...




Is this what we should infer?
Title: Re: Creating .deb packages for Lazarus applications?
Post by: dbannon on September 03, 2021, 02:23:09 am
While there is no reason why you cannot backup an old installation, its not really in keeping with the Debian Packaging model. That says you should upgrade anything that needs it and remove things no longer needed.

With Debian packages, its a continuous process, you can keep applying the new version over the old one and not  take up much more diskspace each time.  If you make a backup copy, and do another Debian update, and it makes a backup copy, and the next one makes yet another backup copy .....

Mind you, if you are providing just binary packages direct to users and not making source packages to submit to Debian, you are free to do what you wish !

Could you, instead, offer a "roll back" package, one that replaces your newer one with the old version and have a utility that converts the newer data back to the old format ?

Davo
Title: Re: Creating .deb packages for Lazarus applications?
Post by: devEric69 on September 03, 2021, 12:17:38 pm
Hello @Davo,

While there is no reason why you cannot backup an old installation, its not really in keeping with the Debian Packaging model.

Just for information, this backup of a previous installation was inspired by looking at the bash 'maintainer scripts' of a Debian installation of the Firebird servers.  I thought it was clever: indeed, if a big bug in a new version (which never happens, of course ::) <-- eyes applied to myself ) appears, then the old one can easily be put back on work again.

For information, I'll only provide binary packages (not yet at the top level in order to allow source packages (*.pas) to be fetched from a repository with dependencies like Lazbuild in order to do a rebuild of everything on the user's machine (like a true "Debian-proof" source package).

Could you, instead, offer a "roll back" package, one that replaces your newer one with the old version and have a utility that converts the newer data back to the old format ?

Well, I thought about that (using solutions such as LazAutoUpdater). But, at the end, I've decided that it should be the new *.elf (installed in place of the old one) that will carry the responsibility of updating everything around it that needs to be updated.
Title: Re: Creating .deb packages for Lazarus applications?
Post by: metis on February 22, 2023, 02:50:47 pm
Also found two programs to make Debian packages. I haven't tested them - Link #2
Has anyone had any experience with the Debian Packager (http://www.getlazarus.org/apps/makedeb/), in the meantime ?
Title: Re: Creating .deb packages for Lazarus applications?
Post by: dbannon on February 24, 2023, 12:10:11 am
No, I have not, but I suggest that a "one size fits all" approach is going to be harder that you imagine. Especially if you are compiling with FPC, have extra units you need, want to make a src package....

Making a binary is easy, in very simplified terms, you build a directory (I call it BUILD) containing the things you want to appear on the user's system. You then run something like -

fakeroot dpkg-deb -b BUILD/. myapp_amd64.deb <enter>

In practice that will probably have a lot of lintian errors but will probably work fine.

Building a SRC package to submit to debian is a bit harder, it has to (later) build (from src package to binary package) with make and those lintian errors I mentioned will have the debian people shaking their heads. But all that can be fixed and scripted if you are willing to put a bit of effort in.

Here is my script to build debian and rpm binary packages for amd64, i386 and raspi (along with a kit to package a windows installer) - https://github.com/tomboy-notes/tomboy-ng/blob/master/package/package.bash

Its probably far more complicated that you need initially but look into the methods inside.

Here is a my doc of my method of building a SRC a package that I routinely submit to Debian (v0.36 accepted into unstable today) - https://github.com/tomboy-notes/tomboy-ng/blob/master/prepare.md

In both cases, most certainly NOT scripts you can use because they are setup for my particular project. But you can easily pick out the bits you want, modify them accordingly and discard the remainder.

Davo


Title: Re: Creating .deb packages for Lazarus applications?
Post by: metis on September 17, 2023, 05:15:22 pm
@dbannon
Thank You for Your detailed Reply - Phew, sounds pretty complicated.

Quote
Making a binary is easy ...
Should be as shown here (https://www.youtube.com/watch?v=az4IvDUDGig&t=4s) for FFmpeg.

What about Debreate (https://debreate.github.io/) ?
What about the Debian Package Maker (http://debianpackagemaker.blogspot.com/2008/02/debian-package-maker-is-simple-user.html) ?

Anybody any experience with them ?
Title: Re: Creating .deb packages for Lazarus applications?
Post by: maurobio on September 17, 2023, 05:27:50 pm
Hi!

I have done this for years now. I use Debreate fof creating distribution packsges fof both 32-bits and 64-bits Linux applications without any hassles or complications

The trick is just adding the required list of dependencies in the package, but they are pretty stable.from an application to the other.

With warmest regards,
TinyPortal © 2005-2018