[Midnightbsd-cvs] mports: lib/Magus: Various bug fixes and improvements.

ctriv at midnightbsd.org ctriv at midnightbsd.org
Thu Feb 28 15:11:19 EST 2008


Log Message:
-----------
Various bug fixes and improvements.

Modified Files:
--------------
    mports/Tools/lib/Magus:
        Chroot.pm (r1.14 -> r1.15)
        Index.pm (r1.8 -> r1.9)
        Lock.pm (r1.4 -> r1.5)
        Machine.pm (r1.4 -> r1.5)
        Port.pm (r1.12 -> r1.13)
        Run.pm (r1.1 -> r1.2)

Removed Files:
-------------
    mports/Tools/lib/Magus:
        Snap.pm

-------------- next part --------------
Index: Machine.pm
===================================================================
RCS file: /home/cvs/mports/Tools/lib/Magus/Machine.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -L Tools/lib/Magus/Machine.pm -L Tools/lib/Magus/Machine.pm -u -r1.4 -r1.5
--- Tools/lib/Magus/Machine.pm
+++ Tools/lib/Magus/Machine.pm
@@ -35,7 +35,7 @@
 
 
 __PACKAGE__->table('machines');
-__PACKAGE__->columns(Essential => qw/id arch name maintainer run/);
+__PACKAGE__->columns(Essential => qw/id arch name maintainer run osversion/);
 __PACKAGE__->has_a(run => 'Magus::Run');
 
 
Index: Port.pm
===================================================================
RCS file: /home/cvs/mports/Tools/lib/Magus/Port.pm,v
retrieving revision 1.12
retrieving revision 1.13
diff -L Tools/lib/Magus/Port.pm -L Tools/lib/Magus/Port.pm -u -r1.12 -r1.13
--- Tools/lib/Magus/Port.pm
+++ Tools/lib/Magus/Port.pm
@@ -39,51 +39,22 @@
 __PACKAGE__->table('ports');
 
 __PACKAGE__->columns(Essential => qw(id run name version status));
-__PACKAGE__->columns(All       => qw(description license www created updated));
+__PACKAGE__->columns(All       => qw(description license www updated));
 __PACKAGE__->columns(Stringify => qw(name));
 
-__PACKAGE__->has_a(run     => 'Magus::Run');
+__PACKAGE__->has_a(run => 'Magus::Run');
 
 __PACKAGE__->has_many(depends => [ 'Magus::Depend' => 'dependency' ] => 'port');
 __PACKAGE__->has_many(categories => [ 'Magus::PortCategory' => 'category' ]);
-__PACKAGE__->has_many(events => [ 'Magus::Event' => 'port' ]);
+__PACKAGE__->has_many(events => 'Magus::Event');
 
 
-__PACKAGE__->set_sql(ready_ports => <<'END_OF_SQL');
-SELECT ports.*,(SELECT COUNT(*) FROM depends WHERE dependency=ports.id) AS priority 
-FROM ports 
-WHERE 
-    run=:a AND status='untested'
-  AND
-    (id NOT IN (SELECT port FROM locks WHERE port=ports.id)) 
-  AND 
-    ((id NOT IN (SELECT port FROM depends WHERE port=ports.id)) 
-      OR 
-    (id NOT IN (
-      SELECT port FROM depends WHERE 
-          port=ports.id 
-        AND 
-        (
-          (dependency NOT IN (
-            SELECT port FROM ports WHERE 
-                id=dependency 
-              AND 
-                run=:a 
-              AND 
-                (status='pass' OR status='warn')
-          ))
-         OR 
-          (dependency IN (SELECT port FROM locks WHERE port=dependency))
-        )
-    )))
-ORDER BY priority DESC;
-END_OF_SQL
+__PACKAGE__->set_sql(ready_ports => 'SELECT __ESSENTIAL__ FROM ready_ports WHERE run=?');
 
-#__PACKAGE__->
 
 =head2 Magus::Port->get_ready_port($run);
 
-Return a port that is ready to be tested for the current run.
+Return a port that is ready to be tested for the given run.
 Ready is defined as:
 
 =over 4
@@ -98,7 +69,7 @@
 
 =item 3
 
-The port's depends are all tested and unlocked.
+All the port's depends are tested and unlocked.
 
 =back
 
@@ -123,12 +94,7 @@
 }
 
 
-=head2 $port->current_result
-
-Returns the result for the current version and arch, if any.
-
-=cut
-
+# POD removed as method is deprecated.
 sub current_result {
   require Carp;
   Carp::confess("Use of deprecated method: Magus::Port->current_result.  There is no replacement.");
@@ -220,14 +186,14 @@
 
 
 sub _set_result {
-  my ($self, $summary, $phase, $name, $msg) = @_;
+  my ($self, $status, $phase, $name, $msg) = @_;
   
-  $self->status($summary);
+  $self->status($status);
   $self->update;
     
   $self->add_to_events({
     machine   => $Magus::Machine,
-    type  => $summary,
+    type  => $status,
     name  => $name,
     msg   => $msg,
     phase => $phase,
--- Tools/lib/Magus/Snap.pm
+++ /dev/null
@@ -1,65 +0,0 @@
-package Magus::Snap;
-#
-# Copyright (c) 2007 Chris Reinhardt. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# 1. Redistributions of source code must retain the above copyright notice
-#    this list of conditions and the following disclaimer.
-#
-# 2. Redistributions in binary form must reproduce the above copyright
-#    notice, this list of conditions and the following disclaimer in the
-#    documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
-# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# $MidnightBSD: mports/Tools/lib/Magus/Snap.pm,v 1.2 2007/11/20 17:03:45 ctriv Exp $
-# 
-# MAINTAINER=   ctriv at MidnightBSD.org
-#
-
-use strict;
-use warnings;
-use base qw(Magus::DBI);
-
-
-__PACKAGE__->table('snaps');
-__PACKAGE__->columns(Essential => qw/id created/);
-
-__PACKAGE__->set_sql(latest_snaps => 'SELECT __ESSENTIAL__ FROM __TABLE__ ORDER BY id DESC');
-
-
-sub latest {
-  my ($class) = @_;
-  
-  return $class->search_latest_snaps->next;
-}  
-
-sub tarball {
-  my ($self) = @_;
-  my $id = $self->id;
-  
-  return "$id.tar.bz2"
-}
-
-sub tarballpath {
-  return "$Magus::Config{MasterDataDir}/$Magus::Config{MportsSnapDir}/" . shift->tarball;
-}
-
-
-
-
-1;
-__END__
-
Index: Chroot.pm
===================================================================
RCS file: /home/cvs/mports/Tools/lib/Magus/Chroot.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -L Tools/lib/Magus/Chroot.pm -L Tools/lib/Magus/Chroot.pm -u -r1.14 -r1.15
--- Tools/lib/Magus/Chroot.pm
+++ Tools/lib/Magus/Chroot.pm
@@ -33,7 +33,7 @@
 use warnings;
 use File::Path qw(mkpath rmtree);
 
-# load Carp::Heavy so its in memory before we chroot.
+# load Carp::Heavy so it's in memory before we chroot.
 use Carp::Heavy;
 
 =head1 NAME 
Index: Lock.pm
===================================================================
RCS file: /home/cvs/mports/Tools/lib/Magus/Lock.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -L Tools/lib/Magus/Lock.pm -L Tools/lib/Magus/Lock.pm -u -r1.4 -r1.5
--- Tools/lib/Magus/Lock.pm
+++ Tools/lib/Magus/Lock.pm
@@ -30,7 +30,6 @@
 #
 
 
-
 use base qw(Magus::DBI);
 use strict;
 use warnings;
@@ -41,15 +40,27 @@
 __PACKAGE__->has_a(machine => "Magus::Machine");
 __PACKAGE__->has_a(port    => "Magus::Port");
 
+__PACKAGE__->set_sql(by_run => <<'END_OF_SQL');
+SELECT locks.* FROM locks,ports WHERE port=ports.id AND ports.run=?
+END_OF_SQL
 
 sub get_ready_lock {
-  my ($class, $port) = @_;
+  my ($class, $run) = @_;
+
+  my $lock;
+  my $port;
   
-  if (defined $port) {
-    return $class->_get_lock($port);
-  } else {
-    return $class->_find_and_lock_unlocked_port();
+  while (!defined $lock) {
+    my $port = Magus::Port->get_ready_port($run);
+   
+    if (!$port) { # we ran thru all the ports...
+      return;
+    }
+    
+    $lock = $class->_get_lock($port);
   }
+  
+  return $lock;
 }
 
 
@@ -75,25 +86,6 @@
   return $lock;
 }
 
-sub _find_and_lock_unlocked_port {
-  my ($class) = @_;
-  
-  my $lock;
-  my $port;
-  
-  while (!defined $lock) {
-    my $port = Magus::Port->get_ready_port;
-   
-    if (!$port) { # we ran thru all the ports...
-      return;
-    }
-    
-    $lock = $class->_get_lock($port);
-  }
-  
-  return $lock;
-}
-
 #
 # depreacted method
 #
Index: Index.pm
===================================================================
RCS file: /home/cvs/mports/Tools/lib/Magus/Index.pm,v
retrieving revision 1.8
retrieving revision 1.9
diff -L Tools/lib/Magus/Index.pm -L Tools/lib/Magus/Index.pm -u -r1.8 -r1.9
--- Tools/lib/Magus/Index.pm
+++ Tools/lib/Magus/Index.pm
@@ -91,9 +91,6 @@
     print "done.\n";
   } root    => $root;
 
-  my $ports = Magus::Port->retrieve_all;
-  
-
   print "Building depends list... \n";
   
   PORT: while (my ($id, $depends) = each %depends) {
Index: Run.pm
===================================================================
RCS file: /home/cvs/mports/Tools/lib/Magus/Run.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -L Tools/lib/Magus/Run.pm -L Tools/lib/Magus/Run.pm -u -r1.1 -r1.2
--- Tools/lib/Magus/Run.pm
+++ Tools/lib/Magus/Run.pm
@@ -40,7 +40,7 @@
 
 =head2 Magus::Run->latest($machine)
 
-Takes a machine, and returns the latest run for that machine's osversion and arch.
+Takes a machine, and returns the latest active run for that machine's osversion and arch.
 
 =cut
 
@@ -50,6 +50,7 @@
   return $class->search(
     osversion => $machine->osversion,
     arch      => $machine->arch,
+    status    => 'active',
     { order_by => 'id DESC' }
   )->next;
 }
@@ -64,6 +65,9 @@
 sub is_empty {
   my ($self) = @_;
   
+  # if there is a locked port, then there may be new ports once this one is done.
+  return 0 if Magus::Lock->search_by_run($self)->count;
+
   return Magus::Port->get_ready_port($self) ? 0 : 1;
 }
 


More information about the Midnightbsd-cvs mailing list