From 54e7d5f94311767536f5ecaccb2206fc10234d04 Mon Sep 17 00:00:00 2001
From: Tomas Pecka <tomas.pecka@fit.cvut.cz>
Date: Thu, 12 Sep 2019 15:31:48 +0200
Subject: [PATCH] CI/CD: Package & deploy: Debian, Arch, Ubuntu, Docker,
 sources

---
 .gitlab-ci.yml                                | 392 ++++++++++++------
 .../arch/{nightly => snapshot}/PKGBUILD       |  10 +-
 .../arch/{release => stable}/PKGBUILD         |   0
 .../deb/snapshot/debian/README.Debian         |   6 +
 .../deb/snapshot/debian/README.source         |   9 +
 .../algorithms-library-dev-snapshot.install   |   1 +
 .../debian/algorithms-library-docs.docs       |   2 +
 .../algorithms-library-gui-snapshot.install   |   2 +
 .../algorithms-library-snapshot.install       |  20 +
 .../debian/algorithms-library.doc-base.EX     |  20 +
 .../debian/algorithms-library.substvars       |   2 +
 .../distrofiles/deb/snapshot/debian/changelog |   5 +
 .../CD/distrofiles/deb/snapshot/debian/compat |   1 +
 .../distrofiles/deb/snapshot/debian/control   |  48 +++
 .../distrofiles/deb/snapshot/debian/copyright |  47 +++
 .../deb/snapshot/debian/debhelper-build-stamp |   1 +
 .../CD/distrofiles/deb/snapshot/debian/dirs   |   2 +
 .../deb/snapshot/debian/manpage.1.ex          |  56 +++
 .../deb/snapshot/debian/manpage.sgml.ex       | 154 +++++++
 .../deb/snapshot/debian/manpage.xml.ex        | 291 +++++++++++++
 .../distrofiles/deb/snapshot/debian/postrm.ex |  37 ++
 .../deb/snapshot/debian/preinst.ex            |  35 ++
 .../distrofiles/deb/snapshot/debian/prerm.ex  |  38 ++
 .../CD/distrofiles/deb/snapshot/debian/rules  |  28 ++
 .../deb/snapshot/debian/source/format         |   1 +
 .../scripts/CD/packaging/package-archlinux.sh |  32 +-
 extra/scripts/CD/packaging/package-debian.sh  |  72 +++-
 extra/scripts/CD/packaging/package-docker.sh  |  52 ++-
 extra/scripts/CD/packaging/package-sources.sh |  13 +
 extra/scripts/CD/packaging/package.sh         |  85 ++--
 30 files changed, 1262 insertions(+), 200 deletions(-)
 rename extra/scripts/CD/distrofiles/arch/{nightly => snapshot}/PKGBUILD (87%)
 rename extra/scripts/CD/distrofiles/arch/{release => stable}/PKGBUILD (100%)
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/README.Debian
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/README.source
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library-dev-snapshot.install
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library-docs.docs
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library-gui-snapshot.install
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library-snapshot.install
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library.doc-base.EX
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library.substvars
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/changelog
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/compat
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/control
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/copyright
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/debhelper-build-stamp
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/dirs
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/manpage.1.ex
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/manpage.sgml.ex
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/manpage.xml.ex
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/postrm.ex
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/preinst.ex
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/prerm.ex
 create mode 100755 extra/scripts/CD/distrofiles/deb/snapshot/debian/rules
 create mode 100644 extra/scripts/CD/distrofiles/deb/snapshot/debian/source/format

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f87b295297..10a13f2d5e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -282,201 +282,322 @@ static-analysis:clang-tidy:
 # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 # release.yml
 
-.template:only:nightly: &release_nightly
+.template:only:snapshot: &release_snapshot
   only:
     refs:
       - master
 
-.template:only:tag: &release_tag
+.template:only:tag: &release_stable
   only:
     - tags
     - /^v.*$/
 
 .template:package:
   stage: package
+  tags:
+    - altbuilder
   dependencies: []
   script:
-    - DISTRO=$(echo "$CI_JOB_NAME" | cut -d":" -f2)
-    - MODE=$(echo "$CI_JOB_NAME" | cut -d":" -f3)
-    - extra/scripts/CD/packaging/package.sh $MODE $DISTRO .
+    - LINUX=$(echo "$CI_JOB_NAME" | cut -d":" -f2)
+    - MODE=$(echo "$CI_JOB_NAME" | cut -d":" -f4)
+    - export DISTRIBUTION=$(echo "$CI_JOB_NAME" | cut -d":" -f3)
+    - if [[ $LINUX == "ubuntu" ]]; then LINUX="debian"; fi
+    - ./extra/scripts/CD/packaging/package.sh $MODE $LINUX package .
 
-.template:release:
-  stage: release
-  dependencies: []
 
-.releaser:
-  extends: .template:release
+.docker: &docker
+  image: docker:dind
+  cache: {}  # disable
+  services:
+    - docker:dind
+  variables:
+    DOCKER_DRIVER: overlay2
+    DOCKER_TLS_CERTDIR: "/certs"
   before_script:
-    - apk add --no-cache curl tar
-    - DISTRO=$(echo "$CI_JOB_NAME" | cut -d":" -f2)
-    - MODE=$(echo "$CI_JOB_NAME" | cut -d":" -f3)
-    - URL="$REPOMGR/upload/$DISTRO/$MODE"
-    - if [[ $DISTRO != "sources" ]]; then URL="$URL/x86_64"; fi
-  script:
-    - tar cvf archive.tar $RELEASER_WILDCARD_UPLOAD
-    - curl --fail --w "%{http_code}\n\n" -s --show-error -X POST -F "data=@archive.tar" $URL
+    - apk add docker bash
+    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
+    - docker info
+
+.package:docker:
+  <<: *docker
+  extends: .template:package
+  artifacts:
+    paths:
+      - images.tar
+    expire_in: 1 day
+
+package:docker::snapshot:
+  <<: *release_snapshot
+  extends: .package:docker
+
+package:docker::stable:
+  <<: *release_stable
+  extends: .package:docker
+
+
+
+
+.package:sources:
+  image: alpine:latest
+  extends: .template:package
+  before_script:
+    - apk add bash
+  artifacts:
+    paths:
+      - "*.tar.gz*"
+    expire_in: 1 day
+
+package:sources::snapshot:
+  <<: *release_snapshot
+  extends: .package:sources
+
+package:sources::stable:
+  <<: *release_stable
+  extends: .package:sources
 
-# -----------------------------------------------------------------------------
 
-# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-# release_archlinux.yml
 
 .package:archlinux:
+  image: archlinux/base
   extends: .template:package
-  image: archlinux/base:latest
   artifacts:
     paths:
       - "*.pkg.tar.xz*"
     expire_in: 1 day
   variables:
-    MAKEFLAGS: "-j3"
     PACKAGER: "Tomáš Pecka <peckato1@fit.cvut.cz>"
 
-package:archlinux:nightly:
-  <<: *release_nightly
+package:archlinux::snapshot:
+  <<: *release_snapshot
   extends: .package:archlinux
 
-package:archlinux:release:
-  <<: *release_tag
+package:archlinux::stable:
+  <<: *release_stable
   extends: .package:archlinux
 
-# -----------------------------------------------------------------------------
-.release:archlinux:
-  extends: .releaser
-  variables:
-    RELEASER_WILDCARD_UPLOAD: "*.pkg.tar.xz*"
-
-release:archlinux:nightly:
-  <<: *release_nightly
-  extends: .release:archlinux
-  environment:
-    name: arch-nightly
-    url: https://repository.alt.pecka.me/archlinux/nightly/x86_64/
-  dependencies:
-    - package:archlinux:nightly
-
-release:archlinux:release:
-  <<: *release_tag
-  extends: .release:archlinux
-  environment:
-    name: arch-release
-    url: https://repository.alt.pecka.me/archlinux/release/x86_64/
-  dependencies:
-    - package:archlinux:release
-
 
-# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-# release_docker.yml
 
-.package:docker: &docker
+.package:debian:
   extends: .template:package
-  cache: {}  # disable
-  services:
-    - docker:dind
-  variables:
-    DOCKER_DRIVER: overlay2
-    DOCKER_HOST: docker
-  before_script:
-    - apk add --no-cache docker
-    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
-    - docker info
-  dependencies: []
   artifacts:
     paths:
-      - images.tar
+      - "*.deb"
+      - "*.ddeb"
+      - "*.changes"
+      - "*.buildinfo"
     expire_in: 1 day
+  variables:
+    LOGNAME: "peckato1"
+    DEBFULLNAME: "Tomáš Pecka"
+    DEBEMAIL: "peckato1@fit.cvut.cz"
 
-# -----------------------------------------------------------------------------
+# ---------------------------
 
-package:docker:nightly:
-  <<: *release_nightly
-  <<: *docker
-  extends: .package:docker
+.package:debian:buster:
+  image: amd64/debian:buster
+  extends: .package:debian
 
-package:docker:release:
-  <<: *release_tag
-  <<: *docker
-  extends: .package:docker
+.package:debian:bullseye:
+  image: amd64/debian:bullseye
+  extends: .package:debian
 
-# -----------------------------------------------------------------------------
+package:debian:buster:snapshot:
+  <<: *release_snapshot
+  extends: .package:debian:buster
+
+package:debian:buster:stable:
+  <<: *release_stable
+  extends: .package:debian:buster
+
+package:debian:bullseye:snapshot:
+  <<: *release_snapshot
+  extends: .package:debian:bullseye
+
+package:debian:bullseye:stable:
+  <<: *release_stable
+  extends: .package:debian:bullseye
+
+# ---------------------------
+
+.package:ubuntu:bionic:
+  image: ubuntu:bionic
+  extends: .package:debian
+
+.package:ubuntu:cosmic:
+  image: ubuntu:bionic
+  extends: .package:debian
 
-release:docker:nightly:
-  <<: *release_nightly
+.package:ubuntu:disco:
+  image: ubuntu:bionic
+  extends: .package:debian
+
+package:ubuntu:bionic:snapshot:
+  <<: *release_snapshot
+  extends: .package:ubuntu:bionic
+
+package:ubuntu:bionic:stable:
+  <<: *release_stable
+  extends: .package:ubuntu:bionic
+
+package:ubuntu:cosmic:snapshot:
+  <<: *release_snapshot
+  extends: .package:ubuntu:cosmic
+
+package:ubuntu:cosmic:stable:
+  <<: *release_stable
+  extends: .package:ubuntu:cosmic
+
+package:ubuntu:disco:snapshot:
+  <<: *release_snapshot
+  extends: .package:ubuntu:disco
+
+package:ubuntu:disco:stable:
+  <<: *release_stable
+  extends: .package:ubuntu:disco
+
+
+# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+# release.yml
+
+.template:release:
+  stage: release
+  dependencies: []
+  tags:
+    - altvm
+  script:
+    - LINUX=$(echo "$CI_JOB_NAME" | cut -d":" -f2)
+    - MODE=$(echo "$CI_JOB_NAME" | cut -d":" -f4)
+    - export DISTRIBUTION=$(echo "$CI_JOB_NAME" | cut -d":" -f3)
+    - if [[ $LINUX == "ubuntu" ]]; then LINUX="debian"; fi
+    - extra/scripts/CD/packaging/package.sh $MODE $LINUX deploy .
+
+
+
+.release:docker:
   <<: *docker
   extends: .template:release
+  tags:
+    - altbuilder
   environment:
     name: docker-nightly
     url: https://gitlab.fit.cvut.cz/algorithms-library-toolkit/automata-library/container_registry
-  script:
-    - docker load -i images.tar
-    - docker push $CI_REGISTRY_IMAGE/cli:nightly
-    - docker push $CI_REGISTRY_IMAGE/gui:nightly
-    - docker push $CI_REGISTRY_IMAGE:nightly
+
+release:docker::snapshot:
+  <<: *release_snapshot
+  extends: .release:docker
   dependencies:
-    - package:docker:nightly
+    - package:docker::snapshot
 
-release:docker:release:
-  <<: *release_tag
-  <<: *docker
+release:docker::stable:
+  <<: *release_stable
+  extends: .release:docker
+  dependencies:
+    - package:docker::stable
+
+
+
+.release:archlinux:
   extends: .template:release
   environment:
-    name: docker-release
-    url: https://gitlab.fit.cvut.cz/algorithms-library-toolkit/automata-library/container_registry
-  script:
-    - docker load -i images.tar
-    - docker push $CI_REGISTRY_IMAGE/cli:latest
-    - docker push $CI_REGISTRY_IMAGE/gui:latest
-    - docker push $CI_REGISTRY_IMAGE:latest
-    - docker push $CI_REGISTRY_IMAGE/cli:$CI_COMMIT_REF_NAME
-    - docker push $CI_REGISTRY_IMAGE/gui:$CI_COMMIT_REF_NAME
-    - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
+    name: archlinux
+    url: https://repository.alt.pecka.me/archlinux/
+
+release:archlinux::snapshot:
+  <<: *release_snapshot
+  extends: .release:archlinux
   dependencies:
-    - package:docker:release
+    - package:archlinux::snapshot
 
+release:archlinux:release:
+  <<: *release_stable
+  extends: .release:archlinux
+  dependencies:
+    - package:archlinux::stable
 
-# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-# release_sources.yml
 
-.package:sources:
-  extends: .template:package
-  artifacts:
-    paths:
-      - "*.tar.gz*"
-    expire_in: 1 day
+.release:debian:
+  extends: .template:release
+  environment:
+    name: debian
+    url: https://repository.alt.pecka.me/debian/
 
-package:sources:nightly:
-  <<: *release_nightly
-  extends: .package:sources
+release:debian:buster:snapshot:
+  <<: *release_snapshot
+  extends: .release:debian
+  dependencies:
+    - package:debian:buster:snapshot
 
-package:sources:release:
-  <<: *release_tag
-  extends: .package:sources
+release:debian:buster:stable:
+  <<: *release_stable
+  extends: .release:debian
+  dependencies:
+    - package:debian:buster:stable
 
-# -----------------------------------------------------------------------------
+release:debian:bullseye:snapshot:
+  <<: *release_snapshot
+  extends: .release:debian
+  dependencies:
+    - package:debian:bullseye:snapshot
+
+release:debian:bullseye:stable:
+  <<: *release_stable
+  extends: .release:debian
+  dependencies:
+    - package:debian:bullseye:stable
+
+release:ubuntu:bionic:snapshot:
+  <<: *release_snapshot
+  extends: .release:debian
+  dependencies:
+    - package:ubuntu:bionic:snapshot
+
+release:ubuntu:bionic:stable:
+  <<: *release_stable
+  extends: .release:debian
+  dependencies:
+    - package:ubuntu:bionic:stable
+
+release:ubuntu:cosmic:snapshot:
+  <<: *release_snapshot
+  extends: .release:debian
+  dependencies:
+    - package:ubuntu:cosmic:snapshot
+
+release:ubuntu:cosmic:stable:
+  <<: *release_stable
+  extends: .release:debian
+  dependencies:
+    - package:ubuntu:cosmic:stable
+
+release:ubuntu:disco:snapshot:
+  <<: *release_snapshot
+  extends: .release:debian
+  dependencies:
+    - package:ubuntu:disco:snapshot
+
+release:ubuntu:disco:stable:
+  <<: *release_stable
+  extends: .release:debian
+  dependencies:
+    - package:ubuntu:disco:stable
 
 .release:sources:
-  extends: .releaser
-  variables:
-    RELEASER_WILDCARD_UPLOAD: "*.tar.gz*"
+  extends: .template:release
+  environment:
+    name: sources
+    url: https://repository.alt.pecka.me/sources/
 
-release:sources:nightly:
-  <<: *release_nightly
+release:sources::snapshot:
+  <<: *release_snapshot
   extends: .release:sources
-  environment:
-    name: sources-nightly
-    url: https://repository.alt.pecka.me/sources/nightly/
   dependencies:
-    - package:sources:nightly
+    - package:sources::snapshot
 
-release:sources:release:
-  <<: *release_tag
+release:sources::stable:
+  <<: *release_stable
   extends: .release:sources
-  environment:
-    name: sources-release
-    url: https://repository.alt.pecka.me/sources/release/
   dependencies:
-    - package:sources:release
-
+    - package:sources::stable
 
 #######################################################################################################################
 #######################################################################################################################
@@ -488,13 +609,18 @@ release:sources:release:
   before_script:
     - apk add --no-cache curl
   dependencies: []
+  only:
+    refs:
+      - master
 
 # -----------------------------------------------------------------------------
 
 notify:pyalib:
   extends: .template:notify
   script:
-    - curl -X POST -F token="$PY_ALIB_TOKEN" -F ref=master https://gitlab.fit.cvut.cz/api/v4/projects/11497/trigger/pipeline
-  only:
-    refs:
-      - master
+    - curl -X POST -F token="$TOKEN_TRIGGER_PYALIB" -F ref=master https://gitlab.fit.cvut.cz/api/v4/projects/11497/trigger/pipeline
+
+notify:website:
+  extends: .template:notify
+  script:
+    - curl -X POST -F token="$TOKEN_TRIGGER_WEBSITE" -F ref=master https://gitlab.fit.cvut.cz/api/v4/projects/15509/trigger/pipeline
diff --git a/extra/scripts/CD/distrofiles/arch/nightly/PKGBUILD b/extra/scripts/CD/distrofiles/arch/snapshot/PKGBUILD
similarity index 87%
rename from extra/scripts/CD/distrofiles/arch/nightly/PKGBUILD
rename to extra/scripts/CD/distrofiles/arch/snapshot/PKGBUILD
index 2950f00c44..d6b4c0214c 100644
--- a/extra/scripts/CD/distrofiles/arch/nightly/PKGBUILD
+++ b/extra/scripts/CD/distrofiles/arch/snapshot/PKGBUILD
@@ -1,6 +1,6 @@
 # Maintainer: Tomas Pecka <peckato1 at fit dot cvut dot cz>
 
-pkgname=('algorithms-library-nightly' 'algorithms-library-gui-nightly')
+pkgname=('algorithms-library-snapshot' 'algorithms-library-gui-snapshot')
 pkgbase='automata-library'
 
 pkgver=0.0.0.r515.gc4bc905a4
@@ -42,10 +42,10 @@ build() {
 
 check() {
 	cd "$pkgbase/build"
-	make test ARGS="--output-on-failure"
+	make test ARGS="--output-on-failure -j$(grep -c processor /proc/cpuinfo)"
 }
 
-package_algorithms-library-nightly() {
+package_algorithms-library-snapshot() {
 	depends=('tclap' 'libxml2' 'readline')
 	optdepends=('graphviz: Visualize data structures')
 	provides=('algorithms-library')
@@ -72,8 +72,8 @@ package_algorithms-library-nightly() {
 	popd
 }
 
-package_algorithms-library-gui-nightly() {
-	depends=('libxml2' 'qt5-base>=5.7' 'graphviz' 'jsoncpp' "algorithms-library-nightly>=$pkgver" "algorithms-library-nightly<=$pkgver")
+package_algorithms-library-gui-snapshot() {
+	depends=('libxml2' 'qt5-base>=5.7' 'graphviz' 'jsoncpp' "algorithms-library-snapshot>=$pkgver" "algorithms-library-snapshot<=$pkgver")
 	provides=('algorithms-library-gui')
 	conflicts=('algorithms-library-gui')
 
diff --git a/extra/scripts/CD/distrofiles/arch/release/PKGBUILD b/extra/scripts/CD/distrofiles/arch/stable/PKGBUILD
similarity index 100%
rename from extra/scripts/CD/distrofiles/arch/release/PKGBUILD
rename to extra/scripts/CD/distrofiles/arch/stable/PKGBUILD
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/README.Debian b/extra/scripts/CD/distrofiles/deb/snapshot/debian/README.Debian
new file mode 100644
index 0000000000..7d38f1a4ae
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/README.Debian
@@ -0,0 +1,6 @@
+algorithms-library for Debian
+-----------------------------
+
+<possible notes regarding this package - if none, delete this file>
+
+ -- Tomáš Pecka <peckato1@fit.cvut.cz>  Sat, 10 Aug 2019 16:04:38 +0000
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/README.source b/extra/scripts/CD/distrofiles/deb/snapshot/debian/README.source
new file mode 100644
index 0000000000..6ec4853845
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/README.source
@@ -0,0 +1,9 @@
+algorithms-library for Debian
+-----------------------------
+
+This is a README.source
+
+
+
+ -- Tomáš Pecka <peckato1@fit.cvut.cz>  Sat, 10 Aug 2019 16:04:38 +0000
+
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library-dev-snapshot.install b/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library-dev-snapshot.install
new file mode 100644
index 0000000000..1b97f54c8a
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library-dev-snapshot.install
@@ -0,0 +1 @@
+debian/tmp/usr/include/ /usr/include
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library-docs.docs b/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library-docs.docs
new file mode 100644
index 0000000000..7319041140
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library-docs.docs
@@ -0,0 +1,2 @@
+README.source
+README.Debian
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library-gui-snapshot.install b/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library-gui-snapshot.install
new file mode 100644
index 0000000000..1ffedb2cea
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library-gui-snapshot.install
@@ -0,0 +1,2 @@
+debian/tmp/usr/bin/agui2        /usr/bin/
+debian/tmp/usr/lib/libalib2gui* /usr/lib/
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library-snapshot.install b/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library-snapshot.install
new file mode 100644
index 0000000000..332df522d8
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library-snapshot.install
@@ -0,0 +1,20 @@
+debian/tmp/usr/bin/aql2                            /usr/bin/
+debian/tmp/usr/lib/libalib2abstraction.so*         /usr/lib/
+debian/tmp/usr/lib/libalib2algo.so*                /usr/lib/
+debian/tmp/usr/lib/libalib2algo_experimental.so*   /usr/lib/
+debian/tmp/usr/lib/libalib2aux.so*                 /usr/lib/
+debian/tmp/usr/lib/libalib2cli.so*                 /usr/lib/
+debian/tmp/usr/lib/libalib2common.so*              /usr/lib/
+debian/tmp/usr/lib/libalib2data.so*                /usr/lib/
+debian/tmp/usr/lib/libalib2data_experimental.so*   /usr/lib/
+debian/tmp/usr/lib/libalib2dummy.so*               /usr/lib/
+debian/tmp/usr/lib/libalib2elgo.so*                /usr/lib/
+debian/tmp/usr/lib/libalib2graph_algo.so*          /usr/lib/
+debian/tmp/usr/lib/libalib2graph_data.so*          /usr/lib/
+debian/tmp/usr/lib/libalib2measure.so*             /usr/lib/
+debian/tmp/usr/lib/libalib2raw.so*                 /usr/lib/
+debian/tmp/usr/lib/libalib2raw_cli_integration.so* /usr/lib/
+debian/tmp/usr/lib/libalib2std.so*                 /usr/lib/
+debian/tmp/usr/lib/libalib2str.so*                 /usr/lib/
+debian/tmp/usr/lib/libalib2str_cli_integration.so* /usr/lib/
+debian/tmp/usr/lib/libalib2xml.so*                 /usr/lib/
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library.doc-base.EX b/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library.doc-base.EX
new file mode 100644
index 0000000000..78e59d8108
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library.doc-base.EX
@@ -0,0 +1,20 @@
+Document: algorithms-library
+Title: Debian algorithms-library Manual
+Author: <insert document author here>
+Abstract: This manual describes what algorithms-library is
+ and how it can be used to
+ manage online manuals on Debian systems.
+Section: unknown
+
+Format: debiandoc-sgml
+Files: /usr/share/doc/algorithms-library/algorithms-library.sgml.gz
+
+Format: postscript
+Files: /usr/share/doc/algorithms-library/algorithms-library.ps.gz
+
+Format: text
+Files: /usr/share/doc/algorithms-library/algorithms-library.text.gz
+
+Format: HTML
+Index: /usr/share/doc/algorithms-library/html/index.html
+Files: /usr/share/doc/algorithms-library/html/*.html
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library.substvars b/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library.substvars
new file mode 100644
index 0000000000..978fc8b5a0
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/algorithms-library.substvars
@@ -0,0 +1,2 @@
+misc:Depends=
+misc:Pre-Depends=
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/changelog b/extra/scripts/CD/distrofiles/deb/snapshot/debian/changelog
new file mode 100644
index 0000000000..16ecd94369
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/changelog
@@ -0,0 +1,5 @@
+algorithms-library (0.0.0-1) unstable; urgency=medium
+
+  * 0.0.0 released
+
+ -- Tomáš Pecka <peckato1@fit.cvut.cz>  Sat, 10 Aug 2019 16:04:38 +0000
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/compat b/extra/scripts/CD/distrofiles/deb/snapshot/debian/compat
new file mode 100644
index 0000000000..f599e28b8a
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/compat
@@ -0,0 +1 @@
+10
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/control b/extra/scripts/CD/distrofiles/deb/snapshot/debian/control
new file mode 100644
index 0000000000..dae00a6d08
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/control
@@ -0,0 +1,48 @@
+Source: algorithms-library
+Section: education
+Maintainer: Tomáš Pecka <peckato1@fit.cvut.cz>
+Uploaders: Tomáš Pecka <peckato1@fit.cvut.cz>, Jan Trávníček <travnja3@fit.cvut.cz>
+Priority: optional
+Standards-Version: 4.1.3
+Homepage: https://alt.pecka.me
+Vcs-Browser: https://gitlab.fit.cvut.cz/algorithms-library-toolkit/automata-library
+Vcs-Git: https://gitlab.fit.cvut.cz/algorithms-library-toolkit/automata-library.git
+Build-Depends: debhelper (>= 10),
+               cmake (>= 3.9),
+               python3 (>= 3.4),
+               libxml2-dev,
+               libtclap-dev,
+               libreadline-dev,
+               qtbase5-dev (>= 5.7),
+               graphviz-dev,
+               libjsoncpp-dev
+
+Package: algorithms-library-snapshot
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+         libxml2,
+         libreadline7 | libreadline8
+Description: Algorithms Library is a science/education toolkit especially for the
+ string and tree area of computer science.
+ This package contains snapshot of the core and CLI.
+
+Package: algorithms-library-dev-snapshot
+Architecture: any
+Depends: algorithms-library-snapshot
+Description: Algorithms Library is a science/education toolkit especially for the
+ string and tree area of computer science.
+ This optional package contains snapshot of the development files.
+
+Package: algorithms-library-gui-snapshot
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+         libxml2,
+         graphviz,
+         libjsoncpp1,
+         libqt5core5a (>= 5.7),
+         libqt5widgets5 (>= 5.7),
+         libqt5xml5 (>= 5.7),
+         algorithms-library-snapshot
+Description: Algorithms Library is a science/education toolkit especially for the
+ string and tree area of computer science.
+ This optional package contains snapshot of the gui part.
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/copyright b/extra/scripts/CD/distrofiles/deb/snapshot/debian/copyright
new file mode 100644
index 0000000000..bad461d635
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/copyright
@@ -0,0 +1,47 @@
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: algorithms-library
+Source: <url://alt.pecka.me>
+
+# -----------------------------------------------------------------------------
+
+Files: *
+Copyright: 2012-2019 Jan Trávníček <jan.travnicek@fit.cvut.cz>
+           2012-2019 Tomáš Pecka <tomas.pecka@fit.cvut.cz>
+           2012-2013 Martin Žák
+License: GPL-2+
+ This package is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+ .
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>
+ .
+ On Debian systems, the complete text of the GNU General
+ Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
+
+# -----------------------------------------------------------------------------
+
+Files: debian/*
+Copyright: 2019 Tomáš Pecka <tomas.pecka@fit.cvut.cz>
+License: GPL-2+
+ This package is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+ .
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>
+ .
+ On Debian systems, the complete text of the GNU General
+ Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/debhelper-build-stamp b/extra/scripts/CD/distrofiles/deb/snapshot/debian/debhelper-build-stamp
new file mode 100644
index 0000000000..9c48c55b7b
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/debhelper-build-stamp
@@ -0,0 +1 @@
+algorithms-library
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/dirs b/extra/scripts/CD/distrofiles/deb/snapshot/debian/dirs
new file mode 100644
index 0000000000..527b78f2d8
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/dirs
@@ -0,0 +1,2 @@
+usr/bin
+usr/lib
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/manpage.1.ex b/extra/scripts/CD/distrofiles/deb/snapshot/debian/manpage.1.ex
new file mode 100644
index 0000000000..f35db5f62f
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/manpage.1.ex
@@ -0,0 +1,56 @@
+.\"                                      Hey, EMACS: -*- nroff -*-
+.\" (C) Copyright 2019 Tomáš Pecka <peckato1@fit.cvut.cz>,
+.\"
+.\" First parameter, NAME, should be all caps
+.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
+.\" other parameters are allowed: see man(7), man(1)
+.TH Algorithms-library SECTION "August 10 2019"
+.\" Please adjust this date whenever revising the manpage.
+.\"
+.\" Some roff macros, for reference:
+.\" .nh        disable hyphenation
+.\" .hy        enable hyphenation
+.\" .ad l      left justify
+.\" .ad b      justify to both left and right margins
+.\" .nf        disable filling
+.\" .fi        enable filling
+.\" .br        insert line break
+.\" .sp <n>    insert n+1 empty lines
+.\" for manpage-specific macros, see man(7)
+.SH NAME
+algorithms-library \- program to do something
+.SH SYNOPSIS
+.B algorithms-library
+.RI [ options ] " files" ...
+.br
+.B bar
+.RI [ options ] " files" ...
+.SH DESCRIPTION
+This manual page documents briefly the
+.B algorithms-library
+and
+.B bar
+commands.
+.PP
+.\" TeX users may be more comfortable with the \fB<whatever>\fP and
+.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
+.\" respectively.
+\fBalgorithms-library\fP is a program that...
+.SH OPTIONS
+These programs follow the usual GNU command line syntax, with long
+options starting with two dashes (`-').
+A summary of options is included below.
+For a complete description, see the Info files.
+.TP
+.B \-h, \-\-help
+Show summary of options.
+.TP
+.B \-v, \-\-version
+Show version of program.
+.SH SEE ALSO
+.BR bar (1),
+.BR baz (1).
+.br
+The programs are documented fully by
+.IR "The Rise and Fall of a Fooish Bar" ,
+available via the Info system.
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/manpage.sgml.ex b/extra/scripts/CD/distrofiles/deb/snapshot/debian/manpage.sgml.ex
new file mode 100644
index 0000000000..b96229a4ac
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/manpage.sgml.ex
@@ -0,0 +1,154 @@
+<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
+
+<!-- Process this file with docbook-to-man to generate an nroff manual
+     page: `docbook-to-man manpage.sgml > manpage.1'.  You may view
+     the manual page with: `docbook-to-man manpage.sgml | nroff -man |
+     less'.  A typical entry in a Makefile or Makefile.am is:
+
+manpage.1: manpage.sgml
+	docbook-to-man $< > $@
+
+
+	The docbook-to-man binary is found in the docbook-to-man package.
+	Please remember that if you create the nroff version in one of the
+	debian/rules file targets (such as build), you will need to include
+	docbook-to-man in your Build-Depends control field.
+
+  -->
+
+  <!-- Fill in your name for FIRSTNAME and SURNAME. -->
+  <!ENTITY dhfirstname "<firstname>FIRSTNAME</firstname>">
+  <!ENTITY dhsurname   "<surname>SURNAME</surname>">
+  <!-- Please adjust the date whenever revising the manpage. -->
+  <!ENTITY dhdate      "<date>August 10 2019</date>">
+  <!-- SECTION should be 1-8, maybe w/ subsection other parameters are
+       allowed: see man(7), man(1). -->
+  <!ENTITY dhsection   "<manvolnum>SECTION</manvolnum>">
+  <!ENTITY dhemail     "<email>peckato1@fit.cvut.cz</email>">
+  <!ENTITY dhusername  "peckato1">
+  <!ENTITY dhucpackage "<refentrytitle>Algorithms-library</refentrytitle>">
+  <!ENTITY dhpackage   "algorithms-library">
+
+  <!ENTITY debian      "<productname>Debian</productname>">
+  <!ENTITY gnu         "<acronym>GNU</acronym>">
+  <!ENTITY gpl         "&gnu; <acronym>GPL</acronym>">
+]>
+
+<refentry>
+  <refentryinfo>
+    <address>
+      &dhemail;
+    </address>
+    <author>
+      &dhfirstname;
+      &dhsurname;
+    </author>
+    <copyright>
+      <year>2003</year>
+      <holder>&dhusername;</holder>
+    </copyright>
+    &dhdate;
+  </refentryinfo>
+  <refmeta>
+    &dhucpackage;
+
+    &dhsection;
+  </refmeta>
+  <refnamediv>
+    <refname>&dhpackage;</refname>
+
+    <refpurpose>program to do something</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>&dhpackage;</command>
+
+      <arg><option>-e <replaceable>this</replaceable></option></arg>
+
+      <arg><option>--example <replaceable>that</replaceable></option></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1>
+    <title>DESCRIPTION</title>
+
+    <para>This manual page documents briefly the
+      <command>&dhpackage;</command> and <command>bar</command>
+      commands.</para>
+
+    <para>This manual page was written for the &debian; distribution
+      because the original program does not have a manual page.
+      Instead, it has documentation in the &gnu;
+      <application>Info</application> format; see below.</para>
+
+    <para><command>&dhpackage;</command> is a program that...</para>
+
+  </refsect1>
+  <refsect1>
+    <title>OPTIONS</title>
+
+    <para>These programs follow the usual &gnu; command line syntax,
+      with long options starting with two dashes (`-').  A summary of
+      options is included below.  For a complete description, see the
+      <application>Info</application> files.</para>
+
+    <variablelist>
+      <varlistentry>
+        <term><option>-h</option>
+          <option>--help</option>
+        </term>
+        <listitem>
+          <para>Show summary of options.</para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-v</option>
+          <option>--version</option>
+        </term>
+        <listitem>
+          <para>Show version of program.</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+  <refsect1>
+    <title>SEE ALSO</title>
+
+    <para>bar (1), baz (1).</para>
+
+    <para>The programs are documented fully by <citetitle>The Rise and
+      Fall of a Fooish Bar</citetitle> available via the
+      <application>Info</application> system.</para>
+  </refsect1>
+  <refsect1>
+    <title>AUTHOR</title>
+
+    <para>This manual page was written by &dhusername; &dhemail; for
+      the &debian; system (and may be used by others).  Permission is
+      granted to copy, distribute and/or modify this document under
+      the terms of the &gnu; General Public License, Version 2 any
+      later version published by the Free Software Foundation.
+    </para>
+    <para>
+      On Debian systems, the complete text of the GNU General Public
+      License can be found in /usr/share/common-licenses/GPL.
+    </para>
+
+  </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:2
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:nil
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+-->
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/manpage.xml.ex b/extra/scripts/CD/distrofiles/deb/snapshot/debian/manpage.xml.ex
new file mode 100644
index 0000000000..e8d43592ed
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/manpage.xml.ex
@@ -0,0 +1,291 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+
+<!--
+
+`xsltproc -''-nonet \
+          -''-param man.charmap.use.subset "0" \
+          -''-param make.year.ranges "1" \
+          -''-param make.single.year.ranges "1" \
+          /usr/share/xml/docbook/stylesheet/docbook-xsl/manpages/docbook.xsl \
+          manpage.xml'
+
+A manual page <package>.<section> will be generated. You may view the
+manual page with: nroff -man <package>.<section> | less'. A typical entry
+in a Makefile or Makefile.am is:
+
+DB2MAN = /usr/share/sgml/docbook/stylesheet/xsl/docbook-xsl/manpages/docbook.xsl
+XP     = xsltproc -''-nonet -''-param man.charmap.use.subset "0"
+
+manpage.1: manpage.xml
+        $(XP) $(DB2MAN) $<
+
+The xsltproc binary is found in the xsltproc package. The XSL files are in
+docbook-xsl. A description of the parameters you can use can be found in the
+docbook-xsl-doc-* packages. Please remember that if you create the nroff
+version in one of the debian/rules file targets (such as build), you will need
+to include xsltproc and docbook-xsl in your Build-Depends control field.
+Alternatively use the xmlto command/package. That will also automatically
+pull in xsltproc and docbook-xsl.
+
+Notes for using docbook2x: docbook2x-man does not automatically create the
+AUTHOR(S) and COPYRIGHT sections. In this case, please add them manually as
+<refsect1> ... </refsect1>.
+
+To disable the automatic creation of the AUTHOR(S) and COPYRIGHT sections
+read /usr/share/doc/docbook-xsl/doc/manpages/authors.html. This file can be
+found in the docbook-xsl-doc-html package.
+
+Validation can be done using: `xmllint -''-noout -''-valid manpage.xml`
+
+General documentation about man-pages and man-page-formatting:
+man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
+
+-->
+
+  <!-- Fill in your name for FIRSTNAME and SURNAME. -->
+  <!ENTITY dhfirstname "FIRSTNAME">
+  <!ENTITY dhsurname   "SURNAME">
+  <!-- dhusername could also be set to "&dhfirstname; &dhsurname;". -->
+  <!ENTITY dhusername  "peckato1">
+  <!ENTITY dhemail     "peckato1@fit.cvut.cz">
+  <!-- SECTION should be 1-8, maybe w/ subsection other parameters are
+       allowed: see man(7), man(1) and
+       http://www.tldp.org/HOWTO/Man-Page/q2.html. -->
+  <!ENTITY dhsection   "SECTION">
+  <!-- TITLE should be something like "User commands" or similar (see
+       http://www.tldp.org/HOWTO/Man-Page/q2.html). -->
+  <!ENTITY dhtitle     "algorithms-library User Manual">
+  <!ENTITY dhucpackage "Algorithms-library">
+  <!ENTITY dhpackage   "algorithms-library">
+]>
+
+<refentry>
+  <refentryinfo>
+    <title>&dhtitle;</title>
+    <productname>&dhpackage;</productname>
+    <authorgroup>
+      <author>
+       <firstname>&dhfirstname;</firstname>
+        <surname>&dhsurname;</surname>
+        <contrib>Wrote this manpage for the Debian system.</contrib>
+        <address>
+          <email>&dhemail;</email>
+        </address>
+      </author>
+    </authorgroup>
+    <copyright>
+      <year>2007</year>
+      <holder>&dhusername;</holder>
+    </copyright>
+    <legalnotice>
+      <para>This manual page was written for the Debian system
+        (and may be used by others).</para>
+      <para>Permission is granted to copy, distribute and/or modify this
+        document under the terms of the GNU General Public License,
+        Version 2 or (at your option) any later version published by
+        the Free Software Foundation.</para>
+      <para>On Debian systems, the complete text of the GNU General Public
+        License can be found in
+        <filename>/usr/share/common-licenses/GPL</filename>.</para>
+    </legalnotice>
+  </refentryinfo>
+  <refmeta>
+    <refentrytitle>&dhucpackage;</refentrytitle>
+    <manvolnum>&dhsection;</manvolnum>
+  </refmeta>
+  <refnamediv>
+    <refname>&dhpackage;</refname>
+    <refpurpose>program to do something</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>&dhpackage;</command>
+      <!-- These are several examples, how syntaxes could look -->
+      <arg choice="plain"><option>-e <replaceable>this</replaceable></option></arg>
+      <arg choice="opt"><option>--example=<parameter>that</parameter></option></arg>
+      <arg choice="opt">
+        <group choice="req">
+          <arg choice="plain"><option>-e</option></arg>
+          <arg choice="plain"><option>--example</option></arg>
+        </group>
+        <replaceable class="option">this</replaceable>
+      </arg>
+      <arg choice="opt">
+        <group choice="req">
+          <arg choice="plain"><option>-e</option></arg>
+          <arg choice="plain"><option>--example</option></arg>
+        </group>
+        <group choice="req">
+          <arg choice="plain"><replaceable>this</replaceable></arg>
+          <arg choice="plain"><replaceable>that</replaceable></arg>
+        </group>
+      </arg>
+    </cmdsynopsis>
+    <cmdsynopsis>
+      <command>&dhpackage;</command>
+      <!-- Normally the help and version options make the programs stop
+           right after outputting the requested information. -->
+      <group choice="opt">
+        <arg choice="plain">
+          <group choice="req">
+            <arg choice="plain"><option>-h</option></arg>
+            <arg choice="plain"><option>--help</option></arg>
+          </group>
+        </arg>
+        <arg choice="plain">
+          <group choice="req">
+            <arg choice="plain"><option>-v</option></arg>
+            <arg choice="plain"><option>--version</option></arg>
+          </group>
+        </arg>
+      </group>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+  <refsect1 id="description">
+    <title>DESCRIPTION</title>
+    <para>This manual page documents briefly the
+      <command>&dhpackage;</command> and <command>bar</command>
+      commands.</para>
+    <para>This manual page was written for the Debian distribution
+      because the original program does not have a manual page.
+      Instead, it has documentation in the GNU <citerefentry>
+        <refentrytitle>info</refentrytitle>
+        <manvolnum>1</manvolnum>
+      </citerefentry> format; see below.</para>
+    <para><command>&dhpackage;</command> is a program that...</para>
+  </refsect1>
+  <refsect1 id="options">
+    <title>OPTIONS</title>
+    <para>The program follows the usual GNU command line syntax,
+      with long options starting with two dashes (`-').  A summary of
+      options is included below.  For a complete description, see the
+      <citerefentry>
+        <refentrytitle>info</refentrytitle>
+        <manvolnum>1</manvolnum>
+      </citerefentry> files.</para>
+    <variablelist>
+      <!-- Use the variablelist.term.separator and the
+           variablelist.term.break.after parameters to
+           control the term elements. -->
+      <varlistentry>
+        <term><option>-e <replaceable>this</replaceable></option></term>
+        <term><option>--example=<replaceable>that</replaceable></option></term>
+        <listitem>
+          <para>Does this and that.</para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-h</option></term>
+        <term><option>--help</option></term>
+        <listitem>
+          <para>Show summary of options.</para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><option>-v</option></term>
+        <term><option>--version</option></term>
+        <listitem>
+          <para>Show version of program.</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+  <refsect1 id="files">
+    <title>FILES</title>
+    <variablelist>
+      <varlistentry>
+        <term><filename>/etc/foo.conf</filename></term>
+        <listitem>
+          <para>The system-wide configuration file to control the
+            behaviour of <application>&dhpackage;</application>. See
+            <citerefentry>
+              <refentrytitle>foo.conf</refentrytitle>
+              <manvolnum>5</manvolnum>
+            </citerefentry> for further details.</para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><filename>${HOME}/.foo.conf</filename></term>
+        <listitem>
+          <para>The per-user configuration file to control the
+             behaviour of <application>&dhpackage;</application>. See
+             <citerefentry>
+               <refentrytitle>foo.conf</refentrytitle>
+               <manvolnum>5</manvolnum>
+             </citerefentry> for further details.</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+  <refsect1 id="environment">
+    <title>ENVIRONMENT</title>
+    <variablelist>
+      <varlistentry>
+        <term><envar>FOO_CONF</envar></term>
+        <listitem>
+          <para>If used, the defined file is used as configuration
+            file (see also <xref linkend="files"/>).</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+  <refsect1 id="diagnostics">
+    <title>DIAGNOSTICS</title>
+    <para>The following diagnostics may be issued
+      on <filename class="devicefile">stderr</filename>:</para>
+    <variablelist>
+      <varlistentry>
+        <term><errortext>Bad configuration file. Exiting.</errortext></term>
+        <listitem>
+          <para>The configuration file seems to contain a broken configuration
+            line. Use the <option>--verbose</option> option, to get more info.
+          </para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+    <para><command>&dhpackage;</command> provides some return codes, that can
+      be used in scripts:</para>
+    <segmentedlist>
+      <segtitle>Code</segtitle>
+      <segtitle>Diagnostic</segtitle>
+      <seglistitem>
+        <seg><errorcode>0</errorcode></seg>
+        <seg>Program exited successfully.</seg>
+      </seglistitem>
+      <seglistitem>
+        <seg><errorcode>1</errorcode></seg>
+        <seg>The configuration file seems to be broken.</seg>
+      </seglistitem>
+    </segmentedlist>
+  </refsect1>
+  <refsect1 id="bugs">
+    <!-- Or use this section to tell about upstream BTS. -->
+    <title>BUGS</title>
+    <para>The program is currently limited to only work
+      with the <package>foobar</package> library.</para>
+    <para>The upstreams <acronym>BTS</acronym> can be found
+      at <ulink url="http://bugzilla.foo.tld"/>.</para>
+  </refsect1>
+  <refsect1 id="see_also">
+    <title>SEE ALSO</title>
+    <!-- In alpabetical order. -->
+    <para><citerefentry>
+        <refentrytitle>bar</refentrytitle>
+        <manvolnum>1</manvolnum>
+      </citerefentry>, <citerefentry>
+        <refentrytitle>baz</refentrytitle>
+        <manvolnum>1</manvolnum>
+      </citerefentry>, <citerefentry>
+        <refentrytitle>foo.conf</refentrytitle>
+        <manvolnum>5</manvolnum>
+      </citerefentry></para>
+    <para>The programs are documented fully by <citetitle>The Rise and
+      Fall of a Fooish Bar</citetitle> available via the <citerefentry>
+        <refentrytitle>info</refentrytitle>
+        <manvolnum>1</manvolnum>
+      </citerefentry> system.</para>
+  </refsect1>
+</refentry>
+
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/postrm.ex b/extra/scripts/CD/distrofiles/deb/snapshot/debian/postrm.ex
new file mode 100644
index 0000000000..bbe8b8629b
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/postrm.ex
@@ -0,0 +1,37 @@
+#!/bin/sh
+# postrm script for algorithms-library
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postrm> `remove'
+#        * <postrm> `purge'
+#        * <old-postrm> `upgrade' <new-version>
+#        * <new-postrm> `failed-upgrade' <old-version>
+#        * <new-postrm> `abort-install'
+#        * <new-postrm> `abort-install' <old-version>
+#        * <new-postrm> `abort-upgrade' <old-version>
+#        * <disappearer's-postrm> `disappear' <overwriter>
+#          <overwriter-version>
+# for details, see https://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+    ;;
+
+    *)
+        echo "postrm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/preinst.ex b/extra/scripts/CD/distrofiles/deb/snapshot/debian/preinst.ex
new file mode 100644
index 0000000000..cdffafa097
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/preinst.ex
@@ -0,0 +1,35 @@
+#!/bin/sh
+# preinst script for algorithms-library
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <new-preinst> `install'
+#        * <new-preinst> `install' <old-version>
+#        * <new-preinst> `upgrade' <old-version>
+#        * <old-preinst> `abort-upgrade' <new-version>
+# for details, see https://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    install|upgrade)
+    ;;
+
+    abort-upgrade)
+    ;;
+
+    *)
+        echo "preinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/prerm.ex b/extra/scripts/CD/distrofiles/deb/snapshot/debian/prerm.ex
new file mode 100644
index 0000000000..da7df7e35c
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/prerm.ex
@@ -0,0 +1,38 @@
+#!/bin/sh
+# prerm script for algorithms-library
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <prerm> `remove'
+#        * <old-prerm> `upgrade' <new-version>
+#        * <new-prerm> `failed-upgrade' <old-version>
+#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
+#        * <deconfigured's-prerm> `deconfigure' `in-favour'
+#          <package-being-installed> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see https://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    remove|upgrade|deconfigure)
+    ;;
+
+    failed-upgrade)
+    ;;
+
+    *)
+        echo "prerm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/rules b/extra/scripts/CD/distrofiles/deb/snapshot/debian/rules
new file mode 100755
index 0000000000..bd4eae84f9
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/rules
@@ -0,0 +1,28 @@
+#!/usr/bin/make -f
+# See debhelper(7) (uncomment to enable)
+# output every command that modifies files on the build system.
+export DH_VERBOSE = 1
+export CXXFLAGS=
+
+
+# see FEATURE AREAS in dpkg-buildflags(1)
+#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
+
+# see ENVIRONMENT in dpkg-buildflags(1)
+# package maintainers to append CFLAGS
+#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
+# package maintainers to append LDFLAGS
+#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
+
+%:
+	dh $@ --buildsystem=cmake --builddirectory=build
+
+override_dh_strip:
+	dh_strip $@
+
+override_dh_auto_configure:
+	./CMake/generate.py -wm
+	dh_auto_configure -- -DCMAKE_BUILD_TYPE=Release
+
+#override_dh_auto_test:
+#	echo "Skipping tests"
diff --git a/extra/scripts/CD/distrofiles/deb/snapshot/debian/source/format b/extra/scripts/CD/distrofiles/deb/snapshot/debian/source/format
new file mode 100644
index 0000000000..163aaf8d82
--- /dev/null
+++ b/extra/scripts/CD/distrofiles/deb/snapshot/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/extra/scripts/CD/packaging/package-archlinux.sh b/extra/scripts/CD/packaging/package-archlinux.sh
index 4cfb58a23c..73a443a817 100644
--- a/extra/scripts/CD/packaging/package-archlinux.sh
+++ b/extra/scripts/CD/packaging/package-archlinux.sh
@@ -1,5 +1,5 @@
 # $GIT_ROOT
-# $TYPE (nightly/release)
+# $TYPE (snapshot/stable)
 # $CWD
 
 before () {
@@ -9,6 +9,8 @@ before () {
 
 	export -f gpg_import
 	su builder -c '/bin/sh -c gpg_import'
+
+	echo "MAKEFLAGS=\"-j$(grep -c processor /proc/cpuinfo)\"" >> /etc/makepkg.conf
 }
 
 package () {
@@ -25,3 +27,31 @@ package () {
 
 	set +e
 }
+
+deploy () {
+	set -e
+	MOUNTPOINTS="-v /srv/repository/archlinux/x86_64:/repository -v$(pwd):/build -v/root/.gnupg/:/root/.gnupg/"
+	DOCKER_IMAGE="archlinux/base"
+	DOCKER_CMD="docker run --rm $MOUNTPOINTS $DOCKER_IMAGE"
+
+	REPO_DIR="/repository"
+	REPO_DB="/repository/algorithms-library.db.tar.gz"
+
+	# docker login gitlab.fit.cvut.cz:5000 -u "$DOCKER_REGISTRY_USERNAME" -p "$DOCKER_REGISTRY_TOKEN"
+    docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
+	docker pull "$DOCKER_IMAGE:latest"
+
+	if [[ $TYPE == "snapshot" ]]; then
+		REMOVE="algorithms-library-gui-snapshot algorithms-library-snapshot"
+	else
+		REMOVE="algorithms-library-gui algorithms-library"
+	fi
+
+	$DOCKER_CMD pacman -Suy --noconfirm --needed gnupg
+	for file in *.tar.xz; do
+		$DOCKER_CMD bash -c "cd $REPO_DIR && [[ -e $REPO_DB ]] && repo-remove -v -s -k $GPG_KEYID $REPO_DB $REMOVE || true"
+		$DOCKER_CMD bash -c "for file in /build/*.tar.xz; do cp \$file $REPO_DIR/ && cp \$file.sig $REPO_DIR/ && repo-add -R -v -s -k $GPG_KEYID $REPO_DB $(basename "\$file"); done"
+	done
+
+	set +e
+}
diff --git a/extra/scripts/CD/packaging/package-debian.sh b/extra/scripts/CD/packaging/package-debian.sh
index c4f229484f..b1c800e171 100644
--- a/extra/scripts/CD/packaging/package-debian.sh
+++ b/extra/scripts/CD/packaging/package-debian.sh
@@ -1,10 +1,13 @@
+before () {
+	apt-get update
+	apt-get install -y dh-make debsigs devscripts build-essential git gnupg
+	gpg_import
+
+	apt-get install -y cmake libxml2-dev libtclap-dev libreadline-dev qtbase5-dev graphviz-dev libjsoncpp-dev
+}
+
 package () {
 	set -e
-	# apt-get install dh-make debsigs devscripts build-essentials
-
-	export LOGNAME="peckato1"
-	export DEBFULLNAME="Tomáš Pecka"
-	export DEBEMAIL="peckato1@fit.cvut.cz"
 
 	# create orig file
 	cp $ARCHIVE ${ARCHIVE%.tar.gz}.orig.tar.gz
@@ -12,14 +15,65 @@ package () {
 	# extract sources and build
 	tar xzvf $ARCHIVE
 	pushd $ARCHIVE_DIR
-	cp -r $GIT_ROOT/extra/scripts/CD/distrofiles/deb/debian .
-	debuild
 
+	cp -r $GIT_ROOT/extra/scripts/CD/distrofiles/deb/$TYPE/debian .
+
+	if [[ -z "$DISTRIBUTION" ]]; then
+		echo "Distribution variable not set"
+		exit 1
+	fi
+
+	# snapshot changelog update
+	if [[ $TYPE == "snapshot" ]]; then
+		CHANGELOG=$(cat debian/changelog)
+		cat > debian/changelog <<DOC
+algorithms-library ($VERSION~$DISTRIBUTION) unstable; urgency=medium
+
+  * Snapshot release changelog bump.
+
+ -- Tomáš Pecka <peckato1@fit.cvut.cz>  $(date "+%a, %d %b %Y %H:%M:%S %z")
+
+$CHANGELOG
+DOC
+	fi
+
+	debuild -b -us -k$GPG_KEYID -j$(grep -c processor /proc/cpuinfo)
 	popd
 
 	set +e
 }
 
-publish () {
-	return 0
+deploy () {
+	set -e
+	# comes from gitlab-ci:
+	# DISTRIBUTION=
+
+	MOUNTPOINTS="-v /srv/repository/debian:/repository -v$(pwd):/build -v/root/.gnupg/:/root/.gnupg/"
+	DOCKER_IMAGE="gitlab.fit.cvut.cz:5000/algorithms-library-toolkit/ci-docker-images/repository/aptly"
+	DOCKER_CMD="docker run --rm $MOUNTPOINTS $DOCKER_IMAGE"
+
+	SNAPSHOT="snapshot-$DISTRIBUTION"
+
+	if [[ $TYPE == "snapshot" ]]; then
+		PACKAGE_REMOVE="algorithms-library-snapshot algorithms-library-dev-snapshot algorithms-library-gui-snapshot"
+		PACKAGE_DBGSYM="algorithms-library-snapshot-dbgsym algorithms-library-gui-snapshot-dbgsym"
+	else
+		PACKAGE_REMOVE="algorithms-library algorithms-library-dev algorithms-library-gui"
+		PACKAGE_DBGSYM="algorithms-library-dbgsym algorithms-library-gui-dbgsym"
+	fi
+
+	# docker login gitlab.fit.cvut.cz:5000 -u "$DOCKER_REGISTRY_USERNAME" -p "$DOCKER_REGISTRY_TOKEN"
+    docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
+	docker pull "$DOCKER_IMAGE:latest"
+
+	$DOCKER_CMD aptly repo create $DISTRIBUTION || true
+	$DOCKER_CMD aptly publish drop "$DISTRIBUTION" filesystem:dir: || true
+	$DOCKER_CMD aptly snapshot drop "$SNAPSHOT" || true
+	$DOCKER_CMD aptly repo remove $DISTRIBUTION $PACKAGE_REMOVE || true
+	$DOCKER_CMD bash -c "aptly repo include -repo="$DISTRIBUTION" /build/*.changes"
+	$DOCKER_CMD aptly repo remove $DISTRIBUTION $PACKAGE_DBGSYM
+	$DOCKER_CMD aptly repo show -with-packages "$DISTRIBUTION"
+	$DOCKER_CMD aptly snapshot create -architectures=amd64 "$SNAPSHOT" from repo "$DISTRIBUTION"
+	$DOCKER_CMD aptly publish snapshot -architectures=amd64 -batch -gpg-key="$GPG_KEYID" -distribution=$DISTRIBUTION $SNAPSHOT filesystem:dir:
+	set +e
 }
diff --git a/extra/scripts/CD/packaging/package-docker.sh b/extra/scripts/CD/packaging/package-docker.sh
index 96d04f3ce1..f31b504d89 100644
--- a/extra/scripts/CD/packaging/package-docker.sh
+++ b/extra/scripts/CD/packaging/package-docker.sh
@@ -8,8 +8,8 @@ package () {
 	IMAGE_CLI=$CI_REGISTRY_IMAGE/cli
 	IMAGE_GUI=$CI_REGISTRY_IMAGE/gui
 	IMAGE_ALL=$CI_REGISTRY_IMAGE
-	TAG_NIGHTLY=nightly
-	TAG_RELEASE=$CI_COMMIT_REF_NAME
+	TAG_SNAPSHOT=snapshot
+	TAG_STABLE=$CI_COMMIT_REF_NAME
 	TAG_LATEST=latest
 
 	BUILD_ALL=all_build
@@ -21,30 +21,50 @@ package () {
 	docker run $BUILD_CLI /usr/bin/aql2 --help
 	docker run $BUILD_ALL /usr/bin/aql2 --help
 
-	if [[ $TYPE == "nightly" ]]; then
-		docker tag "$BUILD_CLI" "$IMAGE_CLI:$TAG_NIGHTLY"
-		docker tag "$BUILD_ALL" "$IMAGE_GUI:$TAG_NIGHTLY" # gui-version is now only a symlink to all-version
-		docker tag "$BUILD_ALL" "$IMAGE_ALL:$TAG_NIGHTLY"
+	if [[ $TYPE == "snapshot" ]]; then
+		docker tag "$BUILD_CLI" "$IMAGE_CLI:$TAG_SNAPSHOT"
+		docker tag "$BUILD_ALL" "$IMAGE_GUI:$TAG_SNAPSHOT" # gui-version is now only a symlink to all-version
+		docker tag "$BUILD_ALL" "$IMAGE_ALL:$TAG_SNAPSHOT"
 
 		docker save -o images.tar \
-			"$IMAGE_CLI:$TAG_NIGHTLY" \
-			"$IMAGE_GUI:$TAG_NIGHTLY" \
-			"$IMAGE_ALL:$TAG_NIGHTLY"
+			"$IMAGE_CLI:$TAG_SNAPSHOT" \
+			"$IMAGE_GUI:$TAG_SNAPSHOT" \
+			"$IMAGE_ALL:$TAG_SNAPSHOT"
 
-	elif [[ $TYPE == "release" ]]; then
-		docker tag "$BUILD_CLI" "$IMAGE_CLI:$TAG_RELEASE"
+	elif [[ $TYPE == "stable" ]]; then
+		docker tag "$BUILD_CLI" "$IMAGE_CLI:$TAG_STABLE"
 		docker tag "$BUILD_CLI" "$IMAGE_CLI:$TAG_LATEST"
-		docker tag "$BUILD_ALL" "$IMAGE_GUI:$TAG_RELEASE" # gui-version is now only a symlink to all-version
+		docker tag "$BUILD_ALL" "$IMAGE_GUI:$TAG_STABLE" # gui-version is now only a symlink to all-version
 		docker tag "$BUILD_ALL" "$IMAGE_GUI:$TAG_LATEST"  # gui-version is now only a symlink to all-version
-		docker tag "$BUILD_ALL" "$IMAGE_ALL:$TAG_RELEASE"
+		docker tag "$BUILD_ALL" "$IMAGE_ALL:$TAG_STABLE"
 		docker tag "$BUILD_ALL" "$IMAGE_ALL:$TAG_LATEST"
 
 		docker save -o images.tar \
-			"$IMAGE_CLI:$TAG_RELEASE" "$IMAGE_CLI:$TAG_LATEST" \
-			"$IMAGE_GUI:$TAG_RELEASE" "$IMAGE_GUI:$TAG_LATEST" \
-			"$IMAGE_ALL:$TAG_RELEASE" "$IMAGE_ALL:$TAG_LATEST"
+			"$IMAGE_CLI:$TAG_STABLE" "$IMAGE_CLI:$TAG_LATEST" \
+			"$IMAGE_GUI:$TAG_STABLE" "$IMAGE_GUI:$TAG_LATEST" \
+			"$IMAGE_ALL:$TAG_STABLE" "$IMAGE_ALL:$TAG_LATEST"
 	fi
 
 	set +e
 }
 
+deploy () {
+	set -e
+
+	docker load -i images.tar
+
+	if [[ $TYPE == "snapshot" ]]; then
+		docker push $CI_REGISTRY_IMAGE/cli:snapshot
+		docker push $CI_REGISTRY_IMAGE/gui:snapshot
+		docker push $CI_REGISTRY_IMAGE:snapshot
+	else
+		docker push $CI_REGISTRY_IMAGE/cli:latest
+		docker push $CI_REGISTRY_IMAGE/gui:latest
+		docker push $CI_REGISTRY_IMAGE:latest
+		docker push $CI_REGISTRY_IMAGE/cli:$CI_COMMIT_REF_NAME
+		docker push $CI_REGISTRY_IMAGE/gui:$CI_COMMIT_REF_NAME
+		docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
+	fi
+
+	set +e
+}
diff --git a/extra/scripts/CD/packaging/package-sources.sh b/extra/scripts/CD/packaging/package-sources.sh
index b43af279e7..2a12d52b55 100644
--- a/extra/scripts/CD/packaging/package-sources.sh
+++ b/extra/scripts/CD/packaging/package-sources.sh
@@ -12,3 +12,16 @@ package () {
 
 	set +e
 }
+
+deploy () {
+	set -e
+	MOUNTPOINTS="-v /srv/repository/sources:/repository -v$(pwd):/build -v/root/.gnupg/:/root/.gnupg/"
+	DOCKER_IMAGE="alpine"
+	DOCKER_CMD="docker run --rm $MOUNTPOINTS $DOCKER_IMAGE"
+
+    docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
+	docker pull "$DOCKER_IMAGE:latest"
+
+	$DOCKER_CMD sh -c "mv /build/*.tar.gz* /repository/"
+	set +e
+}
diff --git a/extra/scripts/CD/packaging/package.sh b/extra/scripts/CD/packaging/package.sh
index e93ab046d2..3bdc7a5ae8 100755
--- a/extra/scripts/CD/packaging/package.sh
+++ b/extra/scripts/CD/packaging/package.sh
@@ -1,14 +1,16 @@
-#!/bin/sh
+#!/bin/bash
 
 usage_and_exit () {
 	cat >&2 << EOF
-Usage: $0 TYPE TARGET CWD
+Usage: $0 TYPE TARGET JOB CWD
 
-CD package script wrapper.
+CD packaging and deploying script wrapper.
 
 Arguments:
-  TYPE       Either 'nightly' or 'release'.
+
+  TYPE       Either 'snapshot' or 'stable'.
   TARGET     Target distro. Determines script to be called.
+  JOB        Either 'package' or 'deploy'
   CWD        Working directory.
 
 EOF
@@ -67,17 +69,20 @@ CWD=
 
 # ---------------------------------------------------------------------------------------------------------------------
 # check input
-[[ $# -ne 3 ]] && usage_and_exit
+[[ $# -ne 4 ]] && usage_and_exit
 
 TYPE=$(tolower "$1")
-[[ $TYPE != "nightly" && $TYPE != "release" ]] && usage_and_exit_with_msg "Invalid type."
+[[ $TYPE != "snapshot" && $TYPE != "stable" ]] && usage_and_exit_with_msg "Invalid type."
 
 TARGET=$(tolower "$2")
 DISTROSCRIPT="$SCRIPT_ROOT/package-$TARGET.sh"
 [[ ! -e "$DISTROSCRIPT" ]] && usage_and_exit_with_msg "Invalid distro. File $(basename $DISTROSCRIPT) not found."
 
-CWD=$(realpath "$3")
-[[ ! -d "$3" ]] && usage_and_exit_with_msg "Directory $3 does not exist".
+JOB=$(tolower "$3")
+[[ $JOB != "package" && $JOB != "deploy" ]] && usage_and_exit_with_msg "Invalid job."
+
+CWD=$(realpath "$4")
+[[ ! -d "$CWD" ]] && usage_and_exit_with_msg "Directory $4 does not exist".
 
 # ---------------------------------------------------------------------------------------------------------------------
 # source distroscript
@@ -87,43 +92,51 @@ source "$DISTROSCRIPT"
 
 function_exists "package" || exit_with_msg "Function package() not found in package-$TARGET.sh" 2
 function_exists "before"  || exit_with_msg "Function before() not found in package-$TARGET.sh" 2
+function_exists "deploy"  || exit_with_msg "Function deploy() not found in package-$TARGET.sh" 2
 
 # ---------------------------------------------------------------------------------------------------------------------
 # run before...
 
-before
-
 # ---------------------------------------------------------------------------------------------------------------------
 # create archive inside $CWD
 
-cd $GIT_ROOT
+if [[ $JOB == "package" ]]; then
+	before
+	cd $GIT_ROOT
 
-if [[ $TYPE == "nightly" ]]; then
-	ARCHIVE_DIR=algorithms-library_$(git describe --long --tags --match="v*" |  sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g')
-	ARCHIVE=$ARCHIVE_DIR.tar.gz
-	echo "Creating archive $ARCHIVE"
+	if [[ $TYPE == "snapshot" ]]; then
+		VERSION="$(git describe --long --tags --match="v*" |  sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g')"
+	elif [[ $TYPE == "stable" ]]; then
+		VERSION="$(git describe --tags --match="v*" --abbrev=0 | sed 's/^v//g')"
+	fi
 
-	git archive --format=tar.gz --prefix="$ARCHIVE_DIR/" HEAD -o $CWD/$ARCHIVE
-elif [[ $TYPE == "release" ]]; then
-	ARCHIVE_DIR=algorithms-library_$(git describe --tags --match="v*" --abbrev=0 | sed 's/^v//g').tar.gz
-	ARCHIVE=$ARCHIVE_DIR.tar.gz
+	ARCHIVE_DIR="algorithms-library_$VERSION"
+	ARCHIVE="$ARCHIVE_DIR.tar.gz"
 	echo "Creating archive $ARCHIVE"
 
-	git archive --format=tar.gz --prefix="$ARCHIVE_DIR/" $(git describe --tags --match="v*" --abbrev=0) -o $CWD/$ARCHIVE
-fi
-
-# ---------------------------------------------------------------------------------------------------------------------
-# output what is going on
-
-echo "Start packaging..."
-echo " - \$TARGET  : $TARGET"
-echo " - \$TYPE    : $TYPE"
-echo " - \$GIT_ROOT: $GIT_ROOT"
-echo " - \$CWD     : $CWD"
-echo " - \$ARCHIVE : $ARCHIVE"
-
-# change directory and run
-cd $CWD
-package
+	if [[ $TYPE == "snapshot" ]]; then
+		git archive --format=tar.gz --prefix="$ARCHIVE_DIR/" HEAD -o $CWD/$ARCHIVE
+	elif [[ $TYPE == "stable" ]]; then
+		git archive --format=tar.gz --prefix="$ARCHIVE_DIR/" $(git describe --tags --match="v*" --abbrev=0) -o $CWD/$ARCHIVE
+	fi
 
-exit $?
+	echo "Start packaging..."
+	echo " - \$TARGET  : $TARGET"
+	echo " - \$TYPE    : $TYPE"
+	echo " - \$GIT_ROOT: $GIT_ROOT"
+	echo " - \$CWD     : $CWD"
+	echo " - \$ARCHIVE : $ARCHIVE"
+
+	# change directory and run
+	cd $CWD
+	package
+	exit $?
+else
+	echo "Start deploying..."
+	echo " - \$TARGET  : $TARGET"
+	echo " - \$TYPE    : $TYPE"
+	echo " - \$CWD     : $CWD"
+
+	deploy
+	exit $?
+fi
-- 
GitLab