OpenWrt does not have bash by default. The following commands are in pure busybox.
- Get installed packages by calling opkg list_installed
- Remove everything after ‘ – ‘ with sed
- Add opkg upgrade at the beginning of each line
- Finally we evaluate the sed output with eval
Full command:
# eval $(opkg list_installed | sed 's/ - .*//' | sed 's/^/opkg upgrade /')
Thank you very much! This is what i’m looking for! And it’s running nice!
Pingback: Geoff's Place » OpenWRT update on an NSLU2 (and some minor OSX stuff mixed in as well)
Why not use opkg list-upgradable ?
Instead, I’d suggest:
opkg list-upgradable | xargs opkg upgrade
opkg list-upgradable | awk -F ‘ – ‘ ‘{print $1}’ | xargs opkg upgrade
opkg list-upgradable | awk -F ' - ' '{print $1}' | xargs opkg upgrade
opkg list-upgradable | awk -F ‘ – ‘ ‘{print $1}’ | xargs -r opkg upgrade
opkg list-upgradable | cut -d ” ” -f1 | xargs -r opkg upgrade
opkg upgrade `opkg list-upgradable|cut -f1 -d-`
opkg upgrade $(opkg list-upgradable | cut -f1 -d ‘ ‘)
I think you want use ‘ ‘ as a delimiter, since some package-names contain a ‘-‘
opkg upgrade $(opkg list-upgradable | grep ‘ – ‘ | cut -f1 -d ‘ ‘)
eval $(opkg list-upgradable |grep -v ‘Multiple packages’| sed ‘s/ – .*//’ | sed ‘s/^/opkg upgrade /’)
OK, so here is mine:
opkg upgrade $(opkg list-upgradable | awk ‘{ print $1 }’)
😀
I think you would need printf there, since print outputs a new line.
Probably awk ‘{ printf “%s “,$1 }’
Just why openWRT doesn’t integrate this fundamental update feature into OPKG command? Why make it complicate make no sense to me.
Thanks for (all) your Solution(s) xD
I have created a script that lists the packages, let you confirm, etc. You can find it here:
https://gist.github.com/tavinus/bf6dff1c11e7c9951b829b4e33eb6076
And this is my one-liner with opkg update included:
opkg update >/dev/null; PACKS=”$(opkg list-upgradable | awk ‘{ printf “%s “,$1 }’)” && [[ ! -z “$PACKS” ]] && opkg install $PACKS || echo $’\nNo packages to install\n’
Hillarious, most commands dont work:) What a terrible firmware – LEDE/OpenWRT – anyway. Remember the Asus merlin luxury – easy upgrades, all configuration preserved.
YES, it is unbelievable that OpenWRT still has no GUI upgrade facility 🙁
This works for me
# opkg update
# opkg list-upgradable | awk -F ‘ – ‘ ‘{print $1}’ | xargs opkg upgrade
I think the main reason most of these commands don’t work is because the blog engine is replacing single quotes with specialized in/out-quote characters that the terminal won’t understand. Considering that this post is a prominent Google search result, please integrate the best of these suggestions into the post in a way that actually preserves the integrity of the commands!
opkg upgrade $(opkg list-upgradable | sed ‘s/ -.*//’)
This works for me without a hassle.
opkg update
opkg list-upgradable |
while read PKG REST
do
echo “opkg upgrade $PKG $REST”
opkg upgrade $PKG
done
Alberto, yours is the only one that works via cut/paste – Thankyou sir
opkg update&opkg upgrade $(opkg list-upgradable | awk ‘{ printf “%s “,$1}’)
Slightly simpler version of what C0rn3J posted above that worked for me:
# opkg update
# opkg list-upgradable | awk ‘{print $1}’ | xargs opkg upgrade
There seems to be some indication that this may be a terrible idea and isn’t actually supported by OpenWRT in any official way (which may account for the lack of any simple GUI way of performing this function):
https://forum.openwrt.org/t/okpg-upgrade-safeguards/30326
https://forum.openwrt.org/t/opkg-upgrade-vs-flashing-sysupgrade/58906
https://forum.openwrt.org/t/sysupgrade-instead-of-opkg-upgrade/32897/4
I’m not an openWRT expert, but this is still a top search result for “updating openwrt” despite its age and seems to be giving what may be very bad advice.
I use:
for i in `opkg list-upgradable | awk -F’ – ‘ -e ‘{ print $1 }’`; do opkg upgrade $i; done
As far as J. Reis’ comment goes… I’ve been applying package upgrades with this loop for several years now, and I have never run into any issues. The actual image still needs to be upgraded from time to time to cover newly discovered vulnerabilities.