Skip to content

Commit 295bb42

Browse files
Merge pull request #29 from sio2project/Michcioperz-master
Debian packaging v2 Co-authored-by: Michał Sidor <public+git@meekchopp.es>
2 parents 369317c + b9672ba commit 295bb42

File tree

16 files changed

+197
-10
lines changed

16 files changed

+197
-10
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
boxes/

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,17 @@ pin.log
2121
.idea
2222
.cache
2323
__pycache__
24+
25+
debian/.debhelper/
26+
debian/debhelper-build-stamp
27+
debian/files
28+
debian/*.substvars
29+
debian/sio2jail/
30+
obj-*/
31+
ccache/
32+
install/
33+
obj-x86*
34+
out/
35+
36+
.vscode/
37+
.devcontainer/

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ ENDIF()
1313
IF(NOT DEFINED ARCH)
1414
SET(ARCH "NATIVE")
1515
ENDIF()
16-
IF(NOT ARCH MATCHES "i386|x86_64|NATIVE")
17-
MESSAGE(FATAL_ERROR "ARCH should be one of i386, x86_64, NATIVE")
16+
IF(NOT ARCH MATCHES "i386|x86_64|amd64|NATIVE")
17+
MESSAGE(FATAL_ERROR "ARCH should be one of i386, amd64, NATIVE")
1818
ENDIF()
1919

2020
IF(NOT DEFINED WITH_CLANG_TIDY)
@@ -43,7 +43,7 @@ ENDIF()
4343
IF(ARCH STREQUAL "i386")
4444
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
4545
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
46-
ELSEIF(ARCH STREQUAL "x86_64")
46+
ELSEIF(ARCH MATCHES "amd64|x86_64")
4747
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
4848
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
4949
ENDIF()

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM debian:bullseye
2+
3+
RUN apt-get update && \
4+
export DEBIAN_FRONTEND=noninteractive && \
5+
apt-get install -y \
6+
build-essential \
7+
libcap-dev \
8+
libtclap-dev \
9+
libseccomp-dev \
10+
libseccomp2 \
11+
cmake \
12+
g++-multilib \
13+
gcc-multilib \
14+
wget \
15+
devscripts \
16+
lintian \
17+
debhelper \
18+
ccache \
19+
fakeroot
20+
21+
ENV LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
22+
ENV DEB_BUILD_OPTIONS "lang=en-US ccache nocheck"
23+
WORKDIR /app
24+
CMD ["/bin/bash"]

Makefile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
CC := g++
2+
INSTALL_PREFIX = $(HOME)/.local
3+
CONTAINER_NAME = sio2jail-dev-container
4+
CCACHE := $(shell ccache --version 2>/dev/null)
5+
6+
ifdef CCACHE
7+
CC := ccache
8+
endif
9+
10+
define run_in_docker
11+
docker build -t sio2jail-dev .
12+
- docker run -v $(shell pwd)/ccache:/ccache -v $(shell pwd):/app -e CCACHE_DIR=/ccache --rm --name $(CONTAINER_NAME) -d -it sio2jail-dev bash
13+
docker exec $(CONTAINER_NAME) $(1)
14+
docker exec $(CONTAINER_NAME) rm -rf build
15+
docker stop $(CONTAINER_NAME)
16+
endef
17+
18+
install: clean
19+
mkdir -p ccache
20+
mkdir -p ccache/tmp
21+
cmake -DCMAKE_CXX_COMPILER_LAUNCHER=$(CC) -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(INSTALL_PREFIX) . -B ./build
22+
make -C build
23+
make -C build install
24+
25+
deb:
26+
mkdir -p out
27+
fakeroot debuild -us -uc -b
28+
mv ../*.deb out/
29+
30+
release: install deb
31+
mkdir -p out
32+
mv $(INSTALL_PREFIX)/bin/sio2jail out/
33+
34+
release-docker: clean-docker
35+
$(call run_in_docker,make release)
36+
37+
install-docker: clean-docker
38+
$(call run_in_docker,make install)
39+
40+
deb-docker: clean-docker
41+
$(call run_in_docker,make deb)
42+
43+
test:
44+
make -C build check
45+
46+
clean:
47+
- rm -rf build
48+
- rm -rf out
49+
- rm -rf obj-*
50+
- rm -rf install
51+
- rm -rf bin
52+
- rm -rf debian/.debhelper
53+
- rm -rf debian/sio2jail
54+
- rm debian/files
55+
- rm debian/sio2jail.substvars
56+
57+
clean-docker:
58+
- docker run -v $(shell pwd):/app --rm --name $(CONTAINER_NAME) -d -it sio2jail-dev bash
59+
docker exec $(CONTAINER_NAME) make clean

README.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
sio2jail
22
========
33

4+
Building in Docker
5+
--------
6+
7+
Available commands:
8+
9+
* `make release-docker ` - build sio2jail binary and
10+
.deb package.
11+
12+
* `make install-docker` - build sio2jail binary.
13+
14+
* `make deb-docker` - build sio2jail .deb package.
415

5-
building
16+
* `make clean-docker` - clean up all temporary files.
17+
18+
The output files are placed in `./out/` directory.
19+
20+
For further reference and configuration see `./Makefile`.
21+
22+
Building manually
623
--------
724

825
You need a CMake, a C/C++ compiler with multilib support and python2. Any
@@ -15,6 +32,9 @@ install files to ~/local directory run:
1532
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/local ..
1633
make && make install
1734

35+
For building with default configuration, see scripts in
36+
`./Makefile`.
37+
1838
Our sio2jail uses some external libraries and programs:
1939
* libcap
2040
* libseccomp (>= 2.3.0)
@@ -55,7 +75,7 @@ option (STATIC by default):
5575
There is also a possibility to control whether output binary should run on other
5676
architecture than the default one (or force given architecture):
5777

58-
-DARCH=i386|x86_64
78+
-DARCH=i386|amd64
5979

6080
Note, that when using ARCH other than build host architecture it may be necessary
6181
(depending on libraries installation) to build sio2jail with custom libseccomp (more
@@ -66,7 +86,7 @@ ignore system libseccomp run:
6686

6787
cmake -DWITH_DOCS=NO -DLIBTCLAP_PREFIX=/opt/tclap -DLIBSECCOMP_BUILD_OWN=YES ..
6888

69-
running
89+
Running
7090
-------
7191

7292
You may need to run
@@ -80,14 +100,14 @@ Additionally, if you want to use sandboxing on older Debian kernels, you'll need
80100
For both settings, you may also put these options in your /etc/sysctl.conf.
81101
This will make the settings persist across reboots.
82102

83-
running tests
103+
Running tests
84104
-------------
85105

86106
To run test suit use 'check' target, e.g in build directory run:
87107

88108
make check
89109

90-
notes for developers
110+
Notes for developers
91111
--------------------
92112

93113
To manually run clang-format on each file run:

debian/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../README.md

debian/changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
sio2jail (1.4.3) UNRELEASED; urgency=medium
2+
3+
* Initial Release.
4+
5+
-- Michał Sidor <michcioperz@asirpa.iscute.ovh> Sun, 12 Jan 2020 15:24:25 +0100

debian/compat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
11

debian/control

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Source: sio2jail
2+
Section: utils
3+
Priority: optional
4+
Maintainer: Oi Admins <oi-admins@dasie.mimuw.edu.pl>
5+
Build-Depends: debhelper (>= 11), cmake
6+
Standards-Version: 4.1.3
7+
Homepage: https://github.com/sio2project/sio2jail
8+
Vcs-Browser: https://github.com/sio2project/sio2jail
9+
Vcs-Git: https://github.com/sio2project/sio2jail.git
10+
11+
Package: sio2jail
12+
Architecture: any
13+
Depends: ${shlibs:Depends}, ${misc:Depends}
14+
Description: Sandbox for programming contests.
15+
A tool for supervising execution of programs
16+
submitted in algorithmic competitions.

0 commit comments

Comments
 (0)