Skip to content

Commit

Permalink
Created unit.cpp. Updated demo3(#7). Fixed MS_ & ST_ enum bug(#6).
Browse files Browse the repository at this point in the history
  • Loading branch information
parke committed Nov 15, 2021
1 parent 6121500 commit 9aa7440
Show file tree
Hide file tree
Showing 6 changed files with 395 additions and 214 deletions.
93 changes: 32 additions & 61 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


# version 20211020
# version 20211111


bin ?= bin
Expand All @@ -11,6 +11,8 @@ unit ?= /tmp/lxroot-unit
Wextra ?= -Wextra -Wno-unused-parameter
gpp_opts ?= -fmax-errors=2 -Wall -Werror $(Wextra)

deps ?= Makefile lxroot.cpp help.cpp str.cpp unit.cpp | $(bin)


help:
@ echo "\
Expand All @@ -29,13 +31,23 @@ Usage: \n\
make unit-clean # delete the unit test environment \n\
make demo-clean # delete the demo environment \n\
make demo3-clean # delete the demo3 environment \n\
make static-clean # delete the static build environment "
make static-clean # delete the static build environment \n\
\n\
make demo3-root # enter demo3 as (simulated) root "


$(bin)/lxroot: Makefile lxroot.cpp help.cpp str.cpp $(bin)
$(bin)/lxroot: $(deps) $(bin)/lxroot-unit
$(bin)/lxroot-unit
g++ -g $(gpp_opts) lxroot.cpp -o $@


# Note: Lxroot has two sets of unit tests.
# 1) unit.cpp compiles to bin/lxroot-unit and test various C++ functions.
# 2) aux/unit.sh tests the compiled bin/lxroot executable.
$(bin)/lxroot-unit: $(deps)
g++ -g $(gpp_opts) unit.cpp -o $@


$(bin) $(unit) $(demo) $(demo)-chromium:
mkdir -p $@

Expand All @@ -44,7 +56,8 @@ build: $(bin)/lxroot


clean:
rm -f bin/lxroot ; true
rm -f $(bin)/lxroot ; true
rm -f $(bin)/lxroot-unit ; true


unit: $(bin)/lxroot $(unit)
Expand All @@ -60,7 +73,17 @@ unit-clean: clean
rm -rf /tmp/lxroot-unit


demo: $(bin)/lxroot $(demo)
demo-prepare: $(bin)/lxroot
@ echo
@ echo 'demo-prepare'
mkdir -p $(demo)/bin
@ # note in certain situations, $(bin) may equal $(demo)
- cp $(bin)/lxroot $(demo)/bin/lxroot
cp aux/demo.sh $(demo)/bin/demo.sh


# demo: $(bin)/lxroot $(demo)
demo: demo-prepare
cp $(bin)/lxroot $(demo)/lxroot
bash aux/demo.sh demo1 $(demo)

Expand All @@ -78,70 +101,18 @@ static:
# demo 3 ----------------------------------------------------------- demo 3


demo3_iso=$(demo)/dist/archlinux-2021.06.01-x86_64.iso
demo3_url=https://mirror.rackspace.com/archlinux/iso/2021.06.01/archlinux-2021.06.01-x86_64.iso


demo3-iso-soft:
if [ ! -f $(demo3_iso) ] ; then \
wget --continue -O $(demo3_iso) $(demo3_url) ; fi
demo3: demo-prepare
/bin/sh aux/demo.sh demo3 $(demo)


demo3-base: demo3-iso-soft $(bin)/lxroot

@ echo
@ echo 'demo3 create userland1'
bash aux/demo.sh demo1_extract $(demo) $(demo)/demo3
cp /etc/resolv.conf $(demo)/demo3/etc/
mkdir -p $(demo)/demo3/dist
ln -f $(demo3_iso) $(demo)/demo3/dist

@ echo
cp aux/demo.sh $(demo)/demo3/root/
$(bin)/lxroot -nw $(demo)/demo3 \
-- /bin/ash /root/demo.sh demo3_u1_create_u2

@ echo
cp aux/demo.sh $(demo)/demo3/userland2/root/
$(bin)/lxroot -nr $(demo)/demo3/userland2 \
-- /bin/bash /root/demo.sh demo3_u2_create_u3

@ echo
cp aux/demo.sh $(demo)/demo3/userland2/userland3/root/
$(bin)/lxroot -nr $(demo)/demo3/userland2/userland3 \
-- /bin/bash /root/demo.sh demo3_u3_finish

@ echo
mkdir -p $(demo)/demo3/userland2/userland3/$(HOME)


demo3:
make demo3-base # This allows overrding of the demo3 recipe.
@ echo
@ echo
@ echo "( The Demo #3 guest userland has been created. )"
@ echo "( )"
@ echo "( Make will now launch an interactive shell in the )"
@ echo "( Demo #3 guest userland. )"
@ echo "( )"
@ echo "( Please run 'chromium' in this shell to attempt to )"
@ echo "( run Chromium. )"
@ echo "( )"
@ echo "( Please press ENTER when you are ready to proceed. )"
@ echo
@ echo
@ read discard
$(bin)/lxroot -nx $(demo)/demo3/userland2/userland3


demo3-root: demo3-base
$(bin)/lxroot -nrx $(demo)/demo3/userland2/userland3
demo3-root: demo-prepare
/bin/sh aux/demo.sh demo3 $(demo) root


demo3-clean:
@ # paths hardcoded for safety
mkdir -p /tmp/lxroot-demo/demo3
chmod -R u+w /tmp/lxroot-demo/demo3
rm -rf /tmp/lxroot-demo/demo3


0 comments on commit 9aa7440

Please sign in to comment.