Installation¶
Dependencies¶
These are our requirements (in particular we highlight those that are not usually installed by default) - previous versions may or may not work:
- build environment for the programming languages allowed in the competition;
- PostgreSQL >= 9.0;
- GNU compiler collection (in particular the C compiler gcc);
- gettext >= 0.18;
- Python >= 2.7, < 3.0;
- setuptools >= 0.6;
- Tornado >= 2.0;
- Psycopg >= 2.4;
- gevent >= 1.0;
- SQLAlchemy >= 0.7;
- libcg;
- psutil >= 0.6;
- netifaces >= 0.5;
- PyCrypto >= 2.3;
- pytz;
- six >= 1.1;
- requests >= 1.1;
- werkzeug >= 0.8;
- iso-codes;
- shared-mime-info;
- PyYAML >= 3.10 (only for some importers);
- BeautifulSoup >= 3.2 (only for running tests);
- mechanize >= 0.2 (only for running tests);
- coverage >= 3.4 (only for running tests);
- mock >= 1.0 (only for running tests);
- Sphinx (only for building documentation).
You will also require a Linux kernel with support for control groups and namespaces. Support has been in the Linux kernel since 2.6.32, and is provided by Ubuntu 12.04 and later. Other distributions, or systems with custom kernels, may not have support enabled. At a minimum, you will need to enable the following Linux kernel options: CONFIG_CGROUPS, CONFIG_CGROUP_CPUACCT, CONFIG_MEMCG (previously called as CONFIG_CGROUP_MEM_RES_CTLR), CONFIG_CPUSETS, CONFIG_PID_NS, CONFIG_IPC_NS, CONFIG_NET_NS. It is anyway suggested to use Linux kernel version at least 3.8.
Then you require the compilation and execution environments for the languages you will use in your contest:
- GNU compiler collection (for C, C++ and Java, respectively with executables gcc, g++ and gcj);
- Free Pascal (for Pascal, with executable fpc);
- Python >= 2.7, < 3.0 (for Python, with executable python2; note though that this must be installed anyway because it is required by CMS itself);
- PHP >= 5 (for PHP, with executable php5).
All dependencies can be installed automatically on most Linux distributions.
On Ubuntu 14.04, one will need to run the following script to satisfy all dependencies:
sudo apt-get install build-essential fpc postgresql postgresql-client \
gettext python2.7 python-setuptools python-tornado python-psycopg2 \
python-sqlalchemy python-psutil python-netifaces python-crypto \
python-tz python-six iso-codes shared-mime-info stl-manual \
python-beautifulsoup python-mechanize python-coverage python-mock \
cgroup-lite python-requests python-werkzeug python-gevent
# Optional.
# sudo apt-get install nginx-full php5-cli php5-fpm phppgadmin \
# python-yaml python-sphinx
On Arch Linux, the following command will install almost all dependencies (two of them can be found in the AUR):
sudo pacman -S base-devel fpc postgresql postgresql-client python2 \
setuptools python2-tornado python2-psycopg2 python2-sqlalchemy \
python2-psutil python2-netifaces python2-crypto python2-pytz \
python2-six iso-codes shared-mime-info python2-beautifulsoup3 \
python2-mechanize python2-mock python2-requests python2-werkzeug \
python2-gevent python2-coverage
# Install the following from AUR.
# https://aur.archlinux.org/packages/libcgroup/
# https://aur.archlinux.org/packages/sgi-stl-doc/
# Optional.
# sudo pacman -S nginx php php-fpm phppgadmin python2-yaml python-sphinx
If you prefer using Python Package Index, you can retrieve all Python dependencies with this line:
sudo pip install -r REQUIREMENTS.txt
Installing CMS¶
You can download CMS 1.1.0 from GitHub and extract it on your filesystem. After that, you can install it (recommended, not necessary though):
./setup.py build
sudo ./setup.py install
If you install CMS, you also need to add your user to the cmsuser group and logout to make the change effective:
sudo usermod -a -G cmsuser <your user>
You can verify to be in the group by issuing the command:
groups
Warning
Users in the group cmsuser will be able to launch the isolate program with root permission. They may exploit this to gain root privileges. It is then imperative that no untrusted user is allowed in the group cmsuser.
Updating CMS¶
As CMS develops, the database schema it uses to represent its data may be updated and new versions may introduce changes that are incompatible with older versions.
To preserve the data stored on the database you need to dump it on the filesystem using cmsContestExporter before you update CMS (i.e. with the old version).
You can then update CMS and reset the database schema by running:
cmsDropDB
cmsInitDB
To load the previous data back into the database you can use cmsContestImporter: it will adapt the data model automatically on-the-fly (you can use cmsDumpUpdater to store the updated version back on disk and speed up future imports).