commit 3a03c7717616d476a52e3d97dc242b1c283ae444
parent 8063b84a55619cf24294d509b4b899561727566f
Author: Pavel Renev <an2qzavok@gmail.com>
Date: Sat, 6 Nov 2021 21:52:33 +0000
install extra binaries into /sys/lib/richterm/...
Diffstat:
6 files changed, 78 insertions(+), 121 deletions(-)
diff --git a/README.md b/README.md
@@ -48,12 +48,9 @@ In addition, Handler manages primitive link history via user menu.
# Installation
-Proper installation and operation of richterm is work in progress.
-
-For now you can run it in the following fashion:
-
- mk
- cd extra; mk install
- cd ..
- 6.out bin/rc/Handler
+The usual `mk install` invocation will install richterm binary
+into /$cputype/bin directory and extra binaries and scripts into
+/sys/lib/richterm/bin/... directories
+/sys/lib/richterm/bin/... will be bound over /bin by richterm
+automatically.
+\ No newline at end of file
diff --git a/bin/rc/Handler b/bin/rc/Handler
@@ -1,111 +0,0 @@
-#!/bin/rc
-
-rfork
-
-rroot=/mnt/richterm
-
-history=`{pwd}
-forward=()
-
-fn clear {
- echo clear > $rroot/ctl
-}
-
-fn _exit {
- clear
- echo -n > $rroot/menu
- exit
-}
-
-fn ldir {
- cd $1
- history = (`{pwd} $history)
- forward = ()
- clear
- Dir
-}
-
-fn lmarkdown {
- fname=`{basename $1}
- cd `{basename -d $1}
- history = (`{pwd}^/$fname $history)
- forward = ()
- clear
- Markdown $fname
-}
-
-fn lgopher {
- history = ($1 $history)
- forward = ()
- clear
- switch ($1) {
- case *.md; Gopher $1 | Markdown
- case *; Gopher $1
- }
-}
-
-fn tryfile {
- type=`{file -m $1}
- switch ($type) {
- case 'text/plain';
- lmarkdown $1
- case *;
- plumb $1
- }
-}
-
-fn menu {
- switch ($1) {
- case 'Back';
- if (test $#history '!=' 1) {
- newforward = ($history(1) $forward)
- link = $history(2)
- history = $history(3-)
- link $link
- forward = $newforward
- }
- case 'Exit'; _exit
- }
-}
-
-fn link {
- switch($1) {
- case http://*; plumb $1
- case gopher://*; lgopher $1
- case *.md; lmarkdown $1
- case *.html
- md=`{echo $1|sed 's/\.html/\.md/'}
- if (test -r $md) lmarkdown $md
- if not echo 'can''t open file' $1
- case *
- if (test -d $1) ldir $1
- if not tryfile $1
- }
-}
-
-bind -a bin/$cputype /bin
-
-cat > $rroot/menu <<EOF
-----
-Back
-Exit
-EOF
-
-clear
-Dir
-
-event=''
-
-if (test -n $"1) {
- link $1
-}
-
-while ( { event=`{read $rroot/ctl} } ) {
- if (test -z $"event) _exit
- type=$event(1)
- action=$event(2)
- switch($type) {
- case 'menu'; menu $action
- case 'link'; link $action
- }
-}
diff --git a/extra/clear b/extra/clear
@@ -0,0 +1,2 @@
+#!/bin/rc
+echo clear > /mnt/richterm/ctl
diff --git a/extra/mkfile b/extra/mkfile
@@ -5,6 +5,22 @@ TARG=\
Dir\
Gopher\
-BIN=../bin/$cputype
+SYSLIB=/sys/lib/richterm
+BIN=$SYSLIB/bin/$cputype
</sys/src/cmd/mkmany
+
+RC=\
+ Handler\
+ clear\
+
+install:V: bindir $RC
+
+bindir:V:
+ mkdir -p $BIN
+
+$RC:V:
+ mkdir -p $SYSLIB/bin/rc
+ for (i in $RC) @{
+ cp $i $SYSLIB/bin/rc
+ }
diff --git a/mkfile b/mkfile
@@ -9,3 +9,48 @@ HFILES=richterm.h array.h
acid:V:
$CC -a *.c > acid.lib
+
+DIRS=extra
+
+all:V: $DIRS
+
+$DIRS:V:
+ for (i in $DIRS) @{
+ echo mk $i
+ cd $i
+ mk all
+ }
+
+install:V: installdirs
+
+nuke:V: nukedirs
+
+installdirs:V:
+ for (i in $DIRS) @{
+ echo mk $i
+ cd $i
+ mk install
+ }
+
+clean:V:
+ for (i in $DIRS) @{
+ echo clean $i
+ cd $i
+ mk clean
+ }
+ rm -f [$OS].* *.[$OS]
+
+nukedirs:V:
+ for (i in $DIRS) @{
+ echo nuke $i
+ cd $i
+ mk nuke
+ }
+
+update:V:
+ update $UPDATEFLAGS $UPDATE
+ for (i in $DIRS) @{
+ echo update $i
+ cd $i
+ mk 'UPDATEFLAGS='$"UPDATEFLAGS update
+ }
diff --git a/richterm.c b/richterm.c
@@ -453,7 +453,7 @@ void
runcmd(void *args)
{
char **argv = args;
- char *cmd;
+ char *cmd, *syslib, *cputype;
rfork(RFNAMEG);
@@ -462,6 +462,13 @@ runcmd(void *args)
bind("/mnt/richterm", "/dev/", MBEFORE);
+ bind("/sys/lib/richterm/bin/rc/", "/bin", MAFTER);
+ cputype = getenv("cputype");
+ syslib = smprint("/sys/lib/richterm/bin/%s/", cputype);
+ bind(syslib, "/bin", MAFTER);
+ free(cputype);
+ free(syslib);
+
rfork(RFFDG);
close(0);
open("/dev/cons", OREAD);