SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2011-02-17 15:53:10

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,462
Website

Utility to edit .deb file control data

True, if you know why you might want to edit a deb file's control data you probably know how to do it - or will after you've checked out half a dozen man pages to remind yourself of the exact commands... So if you're not doing this every day it can be handy to have a script that remebers it all for you. wink

Occasionally you might have downloaded a deb file with a dependency that you know you don't need, can't install or maybe doesn't exist because it's mis-spelled - whatever, gdebi or dpkg won't let you install it unless you change the dependencies in the control file. If you add this script to your Thunar custom actions, for "other files", pattern "*.deb", then it will appear in the right-click menu for .deb files, and let you make a modified file in the same directory with edited control data. Be careful. Don't do this kind of thing too often, as you can get in a real mess (as I discovered yesterday trying to install a recent vlc on #! 9.04). Even so, it can come in quite handy now and then.

This script is adapted from this Ubuntu forums thread, tweaked to be usable without a terminal (using notify-send for feedback) and a couple of other what-I-like-to-think-of-as improvements cool

#!/bin/bash
# edit the control data of a deb file,
# usually to get round a dependency problem
# adapted from http://ubuntuforums.org/showthread.php?t=636724
# needs libnotify-bin for notifications if used without a terminal

# choose your editor:
EDITOR=gedit

####################

[[ "$1" ]] ||  { echo "Syntax: $0 debfile" >&2; exit 1; }

DEBFILE="$1"
TMPDIR=$(mktemp -d /tmp/deb.XXXXXXXXXX) || exit 1
OUTPUT="${DEBFILE%.deb}".modfied-$( date +%FT%T ).deb

if [[ -e "$OUTPUT" ]]; then
  echo "$0: $OUTPUT exists." >&2
  rm -r "$TMPDIR"
  exit 1
fi

dpkg-deb -x "$DEBFILE" "$TMPDIR"
dpkg-deb --control "$DEBFILE" "$TMPDIR"/DEBIAN
CONTROL="$TMPDIR"/DEBIAN/control
[[ -e "$CONTROL" ]] || {
  echo "$0: DEBIAN/control not found in $1." >&2
  [ -t 1 ] || notify-send "$1: DEBIAN/control not found."
  rm -r "$TMPDIR"
  exit 1
}

MOD=$(md5sum "$CONTROL")
$EDITOR "$CONTROL"

if [[ $MOD = $(md5sum "$CONTROL") ]]; then
  [ -t 1 ] && echo "Not modfied."
else
  [ -t 1 ] && echo "Building new deb..." || notify-send "Building new deb..." "Please wait a moment."
  dpkg -b "$TMPDIR" "$OUTPUT"
  [ -t 1 ] && echo "Built new debfile: $OUTPUT" || notify-send "Built new debfile:" "$OUTPUT"
fi

rm -r "$TMPDIR"
exit

John
--------------------
( a boring Japan blog , and idle twitterings )

Offline

Help fund CrunchBang, donate to the project!

#2 2011-02-17 16:18:08

iann
#! CrunchBanger
Registered: 2010-09-10
Posts: 223

Re: Utility to edit .deb file control data

Or just use the --force-depends option smile  Also capable of really borking your machine!

Offline

#3 2012-04-08 10:25:34

thievingweka
Member
Registered: 2012-02-25
Posts: 10

Re: Utility to edit .deb file control data

hi! thanks for the very useful post. i've just used your script as a solution to my problem. I wanted to install MIT's scratch, a tool for learning to programme. in order to get the deb to install i needed to edit the control file (more details on that here: http://forums.debian.net/viewtopic.php?f=6&t=70241. not having any idea how to do this i searched and stumbled across your post. I saved your script as a file in my /usr/bin/ folder, gave the 'users' group r+w access, made the file executable, followed your instructions, installed libnotify-bin, and it worked like a charm. thanks so much!

Offline

#4 2012-04-09 18:08:24

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,462
Website

Re: Utility to edit .deb file control data

Glad it helped smile


John
--------------------
( a boring Japan blog , and idle twitterings )

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo