Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I ended up dealing with a software meant to be deployed using dpkg. The .deb package works fine on the test env but fail on staging. Both are running the same version of Ubuntu but I am not 100% sure of the rest of the configs. How to debug this dpkg issue further?

The installation fails like this:

sudo dpkg -i --debug=7337 package.deb 
D000010: ensure_pathname_nonexisting `/var/lib/dpkg/tmp.ci'
(Reading database ... 201812 files and directories currently installed.)
Unpacking myProprietarySoftware (from package.deb) ...
D000001: process_archive oldversionstatus=not installed
D000002: fork/exec /var/lib/dpkg/tmp.ci/preinst ( install )
dpkg: error processing package.deb (--install):
 subprocess new pre-installation script returned error exit status 1
D000002: maintainer_script_new nonexistent postrm `/var/lib/dpkg/tmp.ci/postrm'
D000010: ensure_pathname_nonexisting `/var/lib/dpkg/tmp.ci'
D000010: ensure_pathname_nonexisting running rm -rf
D000010: ensure_pathname_nonexisting `/var/lib/dpkg/reassemble.deb'
Errors were encountered while processing:
 package.deb
share|improve this question

4 Answers 4

up vote 3 down vote accepted

The package's .preinst script is failing for some reason.

To find out why, examine the script in /var/lib/dpkg/info/PACKAGENAME.preinst

If you want to see exactly which line the script is failing on, edit the .preinst script and add set -x immediately after the #! line. This turns on execution tracing in the script.

NOTE: This assumes that the .preinst script is a shell script (either posix sh or bash). Almost all .preinst (and .postinst, .prerm, and .postrm) scripts are shell scripts but they don't have to be, they could be any executable. e.g. on my main desktop machine with 9104 packages installed, 14 are perl scripts, 1 is a compiled executable (bash's preinst - it can't assume there is a functioning shell already installed), and all of the rest are shell scripts...9041 are POSIX shell scripts, 63 are bash scripts. If the .preinst is perl or python or something else, you'll have to figure out how to enable debugging or execution trace mode or similar in that language.

Then run dpkg --configure --pending.

This will cause dpkg to try to configure the half-installed package. DO NOT reinstall it with dpkg -i, that will overwrite your edited .preinst script with the version in the .deb package.

This may give you enough information to fix the problem. It may be something simple like an unexpected or uncaught exit code from a program (most .preinst etc scripts have set -e, to make them terminate on the first error), or assuming that a directory already exists (and this may be due to an undeclared dependency in the package's debian/control file - i.e it should depend on foo but doesn't. just install foo anyway)

Once it's fixed, run dpkg --configure --pending again, and the package should be properly installed.

If the .preinst script is buggy, there's a reasonable chance that the .postinst (and/or .prerm and .postrm) scripts will be too. You may need to fix them as well.

Don't forget to submit a bug report to whoever made the package so they can fix it.

share|improve this answer

Your packaged software includes a "pre-installation script" (preinst) which is failing. This is a shell-script embedded within the .deb file. You can extract it with:

 dpkg-deb -e some-deb.deb out-dir

Then you can look at out-dir/preinst and see if you can figure out why it is failing.

If you want to modify that script and rebuild the .deb (perhaps to add some debugging code), try

 dpkg-deb -x some-deb.deb another-out-dir
 dpkg-deb -e some-deb.deb another-out-dir/DEBIAN
 (modify another-out-dir/DEBIAN/preinst)
 dpkg-deb -b another-out-dir some-deb2.deb
share|improve this answer

You will need to extract the file and see why the preinst script exits with code 1.

Not sure if there was a discussion on UNIX.SE related to how to do this but you can take a look at this question from AskUbuntu to get an idea on how to extract.

After this you will have to manually run the preinst script to see why the package installation fails.

share|improve this answer

If you want to edit the package directly try this:

#!/bin/bash

if [[ -z "$1" ]]; then
  echo "Syntax: $0 debfile"
  exit 1
fi

DEBFILE="$1"
TMPDIR=`mktemp -d /tmp/deb.XXXXXXXXXX` || exit 1
OUTPUT=`basename "$DEBFILE" .deb`.modfied.deb

if [[ -e "$OUTPUT" ]]; then
  echo "$OUTPUT exists."
  rm -r "$TMPDIR"
  exit 1
fi

dpkg-deb -x "$DEBFILE" "$TMPDIR"
dpkg-deb --control "$DEBFILE" "$TMPDIR"/DEBIAN

if [[ ! -e "$TMPDIR"/DEBIAN/control ]]; then
  echo DEBIAN/control not found.

  rm -r "$TMPDIR"
  exit 1
fi

CONTROL="$TMPDIR"/DEBIAN/control

MOD=`stat -c "%y" "$CONTROL"`
vi "$CONTROL"

if [[ "$MOD" == `stat -c "%y" "$CONTROL"` ]]; then
  echo Not modfied.
else
  echo Building new deb...
  dpkg -b "$TMPDIR" "$OUTPUT"
fi

rm -r "$TMPDIR"

Source: http://ubuntuforums.org/showthread.php?t=636724

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.