[csw-devel] SF.net SVN: gar:[12552] csw/mgar/gar/v2-uwatch2

wbonnet at users.sourceforge.net wbonnet at users.sourceforge.net
Sun Jan 16 00:08:02 CET 2011


Revision: 12552
          http://gar.svn.sourceforge.net/gar/?rev=12552&view=rev
Author:   wbonnet
Date:     2011-01-15 23:08:02 +0000 (Sat, 15 Jan 2011)

Log Message:
-----------
Fix sql date and return value check

Modified Paths:
--------------
    csw/mgar/gar/v2-uwatch2/bin/uwatch
    csw/mgar/gar/v2-uwatch2/gar.lib.mk

Modified: csw/mgar/gar/v2-uwatch2/bin/uwatch
===================================================================
--- csw/mgar/gar/v2-uwatch2/bin/uwatch	2011-01-15 17:24:47 UTC (rev 12551)
+++ csw/mgar/gar/v2-uwatch2/bin/uwatch	2011-01-15 23:08:02 UTC (rev 12552)
@@ -1193,6 +1193,11 @@
                 if self.configParser.getVerbose() == True:
                     print "Package %(pkg)s has been undeleted" % { 'pkg' : self.configParser.getCatalogName() }
 
+            # Test if the package has just been created. If yes the history line for gar version has to be inserted
+            if isNewlyCreatedPackage:
+                cursor.execute("insert into UWATCH_VERSION_HISTORY ( ID_PKG , HIST_VERSION_TYPE , HIST_VERSION_VALUE , HIST_VERSION_DATE ) \
+                                values ( %s, %s, %s, %s)" , ( pkg["ID_PKG"], "gar", self.configParser.getGarVersion() , self.configParser.getExecutionDate() ) )
+
             # Test if current version is passed
             if self.configParser.getCurrentVersion():
                 # In all cases (update or not) we update the last version check according to the argument
@@ -1293,8 +1298,6 @@
         if self.configParser.getExecutionDate() == None:
             print "Error : Execution date is not defined. Please use --execution-date flag, or --help to display help"
             argsValid = False
-#        else:
-#            dt = datetime.strptime(self.configParser.getExecutionDate(), "%d/%m/%y")
 
         # Gar version is mandatory, other version are optional. Gar the version is the only mandatory in the database
         # It has to be passed in argument in case the package does not exist yet
@@ -1421,7 +1424,11 @@
         # The first element in the arguments array is the action verb. Retrieve the command
         # using action verb as key
         if self.commandArray.has_key(arguments[0]):
-            return self.commandArray[arguments[0]].execute(opts, arguments)
+            res =  self.commandArray[arguments[0]].execute(opts, arguments)
+            if res:
+                return 0
+            else:
+                return 1
         else:
             print "Error : %(action)s action is not supported" % { 'action' : arguments[0] }
             return 2
@@ -1449,5 +1456,6 @@
 
 # Exit with main return code
 if __name__ == '__main__':
-    sys.exit(main())
+    res = main()
+    sys.exit(res)
 

Modified: csw/mgar/gar/v2-uwatch2/gar.lib.mk
===================================================================
--- csw/mgar/gar/v2-uwatch2/gar.lib.mk	2011-01-15 17:24:47 UTC (rev 12551)
+++ csw/mgar/gar/v2-uwatch2/gar.lib.mk	2011-01-15 23:08:02 UTC (rev 12552)
@@ -234,23 +234,27 @@
 	@if [ '$(ENABLE_UWATCH)' -ne '1' ] ; then \
 		echo "$(NAME) - Upstream Watch is disabled" ; \
 	else \
+		UWATCHCONFCHECK="Ok" ; \
 		if [ ! -n '$(UFILES_REGEX)' ]; then \
 			echo "$(NAME) - Error UFILES_REGEX is not set" ; \
-			false; \
+			UWATCHCONFCHECK="Error" ; \
 		fi; \
 		if [ ! -n '$(UPSTREAM_MASTER_SITES)' ]; then \
 			echo "$(NAME) - Error UPSTREAM_MASTER_SITES is not set" ; \
-			false; \
+			UWATCHCONFCHECK="Error" ; \
 		fi; \
 		if [ ! -n '$(VERSION)' ]; then \
 			echo "$(NAME) - Error VERSION is not set" ; \
-			false; \
+			UWATCHCONFCHECK="Error" ; \
 		fi; \
+		if [ "$$UWATCHCONFCHECK" -ne "Ok" ] ; then \
+			exit 1 ; \
+		fi ; \
 		VERSIONLIST=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch get-upstream-version-list --upstream-url="$(UPSTREAM_MASTER_SITES)" --regexp="$(UFILES_REGEX)"` ; \
-		if [ "#?" -ne "0" ] ; then \
-			echo "Error occured while executing uwatch get-upstream-version-list. Please check configuration with target get-uwatch-configuration" ; \
+		if [ "$$?" -ne "0" ] ; then \
+			echo "Error occured while executing uwatch. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
 			echo "Output : $$VERSIONLIST" ; \
-			false ; \
+			exit 1 ; \
 		fi; \
 		if [ -n "$$VERSIONLIST" ] ; then \
 			for VERSION in $$VERSIONLIST ; do \
@@ -270,23 +274,27 @@
 	@if [ '$(ENABLE_UWATCH)' -ne '1' ] ; then \
 		echo "$(NAME) - Upstream Watch is disabled" ; \
 	else \
+		UWATCHCONFCHECK="Ok" ; \
 		if [ ! -n '$(UFILES_REGEX)' ]; then \
 			echo "$(NAME) - Error UFILES_REGEX is not set" ; \
-			false; \
+			UWATCHCONFCHECK="Error" ; \
 		fi; \
 		if [ ! -n '$(UPSTREAM_MASTER_SITES)' ]; then \
 			echo "$(NAME) - Error UPSTREAM_MASTER_SITES is not set" ; \
-			false; \
+			UWATCHCONFCHECK="Error" ; \
 		fi; \
 		if [ ! -n '$(VERSION)' ]; then \
 			echo "$(NAME) - Error VERSION is not set" ; \
-			false; \
+			UWATCHCONFCHECK="Error" ; \
 		fi; \
+		if [ "$$UWATCHCONFCHECK" -ne "Ok" ] ; then \
+			exit 1 ; \
+		fi ; \
 		LATEST=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch get-upstream-latest-version --upstream-url="$(UPSTREAM_MASTER_SITES)" --regexp="$(UFILES_REGEX)"` ; \
-		if [ "#?" -ne "0" ] ; then \
-			echo "Error occured while executing uwatch get-upstream-latest-version. Please check configuration with target get-uwatch-configuration" ; \
-			echo "Output : $$LATEST" ; \
-			false ; \
+		if [ "$$?" -ne "0" ] ; then \
+			echo "Error occured while executing uwatch. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
+			echo "$$LATEST" ; \
+			exit 1 ; \
 		fi; \
 		if [ -n "$$LATEST" ] ; then \
 			echo "$(NAME) - Latest upstream version is $$LATEST" ; \
@@ -302,23 +310,27 @@
 	@if [ '$(ENABLE_UWATCH)' -ne '1' ] ; then \
 		echo "$(NAME) - Upstream Watch is disabled" ; \
 	else \
+		UWATCHCONFCHECK="Ok" ; \
 		if [ ! -n '$(UFILES_REGEX)' ]; then \
 			echo "$(NAME) - Error UFILES_REGEX is not set" ; \
-			false; \
+			UWATCHCONFCHECK="Error" ; \
 		fi; \
 		if [ ! -n '$(UPSTREAM_MASTER_SITES)' ]; then \
 			echo "$(NAME) - Error UPSTREAM_MASTER_SITES is not set" ; \
-			false; \
+			UWATCHCONFCHECK="Error" ; \
 		fi; \
 		if [ ! -n '$(VERSION)' ]; then \
 			echo "$(NAME) - Error VERSION is not set" ; \
-			false; \
+			UWATCHCONFCHECK="Error" ; \
 		fi; \
+		if [ "$$UWATCHCONFCHECK" -ne "Ok" ] ; then \
+			exit 1 ; \
+		fi ; \
 		LATEST=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch check-upstream --upstream-url="$(UPSTREAM_MASTER_SITES)" --regexp="$(UFILES_REGEX)" --current-version="$(VERSION)"` ; \
-		if [ "#?" -ne "0" ] ; then \
-			echo "Error occured while executing uwatch check-upstream. Please check configuration with target get-uwatch-configuration" ; \
-			echo "Output : $$LATEST" ; \
-			false ; \
+		if [ "$$?" -ne "0" ] ; then \
+			echo "Error occured while executing uwatch. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
+			echo "$$LATEST" ; \
+			exit 1 ; \
 		fi; \
 		if [ -n "$$LATEST" ] ; then \
 			echo "$(NAME) : A new version of upstream files is available. Package can be upgraded from version $(VERSION) to $$LATEST"; \
@@ -332,37 +344,40 @@
 # Create upgrade branch from current to latest upstream
 #
 upgrade-to-latest-upstream:
-	echo "In upgrade-to-latest-upstream" ; \
-	if [ '$(ENABLE_UWATCH)' -ne '1' ] ; then \
+	@if [ '$(ENABLE_UWATCH)' -ne '1' ] ; then \
 		echo "$(NAME) - Upstream Watch is disabled" ; \
 	else \
+		UWATCHCONFCHECK="Ok" ; \
 		if [ ! -n '$(UFILES_REGEX)' ]; then \
 			echo "$(NAME) - Error UFILES_REGEX is not set" ; \
-			false; \
+			UWATCHCONFCHECK="Error" ; \
 		fi; \
 		if [ ! -n '$(UPSTREAM_MASTER_SITES)' ]; then \
 			echo "$(NAME) - Error UPSTREAM_MASTER_SITES is not set" ; \
-			false; \
+			UWATCHCONFCHECK="Error" ; \
 		fi; \
 		if [ ! -n '$(VERSION)' ]; then \
 			echo "$(NAME) - Error VERSION is not set" ; \
-			false; \
+			UWATCHCONFCHECK="Error" ; \
 		fi; \
+		if [ "$$UWATCHCONFCHECK" -ne "Ok" ] ; then \
+			exit 1 ; \
+		fi ; \
 		LATEST=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch check-upstream --upstream-url="$(UPSTREAM_MASTER_SITES)" --regexp="$(UFILES_REGEX)" --current-version="$(VERSION)"` ; \
-		if [ "#?" -ne "0" ] ; then \
-			echo "Error occured while executing uwatch check-upstream. Please check configuration with target get-uwatch-configuration" ; \
-			echo "Output : $$LATEST" ; \
-			false ; \
+		if [ "$$?" -ne "0" ] ; then \
+			echo "Error occured while executing uwatch. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
+			echo "$$LATEST" ; \
+			exit 1 ; \
 		fi; \
 		if [ ! -f "$(COOKIEDIR)/upgrade-to-latest-upstream-$$LATEST" ] ; then \
 			if [ ! -d "../branches/upgrade_from_$(VERSION)_to_$$LATEST" ] ; then \
 				if [ -n "$$LATEST" ] ; then \
 					echo "$(NAME) : a new version of upstream files is available. Creating upgrade branch from version $(VERSION) to $$LATEST"; \
 					VERSIONUPGRADE=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch upgrade-to-version --current-version="$(VERSION)" --target-version="$$LATEST"` ; \
-					if [ "#?" -ne "0" ] ; then \
-						echo "Error occured while executing uwatch check-upstream. Please check configuration with target get-uwatch-configuration" ; \
-						echo "Output : $$LATEST" ; \
-						false ; \
+					if [ "$$?" -ne "0" ] ; then \
+						echo "Error occured while executing uwatch. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
+						echo "$$VERSIONUPGRADE" ; \
+						exit 1 ; \
 					fi; \
 					if [ -n "$$VERSIONUPGRADE" ] ; then \
 						echo "$(NAME) - $$VERSIONUPGRADE" ; \
@@ -381,11 +396,53 @@
 
 
 ########################################################
+# Create upgrade branch from current to latest upstream
 #
+report-package-version:
+	if [ '$(ENABLE_UWATCH)' -ne '1' ] ; then \
+		echo "$(NAME) - Upstream Watch is disabled" ; \
+	else \
+		UWATCHCONFCHECK="Ok" ; \
+		if [ ! -n '$(UFILES_REGEX)' ]; then \
+			echo "$(NAME) - Error UFILES_REGEX is not set" ; \
+			UWATCHCONFCHECK="Error" ; \
+		fi; \
+		if [ ! -n '$(UPSTREAM_MASTER_SITES)' ]; then \
+			echo "$(NAME) - Error UPSTREAM_MASTER_SITES is not set" ; \
+			UWATCHCONFCHECK="Error" ; \
+		fi; \
+		if [ ! -n '$(VERSION)' ]; then \
+			echo "$(NAME) - Error VERSION is not set" ; \
+			UWATCHCONFCHECK="Error" ; \
+		fi; \
+		if [ "$$UWATCHCONFCHECK" -ne "Ok" ] ; then \
+			exit 1 ; \
+		fi ; \
+		LATEST=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch get-upstream-latest-version --upstream-url="$(UPSTREAM_MASTER_SITES)" --regexp="$(UFILES_REGEX)"` ; \
+		if [ "$$?" -ne "0" ] ; then \
+			echo "Error occured while executing uwatch. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
+			echo "$$LATEST" ; \
+			exit 1 ; \
+		fi; \
+		EXECUTIONDATE=`date +"%Y-%m-%d %H:%M:%S"` ; \
+		REPORTVERSION=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch report-package-version --catalog-name=firefox --package-name=CSWthunderbird --execution-date="$$EXECUTIONDATE" --gar-path=pkg/thunderbird/trunk --gar-version=$(VERSION) --upstream-version=$$LATEST --database-host=hastur --database-user=root --database-password=root --database-schema=spmtcsw"` ; \
+		if [ "$$?" -ne "0" ] ; then \
+			echo "Error occured while executing uwatch. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
+			echo "$$REPORTVERSION" ; \
+			exit 1 ; \
+		fi; \
+		if [ -n "$$REPORTVERSION" ] ; then \
+			echo "$(NAME) - $$REPORTVERSION" ; \
+		fi ; \
+	fi
+
+
+########################################################
+#
 get-gar-version:
 	@if [ ! -n '$(VERSION)' ]; then \
 		echo "$(NAME) - VERSION is not defined" ; \
-		false; \
+		exit 1 ; \
 	else \
 		echo "$(NAME) - GAR version is $(VERSION)" ; \
 	fi ;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


More information about the devel mailing list