I am trying to build a deb package A that depends on another deb package B that is downloaded from URL and then installed.
The obvious solution I tried was putting the script that downloads and installs package B in the postinst/preinst scripts of package A.
wget package_url
dpkg -i package_name.deb
But it gives me an error dpkg: error: dpkg database lock is locked by another process
because the lock is already locked when installing package A.
How can manage to do this? Is there a way to declare dependencies from the deb URL in the package control file?