rpms/ocsinventory/F-9 ocsinventory-r1423.patch, NONE, 1.1 ocsinventory.spec, 1.3, 1.4

Remi Collet remi at fedoraproject.org
Fri Oct 17 17:33:26 UTC 2008


Author: remi

Update of /cvs/extras/rpms/ocsinventory/F-9
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv18879

Modified Files:
	ocsinventory.spec 
Added Files:
	ocsinventory-r1423.patch 
Log Message:
add migration patch from upstream

ocsinventory-r1423.patch:

--- NEW FILE ocsinventory-r1423.patch ---
--- trunk/server/ocsreports/install.php	2008/03/04 17:07:55	1108
+++ trunk/server/ocsreports/install.php	2008/10/16 15:56:16	1423
@@ -94,15 +94,15 @@
 	else
 		$instOk = true;
 }
-if( ! $instOk ) {
+if( $hnd = @fopen("dbconfig.inc.php", "r") ) {
+		fclose($hnd);
+		require("dbconfig.inc.php");
+		$valNme = $_SESSION["COMPTE_BASE"];
+		$valPass = $_SESSION["PSWD_BASE"];
+		$valServ = $_SESSION["SERVEUR_SQL"];
+}
 
-	if( $hnd = @fopen("dbconfig.inc.php", "r") ) {
-			fclose($hnd);
-			require("dbconfig.inc.php");
-			$valNme = $_SESSION["COMPTE_BASE"];
-			$valPass = $_SESSION["PSWD_BASE"];
-			$valServ = $_SESSION["SERVEUR_SQL"];
-	}
+if( ! $instOk ) {
 
 	echo "<br><form name='fsub' action='install.php' method='POST'><table width='100%'>
 	<tr>
@@ -162,7 +162,8 @@
 }
 
 if($_POST["fin"]=="fin") {
-	if(!@mysql_connect($_POST["host"],"ocs","ocs")) {
+	// Configuration done, so try with account from config file
+	if(!@mysql_connect($valServ,$valNme,$valPass)) {
 		if(mysql_errno()==0) {
 			echo "<br><center><font color=red><b>ERROR: MySql authentication problem. You must add the 'old-passwords' in your mysql configuration file (my.ini). Then restart mysql, and relaunch install.php</b><br></font></center>";
 			die();
@@ -185,10 +186,7 @@
 	die();
 }
 
-fwrite($ch,"<?php \n\$_SESSION[\"SERVEUR_SQL\"]=\"".$_POST["host"]."\";\n\$_SESSION[\"COMPTE_BASE\"]=\"ocs\";\n\$_SESSION[\"PSWD_BASE\"]=\"ocs\";\n?>");
-fclose($ch);
-
-echo "<br><center><font color=green><b>MySql config file successfully written</b></font></center>";
+$keepuser=false;
 
 $db_file = "files/ocsbase.sql";
 if($dbf_handle = @fopen($db_file, "r")) {
@@ -201,7 +199,12 @@
 	foreach ( explode(";", "$sql_query") as $sql_line) {
 		$li++;
 		if(!mysql_query($sql_line)) {
-			if(  mysql_errno()==1062 || mysql_errno()==1061 || mysql_errno()==1044 || mysql_errno()==1065 || mysql_errno()==1060 || mysql_errno()==1054 || mysql_errno()==1091 || mysql_errno()==1061) 
+			if (mysql_errno()==1044 && strpos($sql_line, "GRANT ALL")!==false) {
+				// Provided user not MySQL Administror
+				$keepuser=true;
+				continue;
+			}
+			if(  mysql_errno()==1062 || mysql_errno()==1061 || mysql_errno()==1065 || mysql_errno()==1060 || mysql_errno()==1054 || mysql_errno()==1091 || mysql_errno()==1061) 
 				continue;		
 
 			if(  mysql_errno()==1071 ) {
@@ -230,6 +233,19 @@
 	die();
 }
 
+if ($keepuser) {
+	// Provided user not MySQL Administror
+	// Keep the account used for migration
+	fwrite($ch,"<?php \n\$_SESSION[\"SERVEUR_SQL\"]=\"".$_POST["host"]."\";\n\$_SESSION[\"COMPTE_BASE\"]=\"".$_POST["name"]."\";\n\$_SESSION[\"PSWD_BASE\"]=\"".$_POST["pass"]."\";\n?>");
+	fclose($ch);
+	echo "<br><center><font color=green><b>MySql config file successfully written (using ".$_POST["name"]." account)</b></font></center>";
+} else {
+	// Use account created during installation
+	fwrite($ch,"<?php \n\$_SESSION[\"SERVEUR_SQL\"]=\"".$_POST["host"]."\";\n\$_SESSION[\"COMPTE_BASE\"]=\"ocs\";\n\$_SESSION[\"PSWD_BASE\"]=\"ocs\";\n?>");
+	fclose($ch);
+	echo "<br><center><font color=green><b>MySql config file successfully written (using new ocs account)</b></font></center>";
+}
+
 if($dejaLance>0)	
 	echo "<br><center><font color=green><b>Existing database updated</b></font></center>";
 	


Index: ocsinventory.spec
===================================================================
RCS file: /cvs/extras/rpms/ocsinventory/F-9/ocsinventory.spec,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ocsinventory.spec	11 Oct 2008 16:52:32 -0000	1.3
+++ ocsinventory.spec	17 Oct 2008 17:32:55 -0000	1.4
@@ -10,7 +10,7 @@
 Summary:     Open Computer and Software Inventory Next Generation
 
 Version:     1.02
-Release:     0.8.rc3%{?dist}.1
+Release:     0.9.rc3%{?dist}
 
 Group:       Applications/Internet
 License:     GPLv2
@@ -19,9 +19,14 @@
 Source0:     http://downloads.sourceforge.net/%{name}/%{tarname}.tar.gz
 Source1:     ocsinventory-reports.conf
 
+# Database Schema
 # http://ocsinventory.svn.sourceforge.net/viewvc/ocsinventory/trunk/server/ocsreports/files/ocsbase.sql?r1=1390&r2=1413&view=patch
 Patch0:      ocsinventory-r1413.patch
 
+# Update Script
+# http://ocsinventory.svn.sourceforge.net/viewvc/ocsinventory/trunk/server/ocsreports/install.php?r1=1108&r2=1423&view=patch
+Patch1:      ocsinventory-r1423.patch
+
 BuildArch:   noarch
 BuildRoot:   %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: perl(ExtUtils::MakeMaker)
@@ -124,6 +129,7 @@
 %setup -q -n %{tarname}
 
 %patch0 -p2
+%patch1 -p2
 
 
 %build
@@ -270,8 +276,11 @@
 
 
 %changelog
+* Fri Oct 17 2008 Remi Collet <Fedora at famillecollet.com> 1.02-0.9.rc3
+- upstream r1423 patch - migration script
+
 * Sat Oct 11 2008 Remi Collet <Fedora at famillecollet.com> 1.02-0.8.rc3
-- last minute patch
+- upstream r1413 patch - database schema
 
 * Sat Oct 11 2008 Remi Collet <Fedora at famillecollet.com> 1.02-0.7.rc3
 - update to RC3




More information about the fedora-extras-commits mailing list