From 1854bd708ef1ca1ec92223eb2a0f9b12914f936c Mon Sep 17 00:00:00 2001 From: nd <git@notandy.de> Date: Sat, 31 Jul 2021 01:02:48 +0200 Subject: [PATCH] package uffd for apt --- .gitlab-ci.yml | 41 ++++++++++++++++++++++++++++++++++++++--- MANIFEST.in | 6 ++++++ README.md | 24 ++---------------------- debian/changelog | 5 +++++ debian/control | 30 ++++++++++++++++++++++++++++++ debian/rules | 7 +++++++ debian/uffd.dirs | 3 +++ debian/uffd.install | 2 ++ debian/uffd.links | 1 + nginx.include.conf | 7 +++++++ setup.py | 1 + uwsgi.ini | 15 +++++++++++++++ 12 files changed, 117 insertions(+), 25 deletions(-) create mode 100644 MANIFEST.in create mode 100644 debian/changelog create mode 100644 debian/control create mode 100755 debian/rules create mode 100644 debian/uffd.dirs create mode 100644 debian/uffd.install create mode 100644 debian/uffd.links create mode 100644 nginx.include.conf create mode 100644 uwsgi.ini diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e3385bbc..0f7b4190 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,6 +11,31 @@ before_script: - uname -a - python3 -m pylint --version - python3 -m coverage --version + - echo "${CI_COMMIT_TAG}" | grep -qE "v[0-9]+[.][0-9]+[.][0-9]+.*" && export UFFD_PACKAGE_VERSION="${CI_COMMIT_TAG#v}" || export UFFD_PACKAGE_VERSION="${CI_COMMIT_SHA}" + +build:pip: + stage: build + script: + - pip3 install build + - PACKAGE_VERSION="${UFFD_PACKAGE_VERSION}" python3 -m build + artifacts: + paths: + - dist/* + +build:apt: + stage: build + script: + - apt update + - apt-get install -y python3-all debhelper python3-pip git-buildpackage + - export PYBUILD_INSTALL_ARGS="--install-lib=/usr/share/uffd/ --install-scripts=/usr/share/uffd/" + - gbp dch --ignore-branch --debian-tag=v%\(version\)s + - dpkg-buildpackage -us -uc + - mkdir build + - mv ../*.deb build/ + artifacts: + paths: + - build/*.deb + - debian/changelog db_migrations_updated: stage: test @@ -72,12 +97,22 @@ trans_de: - ./update_translations.sh de coverage: '/^TOTAL.*\s+(\d+\%)$/' -publish-pip: +publish:pip: stage: deploy script: - - pip3 install build twine - - PACKAGE_VERSION="${CI_COMMIT_TAG#v}" python3 -m build + - pip3 install twine - TWINE_USERNAME="${GITLABPKGS_USERNAME}" TWINE_PASSWORD="${GITLABPKGS_PASSWORD}" python3 -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/* - TWINE_USERNAME="${PYPI_USERNAME}" TWINE_PASSWORD="${PYPI_PASSWORD}" python3 -m twine upload dist/* + dependencies: + - build:pip + rules: + - if: '$CI_COMMIT_TAG =~ /v[0-9]+[.][0-9]+[.][0-9]+.*/' + +publish:apt: + stage: deploy + script: + - exit 0 + dependencies: + - build:apt rules: - if: '$CI_COMMIT_TAG =~ /v[0-9]+[.][0-9]+[.][0-9]+.*/' diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..d5e3a562 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +include setup.py +graft migrations/* +graft uffd/templates +graft uffd/*/templates +graft uffd/static/ +graft uffd/translations/ diff --git a/README.md b/README.md index a4ded7a1..9d28e898 100644 --- a/README.md +++ b/README.md @@ -41,27 +41,7 @@ Please note that the mocked LDAP functionality is very limited and many uffd fea ## deployment Use uwsgi. Make sure to run `flask db upgrade` after every update! - -### example uwsgi config - -``` -[uwsgi] -plugin = python3 -env = PYTHONIOENCODING=UTF-8 -env = LANG=en_GB.utf8 -env = TZ=Europe/Berlin -manage-script-name = true -chdir = /var/www/uffd -module = uffd:create_app() - -uid = uffd -gid = uffd - -vacuum = true -die-on-term = true - -hook-pre-app = exec:FLASK_APP=uffd flask db upgrade -``` +For an example uwsgi config, see our [uswgi.ini](uwsgi.ini). You might find our [nginx include file](nginx.include.conf) helpfull to setup a web server infront of uwsgi. ## python style conventions @@ -114,7 +94,7 @@ The userinfo endpoint returns json data with the following structure: ## Translation -The web frontend is translated in the following Languages: +The web frontend is initially written in English and translated in the following Languages:  diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000..8ec8f739 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +uffd (0.1.2) unstable; urgency=medium + + * Initial release. + + -- Andreas Valder <nd@cccv.de> Fri, 31 Jul 2021 23:02:31 +0200 diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..5d85a101 --- /dev/null +++ b/debian/control @@ -0,0 +1,30 @@ +Source: uffd +Section: python +Priority: optional +Maintainer: CCCV <it@cccv.de> +Build-Depends: + debhelper-compat (= 12), + dh-python, + python3-all, + python3-setuptools, +Standards-Version: 4.5.0 +Homepage: https://git.cccv.de/uffd/uffd +Vcs-Git: https://git.cccv.de/uffd/uffd.git + +Package: uffd +Architecture: any +Depends: + ${misc:Depends}, + ${python3:Depends}, + python3-ldap3, + python3-flask, + python3-flask-sqlalchemy, + python3-flask-migrate, + python3-qrcode, + python3-fido2, + python3-flask-oauthlib, + python3-flask-babel, + nginx, + uwsgi, + uwsgi-plugin-python3, +Description: UserFerwaltungsFrontend: Ldap based single sign on and user management web software diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..51a9034e --- /dev/null +++ b/debian/rules @@ -0,0 +1,7 @@ +#!/usr/bin/make -f +export DH_VERBOSE = 1 + +export PYBUILD_NAME=uffd + +%: + dh $@ --with python3 --buildsystem pybuild diff --git a/debian/uffd.dirs b/debian/uffd.dirs new file mode 100644 index 00000000..fe0717b3 --- /dev/null +++ b/debian/uffd.dirs @@ -0,0 +1,3 @@ +/etc/uffd +/var/lib/uffd +/usr/share/uffd/uffd/instance diff --git a/debian/uffd.install b/debian/uffd.install new file mode 100644 index 00000000..f58a61a6 --- /dev/null +++ b/debian/uffd.install @@ -0,0 +1,2 @@ +uwsgi.ini /etc/uwsgi/apps-available/uffd.ini +nginx.include.conf /etc/nginx/snippets/uffd-locations.conf diff --git a/debian/uffd.links b/debian/uffd.links new file mode 100644 index 00000000..d9fac40f --- /dev/null +++ b/debian/uffd.links @@ -0,0 +1 @@ +/usr/share/uffd/uffd/instance/config.py /etc/uffd/config.py diff --git a/nginx.include.conf b/nginx.include.conf new file mode 100644 index 00000000..f2896894 --- /dev/null +++ b/nginx.include.conf @@ -0,0 +1,7 @@ +location / { + uwsgi_pass unix:///run/uwsgi/app/uffd/socket; + include uwsgi_params; +} +location /static { + alias /usr/share/uffd/uffd/static; +} diff --git a/setup.py b/setup.py index ead7fb04..12287a2f 100644 --- a/setup.py +++ b/setup.py @@ -25,6 +25,7 @@ setup( author_email='it@cccv.de', license='AGPL3', packages=find_packages(), + include_package_data=True, zip_safe=False, python_requires='>=3.7', ) diff --git a/uwsgi.ini b/uwsgi.ini new file mode 100644 index 00000000..1ccf819f --- /dev/null +++ b/uwsgi.ini @@ -0,0 +1,15 @@ +[uwsgi] +plugin = python3 +env = PYTHONIOENCODING=UTF-8 +env = LANG=en_GB.utf8 +env = TZ=Europe/Berlin +manage-script-name = true +chdir = /usr/share/uffd +module = uffd:create_app() + +uid = uffd +gid = uffd + +vacuum = true + +hook-pre-app = exec:FLASK_APP=uffd flask db upgrade -- GitLab