#! /usr/bin/perl -w # ---------------------------------------------------------------------------- # "THE BEER-WARE LICENSE" (Revision 42) # wrote this file. As long as you retain this notice you # can do whatever you want with this stuff. If we meet some day, and you think # this stuff is worth it, you can buy me a beer in return. Anton Berezin # ---------------------------------------------------------------------------- # # Version 0.1 # use Cwd; my $dir = getcwd; my @jails = qw(ports56 ports58 j4); make_sum(); my_system("cpdup-port"); for my $jail (@jails) { remove_packages($jail); my_system("build_mtree /home/jails/$jail $jail"); my ($ignore) = ssh_backticks($jail, "cd $dir; make BATCH=yes -V IGNORE"); if ($ignore) { print "$jail: port IGNOREd because of $ignore\n"; next; } if (!ssh_system($jail, "cd $dir; make BATCH=yes clean")) { die "A problem cleaning things on $jail\n"; } if (!ssh_system($jail, "cd $dir; make BATCH=yes")) { die "A problem building things on $jail\n"; } my_system("build_mtree /home/jails/$jail $jail"); my ($wrksrc) = ssh_backticks($jail, "cd $dir; make BATCH=yes -V WRKSRC"); if (!ssh_system($jail, "cd $wrksrc; make test BATCH=yes")) { die "Error testing shit\n"; } if (!ssh_system($jail, "cd $dir; make install BATCH=yes")) { die "A problem installing the thing on $jail\n"; } if (!ssh_system($jail, "cd $dir; make deinstall BATCH=yes")) { die "A problem deinstalling the thing on $jail\n"; } my @list = my_backticks("plist $jail"); if (@list) { print "$_\n" for @list; die "Fix PLIST please\n"; } print "\n$jail success\n"; } continue { print "\n\n\n**** Press ENTER to continue *****\n"; $_ = ; } print "All is fine, /methinks\n"; sub my_system { my @p = @_; system(@p) and die "$p[0] had a problem\n"; } sub my_backticks { my @p = @_; my @r = `@p`; for (@r) { chomp } @r; } sub ssh_backticks { my ($jail, @p) = @_; my @r = `ssh root\@$jail /bin/sh -c "'( @p )'" 2>&1`; for (@r) { chomp } @r; } sub ssh_system { my ($jail, @p) = @_; system("ssh root\@$jail /bin/sh -c \"'( @p ) && touch /tmp/ssh.done'\""); my $okfile = "/home/jails/$jail/tmp/ssh.done"; if (-f $okfile) { unlink $okfile; return 1; } return 0; } sub make_sum { my %df = map { $_ => 0 } my_backticks("make BATCH=yes -V DISTFILES"); open DI, "< distinfo" or die "cannot find distinfo!\n"; while () { chomp; next unless /^\S+\s+\((\S+)\)/; if (exists $df{$1}) { $df{$1}++; } else { $need_make_sum = 1; last; } } close DI; $need_make_sum = $need_make_sum || grep { $_ == 0 } values %df; if ($need_make_sum) { my_system("make BATCH=yes makesum"); } } sub remove_packages { my ($jail) = @_; my @pkg = grep { !/^perl-/ && !/^pkg_info:/ } map { /^(\S+)\s/ && $1 } ssh_backticks($jail, "pkg_info"); if (@pkg) { ssh_system($jail, "pkg_delete @pkg"); } }