diff --git a/CHANGELOG b/CHANGELOG
index af4ff48bca5d91abcc556a3791c83031cf93620c..13ec657dfad5e5babf702239466fd2f750de6c00 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,211 +1,211 @@
-minerva (11.0.3) stable; urgency=medium
-  * Bug fix: removing empty project removed images from all projects 
-  * Bug fix: clicking on map when left panel was hidden threw error
-  * Bug fix: links to invalid annotations were opening invalid web page
-  * Bug fix: service resolving miriam resources doesn't worki over http
-    anymore
-  * Bug fux: chebi annotator doesn't work over http anymore
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 19 Oct 2017 13:50:00 +0200
-
-minerva (11.0.2) stable; urgency=medium
-  * Bug fix: login issues when default page is in secure area 
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Fri, 25 Sep 2017 12:00:00 +0200
-
-minerva (11.0.1) stable; urgency=medium
-  * Bug fix: logout caused issues with session data 
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Fri, 08 Sep 2017 12:00:00 +0200
-
-minerva (11.0.0) stable; urgency=medium
-
-  * Bug fix: security issue - access to specific map can be restricted 
-    by the userlogin 
-  * Bug fix: sbgn import
-  * Bug fix: mesh connector
-  * Rest API (documentation can be found here: 
-    https://git-r3lab.uni.lu/piotr.gawron/minerva/blob/master/README.md)
-  * Selecting an element on the map shows info about it in the bottom left
-    corner (when Search tab is not open) 
-  * Upload of data overlays allows to upload just names of the proteins
-    (or other elements), it can be done via file or just by typing in the
-    proper text box 
-  * Layout changes: the main one is that there are only 3 tab panels 
-    (search, overlay, info), so it should be easier to navigate
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Mon, 28 Aug 2017 12:00:00 +0200
-
-minerva (10.0.5) stable; urgency=medium
-
-  * Bug fix: interacting drugs can be found for RNAs
-  * Bug fix: error handling improved on map upload
-  * Bug fix: taxonomy ncbi server switched to https
-  * Overlay presents description field if possible 
-   
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Sat, 04 Mar 2017 12:00:00 +0200
- 
-minerva (10.0.4) stable; urgency=medium
-
-  * Bug fix: overlays colors are centered in white (not black)
-  * Bug fix: export to CellDesigner fixed
-  * Bug fix: DrugBank connector updated due to change in DrugBank website
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 29 Dec 2016 17:01:16 +0200
-
-minerva (10.0.3) stable; urgency=medium
-
-  * Bug fix: login cannot contain whitespace
-  * Bug fix: search for multiple drugs will not return more drugs than 
-    queried for
-  * Bug fix: drug list for some proteins (like RHOA) hung webpage
-  * Bug fix: comments on submaps issue
-  * Bug fix: link to submap from comment panel
-  * Overlay coloring can be defined in Configuration
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 15 Dec 2016 15:01:16 +0200
-
-minerva (10.0.2) stable; urgency=medium
-
-  * Bug fix: markers for mirna targets visibility
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 29 Sep 2016 10:01:16 +0200
-
-minerva (10.0.1) stable; urgency=medium
-
-  * Bug fix: export to image
-  * Bug fix: trigger reaction and physical stimulation reactions are no 
-    longer allowed (CellDesigner data model issue) 
-  * Bug fix: clicking on reactions in submaps
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Fri, 21 Sep 2016 13:01:16 +0200
-
-minerva (10) stable; urgency=medium
-
-  * Project info tab available for users
-  * Management of overlays in admin panel
-  * Bug fix: Visualization of text mining
-  * Bug fix: Exception when accessing non-existing project
-  * Bug fix: Zooming issue when searching for results on submaps
-  * Bug fix: Out of memory when caching a lot of data
-  * Bug fix: Corrupted drug names
-  * Bug fix: Unexpected errors when uploading layouts
-  * Bug fix: Coordinates in url
-  * Bug fix: Hiding left panel
-  * Bug fix: CellDesigner font size is processed properly
-  * Bug fix: Search by reaction id is not case sensitive
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Mon, 22 Aug 2016 13:01:16 +0200
-
-minerva (9) stable; urgency=medium
-
-  * Fix on install script of version 8 that crashed some new installations
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Wed, 29 Jun 2016 09:58:34 +0200
-
-minerva (8) stable; urgency=medium
-
-  * Micro RNA interface
-  * Toxic chemicals interdace
-  * Data sets (layouts) visualized dynamically in the browser
-  * Reverse query for drugs, chemicals, micro RNAs interfaces
-  * Small bug fixes
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 14 Apr 2016 13:03:55 +0200
-
-minerva (7) stable; urgency=low
-
-  * Uploaded datasets are available for download  
-  * Entrez annotator  
-  * Ensembl annotator  
-  * Valid/required annotations and used annotations saved in user profile  
-  * Export to pdf/png/jpg/svg  
-  * New web interface  
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 3 Dec 2015 22:00:00 +0200
-
-minerva (6) stable; urgency=low
-
-  * Searching by annotations  
-  * Errors from parsing data forwarded to client  
-  * Notification email system added  
-  * Warnings are downloadable  
-  * Complex map (composed from many small maps)  
-  * Visualization of Recon specific annotations
-  * Versioning system  
-  * Galaxy connector  
-  * Miriam types report  
-  * Advanced annotation options  
-  * Uniprot annotation module  
-  * Customized validation of miriam annotations  
-  * Recon annotation service  
-  * Bug fix: Data autofill problem in user management
-  * Bug fix: User privileges for adding project  
-  * Bug fix: Problem with some miriam entries in RDF format  
-  * Bug fix: Reporting of drawing problems
-  * Bug fix: Visualization of posttranslationa modification  
-  * Bug fix: Drugbank problem after update of Drugbank interface  
-  * Bug fix: Session scope fixed (browsing many maps at the same time)
-  * Bug fix: Asynchronous removing/adding maps  
-  * Bug fix: Export to CellDesigner rarely produced corrupted CellDesigner file  
-  * Bug fix: Recon annotations of reactions  
-  * Bug fix: Login problem when browsing not default map  
-  * Bug fix: Multimers are available for every element  
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Tue, 21 Jul 2015 22:00:00 +0200
- 
-minerva (5) stable; urgency=low
-
-  * Additional checkboxes in upload model: annotate automatically, cache data, verify annotations  
-  * Popup window in admin panel that list warnings
-  * Information about build  
-  * Parsing and annotation warnings for models in admin panel  
-  * Custom reaction visualization in upload overlay
-  * Bug fix: Problem with touch interface on Windows 8.1  
-  * Bug fix: Google Maps API problem with floating bubbles  
-  * Bug fix: Error handling in admin panel  
-  * Bug fix: Reaction color in CellDesigner file  
-  * Bug fix: Reaction line width  
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 18 Dec 2014 22:00:00 +0200
- 
-minerva (4) stable; urgency=low
-
-  * Export of the part of the map into CellDesigner file
-  * Logo files managable via config webpage  
-  * Import data from GO  
-  * Custom overlay upload
-  * Additional structural information imported from annotation service
-  * Bug fix: Fonts and lines in hierarchical view
-  * Bug fix: Visualization of residues in rna, antisense rna, proteins  
-  * Bug fix: Problem with touching bubbles on touch interface  
-  * Bug fix: Problem with special UTF-8 characters in CellDesigner file  
-  * Bug fix: Problem with users and session expire  
-  * Bug fix: Export problem  
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 11 Sep 2014 22:00:00 +0200
- 
-minerva (3) stable; urgency=low
-
-  * Drug targeting interface
-  * Export to CellDesigner  
-  * Status page of all dependent services  
-  * Configuration page  
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 5 Jun 2014 22:00:00 +0200
- 
-minerva (2) stable; urgency=low
-
-  * Upload of the CellDesigner map
-  * Bug fix: Problem with touch interface after update of browsers engine 
-  * Bug fix: Problem in Safari when searching for elements  
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Wed, 2 Apr 2014 22:00:00 +0200
- 
-minerva (1) stable; urgency=low
-
-  * Initial release 
-
- -- Piotr Gawron <piotr.gawron@uni.lu>  Wed, 4 Dec 2013 22:00:00 +0200
- 
+minerva (11.0.3) stable; urgency=medium
+  * Bug fix: removing empty project removed images from all projects
+  * Bug fix: clicking on map when left panel was hidden threw error
+  * Bug fix: links to invalid annotations were opening invalid web page
+  * Bug fix: service resolving miriam resources doesn't worki over http
+    anymore
+  * Bug fux: chebi annotator doesn't work over http anymore
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 19 Oct 2017 13:50:00 +0200
+
+minerva (11.0.2) stable; urgency=medium
+  * Bug fix: login issues when default page is in secure area
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Fri, 25 Sep 2017 12:00:00 +0200
+
+minerva (11.0.1) stable; urgency=medium
+  * Bug fix: logout caused issues with session data
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Fri, 08 Sep 2017 12:00:00 +0200
+
+minerva (11.0.0) stable; urgency=medium
+
+  * Bug fix: security issue - access to specific map can be restricted
+    by the userlogin
+  * Bug fix: sbgn import
+  * Bug fix: mesh connector
+  * Rest API (documentation can be found here:
+    https://git-r3lab.uni.lu/piotr.gawron/minerva/blob/master/README.md)
+  * Selecting an element on the map shows info about it in the bottom left
+    corner (when Search tab is not open)
+  * Upload of data overlays allows to upload just names of the proteins
+    (or other elements), it can be done via file or just by typing in the
+    proper text box
+  * Layout changes: the main one is that there are only 3 tab panels
+    (search, overlay, info), so it should be easier to navigate
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Mon, 28 Aug 2017 12:00:00 +0200
+
+minerva (10.0.5) stable; urgency=medium
+
+  * Bug fix: interacting drugs can be found for RNAs
+  * Bug fix: error handling improved on map upload
+  * Bug fix: taxonomy ncbi server switched to https
+  * Overlay presents description field if possible
+
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Sat, 04 Mar 2017 12:00:00 +0200
+
+minerva (10.0.4) stable; urgency=medium
+
+  * Bug fix: overlays colors are centered in white (not black)
+  * Bug fix: export to CellDesigner fixed
+  * Bug fix: DrugBank connector updated due to change in DrugBank website
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 29 Dec 2016 17:01:16 +0200
+
+minerva (10.0.3) stable; urgency=medium
+
+  * Bug fix: login cannot contain whitespace
+  * Bug fix: search for multiple drugs will not return more drugs than
+    queried for
+  * Bug fix: drug list for some proteins (like RHOA) hung webpage
+  * Bug fix: comments on submaps issue
+  * Bug fix: link to submap from comment panel
+  * Overlay coloring can be defined in Configuration
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 15 Dec 2016 15:01:16 +0200
+
+minerva (10.0.2) stable; urgency=medium
+
+  * Bug fix: markers for mirna targets visibility
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 29 Sep 2016 10:01:16 +0200
+
+minerva (10.0.1) stable; urgency=medium
+
+  * Bug fix: export to image
+  * Bug fix: trigger reaction and physical stimulation reactions are no
+    longer allowed (CellDesigner data model issue)
+  * Bug fix: clicking on reactions in submaps
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Fri, 21 Sep 2016 13:01:16 +0200
+
+minerva (10) stable; urgency=medium
+
+  * Project info tab available for users
+  * Management of overlays in admin panel
+  * Bug fix: Visualization of text mining
+  * Bug fix: Exception when accessing non-existing project
+  * Bug fix: Zooming issue when searching for results on submaps
+  * Bug fix: Out of memory when caching a lot of data
+  * Bug fix: Corrupted drug names
+  * Bug fix: Unexpected errors when uploading layouts
+  * Bug fix: Coordinates in url
+  * Bug fix: Hiding left panel
+  * Bug fix: CellDesigner font size is processed properly
+  * Bug fix: Search by reaction id is not case sensitive
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Mon, 22 Aug 2016 13:01:16 +0200
+
+minerva (9) stable; urgency=medium
+
+  * Fix on install script of version 8 that crashed some new installations
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Wed, 29 Jun 2016 09:58:34 +0200
+
+minerva (8) stable; urgency=medium
+
+  * Micro RNA interface
+  * Toxic chemicals interdace
+  * Data sets (layouts) visualized dynamically in the browser
+  * Reverse query for drugs, chemicals, micro RNAs interfaces
+  * Small bug fixes
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 14 Apr 2016 13:03:55 +0200
+
+minerva (7) stable; urgency=low
+
+  * Uploaded datasets are available for download
+  * Entrez annotator
+  * Ensembl annotator
+  * Valid/required annotations and used annotations saved in user profile
+  * Export to pdf/png/jpg/svg
+  * New web interface
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 3 Dec 2015 22:00:00 +0200
+
+minerva (6) stable; urgency=low
+
+  * Searching by annotations
+  * Errors from parsing data forwarded to client
+  * Notification email system added
+  * Warnings are downloadable
+  * Complex map (composed from many small maps)
+  * Visualization of Recon specific annotations
+  * Versioning system
+  * Galaxy connector
+  * Miriam types report
+  * Advanced annotation options
+  * Uniprot annotation module
+  * Customized validation of miriam annotations
+  * Recon annotation service
+  * Bug fix: Data autofill problem in user management
+  * Bug fix: User privileges for adding project
+  * Bug fix: Problem with some miriam entries in RDF format
+  * Bug fix: Reporting of drawing problems
+  * Bug fix: Visualization of posttranslationa modification
+  * Bug fix: Drugbank problem after update of Drugbank interface
+  * Bug fix: Session scope fixed (browsing many maps at the same time)
+  * Bug fix: Asynchronous removing/adding maps
+  * Bug fix: Export to CellDesigner rarely produced corrupted CellDesigner file
+  * Bug fix: Recon annotations of reactions
+  * Bug fix: Login problem when browsing not default map
+  * Bug fix: Multimers are available for every element
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Tue, 21 Jul 2015 22:00:00 +0200
+
+minerva (5) stable; urgency=low
+
+  * Additional checkboxes in upload model: annotate automatically, cache data, verify annotations
+  * Popup window in admin panel that list warnings
+  * Information about build
+  * Parsing and annotation warnings for models in admin panel
+  * Custom reaction visualization in upload overlay
+  * Bug fix: Problem with touch interface on Windows 8.1
+  * Bug fix: Google Maps API problem with floating bubbles
+  * Bug fix: Error handling in admin panel
+  * Bug fix: Reaction color in CellDesigner file
+  * Bug fix: Reaction line width
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 18 Dec 2014 22:00:00 +0200
+
+minerva (4) stable; urgency=low
+
+  * Export of the part of the map into CellDesigner file
+  * Logo files managable via config webpage
+  * Import data from GO
+  * Custom overlay upload
+  * Additional structural information imported from annotation service
+  * Bug fix: Fonts and lines in hierarchical view
+  * Bug fix: Visualization of residues in rna, antisense rna, proteins
+  * Bug fix: Problem with touching bubbles on touch interface
+  * Bug fix: Problem with special UTF-8 characters in CellDesigner file
+  * Bug fix: Problem with users and session expire
+  * Bug fix: Export problem
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 11 Sep 2014 22:00:00 +0200
+
+minerva (3) stable; urgency=low
+
+  * Drug targeting interface
+  * Export to CellDesigner
+  * Status page of all dependent services
+  * Configuration page
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Thu, 5 Jun 2014 22:00:00 +0200
+
+minerva (2) stable; urgency=low
+
+  * Upload of the CellDesigner map
+  * Bug fix: Problem with touch interface after update of browsers engine
+  * Bug fix: Problem in Safari when searching for elements
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Wed, 2 Apr 2014 22:00:00 +0200
+
+minerva (1) stable; urgency=low
+
+  * Initial release
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Wed, 4 Dec 2013 22:00:00 +0200
+
diff --git a/checkstyle.xml b/checkstyle.xml
index cf13403c2f932c8bf48a761e81ef0b95ba94ae76..b4ae1463262e7beed047c9c943c4a4abc7d7b2f1 100644
--- a/checkstyle.xml
+++ b/checkstyle.xml
@@ -1,12 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
 
-<!--
-    This configuration file was written by the eclipse-cs plugin configuration editor
+<!--
+    This configuration file was written by the eclipse-cs plugin configuration editor
 -->
-<!--
-    Checkstyle-Configuration: MapViewer checkstyle
-    Description: none
+<!--
+    Checkstyle-Configuration: MapViewer checkstyle
+    Description: none
 -->
 <module name="Checker">
   <property name="severity" value="warning"/>
diff --git a/debian/create-debian-pkg.sh b/debian/create-debian-pkg.sh
index 1a6936e6fc9fa7c2cd17bd88b313eb2a8acc7a19..654df170b9de5f453019e137908583eb9650cc6b 100755
--- a/debian/create-debian-pkg.sh
+++ b/debian/create-debian-pkg.sh
@@ -9,6 +9,8 @@ versionCompLt() {
     [ "$1" = "$2" ] && return 1 || versionCompLte $1 $2
 }
 
+# file with bash code generating DB schema diffs for different versions
+dbschemadiff=management_scripts/db_schema_and_diff.sh
 
 #Where source file of the debian package should be placed
 SRC_DIR=debian/src
@@ -54,22 +56,9 @@ cp debian/scripts/common.sh $SRC_DIR/
 #copy changelog file
 cp CHANGELOG $ROOT_DIR/debian/template/changelog
 
-#this variable will contain all available versions of the package
-versions=();
-
-#this is current (latest) version of the package
-current_version=-1;
-
-#find all available versions
-
-for version in `ls $DB_SCHEMA_DIR | sort -V`;
-do
-	if [ -d "$DB_SCHEMA_DIR/$version" ]
-	then
-		versions+=($version);
-		current_version=$version;
-	fi
-done
+# set $versions and $current_version; generate upgrade scripts in SRC_DIR
+DBSCRIPT_DEST_DIR=$SRC_DIR
+source $dbschemadiff
 
 echo "Current version: " $current_version
 
@@ -81,47 +70,6 @@ then
 	exit 1;
 fi
 
-#--------------------------------------
-# GENERATE DB schemas and diff files
-#--------------------------------------
-
-#last version (used for generating db diff files)
-last_version=-1;
-for version_A in ${versions[*]}
-do
-	#main update file (used to create this version - it's a diff
-	#between base.sql and current version)
-	update_file=$SRC_DIR/db_0_to_$current_version".sql";
-
-	#now iterate through all versions
-	for file in `ls $DB_SCHEMA_DIR/$version_A | sort -V`;
-	do
-		if [ -f "$DB_SCHEMA_DIR/$version_A/$file" ]
-		then
-			#add differemce tp current db schema diff
-			printf "\n\n-- UPDATE $version_A/$file\n\n" >>$update_file;
-			cat $DB_SCHEMA_DIR/$version_A/$file >> $update_file;
-
-			#and now iterate again through all versions to add diffs 
-			#between previous versions and current one
-			for version_B in ${versions[*]}
-			do
-				#update from version_B should contain all db changes that appeard
-				#after #version_B (so version_A must be later)
-				if versionCompLt $version_B $version_A 
-				then
-					upd_file=$SRC_DIR/db_"$version_B"_to_$current_version".sql";
-					printf "\n\n-- UPDATE $version_A/$file\n\n" >>$upd_file;
-					cat $DB_SCHEMA_DIR/$version_A/$file >> $upd_file;
-					
-				fi
-			done
-		fi
-	done
-
-	last_version=$version_A
-done
-
 #------------------------------------------
 # Now we have all db schema diff files. Let's start preparing 
 # debian package
diff --git a/management_scripts/db_schema_and_diff.sh b/management_scripts/db_schema_and_diff.sh
new file mode 100644
index 0000000000000000000000000000000000000000..c6c0783e00fec80662cdb30d86aec5ed637e53a2
--- /dev/null
+++ b/management_scripts/db_schema_and_diff.sh
@@ -0,0 +1,77 @@
+# shell snippet which extracts all available MINERVA versions from
+# subdirectories available in DB_SCHEMA_DIR (typically
+# `persist/src/db`) and generates database upgrade scripts (diff
+# files)
+
+# Precondition: the following variables have to be correctly initialised
+# * DB_SCHEMA_DIR        set to the directory containing database initialisation and upgrade sql commands
+# * DBSCRIPT_DEST_DIR    set to the directory that will be populated with database upgrade scripts
+
+# Postcondition:
+# * versions is set to the available MINERVA versions (bash array)
+# * current_version is set to the latest available version
+# * DBSCRIPT_DEST_DIR contains script to initialise the database from any version to the current version
+
+
+#this variable will contain all available versions of the package
+versions=();
+
+#this is current (latest) version of the package
+current_version=-1;
+
+#find all available versions
+
+for version in `ls "$DB_SCHEMA_DIR" | sort -V`;
+do
+	if [ -d "$DB_SCHEMA_DIR/$version" ]
+	then
+		versions+=($version);
+		current_version=$version;
+	fi
+done
+
+#--------------------------------------
+# GENERATE DB schemas and diff files
+#--------------------------------------
+
+versionCompLte() {
+    [  "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
+}
+
+
+versionCompLt() {
+    [ "$1" = "$2" ] && return 1 || versionCompLte $1 $2
+}
+
+#last version (used for generating db diff files)
+for version_A in ${versions[*]}
+do
+	#main update file (used to create this version - it's a diff
+	#between base.sql and current version)
+	update_file="$DBSCRIPT_DEST_DIR/db_0_to_${current_version}.sql";
+
+	#now iterate through all versions
+	for file in `ls "$DB_SCHEMA_DIR/$version_A" | sort -V`;
+	do
+		if [ -f "$DB_SCHEMA_DIR/$version_A/$file" ]
+		then
+			#add difference to current db schema diff
+			printf "\n\n-- UPDATE $version_A/$file\n\n" >> "$update_file";
+			cat "$DB_SCHEMA_DIR/$version_A/$file" >> "$update_file";
+
+			#and now iterate again through all versions to add diffs 
+			#between previous versions and current one
+			for version_B in ${versions[*]}
+			do
+				#update from version_B should contain all db changes that appeared
+				#after #version_B (so version_A must be later)
+				if versionCompLt $version_B $version_A 
+				then
+					upd_file="$DBSCRIPT_DEST_DIR/db_${version_B}_to_${current_version}.sql";
+					printf "\n\n-- UPDATE $version_A/$file\n\n" >> "$upd_file";
+					cat "$DB_SCHEMA_DIR/$version_A/$file" >> "$upd_file";
+				fi
+			done
+		fi
+	done
+done
diff --git a/rpm/INSTALL.rst b/rpm/INSTALL.rst
new file mode 100644
index 0000000000000000000000000000000000000000..ec7de36f71d814c6093b35751b9849107f100646
--- /dev/null
+++ b/rpm/INSTALL.rst
@@ -0,0 +1,149 @@
+MINERVA installation instructions using RPM Package Manager
+===========================================================
+
+These instructions guide you through the installation process of
+`MINERVA <https://git-r3lab.uni.lu/piotr.gawron/minerva>`_ on Red Hat
+Enterprise Linux 7 or CentOS 7. The server will also host the database
+required for the functioning of MINERVA.
+
+.. note::
+
+   Content visualization of MINERVA platform is supported by Google
+   Maps API. Users of MINERVA platform are obliged to comply with the
+   `Google Maps/Google Earth APIs Terms of Service
+   <https://www.google.com/intl/en-US_US/help/terms_maps.html>`_.
+
+
+Overview
+--------
+
+The main steps are
+
+* Install `Oracle Java SE Development Kit 8 <http://www.oracle.com/technetwork/java/javase/downloads/index.html>`_.
+* Install `PostgreSQL <https://www.postgresql.org/>`_ and set up a
+  database.
+* Install and configure `Apache Tomcat <https://tomcat.apache.org/>`_.
+* Install the MINERVA RPM.
+
+
+Java SE Development Kit
+-----------------------
+
+Red Hat Enterprise Linux 7
+``````````````````````````
+
+Follow the instructions at https://access.redhat.com/solutions/732883
+to install ``java-1.8.0-oracle``.
+
+CentOS 7
+````````
+
+Follow the link for ``Java SE Development Kit 8`` at
+`<http://www.oracle.com/technetwork/java/javase/downloads/index.html>`_,
+download the latest RPM and install it with
+
+.. code:: shell
+
+    yum install -y jdk-8uXXX-linux-x64.rpm
+
+
+.. warning::
+
+    This way of installing Java does **not** ensure that security
+    updates are installed with ``yum update``, therefore you have to
+    establish a process to install such updates manually.
+
+
+PostgreSQL
+----------
+
+Install PostgreSQL and initialise it with
+
+.. code:: shell
+
+    yum install -y postgresql-server
+    postgresql-setup initdb
+
+Ensure that the database authentication on IPv4 on ``localhost`` is
+done with md5-based passwords by adding the following line to
+``/var/lib/pgsql/data/pg_hba.conf``
+
+.. code::
+
+    host    all             all             127.0.0.1/32            md5
+
+
+Enable and start postgresql
+
+.. code:: shell
+
+    systemctl enable postgresql
+    systemctl start postgresql
+
+Create the MINERVA database user and the database
+
+.. code:: shell
+
+    su - postgres -c "createuser -d -r -s map_viewer"
+    su - postgres -c "echo \"ALTER USER map_viewer WITH PASSWORD '123qweasdzxc';\"| psql"
+    su - postgres -c "createdb -O map_viewer map_viewer"
+
+.. warning::
+
+    Currently the password for the database user ``map_viewer`` is
+    hardcoded, therefore make sure the database cannot be accessed
+    from distrusted hosts.
+
+
+Apache Tomcat
+-------------
+
+Install and enable (don't start yet) Apache Tomcat with
+
+.. code:: shell
+
+    yum install -y tomcat
+    systemctl enable tomcat
+
+In ``/etc/sysconfig/tomcat``, adjust the memory settings, e.g.
+
+.. code::
+
+    JAVA_OPTS="-Xms2048M -Xmx4096M"
+
+Make sure to open the port (by default port 8080) to allow incoming
+connections, e.g. using ``firewalld`` this can be accomplished with
+
+.. code:: shell
+
+    firewall-cmd --zone=public --add-port=8080/tcp
+
+.. warning::
+
+    Currently the administrator password of MINERVA is hardcoded,
+    therefore make sure the MINERVA cannot be accessed from distrusted
+    hosts until the password was changed.
+
+MINERVA
+-------
+
+Install MINERVA using ``yum``
+
+.. code:: shell
+
+    yum install -y minerva-X.Y.Z-1.el7.centos.noarch.rpm
+
+and start tomcat
+
+.. code:: shell
+
+    systemctl start tomcat
+
+Now point your browser to the newly installed service, e.g. on a local
+network this could be `<http://192.168.0.42:8080/minerva/>`_.
+
+.. warning::
+
+    This way of installing MINERVA does **not** ensure that security
+    updates are installed with ``yum update``, therefore you have to
+    establish a process to install such updates manually.
diff --git a/rpm/buildrpm.sh b/rpm/buildrpm.sh
new file mode 100755
index 0000000000000000000000000000000000000000..eb3166272ad7a7d7dab709facd55f6340cfe7f32
--- /dev/null
+++ b/rpm/buildrpm.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+set -e
+
+MINERVA_SRC_DIR="$(dirname "$(dirname "$0")")"
+
+# where generated files will be written
+RPMBUILD_TEMP="${RPMBUILD_TEMP:-$MINERVA_SRC_DIR/rpm/rpmbuildtemp}"
+
+if [[ "$RPMBUILD_TEMP" =~ ' ' ]]; then
+    echo "RPMBUILD_TEMP contains whitespace: '$RPMBUILD_TEMP'"
+    echo "This is not allowed. Please provide a different directory to create the RPM with"
+    echo "    RPMBUILD_TEMP=/path/without/whitespace/ \"$0\""
+    exit 1
+fi
+
+# current date (for automatic changelog)
+CURDATE=$(date +"%a %b %d %Y")
+
+# file that should be deployed on tomcat
+TOMCAT_FILE="$MINERVA_SRC_DIR/web/target/web-1.0.war"
+
+# file with bash code generating DB schema diffs for different versions
+dbschemadiff="$MINERVA_SRC_DIR/management_scripts/db_schema_and_diff.sh"
+
+# directory with database schema
+DB_SCHEMA_DIR="$MINERVA_SRC_DIR/persist/src/db"
+
+# destination directory for database upgrade scripts
+DBSCRIPT_DEST_DIR="$RPMBUILD_TEMP/BUILD/sql"
+
+# clean build directories
+rm -rf "$RPMBUILD_TEMP"
+
+# create directory
+mkdir -p "$RPMBUILD_TEMP/"{BUILD,SPECS}
+
+# copy war file and other files
+cp "$TOMCAT_FILE" "$RPMBUILD_TEMP/BUILD/minerva.war"
+cp "$MINERVA_SRC_DIR/README.md" "$MINERVA_SRC_DIR/CHANGELOG" "$MINERVA_SRC_DIR/rpm/INSTALL.rst" "$MINERVA_SRC_DIR/rpm/logrotate_minerva" "$RPMBUILD_TEMP/BUILD"
+
+mkdir -p "$DBSCRIPT_DEST_DIR"
+# copy base sql schema
+cp "$DB_SCHEMA_DIR/base.sql" "$DBSCRIPT_DEST_DIR/db_0.sql"
+
+# set $versions and $current_version; generate upgrade scripts in DBSCRIPT_DEST_DIR
+source "$dbschemadiff"
+
+# create RPM spec file
+cp "$MINERVA_SRC_DIR/rpm/minerva.spec.in" "$RPMBUILD_TEMP/SPECS/minerva.spec"
+sed -i "s/__CURRENT_VERSION__/$current_version/g" "$RPMBUILD_TEMP/SPECS/minerva.spec"
+sed -i "s/__DATE__/$CURDATE/g" "$RPMBUILD_TEMP/SPECS/minerva.spec"
+
+# build RPM
+RPMBUILD_TEMP_ABS="$(readlink -f "$RPMBUILD_TEMP")"
+echo "****** Building miverva $current_version RPM in $RPMBUILD_TEMP_ABS ****** "
+set -x
+rpmbuild -bb --define "_topdir $RPMBUILD_TEMP_ABS" "$RPMBUILD_TEMP_ABS/SPECS/minerva.spec"
+set +x
+echo "****** Finished building RPM ****** "
diff --git a/rpm/logrotate_minerva b/rpm/logrotate_minerva
new file mode 100644
index 0000000000000000000000000000000000000000..001adf1a0734bbf445836bf465621a49565c98c2
--- /dev/null
+++ b/rpm/logrotate_minerva
@@ -0,0 +1,10 @@
+/var/log/tomcat/minerva.txt {
+  copytruncate
+  size 32k
+  weekly
+  dateext
+  rotate 52
+  compress
+  missingok
+  create 0640 tomcat tomcat
+}
diff --git a/rpm/minerva.spec.in b/rpm/minerva.spec.in
new file mode 100644
index 0000000000000000000000000000000000000000..2edcdf292154137850bb234c22e28361f72d51ac
--- /dev/null
+++ b/rpm/minerva.spec.in
@@ -0,0 +1,95 @@
+Name:           minerva
+Version:        __CURRENT_VERSION__
+Release:        1%{?dist}
+Summary:        Platform for visualization and curation of molecular interaction networks
+
+License:        AGPLv3
+URL:            http://r3lab.uni.lu/web/minerva-website/
+Source0:        https://git-r3lab.uni.lu/piotr.gawron/minerva/repository/archive.tar.gz?ref=v%{version}
+
+Requires:       tomcat, postgresql
+BuildArch:      noarch
+
+%description
+Web application for visualization, exploration and management of
+molecular networks encoded in SBGN-compliant format. The resource is
+used and managed via a webbrowser.
+
+%pre -p /bin/bash
+# check that postgres is started and tomcat is stopped, otherwise abort installation/upgrade
+if ! $(systemctl -q is-active postgresql); then
+    echo "postgresql not running, aborting installation/upgrade of minerva" >&2
+    exit -1
+fi
+if $(systemctl -q is-active tomcat); then
+    echo "tomcat is running, aborting installation/upgrade of minerva" >&2
+    exit -1
+fi
+# make sure the user `map_viewer` has the required permissions
+attributes_map_viewer=$(su - postgres -c "psql -F $'\t' --no-align -t -c '\du map_viewer'" | cut -f 2)
+if ! [[ $attributes_map_viewer == *"Superuser"* ]] || ! [[ $attributes_map_viewer == *"Create role"* ]] || ! [[ $attributes_map_viewer == *"Create DB"* ]]; then
+    echo "Postgres user map_viewer does not exist or does not have the required attributes." >&2
+    echo "Make sure to create map_viewer with the permission 'Superuser, Create role, Create DB'." >&2
+    echo "Attributes are: '$attributes_map_viewer'" >&2
+    echo "Aborting installation/upgrade of minerva." >&2
+    exit -1
+fi
+# make sure the database map_viewer exists
+if ! su - postgres -c "psql --dbname map_viewer -q -c '\q'" 2> /dev/null; then
+    echo "Database map_viewer does not exist, aborting installation/upgrade of minerva." >&2
+    exit -1
+fi
+
+%preun -p /bin/bash
+# save version information of the old package to make sure we run the correct DB-update script after installation
+if [ $1 == 1 ]; then
+    mkdir -p %{_sharedstatedir}/rpm-state/%{name}
+    echo -n %{version} > %{_sharedstatedir}/rpm-state/%{name}/OLD_VERSION
+fi
+
+%posttrans -p /bin/bash
+LOGFILE=%{_localstatedir}/log/minerva-install.log
+if [ -e %{_sharedstatedir}/rpm-state/%{name}/OLD_VERSION ]; then
+    OLD_VERSION=$(cat %{_sharedstatedir}/rpm-state/%{name}/OLD_VERSION)
+    echo $(date) "Upgrading minerva from $OLD_VERSION to %{version}" >> $LOGFILE
+    if [ ! -e %{_datadir}/%{name}/schema/db_${OLD_VERSION}_to_%{version}.sql ]; then
+        echo "ERROR: missing DB-update script %{_datadir}/%{name}/schema/db_${OLD_VERSION}_to_%{version}.sql" >&2
+        exit -1
+    fi
+    su - postgres -c "psql map_viewer -f %{_datadir}/%{name}/schema/db_${OLD_VERSION}_to_%{version}.sql" >> $LOGFILE 2>&1
+    rm -f %{_sharedstatedir}/rpm-state/%{name}/OLD_VERSION
+    rmdir %{_sharedstatedir}/rpm-state/%{name}
+else
+    echo $(date) "Installing minerva %{version}"  >> $LOGFILE
+    if [ $(su - postgres -c "psql --dbname map_viewer -F $'\t' --no-align -t -c '\dt'" | wc -l) -gt 51 ]; then
+        echo "The database map_viewer is not empty, aborting initialisation of database." >&2
+        echo "The database map_viewer is not empty, aborting initialisation of database." >> $LOGFILE
+        exit -1
+    fi
+    # install base version of the framework
+    su - postgres -c "psql map_viewer -f %{_datadir}/%{name}/schema/db_0.sql" >> $LOGFILE 2>&1
+    # install patch to current version
+    su - postgres -c "psql map_viewer -f %{_datadir}/%{name}/schema/db_0_to_%{version}.sql" >> $LOGFILE 2>&1
+fi
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/%{_datadir}/%{name}/schema
+install -m 0644 sql/*.sql %{buildroot}/%{_datadir}/%{name}/schema
+install -m 0644 %{name}.war %{buildroot}/%{_datadir}/%{name}/%{name}.war
+mkdir -p %{buildroot}/%{_sysconfdir}/logrotate.d
+install -m 0644 logrotate_minerva %{buildroot}/%{_sysconfdir}/logrotate.d/minerva
+mkdir -p %{buildroot}/%{_sharedstatedir}/tomcat/webapps
+ln -s %{_datadir}/%{name}/%{name}.war %{buildroot}/%{_sharedstatedir}/tomcat/webapps/
+
+%files
+%defattr(-,root,root,-)
+%doc README.md CHANGELOG INSTALL.rst
+%{_datadir}/%{name}/%{name}.war
+%{_datadir}/%{name}/schema/*
+%config(noreplace) %{_sysconfdir}/logrotate.d/minerva
+%attr(-,tomcat,tomcat) %{_sharedstatedir}/tomcat/webapps/%{name}.war
+
+%changelog
+* __DATE__ - %{version}-%{release}
+- Automatically packaged