Skip to content

Instantly share code, notes, and snippets.

@cbednarski
Last active October 23, 2023 16:39
Show Gist options
  • Save cbednarski/fd16689d401b61e0d22d5a127a0333d2 to your computer and use it in GitHub Desktop.
Save cbednarski/fd16689d401b61e0d22d5a127a0333d2 to your computer and use it in GitHub Desktop.
Update deb package with libappindicator3-1 dependency to use libayatana-appindicator3-1 instead. For Debian 11.
#!/bin/bash
# Copying: Public domain.
set -e
sourceName=$1
if [[ $sourceName == "" ]]; then
echo "Usage: fix-libappindicator.sh <.deb>"
exit 1
fi
pwd=$(pwd)
source="${pwd}/${sourceName}"
targetName=$(echo ${sourceName} | sed s/\.deb/\.new\.deb/g)
target="${pwd}/${targetName}"
workdir=/tmp/fix-`date +%s`
controlWorkdir=${workdir}-control
# Extract the debian package
mkdir $workdir
cd $workdir
ar x $source
# Check whether we have a .tar.gz or tar.xz
controlFile=$(find -name control.tar.*)
controlType=${controlFile: -3}
case $controlType in
".xz")
tarFlag="J"
;;
".gz")
tarFlag="z"
;;
*)
echo "unknown control format \"${controlType}\". Hint: add a case here to handle it.";
exit 1;
;;
esac
# Extract the debian control archive
mkdir $controlWorkdir
cd $controlWorkdir
tar "-x${tarFlag}f" "${workdir}/${controlFile}"
# Fix the dependency
sed s/libappindicator3-1/libayatana-appindicator3-1/g control > control.new
# Repackage the control archive
mv control.new control
tar "-c${tarFlag}f" $controlFile *
mv $controlFile "${workdir}/${controlFile}"
# Repackage the debian package
cd $workdir
ar rcs $targetName debian-binary $controlFile data.tar.*
# Make a new copy of the package
mv $targetName $target
echo created: $targetName
@cbednarski
Copy link
Author

Debian 11 deprecated the libappindicator3-1 library and replaced it with libayatana-appindicator3-1. However, a number of vendor-provided deb packages like Discord, Slack, and Lens still reference libappindicator3-1. This script unpacks a .deb package, rewrites the dependency to the new, compatible libayatana-appindicator3-1 library, and repackages the debian package for you to install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment