Skip to content

Commit a4965c2

Browse files
committed
labs: Makefile: Add scp and ssh targets for easier module transfer on images with networking
1 parent b0c2a2e commit a4965c2

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

tools/labs/Makefile

+21-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ LABS ?= $(shell cd templates && find -mindepth 1 -maxdepth 1 -type d)
44
MODS = $(shell cd templates && find $(LABS) -mindepth 1 -name Kbuild | xargs dirname)
55
TODO ?= 0
66

7+
GUEST_IP_CMD ?= $(shell arp -n -i tap0 | tail -1 | cut -d ' ' -f 1)
8+
79
include qemu/Makefile
810

911
skels:
@@ -31,6 +33,24 @@ copy: $(YOCTO_IMAGE)
3133
sudo umount $(TEMPDIR)
3234
rmdir $(TEMPDIR)
3335

36+
scp: ip
37+
scp -r skels root@$(shell cat .ip):
38+
39+
ssh: ip
40+
ssh root@$(shell cat .ip)
41+
42+
ip:
43+
if [ ! -e qemu.mon ]; then exit 1; fi
44+
GUEST_IP=$(GUEST_IP_CMD); \
45+
[ "$$GUEST_IP" = "arp:" ] && echo -n "Waiting for machine"; \
46+
while [ "$$GUEST_IP" = "arp:" ]; do \
47+
echo -n "."; \
48+
sleep 1; \
49+
GUEST_IP=`arp -e -n -i tap0 | tail -1 | cut -d ' ' -f 1`; \
50+
done; \
51+
echo ""; \
52+
echo -n $$GUEST_IP > .ip
53+
3454
docker-docs:
3555
cd docker && docker-compose build docs-build
3656
cd docker && UID=$(shell id -u) GID=$(shell id -g) docker-compose run docs-build bash -c "cd /linux/tools/labs && make docs"
@@ -57,4 +77,4 @@ clean::
5777
clean_skels:
5878
rm -rf skels
5979

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

0 commit comments

Comments
 (0)