Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

DEB package development - few questions from newbie

User discussion about Debian Development, Debian Project News and Announcements. Not for support questions.
Post Reply
Message
Author
doman18
Posts: 3
Joined: 2019-04-24 05:16

DEB package development - few questions from newbie

#1 Post by doman18 »

Hello all, this is my first porst here.

I recently started to learn deb packaging. I have to package some python application for easier mainenance/upgrading. Before you redirect me to Maintenance guide and similar HUGE manuals about packaging i want to say that this app will NEVER get to any official/unnoficial repository. It will be always installed/upgraded with DPKG, not APT - hosts are ment to be offline all the time. So i dont have to be so strict in following packaging rules and thus dont have to do things in very complicated manner.

So far the easiest place to start i found is this tutorial ...

https://www.leaseweb.com/labs/2013/06/c ... -packages/

I didnt do any template stuff but just made some simple /myapp-1.0/home/bin/helloworld.py script along with /myapp-1.0/DEBIAN/control and /myapp-1.0/DEBIAN/postinst script which just copies some file.conf to proper place. Everything worked as it should. Offcourse i know this way is not proper one, and i should use things like debhelper. My application is in repository so i will have to copy things into proper folder structure. Thats why i started to do things this way ...

https://github.com/phusion/debian-packa ... tutorial-2

... and im even closer to what i want to achieve but there are still 2 things bother me ...

1. My app will be installed in offline environment. All dependencies needed by app will have to be already installed on the host. I want to add host versioning and correlate it with debian packages so installing/upgrading myapp.deb first will check if host version is new enough to install. How to (properly) achieve that? I have two ideas :
- put host version to some /etc/somefile.txt and read it in DEBIAN/preinst and decide there whether to continue installation or not (is it even possible in preinst?)
- make some very simple dummy hostversion.deb package and add depency for it in myapp.deb
2. What happens with obsolete files during updates? Lets say i have 1.0 version with some files. Now im doing big change, and deleting many of them in version 1.1. What happens when i will perform upgrade? I dont want to delete them in /postinst or build some lists of files/dirs to delete because it seems to me very inefficient. Is there any efficient way of removing files which does not exist in newest versions?

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: DEB package development - few questions from newbie

#2 Post by Head_on_a_Stick »

doman18 wrote:Before you redirect me to Maintenance guide and similar HUGE manuals about packaging i want to say that this app will NEVER get to any official/unnoficial repository. It will be always installed/upgraded with DPKG, not APT - hosts are ment to be offline all the time. So i dont have to be so strict in following packaging rules and thus dont have to do things in very complicated manner.
I think you should still read and follow the New Maintainers Guide because the packaging abstractions provided by debhelper should actually make things simpler and also more reliable.

For example, neither of your linked guides mention dh_make, which will create the debian directory for you and populate it with all the required files complete with templates.

It may take longer to read through the offical documentation than your hacky tutorials but it will save you time in the long run.
doman18 wrote:1. My app will be installed in offline environment. All dependencies needed by app will have to be already installed on the host. I want to add host versioning and correlate it with debian packages so installing/upgrading myapp.deb first will check if host version is new enough to install. How to (properly) achieve that?
Use the Depends field in debian/control.
doman18 wrote:2. What happens with obsolete files during updates? Lets say i have 1.0 version with some files. Now im doing big change, and deleting many of them in version 1.1. What happens when i will perform upgrade?
As long as the files are still in the same location then APT will ask if the user wants to replace them or not.

I suppose you could use postinst to delete old files but perhaps a better solution would be a simple message telling the user to run

Code: Select all

# aptitude purge ?config-files
https://raphaelhertzog.com/2011/01/31/d ... ion-files/
deadbang

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: DEB package development - few questions from newbie

#3 Post by stevepusser »

If the older version of the program installed the obsolete files, they will be removed along with the old version. Dpkg keeps a list of the files each version installs. This is not the case for files that a program creates, though.

I'm not sure exactly what you mean by "host version" checking. The standard way is just to list the dependencies that your python program needs to run and the minimum versions of those. If the host system doesn't have those, your deb will not install with apt or gdebi--no checking of the host system required. Dpkg will happily install a deb without satisfied dependencies, so stay away from that.
MX Linux packager and developer

doman18
Posts: 3
Joined: 2019-04-24 05:16

Re: DEB package development - few questions from newbie

#4 Post by doman18 »

Head_on_a_Stick wrote:
doman18 wrote:Before you redirect me to Maintenance guide and similar HUGE manuals about packaging i want to say that this app will NEVER get to any official/unnoficial repository. It will be always installed/upgraded
For example, neither of your linked guides mention dh_make, which will create the debian directory for you and populate it with all the required files complete with templates.

It may take longer to read through the offical documentation than your hacky tutorials but it will save you time in the long run.
Ive seen that tip in other tutorials/stackoverflow but i didnt follow this way because i thought that even though it will make some stuff easier, but other will be harder to understand as i dont know whats going on "under the hood" and why some things work the way they work. For me tutorial from second link is really one of the best i found for the beginners as all his parts explain well how to go from building very simple packages to using DH commands and why the makefiles look like they look.
https://github.com/phusion/debian-packa ... tutorial-1
https://github.com/phusion/debian-packa ... tutorial-2
https://github.com/phusion/debian-packa ... tutorial-3
https://github.com/phusion/debian-packa ... tutorial-4
https://github.com/phusion/debian-packa ... tutorial-5

The only thing this tutorial lacks are preinstall/postinstall/prerm etc. scripts expanation. I thougt that putting them in debian/ directory like debian/rules will be enough. But it seems that ill have to copy them manually to debian/myapp/DEBIAN/ directory in debian/rules file. Am i wrong?

As for dependecies they are not enough for me. My app is based on tornado framework which has requirements.txt file with list of dependencies but it is not enough. Some other things and settings are set up on the host in /etc and /opt directories. I wanted to gather those changes and current depenecies version under one number to make compatibility checks with deb package much easier. Maybe the idea of making some additional .deb package which will held such version number is the best way to go?

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: DEB package development - few questions from newbie

#5 Post by stevepusser »

The various maintainer scripts you're asking about (preinstall, etc) go in the /debian directory with all the others. The build process automatically puts them in a DEBIAN folder inside the deb file.

If you use dh_make or debmake with extended files to create your /debian folder, you'll get samples of those files to start with, but you really don't need them with your simple python program. I think you're making it more complicated than it needs to be.

You also say that it will always be installed with dpkg, but in Stretch and above, you can also use apt to install local deb files, and that does dependency checks, unlike dpkg, so is vastly better.
MX Linux packager and developer

doman18
Posts: 3
Joined: 2019-04-24 05:16

Re: DEB package development - few questions from newbie

#6 Post by doman18 »

stevepusser wrote:The various maintainer scripts you're asking about (preinstall, etc) go in the /debian directory with all the others. The build process automatically puts them in a DEBIAN folder inside the deb file.
Well i already tried that, to put those scripts to debian/ dir. But none of them worked, and none of them i saw in debian/myapp/DEBIAN/ directory. So then i manually copied them with the debian/rules script and then they did work. However in the meanwhile builder complained that they doesnt have execute permissions. Maybe it was the reason they havent been copied in the first try.?

Yeah i think that with all the things i know now, its time to generate whole directory with dh_hepler and See how all should be done.

Thank you very much for your help!

Post Reply