5

Is there a way for the postinst, pre, etc. scriptlets to access the information in the Debian control file when installing?

e.g. 
   Package: name
   Version: 0.1-1
   Depends: ...

2 Answers 2

2

Apparently, the postinst, pre, etc. scriptlets are run in an environment created by dpkg. The control information are environment variables that the scriptlets can access.

e.g.

DPKG_MAINTSCRIPT_ARCH=all
DPKG_RUNNING_VERSION=1.16.10
DPKG_MAINTSCRIPT_NAME=postinst
DPKG_MAINTSCRIPT_PACKAGE=zip
DPKG_NO_TSTP=yes
DPKG_ADMINDIR=/var/lib/dpkg
1

There's a few ways to do it, but the way I like to do it is by using dpkg.

Try this:

  1. Create a temporary directory ex: mkdir /tmp/pkg-tmp
  2. Extract control info with dpkg: dpkg -e ./path/to/file.deb /tmp/pkg-tmp
  3. Check out the control file, it should be in the top level directory: cat /tmp/pkg-tmp/control
  4. You may want to clean up the temp directory when you are done examining: rm -rf /tmp/pkg-tmp

The postinst, preinst, and prerm scripts will be in there too. If there are no files named preinst, postinst, postrm, or prerm, then that means none of those scripts are part of the Debian packaging.

Some packages might have all of them, only 1 or 2, or none -- just depends on the package.

If the package is in an APT repository, you can run apt-get download package-name to first download the Debian package in the current directory, then run the commands listed above.

I wrote a blog post about extracting Debian packages and examining the control file, preinstall, postinstall, prerm files that has more information.

1
  • I think you missed my question. I'm looking for the post, pre, etc scriplets to access the control information while the installation is going on. Oct 28, 2015 at 17:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .