openwrt opkg
install not support specify package version.
ref:
https://stackoverflow.com/a/37938130/4896468
https://forum.openwrt.org/t/opkg-install-a-specific-package-version/33158/21
here is a workgroud to implement install specified version of package with opkg.
principle:
- find packge url in package list cache
- opkg install $pkg_url
shell code:
find_pkg(){
local name=$1
local f
awk '$1 ~ /^src/' /etc/opkg.conf /etc/opkg/*.conf | while read type repo url pad; do
f=/var/opkg-lists/$repo
{
[ $type == "src/gz" ] && zcat $f || cat $f;
} | {
awk -vname="$name" '$1=="Package:" && $2==name {f=1;r=1} $0=="" {f=0} f {print} END{exit 1-r}'
} | while read key val pad; do
[ "$key" == "Version:" ] && ver=$val
[ "$key" == "Filename:" ] && {
echo found $ver @$repo
echo $url/$val
}
done
done
}
$ find_pkg tree
found 9.9.9-1 @chen_test.txt
http://www.example.com/path/to/file?xxx/aaa/bbb/aa_tree_9.9.9-1_mips_24kc.ipk
found 1.7.0-2 @test_30
http://10.1.1.30/ipk/tree_1.7.0-2_ramips_24kec.ipk
found 1.8.0-1 @packages
http://downloads.openwrt.org/releases/18.06.1/packages/mipsel_24kc/packages/tree_1.8.0-1_mipsel_24kc.ipk
then
$ opkg install $url_of_ipk
@Vir-Dominary
if only use in terminal shell, just write func define into
~/.profile
, which will auto load when login into shell.or save them to some file
~/_my_util
(for example), thensource ~/_my_util
(in terminal or in script) when you need them.