[Midnightbsd-cvs] mports: Tools/magus: Add master and slave scripts.
ctriv at midnightbsd.org
ctriv at midnightbsd.org
Sat Oct 20 18:35:35 EDT 2007
Log Message:
-----------
Add master and slave scripts.
Add schema.
Add sample configuration file.
Modified Files:
--------------
mports/Tools/magus:
make_chroot_tarball.pl (r1.1 -> r1.2)
Added Files:
-----------
mports/Tools/magus:
config.yaml.example (r1.1)
schema.sql (r1.1)
mports/Tools/magus/master:
make_index_db (r1.1)
mports/Tools/magus/slave:
magus.pl (r1.1)
-------------- next part --------------
--- /dev/null
+++ Tools/magus/config.yaml.example
@@ -0,0 +1,8 @@
+---
+DBHost: localhost
+DBName: magus
+DBUser: magus
+DBPass: biteme
+
+Machine: vm-current
+DoneWaitPeriod: 600
Index: make_chroot_tarball.pl
===================================================================
RCS file: /home/cvs/mports/Tools/magus/make_chroot_tarball.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -LTools/magus/make_chroot_tarball.pl -LTools/magus/make_chroot_tarball.pl -u -r1.1 -r1.2
--- Tools/magus/make_chroot_tarball.pl
+++ Tools/magus/make_chroot_tarball.pl
@@ -37,29 +37,6 @@
my $ballname = shift || die "Usage: $0 <tarball name>\n";
-# list of dirs we don't want to recuse into
-my @dirs = qw(
- /dev
- /mnt
- /proc
- /sys
- /tmp
- /usr/local
- /usr/obj
- /usr/mports
- /usr/src
- /usr/X11R6
- /var/db/pkg
- /var/db/ports
- /var/db/portsnap
- /var/log
- /var/cron/tabs
- /var/mail
- /var/msgs
- /var/rwho
- /var/spool
-);
-
# list of files and dirs that are passed to tar normally.
my @files = qw(
/.cshrc
@@ -89,6 +66,7 @@
/COPYRIGHT
/etc
/lib
+ /libexec
/mnt
/proc
/rescue
@@ -146,6 +124,5 @@
}
run(qq(/usr/bin/tar -c -f $ballname @files));
-run(qq(/usr/bin/tar -n -r -f $ballname @dirs));
run(qq(/bin/ls -hl $ballname));
--- /dev/null
+++ Tools/magus/schema.sql
@@ -0,0 +1,131 @@
+-- MySQL dump 10.12
+--
+-- Host: localhost Database: magus
+-- ------------------------------------------------------
+-- Server version 5.1.20-beta
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Table structure for table `categories`
+--
+
+DROP TABLE IF EXISTS `categories`;
+CREATE TABLE `categories` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `category` varchar(64) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM AUTO_INCREMENT=577 DEFAULT CHARSET=latin1;
+
+--
+-- Table structure for table `depends`
+--
+
+DROP TABLE IF EXISTS `depends`;
+CREATE TABLE `depends` (
+ `port` varchar(128) NOT NULL,
+ `dependency` varchar(128) NOT NULL,
+ KEY `port` (`port`),
+ KEY `dependency` (`dependency`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+--
+-- Table structure for table `locks`
+--
+
+DROP TABLE IF EXISTS `locks`;
+CREATE TABLE `locks` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `port` varchar(128) NOT NULL,
+ `arch` varchar(8) NOT NULL,
+ `machine` int(11) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `port` (`port`,`arch`)
+) ENGINE=MyISAM AUTO_INCREMENT=3547 DEFAULT CHARSET=latin1;
+
+--
+-- Table structure for table `machines`
+--
+
+DROP TABLE IF EXISTS `machines`;
+CREATE TABLE `machines` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `arch` varchar(128) NOT NULL,
+ `name` varchar(128) NOT NULL,
+ `maintainer` varchar(128) NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
+
+--
+-- Table structure for table `port_categories`
+--
+
+DROP TABLE IF EXISTS `port_categories`;
+CREATE TABLE `port_categories` (
+ `port` varchar(128) NOT NULL,
+ `category_id` int(11) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+--
+-- Table structure for table `ports`
+--
+
+DROP TABLE IF EXISTS `ports`;
+CREATE TABLE `ports` (
+ `name` varchar(128) NOT NULL,
+ `version` varchar(32) DEFAULT NULL,
+ `description` text,
+ `license` varchar(16) DEFAULT NULL,
+ `pkgname` varchar(128) NOT NULL,
+ PRIMARY KEY (`name`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+--
+-- Table structure for table `results`
+--
+
+DROP TABLE IF EXISTS `results`;
+CREATE TABLE `results` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `port` varchar(128) NOT NULL,
+ `version` varchar(32) NOT NULL,
+ `summary` varchar(32) NOT NULL,
+ `machine` int(11) NOT NULL,
+ `arch` varchar(8) NOT NULL,
+ PRIMARY KEY (`id`),
+ KEY `port` (`port`,`version`),
+ KEY `port_2` (`port`,`version`,`arch`)
+) ENGINE=MyISAM AUTO_INCREMENT=3522 DEFAULT CHARSET=latin1;
+
+--
+-- Table structure for table `subresults`
+--
+
+DROP TABLE IF EXISTS `subresults`;
+CREATE TABLE `subresults` (
+ `result_id` int(11) NOT NULL,
+ `phase` varchar(16) NOT NULL,
+ `type` varchar(32) NOT NULL,
+ `name` varchar(128) NOT NULL,
+ `msg` text
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+-- Dump completed on 2007-10-20 15:15:35
--- /dev/null
+++ Tools/magus/master/make_index_db
@@ -0,0 +1,13 @@
+#!/usr/local/bin/perl
+#
+# $MidnightBSD: mports/Tools/magus/master/make_index_db,v 1.1 2007/10/20 22:35:33 ctriv Exp $
+#
+
+use strict;
+use warnings;
+use lib qw(/usr/mports/Tools/lib);
+use Magus;
+
+
+Magus::Index->build;
+
--- /dev/null
+++ Tools/magus/slave/magus.pl
@@ -0,0 +1,131 @@
+#!/usr/local/bin/perl
+
+use strict;
+use warnings;
+use lib qw(/usr/mports/Tools/lib);
+
+use Magus;
+
+main(@ARGV);
+
+
+sub main {
+ my $lock;
+
+ eval {
+ while (1) {
+ $lock = Magus::Lock->get_ready_lock();
+
+ if (!$lock) {
+ # there's no more ports to test, sleep for a while and check again.
+ sleep($Magus::Config{'DoneWaitPeriod'});
+ next;
+ }
+
+ print "Installing: " . $lock->port->name . "\n";
+
+ install_depends($lock) || next;
+ run_test($lock);
+ $lock->delete;
+ }
+ };
+
+ my $err = $@;
+ eval { $lock->delete if defined $lock && ref $lock !~ m/deleted/i; };
+
+ die $err if $err;
+}
+
+
+sub install_depends {
+ my ($lock) = @_;
+
+ foreach my $depend ($lock->port->depends) {
+ print "\tDep $depend\n";
+ if (!$depend->current_result || $depend->current_result->summary eq 'pass' || $depend->current_result->summary eq 'warn') {
+ # There should be a package that we can use to install the port.
+ install_package($depend) || last;
+ next;
+ }
+
+ # We got a port that was scheduled ready, but wasn't!
+ my $result = $lock->port->add_to_results({
+ version => $lock->port->version,
+ machine => $Magus::Machine,
+ summary => 'fail',
+ arch => $Magus::Machine->arch,
+ });
+
+ $result->add_to_subresults({
+ type => 'prebuild',
+ name => 'SchedulerFailure',
+ msg => 'Port was schedualed as ready to build, but a dependancy had not been built successfuly.'
+ });
+
+ return 0;
+ }
+
+ return 1;
+}
+
+
+
+sub install_package {
+ #
+ # we just return 1, cause we're just testing the scheduler.
+ #
+ print "\tinstall_package: @_\n";
+ return 1;
+}
+
+
+sub run_test {
+ my ($lock) = @_;
+
+ sleep(2);
+
+ $lock->port->add_to_results({
+ version => $lock->port->version,
+ machine => $Magus::Machine,
+ summary => 'pass',
+ arch => $Magus::Machine->arch,
+ });
+}
+
+sub real_run_test {
+ my ($port) = @_;
+
+ my $chroot = Magus::Chroot->new(tarball => $Magus::Config{chroot_tarball});
+
+ # we fork so just the child chroots, then we can get out of the chroot.
+ my $pid = fork();
+ if ($pid) {
+ # Parent, we wait for the child to finish.
+ waitpid($pid, 0);
+ } elsif (defined $pid) {
+ # Child, chroot and go.
+ $chroot->do_chroot();
+ chdir($port->origin);
+
+ my $test = Magus::PortTest->new(port => $port, chroot => $chroot);
+ my $results = $test->run;
+
+ insert_results($results);
+ } else {
+ die "Could not fork: $!\n";
+ }
+
+ # Back to the parent here.
+ if ($? == 0) {
+ return 1;
+ } else {
+ die "Child exited unexpectantly: $?\n";
+ }
+}
+
+
+
+
+1;
+__END__
+
More information about the Midnightbsd-cvs
mailing list