[Midnightbsd-cvs] mports: Tools/lib: Sync magus libs with the current devel version.

ctriv at midnightbsd.org ctriv at midnightbsd.org
Mon Oct 29 02:56:31 EDT 2007


Log Message:
-----------
Sync magus libs with the current devel version.

Modified Files:
--------------
    mports/Tools/lib:
        Magus.pm (r1.1 -> r1.2)
    mports/Tools/lib/Magus:
        Port.pm (r1.5 -> r1.6)

Added Files:
-----------
    mports/Tools/lib/Magus:
        Category.pm (r1.1)
        Cluster.pm (r1.1)
        PortCategory.pm (r1.1)
        Task.pm (r1.1)
    mports/Tools/lib/Magus/Task:
        UpdateMports.pm (r1.1)
        Wait.pm (r1.1)

-------------- next part --------------
Index: Magus.pm
===================================================================
RCS file: /home/cvs/mports/Tools/lib/Magus.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -LTools/lib/Magus.pm -LTools/lib/Magus.pm -u -r1.1 -r1.2
--- Tools/lib/Magus.pm
+++ Tools/lib/Magus.pm
@@ -9,14 +9,18 @@
 
 
 use Magus::Config;
-use Magus::Port      ();
-use Magus::Lock      ();
-use Magus::Result    ();
-use Magus::SubResult ();
-use Magus::Machine   ();
-use Magus::PortTest  ();
-use Magus::Chroot    ();
-use Magus::Index     ();
+use Magus::Port      	();
+use Magus::Lock      	();
+use Magus::Result    	();
+use Magus::Category  	();
+use Magus::PortCategory ();
+use Magus::SubResult 	();
+use Magus::Machine   	();
+use Magus::PortTest  	();
+use Magus::Chroot    	();
+use Magus::Index     	();
+use Magus::Cluster	();
+use Magus::Task		();
 
 use Mport::Globals   ();
 our $Machine;
--- /dev/null
+++ Tools/lib/Magus/Task.pm
@@ -0,0 +1,81 @@
+package Magus::Task;
+#
+# 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/Task.pm,v 1.1 2007/10/29 06:56:29 ctriv Exp $
+# 
+# MAINTAINER=   ctriv at MidnightBSD.org
+#
+
+
+
+use base qw(Magus::DBI);
+use strict;
+use warnings;
+
+use Magus::Task::Wait         ();
+use Magus::Task::UpdateMports ();
+
+
+__PACKAGE__->table('results');
+__PACKAGE__->columns(All => qw/machine type completed/);
+
+__PACKAGE__->has_a(machine => 'Magus::Machine');
+
+sub construct {
+  my ($class, @args) = @_;
+  
+  my $self = $class->SUPER::construct(@args);
+  
+  bless $self, ref $self . "::" . $self->type;
+  
+  return $self;
+}
+
+__PACKAGE__->mk_classdata('callbacks');
+
+sub set_callbacks {
+  my ($class, %cbs) = @_;
+  
+  $class->callbacks = \%cbs;
+}
+
+sub is_complete {
+  my ($self) = @_;
+  
+  my $dbh   = $self->db_Main();
+  my $table = $self->table;
+  my $id    = $self->id;
+  
+  my ($complete) = $dbh->selectrow_array("SELECT completed FROM $table WHERE id=?", undef, $id);
+  return $complete;
+}
+
+
+
+
+1;
+__END__
+
Index: Port.pm
===================================================================
RCS file: /home/cvs/mports/Tools/lib/Magus/Port.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -LTools/lib/Magus/Port.pm -LTools/lib/Magus/Port.pm -u -r1.5 -r1.6
--- Tools/lib/Magus/Port.pm
+++ Tools/lib/Magus/Port.pm
@@ -41,6 +41,7 @@
 __PACKAGE__->columns(All       => qw(description));
 __PACKAGE__->has_many(depends => [ 'Magus::Depend' => 'dependency' ] => 'port');
 __PACKAGE__->has_many(results => 'Magus::Result');
+__PACKAGE__->has_many(categories => [ 'Magus::PortCategory' => 'category' ]);
 
 __PACKAGE__->set_sql(ready_ports => <<END_OF_SQL);
 SELECT ports.* FROM ports 
--- /dev/null
+++ Tools/lib/Magus/Cluster.pm
@@ -0,0 +1,75 @@
+package Magus::Cluster;
+#
+# 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/Cluster.pm,v 1.1 2007/10/29 06:56:29 ctriv Exp $
+# 
+# MAINTAINER=   ctriv at MidnightBSD.org
+#
+
+
+
+use strict;
+use warnings;
+
+
+sub halt {
+  _send_tasks('Wait');
+}
+
+sub resume {
+  $_->complete(1) for Magus::Tasks->search(type => wait);
+}
+
+
+sub run_task {
+  my ($type) = @_;
+  
+  _send_tasks($type);
+  
+  my $running_count = 1;
+  
+  while ($running_count > 0) {
+    $running_count = Magus::Task->search(type => $type, complete => 0)->count;  
+  }
+}
+  
+   
+sub _send_task {
+  my ($type) = @_;
+  
+  foreach my $machine (Magus::Machine->retrive_all) {
+    next if $machine eq $Magus::Machine;
+    
+    Magus::Task->insert({
+      machine => $machine,
+      type    => $type
+    });
+  }
+}
+
+1;
+__END__
+
--- /dev/null
+++ Tools/lib/Magus/PortCategory.pm
@@ -0,0 +1,45 @@
+package Magus::PortCategory;
+#
+# 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/PortCategory.pm,v 1.1 2007/10/29 06:56:29 ctriv Exp $
+# 
+# MAINTAINER=   ctriv at MidnightBSD.org
+#
+
+use strict;
+use warnings;
+use base qw(Magus::DBI);
+
+
+__PACKAGE__->table('categories');
+__PACKAGE__->columns(Essential => qw/port category/);
+__PACKAGE__->has_a(port => 'Magus::Port');
+__PACKAGE__->has_a(category => 'Magus::Category');
+
+
+1;
+__END__
+
--- /dev/null
+++ Tools/lib/Magus/Category.pm
@@ -0,0 +1,44 @@
+package Magus::Category;
+#
+# 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/Category.pm,v 1.1 2007/10/29 06:56:29 ctriv Exp $
+# 
+# MAINTAINER=   ctriv at MidnightBSD.org
+#
+
+use strict;
+use warnings;
+use base qw(Magus::DBI);
+
+
+__PACKAGE__->table('categories');
+__PACKAGE__->columns(Essential => qw/id category/);
+__PACKAGE__->has_many(ports => [ 'Magus::PortCategory' => 'port']);
+
+
+1;
+__END__
+
--- /dev/null
+++ Tools/lib/Magus/Task/UpdateMports.pm
@@ -0,0 +1,69 @@
+package Magus::Task::UpdateMports;
+#
+# 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/Task/UpdateMports.pm,v 1.1 2007/10/29 06:56:29 ctriv Exp $
+# 
+# MAINTAINER=   ctriv at MidnightBSD.org
+#
+
+
+
+use base qw(Magus::Task);
+use strict;
+use warnings;
+
+use File::Path qw(rmtree);
+
+=head1 Magus::Task::UpdateMports
+
+This task updates /usr/mports, using C<MasterMportsTarBall>.
+
+=cut
+
+
+
+sub exec {  
+  my ($self) = @_;
+  
+  $self->callbacks->{'log'}->('Updating mports tree');
+  
+  chdir("/usr") || die "Couldn't CD to user: $!";
+  
+  my $scp = "/usr/bin/scp $Magus::Config{MasterMportsTarBall} $Magus::Config{MportsTarBall}";
+  system($scp) == 0 || die "$scp returned non-zero: $?";  
+
+  rmtree("mports") || die "Couldn't delete /usr/mports: $!";
+  
+  my $tar = "/usr/bin/tar xf $Magus::Config{MportsTarBall}";
+  system($tar) == 0 || die "$tar returned non-zero: $?";
+  
+  $self->callbacks->{'restart'}->();
+}
+
+
+1;
+__END__
+
--- /dev/null
+++ Tools/lib/Magus/Task/Wait.pm
@@ -0,0 +1,67 @@
+package Magus::Task::Wait;
+#
+# 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/Task/Wait.pm,v 1.1 2007/10/29 06:56:29 ctriv Exp $
+# 
+# MAINTAINER=   ctriv at MidnightBSD.org
+#
+
+
+
+use base qw(Magus::Task);
+use strict;
+use warnings;
+
+
+=head1 Magus::Task::Wait
+
+This task is a special case. All other tasks are started, and once the node
+is done, the node marks the task as complete.  The wait task is started, and
+the node will sleep until the I<master> marks the task as complete.  This
+way the master can halt the cluster as needed.
+
+=cut
+
+
+
+sub exec {
+  my ($self) = @_;
+  
+  while (1) {
+    sleep(60);
+    
+    if ($self->is_complete) {
+      last;
+    }
+  }
+}
+
+
+
+
+1;
+__END__
+


More information about the Midnightbsd-cvs mailing list