-
-
Save vbajpai/4463250 to your computer and use it in GitHub Desktop.
#!/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" |
This gives error as opkg: the ``install'' command requires at least one argument
Sadly it seems i get this when attempting to clean a failed installation attempt of syslog-ng
.
root@OpenWrt:/tmp# ./clean.sh syslog-ng
Downloading http://downloads.lede-project.org/releases/17.01.4/targets/ar71xx/generic/packages/Packages.gz
Updated list of available packages in /var/opkg-lists/reboot_core
Downloading http://downloads.lede-project.org/releases/17.01.4/targets/ar71xx/generic/packages/Packages.sig
Signature check passed.
Downloading http://downloads.lede-project.org/releases/17.01.4/packages/mips_24kc/base/Packages.gz
Updated list of available packages in /var/opkg-lists/reboot_base
Downloading http://downloads.lede-project.org/releases/17.01.4/packages/mips_24kc/base/Packages.sig
Signature check passed.
Downloading http://downloads.lede-project.org/releases/17.01.4/packages/mips_24kc/luci/Packages.gz
Updated list of available packages in /var/opkg-lists/reboot_luci
Downloading http://downloads.lede-project.org/releases/17.01.4/packages/mips_24kc/luci/Packages.sig
Signature check passed.
Downloading http://downloads.lede-project.org/releases/17.01.4/packages/mips_24kc/packages/Packages.gz
Updated list of available packages in /var/opkg-lists/reboot_packages
Downloading http://downloads.lede-project.org/releases/17.01.4/packages/mips_24kc/packages/Packages.sig
Signature check passed.
Downloading http://downloads.lede-project.org/releases/17.01.4/packages/mips_24kc/routing/Packages.gz
Updated list of available packages in /var/opkg-lists/reboot_routing
Downloading http://downloads.lede-project.org/releases/17.01.4/packages/mips_24kc/routing/Packages.sig
Signature check passed.
Downloading http://downloads.lede-project.org/releases/17.01.4/packages/mips_24kc/telephony/Packages.gz
Updated list of available packages in /var/opkg-lists/reboot_telephony
Downloading http://downloads.lede-project.org/releases/17.01.4/packages/mips_24kc/telephony/Packages.sig
Signature check passed.
tar: invalid magic
tar: short read
tar: invalid magic
tar: short read
tar: invalid magic
tar: short read
tar: invalid magic
tar: short read
tar: invalid magic
tar: short read
tar: invalid magic
....
Am running the following:
BusyBox v1.25.1 () built-in shell (ash)
_________
/ /\ _ ___ ___ ___
/ LE / \ | | | __| \| __|
/ DE / \ | |__| _|| |) | _|
/________/ LE \ |____|___|___/|___| lede-project.org
\ \ DE /
\ LE \ / -----------------------------------------------------------
\ DE \ / Reboot (17.01.4, r3560-79f57e422d)
\________\/ -----------------------------------------------------------
have similar error as @hak8or
$ ./gcc.sh gcc
Downloading https://mirrors.ustc.edu.cn/lede/releases/18.06.1/targets/ramips/mt7621/packages/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_core
Downloading https://mirrors.ustc.edu.cn/lede/releases/18.06.1/targets/ramips/mt7621/packages/Packages.sig
Signature check passed.
Downloading https://mirrors.ustc.edu.cn/lede/releases/18.06.1/packages/mipsel_24kc/base/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_base
Downloading https://mirrors.ustc.edu.cn/lede/releases/18.06.1/packages/mipsel_24kc/base/Packages.sig
Signature check passed.
Downloading https://mirrors.ustc.edu.cn/lede/releases/18.06.1/packages/mipsel_24kc/luci/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_luci
Downloading https://mirrors.ustc.edu.cn/lede/releases/18.06.1/packages/mipsel_24kc/luci/Packages.sig
Signature check passed.
Downloading https://mirrors.ustc.edu.cn/lede/releases/18.06.1/packages/mipsel_24kc/packages/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_packages
Downloading https://mirrors.ustc.edu.cn/lede/releases/18.06.1/packages/mipsel_24kc/packages/Packages.sig
Signature check passed.
Downloading https://mirrors.ustc.edu.cn/lede/releases/18.06.1/packages/mipsel_24kc/routing/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_routing
Downloading https://mirrors.ustc.edu.cn/lede/releases/18.06.1/packages/mipsel_24kc/routing/Packages.sig
Signature check passed.
Downloading https://mirrors.ustc.edu.cn/lede/releases/18.06.1/packages/mipsel_24kc/telephony/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_telephony
Downloading https://mirrors.ustc.edu.cn/lede/releases/18.06.1/packages/mipsel_24kc/telephony/Packages.sig
Signature check passed.
gzip: invalid magic
tar: Child returned status 1
tar: Error is not recoverable: exiting now
gzip: invalid magic
tar: Child returned status 1
tar: Error is not recoverable: exiting now
You may need to reboot for the free space to become visible
@hak8or do you have any workaround to solve this?
TL;DR see here for an updated version of this script.
The script was cutting off the last letter of the URL for some reason, causing the wget requests to 404, causing tar to try to extract files from 0 bytes, resulting in errors like tar: short read
and tar: invalid magic
.
The script didn't work on more recent versions of OpenWRT anyways, as it puts overlay files in /overlay/upper/ instead of /overlay/.
I've fixed these issues, made the script a bit more robust and added a few features (it doesn't download the package files twice anymore, to name one) . Hopefully it helps.
@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.
Is it possible to use the script for enigma 2 Recievers ? Like Dream or VU+ ?
best regards
Worked perfectly with OpenWrt 21.02.1 and TP-Link TL-MR3420 v5. Thanks, you are my saviors!
If you've attempted to install a lib package, it's likely to have created symlinks. Remove them too: