1

I have created a .deb package using equivs-build command and providing necessary control, preinst, postinst, etc. I noticed that version can also be mentioned in control file. Now I want to create a .deb package with updated source code and I want to enable user to upgrade the package if it is already installed (and is of previous version, of course), as I won't be changing conf related files, etc. One way I can think of is to write a script which will first check for installed version, and will take actions accordingly (i.e. if installed, just update the source-code, database-migrations, etc. and if not, install the package using dpkg -i <package-name>). I was wondering if there was a way to achieve using dpkg only (something like dpkg upgrade <package-name>) which will handle installation or up-gradation as required.

exAres
  • 263
  • On a side note, the version of the package usually isn't mentioned in control (unless you're declaring dependencies); it's only mentioned in changelog. – saiarcot895 Aug 08 '14 at 14:18
  • @saiarcot895 could you please elaborate a bit in details? As far as I know, mentioning version in control file is working. I tried mentioning different version in control file and tested installations. The package gets upgraded according to the version mentioned in control file. Am I missing out on something important here? Thanks. – exAres Aug 08 '14 at 14:50
  • See the policy here. Note that there is no Version field mentioned in the specifications for the source package control fields, which applies to source packages and the debian archive file; however, the Version field is required for binary package control fields (DEBIAN/control), which is the compiled package and the final deb. Instead, the version should be in debian/changelog (policy here). – saiarcot895 Aug 08 '14 at 14:58
  • However, from what I can tell, you are directly changing the compiled debs, and so you might be fine. – saiarcot895 Aug 08 '14 at 14:59
  • I just looked at the equivs-build manpage, and based on what it does there, you are fine by using Version in the control file. – saiarcot895 Aug 08 '14 at 15:03

1 Answers1

1

The command you are looking for is indeed dpkg -i. This will install if not installed and upgrade if already installed. dpkg doesn't change user-modified configuration files. It will ask you what to do about such cases (keep the modifications, discard the modifications, etc.) and it will always keep a backup of whatever you discard (the new config file provided by the package, or the old user-modified file ). Any file installed by the package in /etc/ is considered by dpkg as a configuration file.

muru
  • 207,970
  • I went through this link: https://wiki.debian.org/MaintainerScripts and what I understood is I need to make changes to prerm, postrm, preinst and postinst scripts. But there are several cases shown (like prerm upgrade and prerm remove for prerm). How do I handle such cases? I mean, how can I separate the code for upgrade and remove in prerm itself? – exAres Aug 07 '14 at 08:59
  • 1
    @user2745266 Since prerm is a script, and usually a bash script, you can use cases in bash. But you don't need to handle all the cases unless your install scripts (postinst and preinst) are doing complex stuff. – muru Aug 07 '14 at 09:01