2018-06-25 09:43:59 +00:00
|
|
|
SHELL := /bin/bash
|
|
|
|
|
|
|
|
# The directory of this file
|
|
|
|
DIR := $(shell echo $(shell cd "$(shell dirname "${BASH_SOURCE[0]}" )" && pwd ))
|
|
|
|
|
2018-06-30 11:50:05 +00:00
|
|
|
# The local users UID/GID
|
|
|
|
LUID := $(shell id -u)
|
|
|
|
LGID := $(shell id -g)
|
|
|
|
|
2018-06-29 19:16:51 +00:00
|
|
|
# To mount a specific binary using BINARY=/absolute/path/to/binary
|
|
|
|
ifdef BINARY
|
|
|
|
MOUNTFLAGS += -v $(BINARY):/home/r2/$(shell basename $(BINARY)):ro
|
|
|
|
RUNFLAGS += /home/r2/$(shell basename $(BINARY))
|
|
|
|
endif
|
|
|
|
|
2018-06-25 09:43:59 +00:00
|
|
|
VERSION ?= latest
|
2018-06-25 10:31:22 +00:00
|
|
|
IMAGE_NAME ?= radareorg/cutter
|
2018-06-25 09:43:59 +00:00
|
|
|
CONTAINER_NAME ?= cutter
|
|
|
|
|
2019-10-06 14:38:01 +00:00
|
|
|
LOCAL_DEV ?= n
|
|
|
|
|
2018-06-25 09:43:59 +00:00
|
|
|
# This will output the help for each task
|
|
|
|
# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
|
|
|
|
.PHONY: help
|
|
|
|
|
|
|
|
help: ## This help
|
|
|
|
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
|
|
|
|
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
|
|
|
|
# Build the container
|
|
|
|
build: ## Build the container
|
2019-10-06 14:38:01 +00:00
|
|
|
sudo docker build --rm -t $(IMAGE_NAME) $(if $(LOCAL_DEV) == 'y',-f ./Dockerfile-dev ../,.)
|
2018-06-25 09:43:59 +00:00
|
|
|
|
|
|
|
build-nc: ## Build the container without caching
|
2019-10-06 14:38:01 +00:00
|
|
|
sudo docker build --rm --no-cache -t $(IMAGE_NAME) $(if $(LOCAL_DEV) == 'y',-f ./Dockerfile-dev ../,.)
|
2018-06-25 09:43:59 +00:00
|
|
|
|
|
|
|
run: ## Run container
|
2018-06-29 19:16:51 +00:00
|
|
|
XSOCK=/tmp/.X11-unix && \
|
|
|
|
XAUTH=$(shell mktemp /tmp/r2cutter_tmp.XXX.xauth) && \
|
|
|
|
xauth nlist $$DISPLAY | sed -e 's/^..../ffff/' | xauth -f $$XAUTH nmerge - && \
|
|
|
|
chmod 644 $$XAUTH && \
|
2018-06-25 09:43:59 +00:00
|
|
|
touch $(DIR)/radare2rc && \
|
|
|
|
mkdir -p $(DIR)/r2-config && \
|
|
|
|
mkdir -p $(DIR)/sharedFolder && \
|
|
|
|
sudo docker run \
|
2018-06-29 19:16:51 +00:00
|
|
|
-it \
|
|
|
|
--name $(CONTAINER_NAME) \
|
|
|
|
--cap-add=SYS_PTRACE \
|
|
|
|
-e DISPLAY=$$DISPLAY \
|
|
|
|
-e XAUTHORITY=$$XAUTH \
|
2018-06-30 11:50:05 +00:00
|
|
|
-e LOCAL_USER_ID=$(LUID) \
|
|
|
|
-e LOCAL_GROUP_ID=$(LGID) \
|
2018-06-29 19:16:51 +00:00
|
|
|
-v $$XSOCK:$$XSOCK:ro \
|
|
|
|
-v $$XAUTH:$$XAUTH \
|
|
|
|
$(MOUNTFLAGS) \
|
|
|
|
-v $(DIR)/sharedFolder:/var/sharedFolder \
|
|
|
|
-v $(DIR)/radare2rc:/home/r2/.radare2rc \
|
|
|
|
-v $(DIR)/r2-config:/home/r2/.config/radare2 \
|
|
|
|
$(IMAGE_NAME):$(VERSION) $(RUNFLAGS) && \
|
|
|
|
rm $$XAUTH
|
|
|
|
|
|
|
|
get: ## Get the latest Cutter image
|
|
|
|
sudo docker pull $(IMAGE_NAME):$(VERSION)
|
2018-06-25 09:43:59 +00:00
|
|
|
|
|
|
|
stop: ## Stop a running container
|
|
|
|
sudo docker stop $(CONTAINER_NAME)
|
|
|
|
|
|
|
|
remove: ## Remove a (running) container
|
|
|
|
sudo docker rm -f $(CONTAINER_NAME)
|
|
|
|
|
|
|
|
remove-image-force: ## Remove the latest image (forced)
|
|
|
|
sudo docker rmi -f $(IMAGE_NAME):$(VERSION)
|
|
|
|
|