Home > bash > Modify dependencies of a .deb file

Modify dependencies of a .deb file

Problem

You have a .deb file that doesn’t install because of some dependency problem. You want to tweak the list of dependencies yourself.

Example: under Ubuntu 10.10 I wanted to install Boxee TV. I downloaded the .deb file but it didn’t install. It said "Dependency is not satisfiable: libdirectfb-1.0-0|libdirectfb-1.2-0", though I had libdirectfb-1.2-9 on the system. So the natural solution is to modify the dependency from libdirectfb-1.2-0 to libdirectfb-1.2-9. This problem and its solution was provided here.

Solution

Here I found a nice script that allows you to modify a .deb file. It extracts the .deb file, you modify the dependencies, then it repacks the file. Easy. The script is the following:

#!/bin/bash

# videbcontrol.sh , from http:// ubuntuforums .org/showthread.php?t=636724

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"

Credits

Categories: bash Tags: ,
  1. January 18, 2011 at 17:21

    Well, they should not depend on packaging versions: ie: libdirectfb-1.2-9 That -9 is the 1.2 packae 9th revision, it’s going to be bothersome and it is a serius debian policy violation. You should report a bug. Workarounds only work for one person. Bugfixes make kittens happy :)

  2. April 24, 2017 at 09:15

    hi. I am encountering a videbcontrol: command not found error. How to rectify that?

  1. August 6, 2014 at 14:47
  2. December 5, 2014 at 16:13

Leave a comment