- 1 Subversion commits
- 2 Mounting a JFFS2 Image
- 3 Iptables
- 4 Compiling Perl scripts into .par archives
- 5 Setting the date via busybox
- 6 Regular Expressions
- SVN Checkout
- svn co svn+ssh://machine.name/dir/to/repository
Create A Reository
- svnadmin create /projects/ubicomp/uwar/subversion/www
- svn import svn+ssh://email@example.com/projects/ubicomp/uwar/subversion/www
Mounting a JFFS2 Image
The filesystem used on the iMote2s is a JFFS2 filesystem. Once you've created the filesystem on a linux desktop you can actually mount it and make changes (so you don't have to change the source files and recreate the image every time).
The JFFS2 filesystem is intended to be used with a flash based filesystem and not a block filesystem like a hard drive (or a USB stick which emulates a block filesystem). Because of this you cannot simply mount a .jffs2 image using the loopback device. Instead you need to use a flash emulator (blkmtd in this case) which reads the .jffs2 image via a loopback device (remember since we need the emulation there's no way to mount the loopback directly).
- Connect a free loop device to the .jffs2 image: <bash>losetup /dev/loop0 ~/fs.jffs2</bash>
- Connect the blkmtd emulator module to the loopback device: <bash>modprobe blkmtd device=/dev/loop0</bash>
- Mount the mtdblock device blkmtd attached to <bash>mount /dev/mtdblock0 /mnt/jffs2Image</bash>
The basic steps are (you will need to be root to mount and load modules):
All together that would be (where you would need to change ~/fs.jffs2 to point to where your image is and /mnt/jffs2Image to your chosen mount point). <bash>losetup /dev/loop0 ~/fs.jffs2 modprobe blkmtd device=/dev/loop0 mount /dev/mtdblock0 /mnt/jffs2Image</bash>
Creating missing devices
If you're missing loop devices here are the mknod commands to create loop0-loop5:
<bash>mknod /dev/loop0 b 7 0
mknod /dev/loop1 b 7 1
mknod /dev/loop2 b 7 2
mknod /dev/loop3 b 7 3
mknod /dev/loop4 b 7 4
mknod /dev/loop5 b 7 5</bash>
And here's how to create the mtdblock devices:
<bash>mknod /dev/mtdblock0 b 31 0
mknod /dev/mtdblock1 b 31 1
mknod /dev/mtdblock2 b 31 2
mknod /dev/mtdblock3 b 31 3
mknod /dev/mtdblock4 b 31 4
mknod /dev/mtdblock5 b 31 5</bash>
Modified from Ed Bartosh's script (here):
- JFFS2 image location:
- Directory to mount the image on:
- Loop back device to use:
IPtables is a userland program for controlling packet filtering in the Linux kernel.
- iptables-save writes the current iptables to the screen. iptables-save is used to dump the iptables to a file (i.e. iptables-save > curtables)
- iptables-restore reads the output from iptables-save and sets up the iptables accordingly (i.e. iptables-restore curtables)
- /etc/init.d/iptables save instruct the iptables program to save the current iptables to /etc/default. These will be loaded on reboot.
Compiling Perl scripts into .par archives
Perl scripts can be used to accomplish a number of useful tasks; however, in order for someone else to use your script they need to make sure they have the appropriate set of modules and libraries that your script requires. Unfortunately, installing all the appropriate versions can become a headache to deal with. Instead you can create an archive that will store all the required perl modules in an archive which you can then distribute and run.
To do this we use PAR which is a 'Cross-Platform Packaging and Deployment tool' for Perl. PAR comes with a packager (pp) that will take a .pl script, find all its dependencies and pack them into a .par archive.
The .par archive can then be run using a parl interpreter/runtime (parl.exe or a parl executable on linux). It is also possible to turn a .par directly into an platform specific (Windows or Linux) executable.
The advantages of .par archives are:
- User doesn't need to have perl installed
- User doesn't have to install perl dependencies
- All things being equal the program doesn't suffer from bit rot (updates to the users Perl installation don't have side effects on the .par)
- Simplifies distribution and runtime (parl <your.par> <args>)
- .par archives can be created on any platform (i.e. it is easier to install PAR on Linux than to install it on Windows with ActivePerl)
To install PAR you can use Perl's package manager, CPAN. Start CPAN in an interactive shell using the command:
<bash>perl -MCPAN -e shell</bash>
Now you can install PAR and its development tools (PAR-Packer) with:
If this is unsuccessful you can also download the .tar.gz file from cpan.org (see the link on the PAR wiki) and just run the appropriate scripts directly.
Note: you may need to add the extracted PAR and PAR-Packer archives to your Perl @INC (or install them by copying the .pm files into your Perl lib directory -- C:\Perl\lib for ActivePerl and /usr/lib/perl for linux). Currently version 0.970 and 0.960 are not working, 0.957 seems to work fine however.
Creating .par Archives
Once PAR and Par-Packer are installed you can then run the packager on your script like so:
<bash>pp -B -p myscript.pl -o myscript.par</bash>
-B tells the packager to include all core/non-core modules required by the script. This way you will have a self contained archive that doesn't require the end user to end have Perl installed on their machine.
-p tells the packager to pack the script instead of creating a standalone executable. .par files are then run with the parl.exe runtime/executable
If you have trouble running the .par on multiple platforms you may need to add --multiarch to your pp command.
Running .par Archives
Once you've created your .par archive you can simply run it by using parl.exe (or a parl linux runtime):
<bash>parl <myapp.par> args</bash>
Setting the date via busybox
The date command can be used to set the clock on an iMote2 via busybox. The format of the command is 'date -s MMDDhhmmYYYY' (month, date, hour, minute, year).
- Match all the characters after an expression is found
- Match all after an epression in Ultraedit