From 40f9ef7de4761d169eb59ec367a38bc15ad52d69 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Mon, 1 Oct 2018 11:15:59 +0200
Subject: [PATCH] current version is properly extracted from changelog

---
 debian/create-debian-pkg.sh              | 19 +++----------------
 management_scripts/db_schema_and_diff.sh |  5 -----
 2 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/debian/create-debian-pkg.sh b/debian/create-debian-pkg.sh
index c57b331479..f56f8a9e04 100755
--- a/debian/create-debian-pkg.sh
+++ b/debian/create-debian-pkg.sh
@@ -58,18 +58,11 @@ DBSCRIPT_DEST_DIR=$SRC_DIR
 MAX_DB_VERSION_FOR_MIGRTION=12.1.0~alpha
 source $dbschemadiff
 
+current_version=`cat CHANGELOG |grep minerva |head -1 | cut -f2 -d'(' | cut -f1 -d')'`
+
 echo "Current version: " $current_version
 echo "Flyway was introduced in version: " $MAX_DB_VERSION_FOR_MIGRTION
 
-# check if the changelog contains info about new version
-tmpVar=`cat debian/template/changelog | grep "minerva ($current_version)"|wc -l`
-if [ $tmpVar -eq "0" ] 
-then
-	echo "Invalid changelog file. Please modify debian/template/changelog to contain information about current version";
-	e-n xit 1;
-fi
-
-
 #default connection params (if /etc/minerva/db.properties is not defined)
 DB_HOST=`cat persist/src/main/resources/db.properties |grep "uri" |cut -f3 -d"/" |cut -f1 -d":"`
 DB_PORT=`cat persist/src/main/resources/db.properties |grep "uri" |cut -f3 -d"/" |cut -f2 -d":"`
@@ -97,9 +90,6 @@ 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 "minerva_$current_version-1_all.deb science optional" > debian/files
-#pwd
-#echo "minerva_$current_version-1_all.deb science optional > debian/files"
 echo "1.0" > debian/source/format
 
 #remove example files generated by dh_make
@@ -134,10 +124,7 @@ sed -i -e "1r common.sh" debian/prerm
 echo db_0_to_$MAX_DB_VERSION_FOR_MIGRTION".sql" /usr/share/minerva/schema >> debian/install
 for version in ${versions[*]}
 do
-	if [ "$version" != "$current_version" ]
-	then
-		echo db_"$version"_to_$MAX_DB_VERSION_FOR_MIGRTION".sql" /usr/share/minerva/schema >> debian/install;
-	fi
+	echo db_"$version"_to_$MAX_DB_VERSION_FOR_MIGRTION".sql" /usr/share/minerva/schema >> debian/install;
 done
 
 #set proper architecture
diff --git a/management_scripts/db_schema_and_diff.sh b/management_scripts/db_schema_and_diff.sh
index 918415cd5a..6f1cfcbe5e 100644
--- a/management_scripts/db_schema_and_diff.sh
+++ b/management_scripts/db_schema_and_diff.sh
@@ -10,16 +10,12 @@
 
 # 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
 versionCompLte() {
     [  "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
@@ -37,7 +33,6 @@ do
 		then
 			versions+=($version);
 		fi
-		current_version=$version;
 	fi
 done
 
-- 
GitLab