I have seen a lot of posts where people are unable to install packages on their router via opkg because of a lack of memory.
So, since the attitude_adjustment beta was released, I want to renew my backfire router.
I switched to attitude_adjustment a few days ago and now I am also unable to install packages as my router runs out of memory.
The problem is that the uncompressed Packages file is just too big, holding lots of packages you may not need.
Here is a small shell script as a solution:
(opkg-filestrip.sh)
#!/bin/sh
PKGFILE=Packages
NEWFILE=Packages.strip
PKGLIST=$(mktemp -q)
packages_depends_r(){
local pkg
local line
local buf
for pkg in $@
do line="$line\|$pkg"
done
buf=$(sed -n -e "/^Package: \($line\)$/,/^$/p" $PKGFILE)
test -z "$buf" && return
echo -e "$buf\n" >> $NEWFILE
echo "$buf" | sed -n -e "s/^Package: \(.*\)/\1/p" >> $PKGLIST
line=
for pkg in $(echo "$buf" | sed -n -e "s/^Depends: \(.*\)/\1/p" | tr , " ")
do grep -q "^$pkg$" $PKGLIST && continue
line="$line $pkg"
done
test "$line" && packages_depends_r "$line"
}
> $NEWFILE
packages_depends_r $@
for pkg in $@
do grep -q "^$pkg$" $PKGLIST || echo "$pkg N/A" > /dev/stderr
done
rm $PKGLIST
Run this script on your PC to strip down the large Packages file, so just the packages you need are included.
Example usage:
(I just want to have "qos-scripts")
$ curl -O http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/atheros/generic/packages/Packages.gz
$ gunzip Packages.gz
$ ./opkg-filestrip.sh qos-scripts
There should have been a file created, called "Packages.strip"
now you have two choices to go on
1. download from "downloads.openwrt.org"
router: # mkdir /tmp/opkg-lists
$ scp Packages.strip root@router.lan:/tmp/opkg-lists/attitude_adjustment
router: # opkg install qos-scripts
Do not run "opkg update"! This will replace our stripped down Packages file with the large one.
2. download from own server
$ sed -n -e "s/^Filename: \(.*\)/\1/p" Packages.strip
Download these files from http://downloads.openwrt.org/attitude_a … /packages/
$ gzip -c Packages.strip > Packages.gz
Just copy all ipk-files and the new Packages.gz to your ftp/http server.
Now edit /etc/opkg.conf on your router and set the address of your server.
router: # opkg update
router: # opkg install qos-scripts
Everything written here and the script itself is in the public domain.
Thanks to all the developers of openwrt!