|
Note: You can, if you wanted too, install every package in the repository manually this way. However this would mean that you will have to resolve the dependencies on your own… and what would be the fun in that?
Obtaining the dynamic library files (“lib”s)
The required “lib” files to make Opkg work, are part of the OpenWRT distribution. To obtain them, one has to extract them from the “Root FileSystem” of said distribution.
To do This, download the latest basic “Root FileSystem” for the openWRT distrebution which containes the required “lib”s from the OpenWRT project trunk:
wget http://downloads.openwrt.org/sna ... neric-rootfs.tar.gz
Extract it using:
tar xvzf openwrt-ar71xx-generic-rootfs.tar.gz
Copy the “libs” files from the “rootfs” we’ve extracted above to the “libs” directory on our JFFS, while preserving their attributes and symbolic links:
cp -Pp /tmp/1/lib/* /jffs/usr/lib/
Note: You will get messages saying that the sub-directories are being omitted. As we don’t need anything but the “lib” files, this is fine and you can safely ignore these messages.
Fixing the LD_LIBRARY “PATH”
We need to tell the router, where to look for the shared libraries (libs) we’ve just “installed” and that it needs to do this before the ones that came with the firmware.
To do this set the LD_LIBRARY environment variable manually (for now), to make it so the location where we copied the new lib files will be the first one in the “PATH”:
export LD_LIBRARY_PATH=/jffs/usr/libLD_LIBRARY_PATH
Read-writable “/etc”
We are going to copy “/etc” to JFFS and then make the regular “/etc” mount point, point to it. Doing so, will both open up a world of possibilities, because “/etc” will become read-writeable (which I personally have been waiting for give or take 7 years now) and enable packages that expect this behavior, to work correctly.
Create the directory that will hold “/etc”:
mkdir -p /jffs/geek/etc
Recursively copy the entirety of “/etc” while preserving all subdirectories, file attributes and symbolic links.
cp -a /etc/* /jffs/geek/etc/
Manually (for now) “bind mount” the “/etc” directory to the JFFS one:
mount -o bind /jffs/geek/etc/ /etc/
Set the Optware directory (“/opt”)
Opkg from OpenWRT, expects to be used when the router’s firmware is built. As at such time, the FileSystem isn’t on the router yet, and thus still subject to change, there is no problem installing to any location on the FileSystem. That is why the Opkg configuration file points packages to install to the “root” (/) of the FileSystem. However, we are using Opkg after the firmware was built and installed on the router, and as we can’t change the root of the filesystem to be read-writeable, we will point all installations to be installed under “/opt”. However Currently “/opt” also points to a read-only location on the router’s firmware. To overcome this, we will make “/opt” point to JFFS, which is read-writable.
To do this, Create the directory that will contain the Optware packages:
mkdir -p /jffs/opt
Manually (for now) “bind mount” the “/opt” directory to the JFFS one:
mount -o bind /jffs/opt/ /opt/
Note: While beyond the scope of this guide, more advanced users may want to change this mount point, to point to an HD.
Adjusting the Opkg configurations file
We want the Opkg configuration file to be where Opkg searches for it by default (which is “/etc”) and adjusted to install to “/opt”.
To do this, move the opkg configuration file installed by the Opkg package to the read-writable “/etc” location:
mv /jffs/etc/opkg.conf /etc/
Change the destination for Optware installations to be “/opt” instead of “root” (/).
To do this, with the “vi” editor or WinSCP navigate to “/etc/” and make the “opkg.conf” file’s content:
vi /etc/opkg.conf
Make it look like:
src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages
dest root /opt
dest ram /tmp
lists_dir ext /var/opkg-lists
option overlay_root /overlay
Note: You can change the “lists_dir” directive to point to a location that isn’t in RAM, but rather on JFFS. While this would relieve you from updating the lists, before you can install additional software (if your router is rebooted from the last time), you would lose about 1.5MB of the scarce JFFS space and you would be compounding to its erosion.
Hello baby
You should be able to see that Opkg is working by issuing the update and lists commands.
If all went well you should be seeing that the Opkg lists have been updated without error and you are ready to implement the script in the next step:
opkg update; opkg list
Take the time to start exploring the packages available on the repository….
StartUp script
We now need to make it so all of the required mounting and path-ing will happen automatically when the router boots. To that end, we’ve created for you, this initialization geek-init script.
Download, then extract it and place it under “/jffs/geek/etc/”. (Consider doing this with WinSCP).
Make the script executable by going into its properties with WinSCP or executing:
chmod +x /jffs/geek/etc/geek-init.sh
Make the script execute on the router’s startup, using the WebGUI. Under Administration -> Commands, in the text box, put:
/jffs/geek/etc/geek-init.sh web-gui
And Click “Save Startup”.
Kicking the tires
If all went well, you should now be able to reboot the router and still use the Opkg package manager. That is to update, list and install applications.
Lets test that everything is working by installing the “netstat” command, which for some reason has been omitted from DD-WRT’s builds lately. Before we do this, execute the netstat command in the terminal and you will see that you’re grated by an error from the shell, saying “-sh: netstat: not found”.
Your first step will always be, to update the Opkg lists, as to have the latest packages listing from the repository:
opkg update
If you don’t know which package contains the “netstat” command, you can filter the results using.
opkg list | grep netstat
And now install “netstat” using:
opkg install net-tools-netstat
And now, when you execute the netstat command again it works… neat ha?
Until the future articles in which we will install and configure software packages using this method, may you have tons of geek fun exploring the vast amount of software that is now right at your finger tips.
|
|