From bbf213e5a04df3b0ff679142346aa0117d8d7929 Mon Sep 17 00:00:00 2001 From: Chuyang Wang Date: Sat, 18 Jan 2025 14:20:21 +0100 Subject: [PATCH 01/10] chore: add Makefile for cms installation on Ubuntu --- .gitignore | 1 + Makefile | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 0ebd068536..8edd88b86f 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ lib/ log/ .vagrant/ codecov/ +cmsvenv/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..7ce5ba29a6 --- /dev/null +++ b/Makefile @@ -0,0 +1,50 @@ +PACKAGE_MGR=apt-get +PACKAGE_MGR_INSTALL_OPT=install -y +PACKAGE_MGR_INSTALL=$(PACKAGE_MGR) $(PACKAGE_MGR_INSTALL_OPT) +PYTHON_VER=3.9 +PYTHON_BIN=python$(PYTHON_VER) +VENV_PATH=./cmsvenv +USR_ROOT=/usr/local +CMS_USER_GROUP=cmsuser + +#Isolate: libsystemd-dev +# create group, copy, set perms + +help: + echo TODO + +clean: + rm -rf isolate + +install-isolate: + sudo $(PACKAGE_MGR_INSTALL) libsystemd-dev + git clone https://github.com/ioi/isolate.git + cd isolate && make isolate + cd isolate && sudo cp ./isolate $(USR_ROOT)/bin/isolate + sudo chgrp $(CMS_USER_GROUP) $(USR_ROOT)/bin/isolate + sudo chmod 4750 $(USR_ROOT)/bin/isolate + cd isolate && sudo cp ./default.cf $(USR_ROOT)/etc/isolate + sudo chgrp $(CMS_USER_GROUP) $(USR_ROOT)/etc/isolate + sudo chmod 640 $(USR_ROOT)/etc/isolate + echo $(isolate --version) + + +python-apt-deps: + sudo add-apt-repository -y ppa:deadsnakes/ppa + sudo apt-get update + sudo $(PACKAGE_MGR_INSTALL) $(PYTHON_BIN) $(PYTHON_BIN)-dev $(PYTHON_BIN)-venv \ + python3-pip + +apt-deps: + sudo $(PACKAGE_MGR_INSTALL) build-essential openjdk-17-jdk-headless fp-compiler \ + postgresql postgresql-client cppreference-doc-en-html \ + cgroup-lite libcap-dev zip libpq-dev libcups2-dev libyaml-dev \ + libffi-dev + +install-cms: + $(PYTHON_BIN) -m venv $(VENV_PATH) + export SETUPTOOLS_USE_DISTUTILS="stdlib" ; . $(VENV_PATH)/bin/activate ; pip3 install -r requirements.txt + export SETUPTOOLS_USE_DISTUTILS="stdlib" ; . $(VENV_PATH)/bin/activate ; $(PYTHON_BIN) setup.py install + +install: install-isolate apt-deps python-apt-deps install-cms + echo "SUCCESS" From 4ca17360cf19ed6a14bdd961b7a431e1b13ea664 Mon Sep 17 00:00:00 2001 From: Chuyang Wang Date: Sat, 18 Jan 2025 14:29:58 +0100 Subject: [PATCH 02/10] allow apt-get update to fail --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7ce5ba29a6..785ed2fdeb 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ install-isolate: python-apt-deps: sudo add-apt-repository -y ppa:deadsnakes/ppa - sudo apt-get update + sudo apt-get update || true sudo $(PACKAGE_MGR_INSTALL) $(PYTHON_BIN) $(PYTHON_BIN)-dev $(PYTHON_BIN)-venv \ python3-pip From b04e9b185601a6ab4f50b36ae4319d35f168ad7f Mon Sep 17 00:00:00 2001 From: Chuyang Wang Date: Sat, 18 Jan 2025 16:34:39 +0100 Subject: [PATCH 03/10] add groupadd --- Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 785ed2fdeb..8ba16a5b9f 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,10 @@ clean: rm -rf isolate install-isolate: - sudo $(PACKAGE_MGR_INSTALL) libsystemd-dev + sudo apt update + sudo $(PACKAGE_MGR_INSTALL) libcap-dev libsystemd-dev + sudo groupadd $(CMS_USER_GROUP) || true + sudo usermod -a -G cmsuser $(whoami) git clone https://github.com/ioi/isolate.git cd isolate && make isolate cd isolate && sudo cp ./isolate $(USR_ROOT)/bin/isolate @@ -31,7 +34,7 @@ install-isolate: python-apt-deps: sudo add-apt-repository -y ppa:deadsnakes/ppa - sudo apt-get update || true + sudo apt-get update sudo $(PACKAGE_MGR_INSTALL) $(PYTHON_BIN) $(PYTHON_BIN)-dev $(PYTHON_BIN)-venv \ python3-pip @@ -46,5 +49,5 @@ install-cms: export SETUPTOOLS_USE_DISTUTILS="stdlib" ; . $(VENV_PATH)/bin/activate ; pip3 install -r requirements.txt export SETUPTOOLS_USE_DISTUTILS="stdlib" ; . $(VENV_PATH)/bin/activate ; $(PYTHON_BIN) setup.py install -install: install-isolate apt-deps python-apt-deps install-cms +install: apt-deps install-isolate python-apt-deps install-cms echo "SUCCESS" From c527f23bab43abd9ac9729dc6458567c7fe5322b Mon Sep 17 00:00:00 2001 From: Chuyang Wang Date: Sat, 18 Jan 2025 16:56:07 +0100 Subject: [PATCH 04/10] disallow root user to execute make --- Makefile | 16 ++++++++++++---- isolate | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) create mode 160000 isolate diff --git a/Makefile b/Makefile index 8ba16a5b9f..c7a98edc1a 100644 --- a/Makefile +++ b/Makefile @@ -13,14 +13,22 @@ CMS_USER_GROUP=cmsuser help: echo TODO +ifeq "$(shell whoami)" "root" +assert-not-root: + @echo "Do not use sudo before make" + exit 1 +else +assert-not-root: +endif + clean: - rm -rf isolate + sudo rm -rf isolate install-isolate: sudo apt update sudo $(PACKAGE_MGR_INSTALL) libcap-dev libsystemd-dev sudo groupadd $(CMS_USER_GROUP) || true - sudo usermod -a -G cmsuser $(whoami) + sudo usermod -a -G cmsuser $(shell whoami) git clone https://github.com/ioi/isolate.git cd isolate && make isolate cd isolate && sudo cp ./isolate $(USR_ROOT)/bin/isolate @@ -49,5 +57,5 @@ install-cms: export SETUPTOOLS_USE_DISTUTILS="stdlib" ; . $(VENV_PATH)/bin/activate ; pip3 install -r requirements.txt export SETUPTOOLS_USE_DISTUTILS="stdlib" ; . $(VENV_PATH)/bin/activate ; $(PYTHON_BIN) setup.py install -install: apt-deps install-isolate python-apt-deps install-cms - echo "SUCCESS" +install: assert-not-root apt-deps install-isolate python-apt-deps install-cms + @echo "SUCCESS" diff --git a/isolate b/isolate new file mode 160000 index 0000000000..758ab000e3 --- /dev/null +++ b/isolate @@ -0,0 +1 @@ +Subproject commit 758ab000e3a1bcf1e57ffddea2340ffa1a5af49b From d5ac612d99f9f7833186e437f99a62c4a5609c77 Mon Sep 17 00:00:00 2001 From: Jonathan Busch Date: Sat, 18 Jan 2025 18:50:45 +0100 Subject: [PATCH 05/10] fix Makefile --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c7a98edc1a..cdd43ae590 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ install-isolate: cd isolate && sudo cp ./default.cf $(USR_ROOT)/etc/isolate sudo chgrp $(CMS_USER_GROUP) $(USR_ROOT)/etc/isolate sudo chmod 640 $(USR_ROOT)/etc/isolate - echo $(isolate --version) + echo $(shell isolate --version) python-apt-deps: @@ -50,7 +50,7 @@ apt-deps: sudo $(PACKAGE_MGR_INSTALL) build-essential openjdk-17-jdk-headless fp-compiler \ postgresql postgresql-client cppreference-doc-en-html \ cgroup-lite libcap-dev zip libpq-dev libcups2-dev libyaml-dev \ - libffi-dev + libffi-dev install-cms: $(PYTHON_BIN) -m venv $(VENV_PATH) From e810e6efbd5c76043a469b2017c8e94fa63bac04 Mon Sep 17 00:00:00 2001 From: Jonathan Busch Date: Sat, 18 Jan 2025 18:54:18 +0100 Subject: [PATCH 06/10] fix isolate installation method --- .gitignore | 1 + Makefile | 3 ++- isolate | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) delete mode 160000 isolate diff --git a/.gitignore b/.gitignore index 8edd88b86f..e6c10747fc 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ log/ .vagrant/ codecov/ cmsvenv/ +isolate diff --git a/Makefile b/Makefile index cdd43ae590..eb6b136511 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ install-isolate: sudo apt update sudo $(PACKAGE_MGR_INSTALL) libcap-dev libsystemd-dev sudo groupadd $(CMS_USER_GROUP) || true - sudo usermod -a -G cmsuser $(shell whoami) + sudo usermod -a -G $(CMS_USER_GROUP) $(shell whoami) git clone https://github.com/ioi/isolate.git cd isolate && make isolate cd isolate && sudo cp ./isolate $(USR_ROOT)/bin/isolate @@ -38,6 +38,7 @@ install-isolate: sudo chgrp $(CMS_USER_GROUP) $(USR_ROOT)/etc/isolate sudo chmod 640 $(USR_ROOT)/etc/isolate echo $(shell isolate --version) + sudo rm -rf isolate python-apt-deps: diff --git a/isolate b/isolate deleted file mode 160000 index 758ab000e3..0000000000 --- a/isolate +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 758ab000e3a1bcf1e57ffddea2340ffa1a5af49b From 300ce704f4e07975c51880dbc53fbda1d181e132 Mon Sep 17 00:00:00 2001 From: Chuyang Wang Date: Sat, 18 Jan 2025 19:54:24 +0100 Subject: [PATCH 07/10] Fix isolate installation --- Makefile | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index eb6b136511..eb4d10daa8 100644 --- a/Makefile +++ b/Makefile @@ -26,18 +26,16 @@ clean: install-isolate: sudo apt update - sudo $(PACKAGE_MGR_INSTALL) libcap-dev libsystemd-dev + sudo $(PACKAGE_MGR_INSTALL) libcap-dev libsystemd-dev pkg-config sudo groupadd $(CMS_USER_GROUP) || true sudo usermod -a -G $(CMS_USER_GROUP) $(shell whoami) git clone https://github.com/ioi/isolate.git - cd isolate && make isolate - cd isolate && sudo cp ./isolate $(USR_ROOT)/bin/isolate - sudo chgrp $(CMS_USER_GROUP) $(USR_ROOT)/bin/isolate - sudo chmod 4750 $(USR_ROOT)/bin/isolate - cd isolate && sudo cp ./default.cf $(USR_ROOT)/etc/isolate - sudo chgrp $(CMS_USER_GROUP) $(USR_ROOT)/etc/isolate - sudo chmod 640 $(USR_ROOT)/etc/isolate - echo $(shell isolate --version) + cd isolate && sudo make install + cd isolate && sudo cp -rf systemd/* /etc/systemd/system/ + sudo systemctl daemon-reload + sudo systemctl enable isolate.service + sudo systemctl start isolate.service + isolate --version sudo rm -rf isolate @@ -58,5 +56,10 @@ install-cms: export SETUPTOOLS_USE_DISTUTILS="stdlib" ; . $(VENV_PATH)/bin/activate ; pip3 install -r requirements.txt export SETUPTOOLS_USE_DISTUTILS="stdlib" ; . $(VENV_PATH)/bin/activate ; $(PYTHON_BIN) setup.py install -install: assert-not-root apt-deps install-isolate python-apt-deps install-cms +assert-isolate-functional: + sudo -E -u $(shell whoami) isolate --cg --init + sudo -E -u $(shell whoami) isolate --cg --cleanup + @echo isolate is functional + +install: assert-not-root apt-deps install-isolate python-apt-deps install-cms assert-isolate-functional @echo "SUCCESS" From c4484bcd05cbb8e097162498dde411169ada672a Mon Sep 17 00:00:00 2001 From: Chuyang Wang Date: Sun, 19 Jan 2025 10:13:41 +0100 Subject: [PATCH 08/10] Add network and tex targets, add help messages --- Makefile | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index eb4d10daa8..735df0594b 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,17 @@ PACKAGE_MGR=apt-get PACKAGE_MGR_INSTALL_OPT=install -y PACKAGE_MGR_INSTALL=$(PACKAGE_MGR) $(PACKAGE_MGR_INSTALL_OPT) + PYTHON_VER=3.9 PYTHON_BIN=python$(PYTHON_VER) VENV_PATH=./cmsvenv + USR_ROOT=/usr/local CMS_USER_GROUP=cmsuser -#Isolate: libsystemd-dev -# create group, copy, set perms - -help: - echo TODO +help: ## Show this help message + @echo "Help: Build and install cms on the current machine" + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) ifeq "$(shell whoami)" "root" assert-not-root: @@ -38,7 +38,6 @@ install-isolate: isolate --version sudo rm -rf isolate - python-apt-deps: sudo add-apt-repository -y ppa:deadsnakes/ppa sudo apt-get update @@ -61,5 +60,14 @@ assert-isolate-functional: sudo -E -u $(shell whoami) isolate --cg --cleanup @echo isolate is functional -install: assert-not-root apt-deps install-isolate python-apt-deps install-cms assert-isolate-functional +install: assert-not-root apt-deps install-isolate python-apt-deps install-cms assert-isolate-functional ## Install cms (inclduing isolate v2) in virtual environment @echo "SUCCESS" + +install-network: ## Install network packages for web server + sudo $(PACKAGE_MGR_INSTALL) nginx-full + +install-tex: ## Install latex related packages for statement compilation + sudo $(PACKAGE_MGR_INSTALL) texlive-latex-base + +install-full: install install-network install-tex ## Install the complete cms suite including web server and statement compilation capability + From 22cd53a521f1c543d843ce8e837d854baa3ff3db Mon Sep 17 00:00:00 2001 From: Chuyang Wang Date: Sun, 19 Jan 2025 11:53:27 +0100 Subject: [PATCH 09/10] update installation docs --- Makefile | 3 +-- README.md | 11 ++--------- docs/Installation.rst | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 735df0594b..e3012e62da 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,7 @@ help: ## Show this help message ifeq "$(shell whoami)" "root" assert-not-root: - @echo "Do not use sudo before make" - exit 1 + $(error Do not use sudo before make) else assert-not-root: endif diff --git a/README.md b/README.md index 416217ff5e..96747385f1 100644 --- a/README.md +++ b/README.md @@ -30,15 +30,8 @@ master branch, is intended for developers and everyone interested in contributing or just curious to see how the code works and wanting to hack on it. -Please note that since the sandbox is contained in a -[git submodule](http://git-scm.com/docs/git-submodule) you should append -`--recursive` to the standard `git clone` command to obtain it. Or, if -you have already cloned CMS, simply run the following command from -inside the repository: - -```bash -git submodule update --init -``` +> [!warning] isolate v2 +> Starting from isolate v2, we recommend installing [isolate](https://github.com/ioi/isolate) from your package manager or building it yourself. The submodule isolate is removed. For further information, see `docs`. In the folder `docs` you can find a Vagrant File; copy it to the top level if you want to use it. Vagrant is a tool that enables to create the same virtual diff --git a/docs/Installation.rst b/docs/Installation.rst index 49934f15a6..b79269cd6e 100644 --- a/docs/Installation.rst +++ b/docs/Installation.rst @@ -71,6 +71,22 @@ All dependencies can be installed automatically on most Linux distributions. Ubuntu ------ +For Ubuntu 24.4 (and probably also 22.*), there is a Makefile for cms +installation. + +.. sourcecode:: bash + + make install + +This should compile and install isolate v2, install dependencies for cms, create +the virtual environment for cms and install cms in this virtual environment. +After installation, you should be able to run cms After + +.. sourcecode:: bash + + . ./cmsvenv/bin/activate + + .. warning:: The instructions below may be outdated. From d0e12717a2350677b263d8f8d7927d513ad9d387 Mon Sep 17 00:00:00 2001 From: Chuyang Wang Date: Sun, 19 Jan 2025 12:49:16 +0100 Subject: [PATCH 10/10] add latex install --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e3012e62da..878aac5c2f 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,9 @@ install-network: ## Install network packages for web server sudo $(PACKAGE_MGR_INSTALL) nginx-full install-tex: ## Install latex related packages for statement compilation - sudo $(PACKAGE_MGR_INSTALL) texlive-latex-base + sudo $(PACKAGE_MGR_INSTALL) texlive-latex-recommended texlive-fonts-extra \ + texlive-fonts-recommended texlive-formats-extra texlive-lang-english \ + texlive-lang-german texlive-luatex texlive-science install-full: install install-network install-tex ## Install the complete cms suite including web server and statement compilation capability