Skip to content

Instantly share code, notes, and snippets.

@alfredkrohmer
Created February 11, 2017 13:39
Show Gist options
  • Save alfredkrohmer/8d4c2a5ab62e690772f3d9de5ad2d978 to your computer and use it in GitHub Desktop.
Save alfredkrohmer/8d4c2a5ab62e690772f3d9de5ad2d978 to your computer and use it in GitHub Desktop.
List all user-installed packages on OpenWrt / LEDE
#!/bin/sh
FLASH_TIME=$(opkg info busybox | grep '^Installed-Time: ')
for i in $(opkg list-installed | cut -d' ' -f1)
do
if [ "$(opkg info $i | grep '^Installed-Time: ')" != "$FLASH_TIME" ]
then
echo $i
fi
done
@guymarc
Copy link

guymarc commented Jul 25, 2018

Sorry but seems like I donot know how to insert code in my message

@abrahamtamayo
Copy link

Oh .. Many Tnxs .. I took care about whats programs installed, wrote at a list .. but is possible I missed something in the way .. it's is very useful ..

@tinxx
Copy link

tinxx commented Feb 19, 2021

Yet another variant:

DISTRI_TIME=$(grep Installed-Time /usr/lib/opkg/status | sort | head -n1)

while read -r line; do
  case "$line" in
    "Package: "*)
        package="$line"
        _skip=false;;
    "${DISTRI_TIME}")
        _skip=true;;
    "Auto-Installed: yes")
        _skip=true;;
    "") # Empty line delimenates individual package blocks
        [ "$_skip" = true ] || echo "$package" | awk '{print $2}';;
  esac
done < /usr/lib/opkg/status | sort

Cheers!

@don-coleman
Copy link

And yet another variant. This one produces a more accurate/minimal list, as it also skips all dependents of other packages. It's based on bash, as it uses associative arrays.

https://gist.github.com/don-coleman/2218210aec58986acc80467f9a15d42b

@ZWx4
Copy link

ZWx4 commented Apr 20, 2021

Thanks @guymarc! Your script is the only one that worked for me. The other scripts here just list every single package installed. Maybe it is that way because I also used the Image Builder.

@rafalfitt
Copy link

as someone suggested on https://www.sindastra.de/p/1213/list-user-installed-packages-in-openwrt

You can update busybox via opkg update, so it’s install time can be wrong as reference.
As a result you will have wrong list.
Only one thing you cannot install via opkg is kernel – because you update it over flashing new firmware.
So the kernel’s install time should be used as flash time.
FLASH_TIME=$(opkg info kernel | grep ‘^Installed-Time: ‘)

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