Last active
September 18, 2024 23:44
-
-
Save benok/10eec2efbe09070150ed2100d29dc743 to your computer and use it in GitHub Desktop.
[entware] List up manually installed packages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ash | |
list_pkgs() { | |
opkg list-installed | cut -f 1 -d " " | |
} | |
show_deps() { | |
opkg depends $1 | sed -e 1d -e 's/^\s*//' | |
} | |
if [ $(id -u) != 0 ]; then | |
echo 'you must be root.' | |
exit 1 | |
fi | |
TMPDIR=/tmp/$$ | |
if [ -d $TMPDIR ]; then | |
rm -rf $TMPDIR | |
fi | |
mkdir $TMPDIR | |
trap "rm -rf $TMPDIR; exit 1" 1 2 3 15 | |
# listup default packages | |
echo "entware-opt" > $TMPDIR/defaults | |
show_deps entware-opt >> $TMPDIR/defaults | |
# listup installed, but not default | |
touch $TMPDIR/pkgs_not_default | |
mkdir $TMPDIR/deps | |
for p in $(list_pkgs); do | |
egrep "^$p\$" $TMPDIR/defaults > /dev/null | |
if [ $? != 0 ]; then | |
echo $p >> $TMPDIR/pkgs_not_default | |
# listup depends | |
show_deps $p > $TMPDIR/deps/$p.deps | |
fi | |
done | |
# listup not depended by any others from not defaults | |
for p in $(cat $TMPDIR/pkgs_not_default); do | |
egrep "^$p\$" $TMPDIR/deps/* > /dev/null | |
if [ $? != 0 ]; then | |
echo $p | |
fi | |
done | |
rm -rf $TMPDIR | |
exit 0 |
Hi,
I wrote a small script to restore packages from installed_packages.txt
packages=$(cat installed_packages.txt)
for package in $packages
do
#echo $package
opkg install $package
done
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@TTimo,
I don't use Entware on the embedded environment like DD-WRT, etc.
If you know some emulated environment (VM or docker image) using busybox, I could make this work.
I'm not sure which part of the script doesn't work with busybox, though.
Are there any missing external commands below?
or