Comment 68 for bug 1707352

Revision history for this message
Warren (wseverin) wrote :

I have created a generalized bash script that rebuilds .deb packages, changing the dependency from libsane (whatever version) to libsane1 (>= 1.0.27). Here for your enjoyment is "fixlibsane1.sh":

[code]
#!/bin/bash

# A simple script to make packages that are uninstallable due to change from
# libsane to libsane1 installable, by changing the dependency in the .deb package.
# First parameter is path to .deb file to modify, like so:
# ./fixlibsane1.sh iscan_2.30.3-1_amd64.deb
# The "Depends: field will have libsane (version)" changed to "libsane1 (>= 1.0.27)"
# A new deb package will be created alongside the original, ending in "-mod.deb"
# --Warren Severin

indebfull=$1
indebbase=$(basename "$indebfull")
indebdir=$(dirname "$indebfull")
indebext="${indebbase##*.}"
indebroot="${indebbase%.*}"
tmpdir=$(mktemp -d)

if [ ! "$indebext" = "deb" ]; then
  echo "Did you enter the path to the .deb file as the first parameter? Exiting."; exit 1; fi
if [ ! -e "$indebfull" ]; then
  echo "Not finding $indebfull. Exiting."; exit 1; fi
if [ -z $(which perl) ]; then
  echo "This script requires perl. Do you need to install it? Exiting."; exit 1; fi

dpkg-deb -x "$indebfull" "$tmpdir"
dpkg-deb --control "$indebfull" "$tmpdir/DEBIAN"
perl -i -pe 's/^(Depends:.*?)libsane( +\(.*?\))?/\1libsane1 (>= 1.0.27)/' "$tmpdir/DEBIAN/control"
dpkg -b "$tmpdir" "${indebdir}/${indebroot}-mod.deb"

rmdir --ignore-fail-on-non-empty "$tmpdir"
echo "Done!"
[/code]