gforge-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gforge-commits] gforge/rpm-specific/patches gforge-4.0-deb_rpm.patch, N


From: gsmet
Subject: [Gforge-commits] gforge/rpm-specific/patches gforge-4.0-deb_rpm.patch, NONE, 1.1
Date: Mon, 01 Nov 2004 13:18:00 -0600

Update of /cvsroot/gforge/gforge/rpm-specific/patches
In directory db.perdue.net:/tmp/cvs-serv2517/patches

Added Files:
        gforge-4.0-deb_rpm.patch 
Log Message:
preliminary work on new RPM packages


--- NEW FILE: gforge-4.0-deb_rpm.patch ---
diff -u gforge/deb-specific/db-upgrade.pl gforge-rpm/deb-specific/db-upgrade.pl
--- gforge/deb-specific/db-upgrade.pl   2004-10-31 20:12:10.000000000 +0100
+++ gforge-rpm/deb-specific/db-upgrade.pl       2004-11-01 19:44:21.000000000 
+0100
@@ -1595,7 +1595,7 @@
     $target = "3.3.0-2+1" ;
     if (&is_lesser ($version, $target)) {
         &debug ("Upgrading with migrateforum.php") ;
-       system("/usr/lib/gforge/db/20040826_migrateforum.php -d 
include_path=/usr/share/gforge/:/usr/share/gforge/www/include") == 0 
+       system("php -q -d 
include_path=/usr/share/gforge/:/usr/share/gforge/www/include 
/usr/lib/gforge/db/20040826_migrateforum.php") == 0 
        or die "system call of 20040826_migrateforum.php failed: $?" ;
         &update_db_version ($target) ;
         &debug ("Committing.") ;
@@ -1606,32 +1606,32 @@
     $target = "3.3.0-2+2" ;
     if (&is_lesser ($version, $target)) {
         &debug ("Upgrading with migraterbac.php") ;
-       system("/usr/lib/gforge/db/20040826_migraterbac.php -d 
include_path=/usr/share/gforge/:/usr/share/gforge/www/include") == 0
+       system("php -q -d 
include_path=/usr/share/gforge/:/usr/share/gforge/www/include 
/usr/lib/gforge/db/20040826_migraterbac.php") == 0
        or die "system call of 20040826_migraterbac.php failed: $?" ;
         &update_db_version ($target) ;
         &debug ("Committing.") ;
         $dbh->commit () ;
     }
 
-    $version = &get_db_version ;
-    $target = "3.3.0-2+3" ;
-    if (&is_lesser ($version, $target)) {
-        &debug ("Upgrading with 20041001.sql") ;
-
-        @reqlist = @{ &parse_sql_file ("/usr/lib/gforge/db/20041001.sql") } ;
-        foreach my $s (@reqlist) {
-            $query = $s ;
-            # debug $query ;
-            $sth = $dbh->prepare ($query) ;
-            $sth->execute () ;
-            $sth->finish () ;
-        }
-        @reqlist = () ;
-
-        &update_db_version ($target) ;
-        &debug ("Committing.") ;
-        $dbh->commit () ;
-    }
+#    $version = &get_db_version ;
+#    $target = "3.3.0-2+3" ;
+#    if (&is_lesser ($version, $target)) {
+#        &debug ("Upgrading with 20041001.sql") ;
+#
+#        @reqlist = @{ &parse_sql_file ("/usr/lib/gforge/db/20041001.sql") } ;
+#        foreach my $s (@reqlist) {
+#            $query = $s ;
+#            # debug $query ;
+#            $sth = $dbh->prepare ($query) ;
+#            $sth->execute () ;
+#            $sth->finish () ;
+#        }
+#        @reqlist = () ;
+#
+#        &update_db_version ($target) ;
+#        &debug ("Committing.") ;
+#        $dbh->commit () ;
+#    }
 
     $version = &get_db_version ;
     $target = "3.3.0-2+4" ;
@@ -1755,62 +1755,62 @@
         $dbh->commit () ;
     }
 
-    $version = &get_db_version ;
-    $target = "4.0.0-0+1" ;
-    if (&is_lesser ($version, $target)) {
-        &debug ("Granting read access permissions to NSS") ;
-
-        @reqlist = ( "GRANT SELECT ON nss_passwd TO gforge_nss",
-                    "GRANT SELECT ON nss_groups TO gforge_nss",
-                    "GRANT SELECT ON nss_usergroups TO gforge_nss",
-                   ) ;
-        foreach my $s (@reqlist) {
-            $query = $s ;
-            # debug $query ;
-            $sth = $dbh->prepare ($query) ;
-            $sth->execute () ;
-            $sth->finish () ;
-        }
-        @reqlist = () ;
-
-        &update_db_version ($target) ;
-        &debug ("Committing.") ;
-        $dbh->commit () ;
-    }
-
-    $version = &get_db_version ;
-    $target = "4.0.0-0+2" ;
-    if (&is_lesser ($version, $target)) {
-        &debug ("Upgrading with 20041031.sql") ;
-
-        @reqlist = @{ &parse_sql_file ("/usr/lib/gforge/db/20041031.sql") } ;
-        foreach my $s (@reqlist) {
-            $query = $s ;
-            # debug $query ;
-            $sth = $dbh->prepare ($query) ;
-            $sth->execute () ;
-            $sth->finish () ;
-        }
-        @reqlist = () ;
-
-        &debug ("Granting read access permissions to NSS") ;
-
-        @reqlist = ( "GRANT SELECT ON mta_users TO gforge_mta",
-                    "GRANT SELECT ON mta_lists TO gforge_mta",
-                   ) ;
-        foreach my $s (@reqlist) {
-            $query = $s ;
-            # debug $query ;
-            $sth = $dbh->prepare ($query) ;
-            $sth->execute () ;
-            $sth->finish () ;
-        }
-        @reqlist = () ;
-
-        &update_db_version ($target) ;
-        &debug ("Committing.") ;
-        $dbh->commit () ;
-    }
+#    $version = &get_db_version ;
+#    $target = "4.0.0-0+1" ;
+#    if (&is_lesser ($version, $target)) {
+#        &debug ("Granting read access permissions to NSS") ;
+#
+#        @reqlist = ( "GRANT SELECT ON nss_passwd TO gforge_nss",
+#                   "GRANT SELECT ON nss_groups TO gforge_nss",
+#                   "GRANT SELECT ON nss_usergroups TO gforge_nss",
+#                  ) ;
+#        foreach my $s (@reqlist) {
+#            $query = $s ;
+#            # debug $query ;
+#            $sth = $dbh->prepare ($query) ;
+#            $sth->execute () ;
+#            $sth->finish () ;
+#        }
+#        @reqlist = () ;
+#
+#        &update_db_version ($target) ;
+#        &debug ("Committing.") ;
+#        $dbh->commit () ;
+#    }
+
+#    $version = &get_db_version ;
+#    $target = "4.0.0-0+2" ;
+#    if (&is_lesser ($version, $target)) {
+#        &debug ("Upgrading with 20041031.sql") ;
+#
+#        @reqlist = @{ &parse_sql_file ("/usr/lib/gforge/db/20041031.sql") } ;
+#        foreach my $s (@reqlist) {
+#            $query = $s ;
+#            # debug $query ;
+#            $sth = $dbh->prepare ($query) ;
+#            $sth->execute () ;
+#            $sth->finish () ;
+#        }
+#        @reqlist = () ;
+#
+#        &debug ("Granting read access permissions to NSS") ;
+#
+#        @reqlist = ( "GRANT SELECT ON mta_users TO gforge_mta",
+#                   "GRANT SELECT ON mta_lists TO gforge_mta",
+#                  ) ;
+#        foreach my $s (@reqlist) {
+#            $query = $s ;
+#            # debug $query ;
+#            $sth = $dbh->prepare ($query) ;
+#            $sth->execute () ;
+#            $sth->finish () ;
+#        }
+#        @reqlist = () ;
+#
+#        &update_db_version ($target) ;
+#        &debug ("Committing.") ;
+#        $dbh->commit () ;
+#    }
 
     &debug ("It seems your database $action went well and smoothly.  That's 
cool.") ;
     &debug ("Please enjoy using Gforge.") ;
@@ -1843,7 +1843,7 @@
 $dbh->disconnect ;
 
 sub get_pg_version () {
-    my $command = q(dpkg -s postgresql | awk '/^Version: / { print $2 }') ;
+    my $command = q(rpm -q --qf %{VERSION} postgresql) ;
     my $version = qx($command) ;
     chomp $version ;
     return $version ;
diff -u gforge/deb-specific/sqlhelper.pm gforge-rpm/deb-specific/sqlhelper.pm
--- gforge/deb-specific/sqlhelper.pm    2004-05-16 18:54:58.000000000 +0200
+++ gforge-rpm/deb-specific/sqlhelper.pm        2004-11-01 19:37:26.000000000 
+0100
@@ -264,18 +264,98 @@
     my $v1 = shift || 0 ;
     my $v2 = shift || 0 ;
 
-    my $rc = system "dpkg --compare-versions $v1 lt $v2" ;
+    my $rc = cmp_version($v1, $v2, 0);
 
-    return (! $rc) ;
+    return ($rc) ;
 }
 
 sub is_greater ( $$ ) {
     my $v1 = shift || 0 ;
     my $v2 = shift || 0 ;
 
-    my $rc = system "dpkg --compare-versions $v1 gt $v2" ;
+    my $rc = cmp_version($v1, $v2, 1);
 
     return (! $rc) ;
 }
 
+#-------------------------------------------------------
+# FUNCTION: cmp_version (STRING, STRING)
+#
+# Compares complete version numbers ala epoch:upstream-debian
+# and returns true if the first version string is greater
+# than the second.
+#
+# Copyright (C) 2001 Christoph Martin
+# http://www.uni-mainz.de/~martin/apt-show-versions
+#--------------------------------------------------------
+
+# recursive function to compare upstream or debian version part
+
+sub compare {
+    my ($first, $last) = @_;
+
+    # equal if both are empty
+    return (0) unless ($first ne "" || $last ne "");
+
+    # parse next version string part and set numerical part to 0 if empty
+    my ($nondig1, $dig1, $remainder1) = ($first =~ /^(\D*)?(\d*)(.*)?/);
+    $dig1 = 0 unless ($dig1 ne "");
+    my ($nondig2, $dig2, $remainder2) = ($last =~ /^(\D*)?(\d*)(.*)?/);
+    $dig2 = 0 unless ($dig2 ne "");
+
+    return ($nondig1 cmp $nondig2) unless ($nondig1 eq $nondig2);
+    return ($dig1 <=> $dig2) unless ($dig1 == $dig2);
+    return compare($remainder1, $remainder2);
+}
+
+sub cmp_version {
+    my ($first, $last, $strict) = @_;
+
+    # parse version number in epoch:upstream-debian and set to 0 if empty
+    my ($first_epoch,
+       $first_upstream,
+       $first_debian) = ($first =~ /^(.*:)?(.*?)(-.*)?$/);
+    $first_epoch = "0:" unless defined $first_epoch;
+    $first_debian = "-0" unless defined $first_debian;
+    $first_epoch =~ s/:$//;
+    $first_debian =~ s/^-//;
+
+    my ($last_epoch,
+       $last_upstream,
+       $last_debian) = ($last =~ /^(.*:)?(.*?)(-.*)?$/);
+    $last_epoch = "0:" unless defined $last_epoch;
+    $last_debian = "-0" unless defined $last_debian;
+    $last_epoch =~ s/:$//;
+    $last_debian =~ s/^-//;
+
+    my $ret;
+    if ($first_epoch == $last_epoch) {
+       $ret = compare($first_upstream, $last_upstream);
+       if ($ret == 0) {
+           $ret = compare($first_debian, $last_debian);
+       }
+    } else {
+       $ret = ($first_epoch <=> $last_epoch);
+    }
+
+    # give the same return codes like 'dpkg --compare-versions .. ge ..'
+    if ($strict == 1 and $ret == 0) {
+        $ret = 256;
+    }
+    if ($ret == -1) {
+       $ret = 256;
+    } elsif ($ret == 1) {
+       $ret = 0;
+    }
+
+    return $ret;
+
+    # this will never be reached, but should give the same
+    # result as $ret
+    
+    my $ret2 = system("dpkg --compare-versions $first ge $last");
+    print "** $ret <> $ret2 ** \n" unless $ret == $ret2;
+    return $ret2;
+}
+
 1 ;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]