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.
Asked
Active
Viewed 1,429 times
1
exAres
- 263
1 Answers
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,preinstandpostinstscripts. But there are several cases shown (likeprerm upgradeandprerm removeforprerm). How do I handle such cases? I mean, how can I separate the code forupgradeandremoveinprermitself? – exAres Aug 07 '14 at 08:59 -
1@user2745266 Since
prermis 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 (postinstandpreinst) are doing complex stuff. – muru Aug 07 '14 at 09:01
versionof the package usually isn't mentioned incontrol(unless you're declaring dependencies); it's only mentioned inchangelog. – saiarcot895 Aug 08 '14 at 14:18versionincontrolfile is working. I tried mentioning different version in control file and tested installations. The package gets upgraded according to theversionmentioned incontrolfile. Am I missing out on something important here? Thanks. – exAres Aug 08 '14 at 14:50Versionfield mentioned in the specifications for the source package control fields, which applies to source packages and the debian archive file; however, theVersionfield is required for binary package control fields (DEBIAN/control), which is the compiled package and the final deb. Instead, the version should be indebian/changelog(policy here). – saiarcot895 Aug 08 '14 at 14:58equivs-buildmanpage, and based on what it does there, you are fine by usingVersionin thecontrolfile. – saiarcot895 Aug 08 '14 at 15:03