-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
41 lines (30 loc) · 863 Bytes
/
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
PROG=cap_file
PROG_C=$(PROG).c
MOUNTPOINT=/media/ext4disk
DISK=disk_cap_file.img
LOOP_DEVICE=loop9
IMAGE_SIZE_KB=500
ESCALATE_CMD=sudo
USER=`whoami`
.DELETE_ON_ERROR:
.PHONY: all clean
all: $(DISK)
clean:
rm -f $(DISK) $(PROG) *.o
$(PROG): $(PROG_C)
../../build/musl-host/bin/musl-clang-target -fPIE -pie -c -g -o $@.o $(PROG_C)
../../build/musl-host/bin/ld.musl-clang-target -g -pie -dynamic-linker /ld.so cap_file.o -o cap_file
$(DISK): $(PROG)
dd if=/dev/zero of="$@" count=$(IMAGE_SIZE_KB) bs=1K
mkfs.ext4 "$@"
$(ESCALATE_CMD) /bin/bash -euxo pipefail -c '\
mkdir -p $(MOUNTPOINT); \
mount -t ext4 -o loop "$@" $(MOUNTPOINT); \
mkdir -p $(MOUNTPOINT)/app; \
cp $(PROG) $(MOUNTPOINT)/app; \
umount $(MOUNTPOINT); \
chown $(USER) "$@"; \
'
install:
sudo mkdir -p ${INSTALL_PATH}
sudo cp ./*.yaml ./*.ci ./*.img ${INSTALL_PATH}