Skip to content

Commit

Permalink
Replace C++ submit client with fully standalone submit client.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicky Gerritsen committed Aug 19, 2021
1 parent f8dd24e commit 055f34e
Show file tree
Hide file tree
Showing 18 changed files with 609 additions and 1,230 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ Version 8.0.0 - DEV
- Improve API action to add submission to adhere to the CCS spec.
- Add API action to create clarification following CCS spec.
- Add support for showing (pending) awards on the scoreboard. Thanks @shuibinlong!
- Remove JudgehostRestriction feature due to new Judgehost API
- Remove JudgehostRestriction feature due to new Judgehost API.
- Replace C++ submit client with (standalone) Python version.


Version 7.3.2 - 23 November 2020
Expand Down
11 changes: 2 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ default:
@echo " - make build (all except 'docs')"
@echo " - make domserver"
@echo " - make judgehost"
@echo " - make submitclient"
@echo " - make docs"
@echo or
@echo " - make install-domserver"
Expand All @@ -39,19 +38,13 @@ install:
all: build
build: domserver judgehost

ifeq ($(SUBMITCLIENT_ENABLED),yes)
build: submitclient
endif

ifeq ($(BUILD_DOCS),yes)
all: docs
dist: distdocs
endif

# MAIN TARGETS
domserver judgehost docs submitclient: paths.mk config
submitclient:
$(MAKE) -C submit submitclient
domserver judgehost docs: paths.mk config
install-domserver: domserver domserver-create-dirs
install-judgehost: judgehost judgehost-create-dirs
install-docs: docs-create-dirs
Expand Down Expand Up @@ -327,6 +320,6 @@ clean-autoconf:

.PHONY: $(addsuffix -create-dirs,domserver judgehost docs) check-root \
clean-autoconf $(addprefix maintainer-,conf install uninstall) \
config submitclient distdocs composer-dependencies \
config distdocs composer-dependencies \
composer-dependencies-dev \
coverity-conf coverity-build
66 changes: 0 additions & 66 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -248,66 +248,6 @@ AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_MKDIR_P

# Check for including optional libmagic.
AC_CHECK_LIB(magic,magic_open,AC_SUBST(LIBMAGIC,[-lmagic]))

# {{{ submitclient

AC_ARG_ENABLE(submitclient,AS_HELP_STRING([--disable-submitclient],
[enable submit client program (default: yes).
This requires JSONcpp and cURL libraries and optionally
libmagic for detecting submission of binary files.]))

if test "x$enable_submitclient" != "xno"; then
AC_SUBST(SUBMITCLIENT_ENABLED,[yes])

# Check for libcURL and JSONcpp when submit is enabled.
AX_LIB_CURL([7.9.7],[],[
AC_MSG_ERROR([libcURL not found (required for submit client)])
])
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $CURL_CFLAGS"
AC_CHECK_HEADERS([curl/curl.h],[],[
AC_MSG_ERROR([libcURL headers not found (required for submit client)])
])
CPPFLAGS="$save_CPPFLAGS"
# The 'curl-config --static-libs' option is accepted since 7.17.1
AC_SUBST(CURL_STATIC,"")
if test "x$enable_static_linking" = "xyes"; then
AX_COMPARE_VERSION([$curl_version],[ge],[7.17.1],[
AC_SUBST(CURL_STATIC,`curl-config --static-libs`)])
fi

# Check for JSONcpp library to decode language/extensions list from
# REST API (this also requires libcURL below).

# Note that under Debian the header files are installed under
# PREFIX/jsoncpp/json/json.h and not PREFIX/json/json.h since that
# conflicts with the libjson C library, so we check that first.
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS([jsoncpp/json/json.h json/json.h],[found_jsoncpp_headers=yes; break;],[])
AS_IF([test "x$found_jsoncpp_headers" != "xyes"],
AC_MSG_ERROR([JSONcpp headers not found (required for submit client)]),
AC_SUBST(LIBJSONCPP,[-ljsoncpp]))
AC_LANG_POP([C++])

fi
# }}}

# Check option to link statically against "special" libraries for
# submit client.
AC_ARG_ENABLE(static-linking,AS_HELP_STRING([--enable-static-linking],
[enable static linking against libcurl, libmagic, libjsoncpp for 'submit'
(default: no).]))

if test "x$enable_static_linking" = "xyes"; then
AC_SUBST(STATIC_LINK_START,[-Wl,-Bstatic])
AC_SUBST(STATIC_LINK_END, [-Wl,-Bdynamic])
else
AC_SUBST(STATIC_LINK_START,[''])
AC_SUBST(STATIC_LINK_END, [''])
fi

# Check option to build documentation. This option is provided to
# allow disabling it.
AC_ARG_ENABLE(doc-build,AS_HELP_STRING([--enable-doc-build],
Expand Down Expand Up @@ -373,12 +313,6 @@ echo " * webserver group.....: $WEBSERVER_GROUP"
echo ""
echo " * website base URL....: $BASEURL"
echo ""
if test "x$SUBMITCLIENT_ENABLED" = xyes ; then
echo " * submitclient........: enabled, cURL version: $curl_version"
else
echo " * submitclient........: disabled"
fi
echo ""
echo -n " * documentation.......: AX_VAR_EXPAND($domjudge_docdir)"
if test "x$DOC_BUILD_ENABLED" != xyes ; then
echo " (disabled)"
Expand Down
35 changes: 26 additions & 9 deletions doc/manual/install-workstation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,39 @@ Command line submit client
DOMjudge comes with a command line submit client which makes it really
convenient for teams to submit their solutions to DOMjudge.

In order to build the submit client, you need libcURL, libJSONcpp and
optionally libmagic. To install this on Debian-like distributions::
In order to use the submit client, you need Python, the python requests
library and optionally the python magic library installed on the team's
workstation. To install this on Debian-like distributions::

sudo apt install libcurl4-gnutls-dev libjsoncpp-dev libmagic-dev
sudo apt install python3 python3-requests python3-magic

Or on RedHat/CentOS/Fedora::

sudo yum install libcurl-devel jsoncpp-devel file-devel
sudo yum install python3 python3-requests python3-magic

Then run (adapt the URL to your environment; look at the Config check
in the admin web interface if unsure)::
You can now copy this client from ``submit/submit`` to the workstations.

./configure --enable-static-linking --with-baseurl="https://yourhost.example.edu/domjudge"
make submitclient
The submit client needs to know the base URL of the domserver where it should
submit to. You have three options to configure this:

You can now copy this client from ``submit/submit`` to the workstations.
* Set it as an environment variable called ``SUBMITBASEURL``, e.g. in
``/etc/profile.d/``.
* Modify the ``submit/submit`` file and set the variable of ``baseurl``
at the top.
* Let teams pass it using the ``--url`` argument.

Note that the environment variable overrides the hardcoded variable at
the top of the file and the ``--url`` argument overrides both other options.

The submit client will need to know to which contest to submit to. If there
is only one active contest, that will be used. If not, you have two options
to configure this:

* Set it as an environment variable called ``SUBMITCONTEST``, e.g. in
``/etc/profile.d/``.
* Let teams pass it using the ``--contest`` argument.

Note that the ``--contest`` argument overrides the environment variable.

In order for the client to authenticate to DOMjudge, credentials can be
pre-provisioned in the file ``~/.netrc`` in the user's homedir, with example
Expand Down
2 changes: 1 addition & 1 deletion etc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include $(TOPDIR)/Makefile.global
SECRETS = dbpasswords.secret restapi.secret symfony_app.secret initial_admin_password.secret

SUBST_CONFIGS = apache.conf nginx-conf nginx-conf-inner domjudge-fpm.conf domserver-static.php \
judgehost-static.php runguard-config.h submit-config.h \
judgehost-static.php runguard-config.h \
sudoers-domjudge

$(SUBST_CONFIGS): %: %.in $(TOPDIR)/paths.mk
Expand Down
1 change: 0 additions & 1 deletion gitlab/base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ parameters:
domjudge.rundir: /output/run
domjudge.tmpdir: /output/tmp
domjudge.baseurl: http://localhost/domjudge
domjudge.submitclient_enabled: yes
EOF

# install all php dependencies
Expand Down
1 change: 1 addition & 0 deletions gitlab/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ section_end more_setup

section_start submitting "Submitting test sources (including Kattis example)"
cd ${DIR}/tests
export SUBMITBASEURL='http://localhost/domjudge/'
make check test-stress

# Prepare to load example problems from Kattis/problemtools
Expand Down
38 changes: 0 additions & 38 deletions m4/ax_lib_curl.m4

This file was deleted.

18 changes: 0 additions & 18 deletions paths.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ CXXFLAGS = @CXXFLAGS@
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@ @LIBS@

STATIC_LINK_START = @STATIC_LINK_START@
STATIC_LINK_END = @STATIC_LINK_END@

EXEEXT = @EXEEXT@
OBJEXT = .@OBJEXT@

Expand All @@ -38,26 +35,12 @@ MKDIR_P = @MKDIR_P@
INSTALL = @INSTALL@
@SET_MAKE@

# Build submit client?
SUBMITCLIENT_ENABLED = @SUBMITCLIENT_ENABLED@

# Build documentation?
DOC_BUILD_ENABLED = @DOC_BUILD_ENABLED@

# libcgroup
LIBCGROUP = @LIBCGROUP@

# libmagic
LIBMAGIC = @LIBMAGIC@

# libJSONcpp
LIBJSONCPP = @LIBJSONCPP@

# libcURL
CURL_CFLAGS = @CURL_CFLAGS@
CURL_LIBS = @CURL_LIBS@
CURL_STATIC = @CURL_STATIC@

# User:group file ownership of password files
DOMJUDGE_USER = @DOMJUDGE_USER@
WEBSERVER_GROUP = @WEBSERVER_GROUP@
Expand Down Expand Up @@ -167,7 +150,6 @@ define substconfigvars
-e 's,@RUNUSER[@],@RUNUSER@,g' \
-e 's,@RUNGROUP[@],@RUNGROUP@,g' \
-e 's,@BASEURL[@],@BASEURL@,g' \
-e 's,@SUBMITCLIENT_ENABLED[@],@SUBMITCLIENT_ENABLED@,g' \
> $@
@chmod --reference=$< $@
endef
2 changes: 0 additions & 2 deletions submit/.gitignore

This file was deleted.

46 changes: 3 additions & 43 deletions submit/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,10 @@ include $(TOPDIR)/Makefile.global

TARGETS =

SUBMITCLIENT = submit$(EXEEXT)
# Statically link against libmagic and libJSONcpp to prevent
# dependency on team workstations (this might be GCC specific):
ifneq ($(LIBMAGIC),)
$(SUBMITCLIENT): LDFLAGS += $(STATIC_LINK_START) $(LIBMAGIC) $(STATIC_LINK_END)
endif
ifneq ($(LIBJSONCPP),)
$(SUBMITCLIENT): LDFLAGS += $(STATIC_LINK_START) $(LIBJSONCPP) $(STATIC_LINK_END)
endif
$(SUBMITCLIENT): CXXFLAGS += $(CURL_CFLAGS)
# Try to link statically against libcURL to prevent dependency
# on team workstations:
ifneq ($(CURL_STATIC),)
$(SUBMITCLIENT): LDFLAGS += $(CURL_STATIC) -lpthread
else
$(SUBMITCLIENT): LDFLAGS += $(CURL_LIBS)
endif
$(SUBMITCLIENT): LDFLAGS := $(filter-out -pie,$(LDFLAGS))

SUBMITHEADERS = $(TOPDIR)/etc/submit-config.h

ifeq ($(SUBMITCLIENT_ENABLED),yes)
submitclient: $(SUBMITCLIENT)
TARGETS += $(SUBMITCLIENT)
else
submitclient:
@echo "Submit client is disabled."
@exit 1
endif

# Explicitly link with C++ compiler, as without any C++ extensions
# these are recognized as plain C objects.
$(SUBMITCLIENT): %$(EXEEXT): %$(OBJEXT) $(LIBOBJECTS)
$(CXX) $^ -o $@ $(LDFLAGS)

$(SUBMITCLIENT:%=%$(OBJEXT)): %$(OBJEXT): %.cc $(SUBMITHEADERS) $(LIBHEADERS)

clean-l:
-rm -f $(TARGETS) $(TARGETS:%=%$(OBJEXT))

check: submitclient
check:
bats submit_standalone.bats

check-full: submitclient
check-full:
bats submit_standalone.bats submit_online.bats

.PHONY: submitclient check check-full
.PHONY: check check-full
26 changes: 0 additions & 26 deletions submit/basename.h

This file was deleted.

Loading

0 comments on commit 055f34e

Please sign in to comment.