I have my own application packaged using dpkg. The application depends on several .deb files which I'm trying to install from within the preinst script of my application. The preinst script checks if a dependent deb file is installed, if not it goes to install it using the dpkg -i
command. This is repeated for all the dependent deb files needed by the main application.
When I try to install the main application using dpkg -i
, the commands returns failure when trying to execute the preinst script. Below is that error message:
dpkg: error: dpkg status database is locked by another process
I deleted /var/lib/dpkg/lock
file and retried to install the application. But to no avail. If I run the preinst script separately like any other shell script, it runs without any issue. All the deb files will be installed properly. So, the issue is only when this preinst script is being run automatically by the dpkg -i command
.
I'm lost trying to determine the root cause. If anyone can shed some light on what the real issue might be, their help will be greatly appreciated.
Thank you, ObsessiveSS0F for your quick response.
I understand the point you are making but that will not help my situation. Let me tell you why.
- My main application (let's say mainapp.deb) depends on five other .deb files
(let's say 1.deb, 2.deb and so on). - The dependent .deb files are my own private packages/libraries. So these are not
downloadable from the web. So, I cannot use apt-get to install these automatically. - I would make the "Depends" field in the control file to point to 1.deb, 2.deb..etc,
but as you know dpkg -i will not automatically install the dependencies. - I can execute dpkg -i, followed by apt-get -f install, but for apt-get to work, I
have to edit the /etc/apt/sources.list file to add a reference to the local directory
on the system where the dependent .deb files are stored. - Well, #4 seems to work but is not an option for me because this application will be
installed on many servers and the installation program has to be fully automated.
I continued to investigate the reason why preinst was failing to install the .deb files and I think I have found out why.
- When I run dpkg -i mainapp.deb,the dpkg process is creating the /var/lib/dpkg/lock
and some files under /var/lib/dkpg/updates directory. - Now, the preinst script has a series of dpkg -i commands to install the dependent
.deb files. So, as soon as the first dpkg -i command in the preinst script is
executed, it fails because of the locks created by the earlier dpkg command. - It seems that two dpkg commands cannot be executed in parallel because of the locks.
I modified the preinst script to backup the locks created by the dpkg process to a temporary location and deleted the original locks. (the lsof command did report that the
locks were deleted). Now that the locks were gone, the dpkg -i commands within the preinst script executed without any issues. I restored the locks back before exiting the preinst script so that the primary dpkg -i command could continue. It worked but I have a feeling that this is not the right approach.
I'm still trying to figure out alternate ways for installing a .deb file along with it's dependencies.
No comments:
Post a Comment