Archive

Posts Tagged ‘boxee’

Modify dependencies of a .deb file

October 27, 2010 4 comments

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: ,