Skip to content

Commit 6bdf2d4

Browse files
committedMar 8, 2021
labs: Makefile: Add scp and ssh targets for easier module transfer on images with networking
1 parent 55deeb9 commit 6bdf2d4

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed
 

‎tools/labs/Makefile

+21-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ copy: $(YOCTO_IMAGE)
3131
sudo umount $(TEMPDIR)
3232
rmdir $(TEMPDIR)
3333

34+
scp:
35+
if [ -e qemu.mon ]; then exit 1; fi
36+
IP=$$(qemu/get_vm_ip.sh); \
37+
if [ -z "$$IP" ]; then exit 1; fi; \
38+
modules=$$(find skels -type f \( -name *.ko -or -executable \)); \
39+
echo -n $$modules | xargs -d ' ' --no-run-if-empty dirname | xargs ssh root@$$IP mkdir -p || true; \
40+
echo -n $$modules | xargs -d ' ' -I _ --no-run-if-empty scp _ root@$$IP:_ || true; \
41+
checkers=$$(find skels -type d \( -name checker \)); \
42+
echo -n $$checkers | xargs -d ' ' --no-run-if-empty dirname | xargs ssh root@$$IP mkdir -p || true; \
43+
echo -n $$checkers | xargs -d ' ' -I _ --no-run-if-empty scp -r _ root@$$IP:_ || true
44+
45+
ssh:
46+
if [ -e qemu.mon ]; then exit 1; fi
47+
IP=$$(qemu/get_vm_ip.sh); \
48+
if [ -z "$$IP" ]; then exit 1; fi; \
49+
ssh root@$$IP
50+
51+
ip:
52+
qemu/get_vm_ip.sh
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

‎tools/labs/qemu/get_vm_ip.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
GUEST_IP=$(arp -n -i tap0 | tail -1 | cut -d ' ' -f 1)
4+
while [ "$GUEST_IP" = "arp:" ]; do
5+
sleep 1
6+
GUEST_IP=$(arp -e -n -i tap0 | tail -1 | cut -d ' ' -f 1)
7+
done
8+
9+
echo $GUEST_IP

0 commit comments

Comments
 (0)