From 045170aa23848a4af297bf9ee4f6720fc4b80c7d Mon Sep 17 00:00:00 2001
From: Piotr Gawron <p.gawron@atcomp.pl>
Date: Thu, 19 Sep 2024 07:34:11 +0200
Subject: [PATCH] first approach to deb package

---
 debian/create-debian-pkg.sh | 72 +++++++++++++++++++++++++++++++++++++
 debian/template/compat      |  1 +
 debian/template/control     | 12 +++++++
 debian/template/install     |  1 +
 4 files changed, 86 insertions(+)
 create mode 100755 debian/create-debian-pkg.sh
 create mode 100644 debian/template/compat
 create mode 100644 debian/template/control
 create mode 100644 debian/template/install

diff --git a/debian/create-debian-pkg.sh b/debian/create-debian-pkg.sh
new file mode 100755
index 00000000..34b1b94e
--- /dev/null
+++ b/debian/create-debian-pkg.sh
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+versionCompLte() {
+    [  "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
+}
+
+
+versionCompLt() {
+    [ "$1" = "$2" ] && return 1 || versionCompLte $1 $2
+}
+
+#Where source file of the debian package should be placed
+SRC_DIR=debian/src
+
+ROOT_DIR=`pwd`
+
+#clean build directories
+rm -rf $SRC_DIR
+rm -rf debian/minerva*
+
+#recreate directory
+mkdir $SRC_DIR
+
+export APP_PREFIX=/minerva
+npm install
+npm run build
+cp -r out $SRC_DIR/front
+
+cd $SRC_DIR
+zip -r front.zip front
+cd $ROOT_DIR
+
+#copy changelog file
+cp CHANGELOG $ROOT_DIR/debian/template/changelog
+
+current_version=`cat CHANGELOG |grep minerva |head -1 | cut -f2 -d'(' | cut -f1 -d')'`
+
+echo "Current version: " $current_version
+
+#dh_make requires directory name to be like <package>-<version>
+# this points to the directory
+DEBIAN_DIR=debian/minerva-$current_version/
+
+mkdir $DEBIAN_DIR
+
+# copy all source files to this directory
+cp $SRC_DIR/* $DEBIAN_DIR
+
+#because dh_make works only from within directory where
+#package data will be generated we need to change it
+cd $DEBIAN_DIR
+#this should be improved (to include src properly)
+dh_make -s --createorig -e piotr.gawron@uni.lu -y -t $ROOT_DIR/debian/template
+
+echo "1.0" > debian/source/format
+
+#remove example files generated by dh_make
+find -name '*.ex' ! -name 'minerva*' -type f -exec rm -f {} +
+
+#set proper architecture
+arch=`dpkg --print-architecture`
+echo "Architecture: $arch" >>debian/control
+
+#remove some sample file
+rm debian/*.EX
+rm debian/*.ex
+
+#build debian package
+debuild -us -uc
+
+# remove temporary changelog
+rm $ROOT_DIR/debian/template/changelog
diff --git a/debian/template/compat b/debian/template/compat
new file mode 100644
index 00000000..f599e28b
--- /dev/null
+++ b/debian/template/compat
@@ -0,0 +1 @@
+10
diff --git a/debian/template/control b/debian/template/control
new file mode 100644
index 00000000..d3ae8ba5
--- /dev/null
+++ b/debian/template/control
@@ -0,0 +1,12 @@
+Package: minerva-front
+Version: 18.0.0~beta.2
+Section: science
+Priority: optional
+Maintainer: Piotr Gawron <piotr.gawron@uni.lu>
+Description: Frontend for standalone web application for visualization,
+ exploration and management of molecular networks encoded in SBGN-compliant
+ format. After installation, the resource is used and managed via a webbrowser,
+ under the default address 'http://localhost:8080/minerva/'. Full documentation
+ can be found here: https://minerva.pages.uni.lu/doc/
+
+
diff --git a/debian/template/install b/debian/template/install
new file mode 100644
index 00000000..965f82bb
--- /dev/null
+++ b/debian/template/install
@@ -0,0 +1 @@
+front.zip /usr/share/minerva/
-- 
GitLab