Skip to content

Instantly share code, notes, and snippets.

@vbajpai
Last active September 6, 2024 10:38
Show Gist options
  • Save vbajpai/4463250 to your computer and use it in GitHub Desktop.
Save vbajpai/4463250 to your computer and use it in GitHub Desktop.
If opkg runs out of space, it will not remove the files it was installing. Run this custom script in order recover the space by removing these files and the installed dependencies.
#!/bin/sh
#takes one argument/parameter: the name of the package which didn't install correctly and should be removed along with its dependencies
#do opkg update first
#example: ./opkgremovepartlyinstalledpackage.sh pulseaudio-daemon
#get list of all packages that would be installed along with package x
opkg update
PACKAGES=`opkg --force-space --noaction install $1 | grep http | cut -f 2 -d ' ' | sed 's/.$//'`
for i in $PACKAGES
do
LIST=`wget -qO- $i | tar -Oxz ./data.tar.gz | tar -tz | sort -r | sed 's/^./\/overlay/'`
for f in $LIST
do
if [ -f $f ]
then
echo "Removing file $f"
rm -f $f
fi
if [ -d $f ]
then
echo "Try to remove directory $f (will only work on empty directories)"
rmdir $f
fi
done
done
echo "You may need to reboot for the free space to become visible"
@codebling
Copy link

@lloydhazlett I've implemented your symlinks idea, but I'm not sure it's a good idea. I've opened an issue for discussion.

@rwv should be fixed here. If not, open an issue.
@hak8or fixed here.

@rverma-nikiai you need to supply an argument when running the script: the package name of the package you wish to clean up.

@skyerjoe
Copy link

Is it possible to use the script for enigma 2 Recievers ? Like Dream or VU+ ?

best regards

@Eugeniusz-Gienek
Copy link

Worked perfectly with OpenWrt 21.02.1 and TP-Link TL-MR3420 v5. Thanks, you are my saviors!

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