#!/bin/bash
-GROUP=$(getent group www-data | cut -f3 -d:)
-USER=$(getent passwd www-data | cut -f3 -d:)
-
rm -rf vm/ vm.squashfs
mkdir -p vm/proc/
mount /proc -o bind vm/proc
ln -s vm/usr/bin/mawk vm/bin/awk
echo '/sbin/poweroff -f' > vm/.bash_logout
cat > vm/etc/fstab <<EOF
-virtfs /mnt 9p trans=virtio,auto 0 0
-tmpfs /tmp tmpfs defaults 0 0
+virtfs /mnt 9p trans=virtio 0 0
+tmpfs /tmp tmpfs defaults 0 0
EOF
cat > vm/.profile <<EOF
-mount -a
+mount /mnt
stty -F /dev/ttyS1 -echo
cd /mnt
export PS1="# "
EOF
-cat > vm/etc/initramfs-tools/modules <<EOF
-squashfs
-9p
-9pnet
-9pnet_virtio
-EOF
cat >> vm/etc/sudoers <<EOF
Defaults>nobody closefrom=5
Defaults>nobody !env_check
Defaults>nobody env_keep="ONLINE_JUDGE PATH HOME"
EOF
install gruntmaster-exec gruntmaster-compile vm/usr/bin/
-chroot vm update-initramfs -d -k 3.2.0-4-amd64
-chroot vm update-initramfs -c -k 3.2.0-4-amd64
umount vm/proc
mksquashfs vm vm.squashfs -comp lzo
#!/bin/bash
-ROOT=/home/marius/git/gruntmaster-daemon
+ROOT=.
qemu-system-x86_64 \
-enable-kvm -cpu host -m 256MB \
-nodefaults -nographic \
- -kernel $ROOT/vm/boot/vmlinuz-3.2.0-4-amd64 \
- -initrd $ROOT/vm/boot/initrd.img-3.2.0-4-amd64 \
- -append 'root=/dev/vda console=ttyS0,38400 quiet init=/bin/bash --login' \
+ -kernel $ROOT/bzImage \
+ -append 'root=/dev/vda console=ttyS0,1200 init=/bin/bash --login' \
-drive file=$ROOT/vm.squashfs,if=virtio,readonly \
-virtfs local,id=virtfs0,path=.,security_model=none,mount_tag=virtfs \
- -chardev stdio,id=stdio,signal=on \
- -chardev pipe,id=hostpipe,path=$1 \
- -serial chardev:stdio \
- -serial chardev:hostpipe
+ -serial stdio "$@"
aptsources=Debian
[Debian]
-packages=linux-image-3.2.0-4-amd64 mawk libbsd-resource-perl libipc-signal-perl gcc g++ mono-gmcs default-jdk golang-go gccgo ghc fpc perl python sudo
+packages=sysvinit-core mawk libbsd-resource-perl libipc-signal-perl gcc g++ mono-gmcs default-jdk golang-go gccgo ghc fpc perl python sudo
source=http://ftp.ro.debian.org/debian
keyring=debian-archive-keyring
-suite=wheezy
+suite=jessie
components=main
omitdebsrc=true
use File::Slurp qw/read_file write_file/;
use List::MoreUtils qw/natatime/;
use Log::Log4perl qw/get_logger/;
-use POSIX qw/mkfifo/;
use String::ShellQuote qw/shell_quote/;
use Try::Tiny;
our (%vm);
sub runvm {
- my ($name) = @_;
+ my ($name, $arg) = @_;
return unless $ENV{GRUNTMASTER_VM};
- mkfifo "$name.in", 0600;
- mkfifo "$name.out", 0600;
- get_logger->trace("Starting VM $name");
+ my $cmd = $ENV{GRUNTMASTER_VM};
+ $cmd .= ' ' . $arg if $arg;
+ get_logger->trace("Starting VM $name ($cmd)");
$vm{$name} = Expect::Simple->new({
- Cmd => "$ENV{GRUNTMASTER_VM} $name",
+ Cmd => $cmd,
Prompt => '# ',
DisconnectCmd => 'exit',
RawPty => 1,
sub prepare_files{
my $meta = shift;
- runvm $_ for keys %{$meta->{files}};
+ if ($meta->{runner} eq 'Interactive') {
+ runvm ver => '-serial unix:vm.sock,nowait,server';
+ runvm prog => '-serial unix:vm.sock,nowait';
+ } else {
+ runvm $_ for keys %{$meta->{files}};
+ }
for my $file (values %{$meta->{files}}) {
my ($format, $name, $content) = @{$file}{qw/format name content/};
mkfifo 'fifo1', 0600 or die "$!\n" unless -e 'fifo1';
mkfifo 'fifo2', 0600 or die "$!\n" unless -e 'fifo2';
- if ($test == 1 && $ENV{GRUNTMASTER_VM}) {
- exec 'cat <prog.out >ver.in' if fork;
- exec 'cat <ver.out >prog.in' if fork;
- }
-
my $ret = fork // get_logger->logdie("Fork failed: $!");
if ($ret) {
try {