-
Notifications
You must be signed in to change notification settings - Fork 34
/
Makefile
56 lines (45 loc) · 1.88 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Helper makefile to demonstrate the use of the rpi-emu docker environment
# This is mostly useful for development and extension as part of an image builder
#
# For an example using this in a project, see Makefile.example
DATE=2019-06-20
DIST=$(DATE)-raspbian-buster-lite
ZIP=$(DIST).zip
IMAGE=$(DIST).img
DL_PATH=http://director.downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2019-06-24/$(ZIP)
CWD=$(shell pwd)
# Docker arguments
# Interactive mode, remove container after running, privileged mode for loopback access
# Mount images to /usr/rpi/images to access image files from container
# Change working directory to /usr/rpi (which is loaded with the helper scripts)
RUN_ARGS=-it --rm --privileged=true -v $(CWD)/images:/usr/rpi/images -w /usr/rpi ryankurte/docker-rpi-emu
MOUNT_DIR=/media/rpi
# Build the docker image
build:
@echo "Building base docker image"
@docker build -t ryankurte/docker-rpi-emu .
# Bootstrap a RPI image into the images directory
bootstrap: images/$(IMAGE)
# Fetch the RPI image from the path above
images/$(IMAGE):
@echo "Pulling Raspbian image"
@mkdir -p images
wget -O images/$(ZIP) -c $(DL_PATH)
@unzip -d images/ images/$(ZIP)
@touch $@
# Expand the image by a specified size
# TODO: implement expand script to detect partition sizes
expand: build bootstrap
dd if=/dev/zero bs=1M count=1024 >> images/$(IMAGE)
@docker run $(RUN_ARGS) ./expand.sh images/$(IMAGE) 1024
# Launch the docker image without running any of the utility scripts
run: build bootstrap
@echo "Launching interactive docker session"
@docker run $(RUN_ARGS) /bin/bash
# Launch the docker image into an emulated session
run-emu: build bootstrap
@echo "Launching interactive emulated session"
@docker run $(RUN_ARGS) /bin/bash -c './run.sh images/$(IMAGE)'
test: build bootstrap
@echo "Running test command"
@docker run $(RUN_ARGS) /bin/bash -c './run.sh images/$(IMAGE) "uname -a"'