Buffalo WZR-HP-G300NH additional packages environment setup (ddwrt)


Assuming you’ve properly configured and initialized your jffs filesystem on your Buffalo WZR-HP-G300NH running the DD-WRT firmware, here’s the instructions to set-up the root filesystem (it needs its own, as the main root is not writable) and its package manager.


Creating root and installing the package manager

Download a compatible rootfs and install it in /jffs

cd /jffs
wget http://downloads.openwrt.org/snapshots/trunk/ar71xx/openwrt-ar71xx-generic-rootfs.tar.gz -O - | tar -zxf -

Download the opkg package manager which allows reconfiguring paths
wget "http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/opkg_*.ipk"
ipkg -d /jffs/ install opkg_*.ipk

Alternative 1 – relocated

Create your opkg configuration (using echo to allow copy/paste without switching to vi)
echo "src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/" > /jffs/etc/opkg_relocated.conf
echo "dest root /jffs" >> /jffs/etc/opkg_relocated.conf
echo "dest ram /tmp" >> /jffs/etc/opkg_relocated.conf
echo "lists_dir ext /jffs/var/opkg-lists" >> /jffs/etc/opkg_relocated.conf

You now have a second root installed in /jffs with its package manager, but we need to fix runtime binaries and libraries paths.
Create the setup script in your jffs root:
echo "export LD_LIBRARY_PATH=/jffs/lib:/jffs/usr/lib:/lib/:/usr/lib" > /jffs/setup.relocated
echo "export PATH=/jffs/bin:/jffs/sbin:/jffs/usr/sbin:/jffs/usr/bin:/bin:/sbin" >> /jffs/setup.relocated
echo "alias opkg='opkg -f /jffs/etc/opkg_relocated.conf'" >> /jffs/setup.relocated
chmod +x /jffs/setup.relocated

Initialize your environment when you need to use it
. /jffs/setup.relocated

Alternative 2 – chroot’ed

Here’s a better alternative relying on chroot, but needs to have completed alternative 1’s steps first. (or you won’t be able to install chroot)

Install chroot

opkg install chroot

Create the setup script for this configuration


echo "BIND_DONE=\`mount | grep /jffs/proc\`" > /jffs/setup.chroot
echo "if [ -z \"\$BIND_DONE\" ]; then for fs in dev sys mnt proc ; do mount --bind /\$fs /jffs/\$fs ; mount --bind /tmp/var /jffs/tmp/ ; done ; fi" >> /jffs/setup.chroot
echo "mkdir /var/lock" >> /jffs/setup.chroot
echo "/jffs/usr/sbin/chroot /jffs" >> /jffs/setup.chroot
chmod +x /jffs/setup.chroot

Create a regular opkg configuration to make it work inside chroot

echo "src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/" > /jffs/etc/opkg.conf
echo "dest root /" >> /jffs/etc/opkg.conf
echo "dest ram /tmp" >> /jffs/etc/opkg.conf
echo "lists_dir ext /var/opkg-lists" >> /jffs/etc/opkg.conf
rm /jffs/etc/opkg/xwrt.conf ; ln -s /etc/opkg.conf /jffs/etc/opkg/xwrt.conf
cp /etc/resolv.conf /jffs/etc/resolv.conf

Initialize your environment when you need to use it
. /jffs/setup.chroot

Finally

don’t forget to fetch the packages list:

opkg update
You can now install any package you want.