i01000001
i01000001

Reputation: 129

how to get debain package unpacked first before debconf prompt is shown?

I am working on Debian packaging source to install few files on user machine. There is common logic that is being used by debconf/config script and postinst script. So, I placed the common logic in a separate file and added it as part of the package under /usr/share/pkg-name/.

Now when I install the package using dpkg everything works fine. First the package is unpacked and the file containing common code base is placed at the said path. Next the debconf/config script reads the file and then prompts the user accordingly.

When I place the file inside a APT repo the same procedure is reversed when I install using apt-get. The package is not unpacked first, instead the debconf prompt is shown and config script is unable to find the script containing common code base.

I want to know why there is a difference in the installation procedure? Is there a way to get the same sequence when installing through apt-get ? All three files are shell scripts.

Is there a better way to handle such common code base to be used by various maintainer scripts ?

Upvotes: 1

Views: 489

Answers (1)

i01000001
i01000001

Reputation: 129

The quest has ended!

Now I understand the complete process as described in debconf manpage. There are different phases or steps whatever you call it. They are:

  • dpkg-preconfigure
  • dpkg -i
  • dpkg-reconfigure

All these steps initiate debconf communication with user. When someone installs a package using dpkg -i then the config script is run just before running the postinst script with same command line options. By the time debconf communication begins the package is already unpacked.

When someone installs a package using apt-get then first dpkg-preconfigure is run that executes the config script and then dpkg -i to actually install the package which again runs the same config script.

In the second case of apt-get, when config script is run as part of dpkg-preconfigure then the package is yet to be unpacked so I was facing this problem.

I just added a if condition to continue if files are unpacked or else exit

if [ ! -f /usr/share/pkg-name/common-codebase ];
 then
    exit 0
 fi
 /usr/share/pkg/common-codebase

This way when installing package using apt-get, dpkg-preconfigure attempt to run config script is skipped while the second attempt at dpkg -i is honored. This works for me because the debconf questions I ask to user does not impact on any other package.

In case you have shared templates and your choices may impact anything outside the package then remember even if you delay your prompts still the other related/dependent packages being installed by apt-get will still prompt user during dpkg-preconfigure step. Make sure that is fine for you before attempting this solution.

Upvotes: 1

Related Questions