I have OpenWrt 18.06-SNAPSHOT r7781-f63a1caf22 installed and I'd like to upgrade to 19.07.1.
The first problem I encounter in following the upgrade instructions here: https://openwrt.org/docs/guide-user/installation/generic.sysupgrade is that I didn't build the firmware so I don't know which packages were installed manually. This seems like a critical step and is mentioned in bold a few times on the instructions page. I tried a few of the suggestions, but they came back with an answer that 'opkg' and 'firewall' were manually installed and that doesn't seem correct. I got the firmware from here: http://www.netadair.de/openwrt/, for TP-LINK TL-WPA8630(P) V2. On RHEL, I could get an approximation by executing: rpm -qa --last. What is the best way to get this answer in OpenWrt?
My second problem is following this line on the instructions page: "Based on the list of user-installed packages customize your backup configuration to save the files not included in the default list." How do I do that? On RHEL, I could do rpm -Va to get a list which I could trim down. I don't see a way to do so with opkg.
opkg list-installed is the only easy way to check what packages are on a system. It doesn't differentiate whether they are built into the initial flash or were installed later.
Then look at the manifest file for the proposed install to see which are built in. Others would need to be installed later.
sysupgrade --create-backup is another useful command. It will make a tar file of all your configurations but not the packages themselves.
Most of the configuration files reside in /etc/config/, which is backed up.
If you added packages that use their own directory for storing the configurations you need to include them too. For example OpenVPN might use /etc/openvpn/ or quagga uses /etc/quagga/
I also backup the /root since I keep there some files and custom scripts.
Finally I am using the following script to backup list of packages and restore them after flashing:
Summary
#! /bin/sh
# Write a list of packages currently installed or read that list,
# presumably after a firmware upgrade, in order to reinstall all packages
# on that list not currently installed
#
# (c) 2013 Malte Forkel <malte.forkel@berlin.de>
#
# Originally found on OpenWrt forums at:
# https://forum.openwrt.org/viewtopic.php?pid=194478#p194478
# Thanks, too, to hnyman for important comments on this script
#
# Version history
# 0.2.2 - editorial tweaks to help text -richb-hanvover
# 0.2.1 - fixed typo in awk script for dependency detection
# 0.2.0 - command interface
# 0.1.0 - Initial release
PCKGLIST=/etc/config/opkg.installed # default package list
SCRIPTNAME=$(basename $0) # name of this script
COMMAND="" # command to execute
INSTLIST=$(mktemp) # list of packages to install
PREQLIST=$(mktemp) # list of prerequisite packages
UPDATE=false # update the package database
OPKGOPT="" # options for opkg calls
VERBOSE=false # be verbose
cleanup () {
rm -f $INSTLIST $PREQLIST
}
echo_usage () {
echo \
"Usage: $(basename $0) [options...] command [packagelist]
Available commands:
help print this help text
write write a list of currently installed packages
install install packages on list not currently installed
script output a script to install missing packages
Options:
-u update the package database
-t test only, execute opkg commands with --noaction
-v be verbose
$SCRIPTNAME can be used to re-install those packages that were installed
before a firmware upgrade but are not part of the new firmware image.
Before the firmware upgrade, execute
$SCRIPTNAME [options...] write [packagelist]
to save the list of currently installed packages. Save the package list in a
place that will not be wiped out by the firmware upgrade. The default package list
is '$PCKGLIST', which works well for normal sysupgrades. Or copy that file to
another computer before the upgrade if you are not preserving the settings.
After the firmware upgrade, execute
$SCRIPTNAME [options...] install [packagelist]
to re-install all packages that were not part of the firmware image.
By default, the script will use the previously-created '$PCKGLIST'.
Alternatively, you can execute
$SCRIPTNAME [options...] script [packagelist]
to output a shell script that will contain calls to opkg to install those
missing packages. This might be useful if you want to check which packages
would be installed of if you want to edit that list.
In order for this script to work after a firmware upgrade or reboot, the
opkg database must have been updated. You can use the option -u to do this.
You can specify the option -t to test what $SCRIPTNAME would do. All calls
to opkg will be made with the option --noaction. This does not influence
the call to opkg to write the list of installed packages, though.
"
}
trap cleanup SIGHUP SIGINT SIGTERM EXIT
# parse command line options
while getopts "htuvw" OPTS; do
case $OPTS in
t )
OPKGOPT="$OPKGOPT --noaction";;
u )
UPDATE=true;;
v )
VERBOSE=true;;
[h\?*] )
echo_usage
exit 0;;
esac
done
shift $(($OPTIND - 1))
# Set the command
COMMAND=$1
# Set name of the package list
if [ "x$2" != "x" ]; then
PCKGLIST="$2"
fi
#
# Help
#
if [ "x$COMMAND" == "x" ]; then
echo "No command specified."
echo ""
COMMAND="help"
fi
if [ $COMMAND == "help" ]; then
echo_usage
exit 0
fi
#
# Write
#
if [ $COMMAND = "write" ] ; then
if $VERBOSE; then
echo "Saving package list to $PCKGLIST"
fi
# NOTE: option --noaction not valid for list-installed
opkg list-installed > "$PCKGLIST"
exit 0
fi
#
# Update
#
if $UPDATE; then
opkg $OPKGOPT update
fi
#
# Check
#
if [ $COMMAND == "install" ] || [ $COMMAND == "script" ]; then
# detect uninstalled packages
if $VERBOSE && [ $COMMAND != "script" ]; then
echo "Checking packages... "
fi
cat "$PCKGLIST" | while read PACKAGE SEP VERSION; do
# opkg status is much faster than opkg info
# it only returns status of installed packages
#if ! opkg status $PACKAGE | grep -q "^Status:.* installed"; then
if [ "x$(opkg status $PACKAGE)" == "x" ]; then
# collect uninstalled packages
echo $PACKAGE >> $INSTLIST
# collect prerequisites
opkg info "$PACKAGE" |
awk "/^Depends: / {
sub(\"Depends: \", \"\"); \
gsub(\", \", \"\\n\"); \
print >> \"$PREQLIST\"; \
}"
fi
done
fi
#
# Install or script
#
if [ $COMMAND == "install" ]; then
# install packages
cat "$INSTLIST" | while read PACKAGE; do
if grep -q "^$PACKAGE\$" "$PREQLIST"; then
# prerequisite package, will be installed automatically
if $VERBOSE; then
echo "$PACKAGE installed automatically"
fi
else
# install package
opkg $OPKGOPT install $PACKAGE
fi
done
elif [ $COMMAND == "script" ]; then
# output install script
echo "#! /bin/sh"
cat "$INSTLIST" | while read PACKAGE; do
if ! grep -q "^$PACKAGE\$" "$PREQLIST"; then
echo "opkg install $PACKAGE"
fi
done
else
echo "Unknown command '$COMMAND'."
echo ""
echo_usage
exit 1
fi
# clean up and exit
exit 0
Is there a command to find all configuration files that were installed by an arbitrary package are were modified? I'm looking for the OpenWrt equivalent of rpm -V [package name] which provides such an answer for rpm-based Linux distributions.
One more question that is related to this subject:
How can I determine which firmware is the closest match for my device if the exact version of my hardware doesn’t list any firmware of version 19.07.1?
Here is my specific example. I have WPA8630 v2 and the device page for it does NOT say that it works with 19.07.1. However, v1 of the same device does say that it works with 19.07.1, specifically: openwrt-ar71xx-generic-tl-wpa8630-v1-squashfs-sysupgrade.bin. How do I decide if this will also work for my v2 device?
That links to unofficial firmware based on 18.06 from jun-2019. I have that running well right now. I’m interested to upgrade to 19.07 and to find the right firmware for my device.