From f11851f501bbcb6417369a47eb4f860214c04c89 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <p.gawron@atcomp.pl>
Date: Thu, 19 Sep 2024 08:37:55 +0200
Subject: [PATCH] template and script for creating debian package

---
 debian/create-debian-pkg.sh | 27 +++++++++++----------------
 debian/template/control     | 15 ++++++++++-----
 debian/template/copyright   | 29 +++++++++++++++++++++++++++++
 debian/template/rules       |  4 ++++
 4 files changed, 54 insertions(+), 21 deletions(-)
 create mode 100644 debian/template/copyright
 create mode 100755 debian/template/rules

diff --git a/debian/create-debian-pkg.sh b/debian/create-debian-pkg.sh
index 34b1b94e..48423e18 100755
--- a/debian/create-debian-pkg.sh
+++ b/debian/create-debian-pkg.sh
@@ -1,13 +1,6 @@
 #!/bin/bash
 
-versionCompLte() {
-    [  "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
-}
-
-
-versionCompLt() {
-    [ "$1" = "$2" ] && return 1 || versionCompLte $1 $2
-}
+set -e
 
 #Where source file of the debian package should be placed
 SRC_DIR=debian/src
@@ -15,8 +8,7 @@ SRC_DIR=debian/src
 ROOT_DIR=`pwd`
 
 #clean build directories
-rm -rf $SRC_DIR
-rm -rf debian/minerva*
+rm -rf $SRC_DIR debian/minerva-front*
 
 #recreate directory
 mkdir $SRC_DIR
@@ -28,18 +20,19 @@ cp -r out $SRC_DIR/front
 
 cd $SRC_DIR
 zip -r front.zip front
+rm -r 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')'`
+current_version=`cat CHANGELOG |grep minerva-front |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/
+DEBIAN_DIR=debian/minerva-front-$current_version/
 
 mkdir $DEBIAN_DIR
 
@@ -55,18 +48,20 @@ 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 {} +
+find -name '*.ex' ! -name 'minerva-front*' -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
+rm debian/*.ex debian/README.Debian debian/README.source debian/minerva-front-docs.docs
 
 #build debian package
-debuild -us -uc
+debuild  --no-lintian -us -uc
+
+#run separately to fail on errors
+lintian --suppress-tags bad-distribution-in-changes-file --fail-on warning,error --no-tag-display-limit
 
 # remove temporary changelog
 rm $ROOT_DIR/debian/template/changelog
diff --git a/debian/template/control b/debian/template/control
index d3ae8ba5..61e03b26 100644
--- a/debian/template/control
+++ b/debian/template/control
@@ -1,12 +1,17 @@
-Package: minerva-front
-Version: 18.0.0~beta.2
+Source: minerva-front
 Section: science
 Priority: optional
 Maintainer: Piotr Gawron <piotr.gawron@uni.lu>
+Standards-Version: 3.9.7
+Vcs-Browser: https://gitlab.lcsb.uni.lu/minerva/frontend
+Build-Depends: debhelper (>=10)
+
+Package: minerva-front
+Priority: optional
 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,
+ format. After installation, the resource is used and managed via a web browser,
  under the default address 'http://localhost:8080/minerva/'. Full documentation
  can be found here: https://minerva.pages.uni.lu/doc/
-
-
+Homepage: https://minerva.pages.uni.lu/
+Depends: ${misc:Depends}
diff --git a/debian/template/copyright b/debian/template/copyright
new file mode 100644
index 00000000..6291b335
--- /dev/null
+++ b/debian/template/copyright
@@ -0,0 +1,29 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: minerva-front
+Source: https://minerva.pages.uni.lu/doc/
+
+Files: front.zip
+Copyright: 2024 Piotr Gawron <piotr.gawron@uni.lu>
+License: AGPL-3.0
+Comment: Manual for the package.
+
+Files: debian/*
+Copyright: 2024 Piotr Gawron <piotr.gawron@uni.lu>
+License: AGPL-3.0
+
+License: AGPL-3.0
+ Copyright (C) 2024 Piotr Gawron
+ .
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+ .
+ This program 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 Affero General Public License for more details.
+ .
+ You should have received a copy of the GNU Affero General Public License
+ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ .
diff --git a/debian/template/rules b/debian/template/rules
new file mode 100755
index 00000000..2d33f6ac
--- /dev/null
+++ b/debian/template/rules
@@ -0,0 +1,4 @@
+#!/usr/bin/make -f
+
+%:
+	dh $@
-- 
GitLab