Skip to content

Commit

Permalink
labs: Makefile: Add scp and ssh targets for easier module transfer on…
Browse files Browse the repository at this point in the history
… images with networking
  • Loading branch information
VladNastase committed Mar 3, 2021
1 parent b0c2a2e commit a4965c2
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tools/labs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ LABS ?= $(shell cd templates && find -mindepth 1 -maxdepth 1 -type d)
MODS = $(shell cd templates && find $(LABS) -mindepth 1 -name Kbuild | xargs dirname)
TODO ?= 0

GUEST_IP_CMD ?= $(shell arp -n -i tap0 | tail -1 | cut -d ' ' -f 1)

include qemu/Makefile

skels:
Expand Down Expand Up @@ -31,6 +33,24 @@ copy: $(YOCTO_IMAGE)
sudo umount $(TEMPDIR)
rmdir $(TEMPDIR)

scp: ip
scp -r skels root@$(shell cat .ip):

ssh: ip
ssh root@$(shell cat .ip)

ip:
if [ ! -e qemu.mon ]; then exit 1; fi
GUEST_IP=$(GUEST_IP_CMD); \
[ "$$GUEST_IP" = "arp:" ] && echo -n "Waiting for machine"; \
while [ "$$GUEST_IP" = "arp:" ]; do \
echo -n "."; \
sleep 1; \
GUEST_IP=`arp -e -n -i tap0 | tail -1 | cut -d ' ' -f 1`; \
done; \
echo ""; \
echo -n $$GUEST_IP > .ip

docker-docs:
cd docker && docker-compose build docs-build
cd docker && UID=$(shell id -u) GID=$(shell id -g) docker-compose run docs-build bash -c "cd /linux/tools/labs && make docs"
Expand All @@ -57,4 +77,4 @@ clean::
clean_skels:
rm -rf skels

.PHONY: skels build copy docs docker-docs docker-kernel stop-docker-kernel clean clean_skels
.PHONY: skels build copy scp ssh ip docs docker-docs docker-kernel stop-docker-kernel clean clean_skels

0 comments on commit a4965c2

Please sign in to comment.