eev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[eev] eevnow and eevnow-at


From: Eduardo Ochs
Subject: [eev] eevnow and eevnow-at
Date: Mon, 11 Jul 2005 17:00:20 -0000

Hi Mailing List. One. Two. Test. Can you hear me?

I'm not in the mood to send a message that is just a test, without any
technical content, so here's a quick description of a feature that I'm
working on...

Sometimes we have e-scripts that end up being composed of many small
"tasks"; for example, now I'm trying to create inside a "host" Debian
system a small "guest" system that can be run in parallel with the
"host" in two ways; either by either chrooting to it, like with, say,

  chroot /guest /bin/sh

or by running it inside an emulator; if /guest is a partition, and the
"block device image" of that partition is in the file /tmp/guest.img,
which was mounted on /guest with

  mount -o loop /tmp/guest.img /guest/

and then we would started the emulator with a command like this:

  qemu -hda    /tmp/guest.img \
       -kernel /tmp/vmlinuz   \
       -pci

Well, it turns out that the full task that I'm trying to accomplish,
"create a guest system and start to run it inside the host", comes in
two flavours, "chroot" and "emulator", and these two flavours have
many sub-tasks in common... for example, both include "copy libraries
from host", "set up the root password" and "create a user `edrx'".

After a while it becomes boring to go over the blocks that describe
these sub-tasks one by one, typing F3 in each one of them, and then
switching to an xterm and typing `ee' then to execute the block; it is
possible to define an alternative action to F3 that instead of just
saving the bounded region to the file $EE (which is what the default
function, eev-bounded, does) it will also send an `ee' to a controlled
shell via a communication channel, like an F9 would do. The functions
that do that eev-bounded+F9 thing are called eevnow and
eevnow-bounded, and they are defined by:

  (defun eevnow (s &optional e)
    (interactive "r")
    (eev s e)
    (eech "ee\n"))

  (eeb-define 'eevnow-bounded 'eevnow 'ee-delimiter-hash nil t t)

But that is not enough! These create-guest-system-blah-blah-blah tasks
are composed of an annoyingly big number of subtasks, and to have to
position Emacs's "point" inside each one of the delimited blocks that
we have to run and then typing F3 there is still not convenient
enough...

The solution that I've found is a kind of subroutine scheme for
e-scripts; it is a 2-line hack, and my impression is that until a
person can see that working (either in reality or by imagining it very
clearly) it will almost certainly look very alien, with too many
steps...

Remember that each delimited block can have a "name" in a comment line
- actually an "anchor", like the ones used by `to' and `find-anchor'.
The idea is to have a command, eevnow-at, that jumps to a named
delimited block _temporarily_, runs eevnow there, then returns the
point to the original position; its code could be:

  (defun eevnow-at (tag)
    (save-excursion (ee-to tag) (ee-once (eevnow-bounded))))

and it is meant to be used "red star lines" inside F9 blocks. Here's
an example, with the ^Os (the red stars) having been substituted by
"<*>"s:

  #<*>
  # «iptables-del-inputfilter»
  iptables -D INPUT -p TCP --dport telnet -j INPUTFILTER
  iptables -F INPUTFILTER
  iptables -X INPUTFILTER

  #<*>
  # «iptables-create-inputfilter»
  iptables -N INPUTFILTER
  iptables -A INPUTFILTER -s 127.0.0.1    -j ACCEPT
  iptables -A INPUTFILTER -j DROP
  iptables -A INPUT -p TCP --dport telnet -j INPUTFILTER

  #<*>
  # Begin typing F9 here
  <*> (eechannel-xterm "A")
  <*> (eevnow-at "iptables-del-inputfilter")
  <*> (eevnow-at "iptables-create-inputfilter")
  chroot /guest /usr/sbin/telnetd &
  telnet 127.0.0.1
  root
  root
  exit
  <*> End of the F9 block

The two first blocks are just "subroutines", to execute the e-script
we go to the "Begin typing F9 here" line and start typing F9s. Huh, I
need to make an animation about this...

The example file

  <http://angg.twu.net/eev-current/examples/busybox.e.html>

was all written using this technique, but its contents are a total
mess...

  Cheers,
    Edrx





reply via email to

[Prev in Thread] Current Thread [Next in Thread]