Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server version of Hercules #10

Open
wants to merge 117 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
879193e
allow running multiple transfers back-to-back
marcopioppini May 13, 2024
a049a76
monitor messages, multiple transfers ok
marcopioppini May 21, 2024
c4fc100
Arguments for daemon
marcopioppini May 23, 2024
d9ee3b8
rework some stuff, fix kick
marcopioppini May 24, 2024
4b26317
make monitor find actual paths
marcopioppini May 25, 2024
88aeea5
allow specifying mtu/nPaths when submitting job
marcopioppini May 26, 2024
f6d047d
look up return path only when needed
marcopioppini May 26, 2024
e579f41
re-enable sending path handshakes
marcopioppini May 26, 2024
88d8187
clean up session states, add error enum
marcopioppini May 27, 2024
77b96d1
timeouts, HS resend
marcopioppini May 27, 2024
cf53b7f
remove unused code, stop session on error instead of stopping hercules
marcopioppini May 27, 2024
a6c38f7
reply to HS packets for PCC
marcopioppini May 28, 2024
3bc1572
remove unused code
marcopioppini May 28, 2024
11c3f65
move xdp setup to separate file
marcopioppini May 28, 2024
dd0ae79
ensure return values are checked, group tx/rx code
marcopioppini May 28, 2024
87596c5
rework event handler
marcopioppini May 29, 2024
31ae2c9
drop received packets when no session running
marcopioppini May 29, 2024
fba658d
reorder code
marcopioppini May 29, 2024
096043c
re-enable pcc
marcopioppini May 30, 2024
929e4cc
inform monitor about finished transfers
marcopioppini May 30, 2024
2937980
periodically ask for new paths
marcopioppini May 31, 2024
7fe725e
session freeing, mark some fields atomic
marcopioppini Jun 1, 2024
ac64813
quit if no paths received
marcopioppini Jun 2, 2024
a889a8a
monitor: configfile
marcopioppini Jun 3, 2024
26d2dce
implement fetching job status
marcopioppini Jun 4, 2024
b696f16
remove sender_state_per_receiver
marcopioppini Jun 4, 2024
961ced9
path swapping, cleanup
marcopioppini Jun 4, 2024
4c89f39
Handle SCMP messages
marcopioppini Jun 4, 2024
459f8d7
update monitor stats
marcopioppini Jun 5, 2024
fdb0484
fix intra-as (empty paths)
marcopioppini Jun 5, 2024
c4ad90f
Change makefile to distinguish server/monitor
marcopioppini Jun 7, 2024
abb8317
Remove monitor socket locking
marcopioppini Jun 7, 2024
29343b4
go code cleanup
marcopioppini Jun 7, 2024
3a13935
implement cancel handler
marcopioppini Jun 9, 2024
52a8eeb
cleanup some todos
marcopioppini Jun 9, 2024
e960cfd
add stat for gfal
marcopioppini Jun 10, 2024
b0340c5
more todos
marcopioppini Jun 11, 2024
45b3277
split umem lock
marcopioppini Jun 11, 2024
9975060
add monitor socket, interfaces and listen addr to config
marcopioppini Jun 11, 2024
f8580cb
Determine payload length based on selected paths
marcopioppini Jun 13, 2024
638eac9
Cap payload length to interface MTU
marcopioppini Jun 13, 2024
1e97502
pathset freeing
marcopioppini Jun 14, 2024
574d580
fix mtu bug
marcopioppini Jun 14, 2024
9daca06
fix fill_rbudp_pkt
marcopioppini Jun 14, 2024
7585de7
implement directory transfer
marcopioppini Jun 15, 2024
fd33abe
enable multiple concurrent sessions
marcopioppini Jun 15, 2024
c36ab42
Merge branch 'directory-transfer' into server
marcopioppini Jun 19, 2024
c7b7ffc
Merge branch 'multiple-sessions' into server
marcopioppini Jun 19, 2024
e1a02dd
set destination path in directory index
marcopioppini Jun 20, 2024
3ba8306
fix session stopping
marcopioppini Jun 20, 2024
ae837f1
add underlay source port randomisation
marcopioppini Jun 20, 2024
cd9e42f
fix nacks with multiple sessions, minor improvements
marcopioppini Jun 21, 2024
9cada06
ensure ports printed correctly
marcopioppini Jun 21, 2024
be4afb6
make sure sessions are freed entirely
marcopioppini Jun 21, 2024
342e26a
cleanup on shutdown
marcopioppini Jun 21, 2024
cdfebfc
make server read config file
marcopioppini Jun 21, 2024
d38c677
big cleanup, check return codes in xdp setup
marcopioppini Jun 22, 2024
4ca77ea
Allow clients to override automatic MTU selection
marcopioppini Jun 23, 2024
78031a1
monitor cleanup
marcopioppini Jun 24, 2024
ac75f79
Ensure RTT is updated at receiver
marcopioppini Jun 26, 2024
269c635
Inform monitor earlier about finished transfers
marcopioppini Jun 26, 2024
0324146
fix some memory leaks (cc state)
marcopioppini Jun 26, 2024
2ec64ba
exit instead of waiting if sciond unreachable
marcopioppini Jun 26, 2024
accd379
print version at startup
marcopioppini Jun 26, 2024
fa56c7b
Improve printed error messages
marcopioppini Jun 26, 2024
98872a9
merge tls-certs
marcopioppini Jun 26, 2024
8a30fd9
commit gfal plugin
marcopioppini Jun 27, 2024
dd10098
retry monitor read if it times out
marcopioppini Jun 27, 2024
92be6a1
check reply path enabled
marcopioppini Jun 27, 2024
7d6b26d
fix nack timings and rtt computation
marcopioppini Jun 28, 2024
efa27a0
Changes for benchmarking mode, performance fix
marcopioppini Aug 9, 2024
ef8fb2e
add hcp: a cli tool to interact with Hercules
marcopioppini Sep 5, 2024
361febf
fix compilation
marcopioppini Sep 20, 2024
3c8e910
monitor: correctly determine directory size
marcopioppini Sep 24, 2024
5095387
Add option to drop privileges after startup
marcopioppini Sep 24, 2024
64c12de
remove timeout from monitor socket
marcopioppini Sep 24, 2024
4901b65
readme: explain api
marcopioppini Oct 10, 2024
78f20a8
config: allow specifying payload length per-dest
marcopioppini Oct 10, 2024
7474850
add systemd service files
marcopioppini Oct 10, 2024
33e434d
fix scmp parsing
marcopioppini Oct 10, 2024
ce9b226
Rework documentation, add manual pages
marcopioppini Oct 28, 2024
64e45e5
add hcp to Makefile, upgrade go (docker) to 1.22.8
marcopioppini Oct 28, 2024
7e37e79
print warning when running as root
marcopioppini Oct 29, 2024
c0ea8a2
Merge branch 'docs' into server
marcopioppini Oct 30, 2024
8d92d31
modify makefile to allow building without docker
marcopioppini Oct 30, 2024
8258876
add dependencies to build instructions
marcopioppini Oct 31, 2024
beac3cb
update go mod files
marcopioppini Oct 31, 2024
911e1c2
make building with clang possible
marcopioppini Oct 31, 2024
cd72e37
add clangd and clang-format config files
marcopioppini Oct 31, 2024
d0ee2d5
update service files
marcopioppini Oct 31, 2024
283aaad
add version field to header
marcopioppini Oct 31, 2024
95780c7
Merge branch 'server' of gitlab.inf.ethz.ch:OU-PERRIG/theses/msc_piop…
marcopioppini Oct 31, 2024
dbb5215
look for config in /usr/local/etc
marcopioppini Oct 31, 2024
86adc4e
make target to build packages
marcopioppini Nov 1, 2024
1d0e015
add payload length option to hcp
marcopioppini Nov 5, 2024
63960ce
add timeout to path selection
marcopioppini Nov 5, 2024
ca5099f
add chroot option
marcopioppini Nov 5, 2024
3032303
improve error messages
marcopioppini Nov 6, 2024
87dde8a
Revert "add version field to header"
marcopioppini Nov 6, 2024
13cc04c
add TxOnly and RxOnly options to use fewer threads
marcopioppini Nov 6, 2024
9c2dac6
small fix for pathset timeout
marcopioppini Nov 6, 2024
e37bcff
small fix in makefile, service file
marcopioppini Nov 8, 2024
47a0b43
looping acks
marcopioppini Nov 13, 2024
d8f966d
move to libxdp
marcopioppini Nov 20, 2024
d53164b
load in frags mode
marcopioppini Nov 26, 2024
7a365bb
jumbo rx/tx (with additional copy)
marcopioppini Nov 27, 2024
31d6a17
fix possible segfault
marcopioppini Nov 13, 2024
bab4acb
use multibuf only if supported, config option
marcopioppini Nov 28, 2024
f7d1618
make sure tx_p does not get stuck
marcopioppini Nov 15, 2024
62c3bcd
remove copy from multibuf TX
marcopioppini Dec 2, 2024
06665ff
add error control packets
marcopioppini Nov 15, 2024
7913ad6
remove copy from multibuf RX
marcopioppini Dec 2, 2024
d2fb21c
hcp: complain if dest port not set
marcopioppini Nov 27, 2024
30a6b1b
Merge branch 'jumbo-frames' into server
marcopioppini Dec 4, 2024
82b1555
fix possible memory leak
marcopioppini Dec 4, 2024
0df87c3
auto-detect zc support, allow disabling via config
marcopioppini Dec 9, 2024
3d32c7f
add copyright/license header to new files
marcopioppini Dec 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
BasedOnStyle: Google
UseTab: Always
IndentWidth: 4
TabWidth: 4
...
2 changes: 2 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Diagnostics:
Suppress: atomic_op_needs_atomic
6 changes: 6 additions & 0 deletions .fpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-s dir
--name hercules-server
--description "Hercules file transfer server"
--url "https://github.com/netsec-ethz/hercules"
--maintainer "Network Security Group, ETH Zuerich"
-C pkgroot
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
bpf_prgm/*.ll
bpf_prgm/*.o
hercules
hercules-server
hercules-monitor
*.o
*.d
monitor/monitor
mockules/mockules
pkgroot
*.deb
*.rpm
*.tar
9 changes: 6 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[submodule "bpf"]
path = bpf
url = https://github.com/libbpf/libbpf/
[submodule "xdp-tools"]
path = xdp-tools
url = https://github.com/xdp-project/xdp-tools.git
[submodule "tomlc99"]
path = tomlc99
url = https://github.com/cktan/tomlc99.git
ignore = untracked
52 changes: 19 additions & 33 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ubuntu/focal with go-1.21.6
# ubuntu/focal with go-1.22.8
# copy pasted from
# https://github.com/docker-library/golang/blob/master/1.21/bullseye/Dockerfile
# but with a different base image (ubuntu:focal instead of debian:bullseye)
Expand All @@ -7,6 +7,10 @@ FROM ubuntu:focal
ARG UID=1001
ARG GID=1001

# to avoid interactive timezone query
ENV TZ Europe/Zürich
ENV DEBIAN_FRONTEND noninteractive

# install cgo-related dependencies
RUN set -eux; \
apt-get update; \
Expand All @@ -25,54 +29,34 @@ RUN set -eux; \
gpg \
gpg-agent \
dirmngr \
clang \
clang-12 \
llvm \
libelf-dev \
libpcap-dev \
gcc-multilib \
build-essential \
ruby \
rpm \
m4 \
; \
rm -rf /var/lib/apt/lists/*

ENV PATH /usr/local/go/bin:$PATH

ENV GOLANG_VERSION 1.21.6
RUN ln -s /usr/bin/clang-12 /usr/bin/clang

RUN gem install dotenv -v 2.8.1
RUN gem install fpm

ENV GOLANG_VERSION 1.22.8

RUN set -eux; \
arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \
url=; \
case "$arch" in \
'amd64') \
url='https://dl.google.com/go/go1.21.6.linux-amd64.tar.gz'; \
sha256='3f934f40ac360b9c01f616a9aa1796d227d8b0328bf64cb045c7b8c4ee9caea4'; \
;; \
'armhf') \
url='https://dl.google.com/go/go1.21.6.linux-armv6l.tar.gz'; \
sha256='6a8eda6cc6a799ff25e74ce0c13fdc1a76c0983a0bb07c789a2a3454bf6ec9b2'; \
;; \
'arm64') \
url='https://dl.google.com/go/go1.21.6.linux-arm64.tar.gz'; \
sha256='e2e8aa88e1b5170a0d495d7d9c766af2b2b6c6925a8f8956d834ad6b4cacbd9a'; \
;; \
'i386') \
url='https://dl.google.com/go/go1.21.6.linux-386.tar.gz'; \
sha256='05d09041b5a1193c14e4b2db3f7fcc649b236c567f5eb93305c537851b72dd95'; \
;; \
'mips64el') \
url='https://dl.google.com/go/go1.21.6.linux-mips64le.tar.gz'; \
sha256='eb309a611dfec52b98805e05bafbe769d3d5966aef05f17ec617c89ee5a9e484'; \
;; \
'ppc64el') \
url='https://dl.google.com/go/go1.21.6.linux-ppc64le.tar.gz'; \
sha256='e872b1e9a3f2f08fd4554615a32ca9123a4ba877ab6d19d36abc3424f86bc07f'; \
;; \
'riscv64') \
url='https://dl.google.com/go/go1.21.6.linux-riscv64.tar.gz'; \
sha256='86a2fe6597af4b37d98bca632f109034b624786a8d9c1504d340661355ed31f7'; \
;; \
's390x') \
url='https://dl.google.com/go/go1.21.6.linux-s390x.tar.gz'; \
sha256='92894d0f732d3379bc414ffdd617eaadad47e1d72610e10d69a1156db03fc052'; \
url='https://go.dev/dl/go1.22.8.linux-amd64.tar.gz'; \
sha256='5f467d29fc67c7ae6468cb6ad5b047a274bae8180cac5e0b7ddbfeba3e47e18f'; \
;; \
*) echo >&2 "error: unsupported architecture '$arch' (likely packaging update needed)"; exit 1 ;; \
esac; \
Expand Down Expand Up @@ -100,6 +84,8 @@ RUN set -eux; \
# https://github.com/docker-library/golang/issues/472
ENV GOTOOLCHAIN=local

RUN git config --global --add safe.directory "*"

RUN groupadd --gid $GID --non-unique buildboy
RUN useradd buildboy --create-home --shell /bin/bash --non-unique --uid $UID --gid $GID
USER buildboy
Expand Down
192 changes: 167 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,56 +1,198 @@
.PHONY: builder builder_image install clean
TARGET_SERVER := hercules-server
TARGET_MONITOR := hercules-monitor
TARGET_HCP := hcp/hcp

all: hercules mockules
CC := gcc
CFLAGS = -O3 -g3 -std=gnu11 -D_GNU_SOURCE -Itomlc99 -Ixdp-tools/lib/libbpf/include/uapi -Ixdp-tools/headers
# CFLAGS += -DNDEBUG
CFLAGS += -Wall -Wextra

## Options:
# Print rx/tx session stats
CFLAGS += -DPRINT_STATS
# Enforce checking the source SCION/UDP address/port of received packets
# CFLAGS += -DCHECK_SRC_ADDRESS
# Randomise the UDP underlay port (no restriction on the range of used ports).
# Enabling this currently breaks SCMP packet parsing
# CFLAGS += -DRANDOMIZE_UNDERLAY_SRC
# Ignore SCMP error messages, just keep sending
# CFLAGS += -DIGNORE_SCMP

## for debugging:
# ASAN_FLAG := -fsanitize=address
# CFLAGS += -g3 -DDEBUG $(ASAN_FLAG)
#
# CFLAGS += -DDEBUG_PRINT_PKTS # print received/sent packets (lots of noise!)


LDFLAGS = -g3 -l:libxdp.a -l:libbpf.a -Ltomlc99 -lm -lelf -latomic -pthread -lz -ltoml -z noexecstack $(ASAN_FLAG)
DEPFLAGS := -MP -MD

SRCS := $(wildcard *.c)
OBJS := $(SRCS:.c=.o)
DEPS := $(OBJS:.o=.d)
MONITORFILES := $(wildcard monitor/*)
HCPFILES := $(filter-out $(TARGET_HCP),$(wildcard hcp/*))

VERSION := $(shell (ref=$$(git describe --tags --long --dirty 2>/dev/null) && echo $$(git rev-parse --abbrev-ref HEAD)-$$ref) ||\
echo $$(git rev-parse --abbrev-ref HEAD)-untagged-$$(git describe --tags --dirty --always))
CFLAGS += -DHERCULES_VERSION="\"$(VERSION)\""

PREFIX ?= /usr/local

.PHONY: all install

all: $(TARGET_MONITOR) $(TARGET_SERVER) $(TARGET_HCP)

install: all
ifndef DESTDIR
$(error DESTDIR is not set)
endif
cp hercules mockules/mockules $(DESTDIR)
install -d $(DESTDIR)$(PREFIX)/bin/
install $(TARGET_MONITOR) $(DESTDIR)$(PREFIX)/bin/
install $(TARGET_SERVER) $(DESTDIR)$(PREFIX)/bin/
install $(TARGET_HCP) $(DESTDIR)$(PREFIX)/bin/

hercules: builder hercules.h hercules.go hercules.c bpf_prgm/redirect_userspace.o bpf_prgm/pass.o bpf/src/libbpf.a
install -d $(DESTDIR)$(PREFIX)/etc/
install hercules.conf $(DESTDIR)$(PREFIX)/etc/

install -d $(DESTDIR)$(PREFIX)/share/doc/hercules/
install hercules.conf.sample $(DESTDIR)$(PREFIX)/share/doc/hercules/

install -d $(DESTDIR)$(PREFIX)/lib/systemd/system/
install dist/hercules-monitor.service $(DESTDIR)$(PREFIX)/lib/systemd/system/
install dist/hercules-server.service $(DESTDIR)$(PREFIX)/lib/systemd/system/

install -d $(DESTDIR)$(PREFIX)/share/man/man1/
install doc/hercules-server.1 $(DESTDIR)$(PREFIX)/share/man/man1/
install doc/hercules-monitor.1 $(DESTDIR)$(PREFIX)/share/man/man1/
install hcp/hcp.1 $(DESTDIR)$(PREFIX)/share/man/man1/
install -d $(DESTDIR)$(PREFIX)/share/man/man5/
install doc/hercules.conf.5 $(DESTDIR)$(PREFIX)/share/man/man5/
install -d $(DESTDIR)$(PREFIX)/share/man/man7/
install doc/hercules.7 $(DESTDIR)$(PREFIX)/share/man/man7/

# Hack to allow building both in docker and natively:
# Prefixing the target with docker_ should use the builder image.
# e.g., make docker_all
docker_%: builder
docker exec hercules-builder $(MAKE) $*

# List all headers as dependency because we include a header file via cgo (which in turn may include other headers)
$(TARGET_MONITOR): $(MONITORFILES) $(wildcard *.h)
cd monitor && go build -o "../$@" -ldflags "-X main.startupVersion=${VERSION}"

$(TARGET_SERVER): $(OBJS) bpf_prgm/redirect_userspace.o tomlc99/libtoml.a
@# update modification dates in assembly, so that the new version gets loaded
@sed -i -e "s/\(load bpf_prgm_pass\)\( \)\?\([0-9a-f]\{32\}\)\?/\1 $$(md5sum bpf_prgm/pass.c | head -c 32)/g" bpf_prgms.s
@sed -i -e "s/\(load bpf_prgm_redirect_userspace\)\( \)\?\([0-9a-f]\{32\}\)\?/\1 $$(md5sum bpf_prgm/redirect_userspace.c | head -c 32)/g" bpf_prgms.s
@taggedRef=$$(git describe --tags --long --dirty 2>/dev/null) && startupVersion=$$(git rev-parse --abbrev-ref HEAD)"-$${taggedRef}" || \
startupVersion=$$(git rev-parse --abbrev-ref HEAD)"-untagged-"$$(git describe --tags --dirty --always); \
docker exec hercules-builder go build -ldflags "-X main.startupVersion=$${startupVersion}"
$(CC) -o $@ $(OBJS) bpf_prgms.s $(LDFLAGS)

$(TARGET_HCP): $(HCPFILES) $(wildcard *.h)
cd hcp && go build -ldflags "-X main.startupVersion=${VERSION}"

hcp: $(TARGET_HCP)

bpf_prgm/%.ll: bpf_prgm/%.c builder
docker exec hercules-builder clang -S -target bpf -D __BPF_TRACING__ -I. -Wall -O2 -emit-llvm -c -g -o $@ $<
%.o: %.c
$(CC) $(DEPFLAGS) $(CFLAGS) -c $< -o $@

bpf_prgm/%.o: bpf_prgm/%.ll builder
docker exec hercules-builder llc -march=bpf -filetype=obj -o $@ $<
bpf_prgm/%.ll: bpf_prgm/%.c
clang -S -target bpf -D __BPF_TRACING__ -I. -Wall -O2 -emit-llvm -c -g -o $@ $<

bpf_prgm/%.o: bpf_prgm/%.ll
llc -march=bpf -filetype=obj -o $@ $<

# explicitly list intermediates for dependency resolution
bpf_prgm/pass.ll:
bpf_prgm/redirect_userspace.ll:

bpf/src/libbpf.a: builder
@if [ ! -d bpf/src ]; then \
echo "Error: Need libbpf submodule"; \
.PHONY: libxdp
libxdp:
@if [ ! -d xdp-tools/lib ]; then \
echo "Error: Need libxdp submodule"; \
echo "May need to run git submodule update --init"; \
exit 1; \
else \
docker exec -w /`basename $(PWD)`/bpf/src hercules-builder $(MAKE) all OBJDIR=.; \
mkdir -p build; \
docker exec -w /`basename $(PWD)`/bpf/src hercules-builder $(MAKE) install_headers DESTDIR=build OBJDIR=.; \
cd xdp-tools && ./configure && \
cd lib && make && \
cd libxdp && make install && \
cd ../libbpf/src && make install; \
fi

mockules: builder mockules/main.go mockules/network.go
docker exec -w /`basename $(PWD)`/mockules hercules-builder go build
tomlc99/libtoml.a:
@if [ ! -d tomlc99 ]; then \
echo "Error: Need libtoml submodule"; \
echo "May need to run git submodule update --init"; \
exit 1; \
else \
cd tomlc99 && $(MAKE) all; \
fi


.PHONY: builder builder_image

# mockules: builder mockules/main.go mockules/network.go
# docker exec -w /`basename $(PWD)`/mockules hercules-builder go build

# docker stuff
builder: builder_image
@docker container ls -a --format={{.Names}} | grep hercules-builder -q || \
docker run -t --entrypoint cat --name hercules-builder -v $(PWD):/`basename $(PWD)` -w /`basename $(PWD)` -d hercules-builder
@docker container ls --format={{.Names}} | grep hercules-builder -q || \
docker start hercules-builder
@docker exec hercules-builder ls /usr/local/include/xdp >/dev/null 2>&1 || docker exec -u0 hercules-builder make libxdp

builder_image:
@docker images | grep hercules-builder -q || \
docker build -t hercules-builder --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) .

clean:

MANFILES := $(wildcard doc/*.[157]) hcp/hcp.1
MDFILES := $(addsuffix .md,$(MANFILES))

%.md: $(basename %)
# Show linter output for all warning levels, but continue if it's not severe
mandoc -T lint -Wall $< || true
mandoc -T markdown -W warning,stop $< > $@

docs: $(MDFILES)

# Packages
# Relies on the fpm tool to build packages.
# More arguments to fpm are specified in the file .fpm
# The package is called hercules-server, because there is already
# one named hercules in Ubuntu's default repos.
PKG_VERSION ?= $(shell git describe --tags 2>/dev/null)

.PHONY: packages pkg_deb pkg_rpm pkg_tar
packages: pkg_deb pkg_rpm pkg_tar
pkg_deb:
@$(if $(PKG_VERSION),,$(error PKG_VERSION not set and no git tag!))
@echo Packaging version $(PKG_VERSION)
mkdir pkgroot
DESTDIR=pkgroot $(MAKE) install
fpm -t deb --version $(PKG_VERSION)
rm -rf pkgroot
pkg_rpm:
@$(if $(PKG_VERSION),,$(error PKG_VERSION not set and no git tag!))
@echo Packaging version $(PKG_VERSION)
mkdir pkgroot
DESTDIR=pkgroot $(MAKE) install
fpm -t rpm --version $(PKG_VERSION)
rm -rf pkgroot
pkg_tar:
@$(if $(PKG_VERSION),,$(error PKG_VERSION not set and no git tag!))
@echo Packaging version $(PKG_VERSION)
mkdir pkgroot
DESTDIR=pkgroot $(MAKE) install
fpm -t tar --version $(PKG_VERSION)
rm -rf pkgroot

.PHONY: clean clean-small
# Clean files only, but don't remove the docker container.
clean-small:
rm -rf $(TARGET_MONITOR) $(TARGET_SERVER) $(TARGET_HCP) $(OBJS) $(DEPS)
rm -rf pkgroot *.deb *.rpm *.tar

clean: clean-small
rm -f hercules mockules/mockules
docker container rm -f hercules-builder || true
docker rmi hercules-builder || true


-include $(DEPS)
Loading