mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-25 05:19:29 +01:00
pbot-vm: add experimental Vagrant provisioning
This commit is contained in:
parent
518b51f060
commit
2547f035a1
@ -12,33 +12,33 @@
|
||||
if [ -f /etc/os-release ]; then
|
||||
# freedesktop.org and systemd
|
||||
. /etc/os-release
|
||||
OS=$NAME
|
||||
VER=$VERSION_ID
|
||||
OS=$PRETTY_NAME
|
||||
elif type lsb_release >/dev/null 2>&1; then
|
||||
# linuxbase.org
|
||||
OS=$(lsb_release -si)
|
||||
VER=$(lsb_release -sr)
|
||||
elif [ -f /etc/lsb-release ]; then
|
||||
# For some versions of Debian/Ubuntu without lsb_release command
|
||||
. /etc/lsb-release
|
||||
OS=$DISTRIB_ID
|
||||
VER=$DISTRIB_RELEASE
|
||||
else
|
||||
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
|
||||
OS=$(uname -s)
|
||||
VER=$(uname -r)
|
||||
fi
|
||||
|
||||
echo "Detected OS: $OS ($VER)"
|
||||
echo "Detected OS: $OS"
|
||||
|
||||
# run known provisioning scripts
|
||||
case $OS in
|
||||
'openSUSE Tumbleweed')
|
||||
echo "Provisioning for openSUSE Tumbleweed"
|
||||
echo "Provisioning for $OS"
|
||||
./guest/provision/tumbleweed
|
||||
;;
|
||||
'Debian GNU/Linux trixie/sid')
|
||||
echo "Provisioning for $OS"
|
||||
./guest/provision/debian-trixie
|
||||
;;
|
||||
*)
|
||||
echo "!! No automatic provisioning script for $OS ($VER). Install packages manually. !!"
|
||||
echo "!! No automatic provisioning script for $OS. Install packages manually. !!"
|
||||
echo
|
||||
;;
|
||||
esac
|
||||
|
@ -97,10 +97,10 @@ sub postprocess {
|
||||
if ($self->{cmdline} =~ /-fsanitize=(?:[^ ]+,)?address/) {
|
||||
# leak sanitizer doesn't work under ptrace/gdb
|
||||
# ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1
|
||||
($exitval, $stdout, $stderr) = $self->execute(60, "$ulimits; ./prog $quoted_args\n", '/bin/sh');
|
||||
($exitval, $stdout, $stderr) = $self->execute(60, "$ulimits; ./prog $quoted_args\n", '/bin/bash');
|
||||
} else {
|
||||
my $input = "$ulimits; guest-gdb ./prog $quoted_args";
|
||||
($exitval, $stdout, $stderr) = $self->execute(60, $input, '/bin/sh');
|
||||
($exitval, $stdout, $stderr) = $self->execute(60, $input, '/bin/bash');
|
||||
}
|
||||
|
||||
$self->{error} = $exitval;
|
||||
|
@ -62,7 +62,7 @@ sub preprocess {
|
||||
$stdin .= "$self->{cmdline} $quoted_args";
|
||||
}
|
||||
|
||||
my ($retval, $stdout, $stderr) = $self->execute(60, $stdin, '/bin/sh');
|
||||
my ($retval, $stdout, $stderr) = $self->execute(60, $stdin, '/bin/bash');
|
||||
|
||||
$self->{output} = $stderr;
|
||||
$self->{output} .= ' ' if length $self->{output};
|
||||
|
25
applets/pbot-vm/guest/provision/debian-trixie
Executable file
25
applets/pbot-vm/guest/provision/debian-trixie
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
# File: debian-trixie
|
||||
#
|
||||
# Purpose: Provisioning script to install packages and set-up environment
|
||||
# on Debian Testing (trixie) for pbot-vm.
|
||||
|
||||
# SPDX-FileCopyrightText: 2024 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
apt update
|
||||
|
||||
# for virt-io socket
|
||||
apt install -y socat
|
||||
|
||||
# for `cc` C language support
|
||||
apt install -y libubsan1 libasan8 gdb gcc gcc-multilib clang
|
||||
|
||||
# for pbot-vm guest-server support
|
||||
apt install -y --no-install-recommends libipc-shareable-perl libipc-run-perl libjson-xs-perl
|
||||
|
||||
# for `cc` additional languages
|
||||
apt install -y ksh zsh tcl lua5.4 php8.2-cli nodejs guile3.0 beef bc g++
|
||||
apt install -y clisp golang-go
|
||||
apt install -y --no-install-recommends default-jre default-jdk
|
@ -15,8 +15,8 @@ zypper -n in socat
|
||||
zypper -n in libubsan1 libasan8 gdb gcc gcc-32bit glibc-32bit clang
|
||||
|
||||
# for pbot-vm guest-server support
|
||||
zypper -n in perl-IPC-Run perl-JSON-XS make
|
||||
PERL_MM_USE_DEFAULT=1 cpan IPC::Shareable
|
||||
zypper -n in perl-IPC-Run perl-JSON-XS make cpanm
|
||||
cpanm -n IPC::Shareable
|
||||
|
||||
# for `cc` additional languages
|
||||
zypper -n in ksh zsh tcl lua php8-cli nodejs-common guile bff bc gcc-c++
|
||||
|
16
applets/pbot-vm/vagrant/Debian-testing64/Vagrantfile
vendored
Normal file
16
applets/pbot-vm/vagrant/Debian-testing64/Vagrantfile
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'
|
||||
|
||||
PBOTVM_SERIAL = ENV['PBOTVM_SERIAL'] || 5555
|
||||
PBOTVM_HEART = ENV['PBOTVM_HEART'] || 5556
|
||||
PBOTVM_NAME = ENV['PBOTVM_NAME'] || 'pbot-vagrant-vm'
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
# Every Vagrant development environment requires a box. You can search for
|
||||
# boxes at https://vagrantcloud.com/search.
|
||||
config.vm.box = "debian/testing64"
|
||||
end
|
||||
|
||||
load '../common/Vagrantfile.common'
|
56
applets/pbot-vm/vagrant/README.md
Normal file
56
applets/pbot-vm/vagrant/README.md
Normal file
@ -0,0 +1,56 @@
|
||||
# Vagrant instructions
|
||||
|
||||
### Install Vagrant
|
||||
|
||||
To install vagrant on openSUSE, use:
|
||||
|
||||
zypper install --no-recommends vagrant vagrant-libvirt
|
||||
|
||||
Otherwise see https://vagrant-libvirt.github.io/vagrant-libvirt/installation.html for installation instructions for your platform.
|
||||
|
||||
### Install vagrant-libvirt
|
||||
|
||||
If your distribution does not have a `vagrant-libvirt` package or if you need an up-to-date version use Vagrant's plugin manager:
|
||||
|
||||
vagrant plugin install vagrant-libvirt
|
||||
|
||||
### Start Vagrant Box
|
||||
|
||||
To start a virtual machine, `cd` into one of the PBot-VM Vagrant sub-directories and run:
|
||||
|
||||
vagrant up
|
||||
|
||||
You may pass optional environment variables to override pbot-vm default configuration (see [Virtual Machine](../../../doc/VirtualMachine.md)):
|
||||
|
||||
PBOTVM_SERIAL=7777 PBOTVM_HEART=7778 vagrant up
|
||||
|
||||
### Shutdown Vagrant Box
|
||||
|
||||
vagrant halt
|
||||
|
||||
### Destroy Vagrant Box
|
||||
|
||||
vagrant destroy
|
||||
|
||||
### Delete Vagrant Box
|
||||
|
||||
vagrant box list
|
||||
vagrant box remove <name>
|
||||
|
||||
### (Optional) Install Alterantive Vagrant Box
|
||||
|
||||
To install an alternative Vagrant box with your preferred OS/distribution, search for one at https://app.vagrantup.com/boxes/search
|
||||
and then run the following command to download its Vagrantfile:
|
||||
|
||||
vagrant init <OS/distribution>
|
||||
|
||||
Examples:
|
||||
|
||||
vagrant init debian/testing64
|
||||
vagrant init debian/bookworm64
|
||||
vagrant init opensuse/Tumbleweed.x86_64
|
||||
vagrant init archlinux/archlinux
|
||||
vagrant init freebsd/FreeBSD-14.0-CURRENT
|
||||
vagrant init generic/openbsd7
|
||||
|
||||
Then use one of the existing PBot-VM Vagrantfiles as a guide for adjusting your alternative Vagrantfile.
|
30
applets/pbot-vm/vagrant/common/Vagrantfile.common
Normal file
30
applets/pbot-vm/vagrant/common/Vagrantfile.common
Normal file
@ -0,0 +1,30 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box_check_update = false
|
||||
|
||||
config.vm.hostname = PBOTVM_NAME
|
||||
|
||||
config.vm.provider :libvirt do |libvirt|
|
||||
libvirt.qemuargs :value => "-chardev"
|
||||
libvirt.qemuargs :value => "socket,id=charserial1,host=127.0.0.1,port=#{PBOTVM_SERIAL},server=on,wait=off"
|
||||
libvirt.qemuargs :value => "-device"
|
||||
libvirt.qemuargs :value => '{"driver":"isa-serial","chardev":"charserial1","id":"serial1","index":2}'
|
||||
libvirt.qemuargs :value => "-chardev"
|
||||
libvirt.qemuargs :value => "socket,id=charserial2,host=127.0.0.1,port=#{PBOTVM_HEART},server=on,wait=off"
|
||||
libvirt.qemuargs :value => "-device"
|
||||
libvirt.qemuargs :value => '{"driver":"isa-serial","chardev":"charserial2","id":"serial2","index":3}'
|
||||
end
|
||||
|
||||
config.vm.synced_folder ".", "/vagrant", disabled: true
|
||||
|
||||
config.vm.synced_folder "../../guest", "/home/vagrant/guest", type: "rsync",
|
||||
rsync__auto: false
|
||||
|
||||
config.vm.provision "shell", inline: "useradd -m vm -s /bin/bash"
|
||||
|
||||
config.vm.provision "shell", inline: "/home/vagrant/guest/bin/setup-guest"
|
||||
|
||||
config.vm.post_up_message = "To start the PBot-VM Guest Server, run `vagrant ssh` to log into the pbot-vagrant-vm and then run `sudo guest-server`."
|
||||
end
|
16
applets/pbot-vm/vagrant/openSUSE-Tumbleweed/Vagrantfile
vendored
Normal file
16
applets/pbot-vm/vagrant/openSUSE-Tumbleweed/Vagrantfile
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'
|
||||
|
||||
PBOTVM_SERIAL = ENV['PBOTVM_SERIAL'] || 5555
|
||||
PBOTVM_HEART = ENV['PBOTVM_HEART'] || 5556
|
||||
PBOTVM_NAME = ENV['PBOTVM_NAME'] || 'pbot-vagrant-vm'
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
# Every Vagrant development environment requires a box. You can search for
|
||||
# boxes at https://vagrantcloud.com/search.
|
||||
config.vm.box = "opensuse/Tumbleweed.x86_64"
|
||||
end
|
||||
|
||||
load '../common/Vagrantfile.common'
|
File diff suppressed because one or more lines are too long
@ -25,8 +25,8 @@ use PBot::Imports;
|
||||
# These are set by the /misc/update_version script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 4733,
|
||||
BUILD_DATE => "2024-03-31",
|
||||
BUILD_REVISION => 4735,
|
||||
BUILD_DATE => "2024-04-04",
|
||||
};
|
||||
|
||||
sub initialize {}
|
||||
|
Loading…
Reference in New Issue
Block a user