From f79112f84fe04daf746c07c7df076f7c18e677d5 Mon Sep 17 00:00:00 2001 From: s3lph Date: Fri, 19 Oct 2018 21:31:11 +0200 Subject: [PATCH] Added build setup for archlinux. Let's test! --- .gitlab-ci.yml | 26 ++++++++++++++++++- package/archlinux/PKGBUILD | 23 ++++++++++++++++ package/archlinux/matemat.install | 24 +++++++++++++++++ .../usr/lib/systemd/system/matemat.service | 10 +++++++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 package/archlinux/PKGBUILD create mode 100755 package/archlinux/matemat.install create mode 100644 package/archlinux/matemat/usr/lib/systemd/system/matemat.service diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9dc1e6e..2f90422 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -51,6 +51,7 @@ build_wheel: paths: - "dist/*.whl" only: + - deployment - staging - master - tags @@ -67,7 +68,7 @@ build_wheel: # - cd package/debian # - mv matemat/usr/lib/python3.7/{site,dist}-packages # - mv matemat/usr/bin/matemat matemat/usr/lib/matemat/matemat -# - rm -r matemat/usr/bin +# - rm -rf matemat/usr/bin # - find . -type f -exec sed -re "s#${PYTHON_BIN}#/usr/bin/python3.7#g" -i {} \; # - dpkg-deb --build matemat # - mv matemat.deb "matemat_${MATEMAT_VERSION}+${CI_COMMIT_REF_NAME}-1_all.deb" @@ -79,6 +80,29 @@ build_wheel: # - master # - tags +build_archlinux: + stage: build + image: base/devel:latest # Use an archlinux image instead of the customized debian image. + script: + - cp -r static/ package/archlinux/matemat/usr/lib/matemat/static/ + - cp -r templates/ package/archlinux/matemat/usr/lib/matemat/templates/ + - python3.7 setup.py egg_info -d -b +master install --root=package/archlinux/matemat/ --prefix=/usr --optimize=1 + - export PYTHON_BIN=$(which python3) + - cd package/archlinux + - mv matemat/usr/bin/matemat matemat/usr/lib/matemat/matemat + - rm -rf matemat/usr/bin + - find . -type f -exec sed -re "s#${PYTHON_BIN}#/usr/bin/python3.7#g" -i {} \; + - makepkg -s MATEMAT_VERSION=${MATEMAT_VERSION} + - mv matemat-${MATEMAT_VERSION}-1-any.pkg.tar.xz "matemat-${MATEMAT_VERSION}+${CI_COMMIT_REF_NAME}-1-any.pkg.tar.xz" + artifacts: + paths: + - "package/archlinux/*.pkg.tar.xz" + only: + - deployment + - staging + - master + - tags + staging: diff --git a/package/archlinux/PKGBUILD b/package/archlinux/PKGBUILD new file mode 100644 index 0000000..9fd4bf7 --- /dev/null +++ b/package/archlinux/PKGBUILD @@ -0,0 +1,23 @@ + +# Maintainer: s3lph + +pkgname=matemat +pkgver=${MATEMAT_VERSION} +pkgrel=1 +arch=('any') + +pkgdesc='A soda machine stock-keeping webservice' +url='https://gitlab.com/s3lph/matemat' +licence=('MIT') + +depends=( + 'python3>=3.7' + 'python-jinja' + 'python-pillow' + 'python-magic' + 'file' +) + +install=$pkgname.install + +pkgdir=matemat/ diff --git a/package/archlinux/matemat.install b/package/archlinux/matemat.install new file mode 100755 index 0000000..7595190 --- /dev/null +++ b/package/archlinux/matemat.install @@ -0,0 +1,24 @@ + +post_install() { + + set -e + + if [[ "$1" == "configure" ]]; then + + if ! getent group matemat >/dev/null; then + groupadd --system matemat + fi + + if ! getent passwd matemat >/dev/null; then + useradd --system --create-home --gid matemat --home-dir /var/lib/matemat --shell /usr/bin/nologin matemat + fi + + chown matemat:matemat -R /var/lib/matemat + find /var/lib/matemat -type d -exec chmod 0750 {} + find /var/lib/matemat -type f -exec chmod 0640 {} + + setcap CAP_NET_BIND_SERVICE=+eip /usr/bin/matemat + + fi + +} diff --git a/package/archlinux/matemat/usr/lib/systemd/system/matemat.service b/package/archlinux/matemat/usr/lib/systemd/system/matemat.service new file mode 100644 index 0000000..ae2283f --- /dev/null +++ b/package/archlinux/matemat/usr/lib/systemd/system/matemat.service @@ -0,0 +1,10 @@ +[Unit] +Description=matemat +After=networking.target + +[Service] +Exec=/usr/lib/matemat/matemat /etc/matemat.conf /usr/lib/matemat/matemat.conf +User=matemat + +[Install] +WantedBy=multi-user.target