Mailinglist Archive: opensuse-buildservice (120 mails)

< Previous Next >
Re: [opensuse-buildservice] [Patch] OBS Worker lxc build support
  • From: Adrian Schröter <adrian@xxxxxxx>
  • Date: Sat, 02 Jul 2011 07:44:30 +0200
  • Message-id: <1523594.BWefADaUA3@scherben>
Am Friday, 1. July 2011, 17:41:14 schrieb Dinar Valeev:
Hi,
With this patch obsworker is able to build packages within lxc container.

diff --git a/dist/obsworker b/dist/obsworker
index bd3015a..8f37b14 100755
--- a/dist/obsworker
+++ b/dist/obsworker
@@ -38,7 +38,7 @@ fi
mkdir -p "$OBS_WORKER_DIRECTORY"

if [ -z "$OBS_RUN_DIR" ]; then
- OBS_RUN_DIR="/var/run/obs"

I know that this is not working anymore on Factory, but I dunno if they will
really keep the noexec flag.

+ OBS_RUN_DIR="/srv/obs/run"

That is not really a good idea, it may conflict with other files and /srv
may not be writable.

The rest looks good. I will import it.

thanks
adrian

fi
if [ -z "$OBS_LOG_DIR" ]; then
OBS_LOG_DIR="/var/log/obs"
@@ -101,7 +101,7 @@ elif [ -e /sys/hypervisor/type ] && grep -q xen
/sys/hypervisor/type; then
vmopt=--xen
fi

-if [ -n "$vmopt" ]; then
+if [ -n "$vmopt" -a "$OBS_VM_TYPE" = "xen" -o "$OBS_VM_TYPE" = "kvm" ]; then
# we start up in VM mode, check for the worker disk options
if [ -n "$OBS_VM_DISK_AUTOSETUP_ROOT_FILESIZE" -a -n
"$OBS_VM_DISK_AUTOSETUP_SWAP_FILESIZE" ]; then
VMDISK_ROOT_FILESIZE="--vmdisk-rootsize
${OBS_VM_DISK_AUTOSETUP_ROOT_FILESIZE}"
@@ -170,7 +170,7 @@ case "$1" in
R=$OBS_WORKER_DIRECTORY/root_$I
# prepare obsworker startup in screen...
TMPFS=
- if [ -n "$vmopt" ]; then
+ if [ -n "$vmopt" -a "$OBS_VM_TYPE" = "xen" -o
"$OBS_VM_TYPE" = "kvm" ]; then
mkdir -p $R
DEVICE="$OBS_WORKER_DIRECTORY/root_$I/root"
SWAP="$OBS_WORKER_DIRECTORY/root_$I/swap"
diff --git a/dist/sysconfig.obs-worker b/dist/sysconfig.obs-worker
index 93edfea..0e68fd7 100644
--- a/dist/sysconfig.obs-worker
+++ b/dist/sysconfig.obs-worker
@@ -135,7 +135,7 @@ OBS_WORKER_NICE_LEVEL=18

## Path: Applications/OBS
## Description: Set used VM type by worker
-## Type: ("auto" | "xen" | "kvm" | "none")
+## Type: ("auto" | "xen" | "kvm" | "lxc" | "none")
## Default: "auto"
## Config: OBS
#
diff --git a/src/backend/bs_worker b/src/backend/bs_worker
index 3144954..845997b 100755
--- a/src/backend/bs_worker
+++ b/src/backend/bs_worker
@@ -193,6 +193,8 @@ Usage: $0 [OPTION] --root <directory> --statedir
<directory>

--xen : enable xen

+ --lxc : enable lxc
+
--tmpfs : uses tmpfs (memory) for for the build root

--device : set kvm or xen root device (default is <root>/root file)
@@ -319,6 +321,11 @@ while (@ARGV) {
shift @ARGV;
next;
}
+ if ($ARGV[0] eq '--lxc') {
+ $vm = 'lxc';
+ shift @ARGV;
+ next;
+ }
if ($ARGV[0] eq '--tmpfs') {
shift @ARGV;
$vm_tmpfs_mode = 1;
@@ -1519,7 +1526,7 @@ sub dobuild {
}

push @args, "$statedir/build/build";
- if ($vm) {
+ if ($vm =~ /(xen|kvm)/) {
# add a bit delay - not all workers should start at the same time
after idle.
sleep (int(rand(5)) + 1);
mkdir("$buildroot/.mount") unless -d "$buildroot/.mount";
@@ -1534,6 +1541,9 @@ sub dobuild {
push @args, '--vmdisk-rootsize', $vmdisk_rootsize if $vmdisk_rootsize;
push @args, '--vmdisk-swapsize', $vmdisk_swapsize if $vmdisk_swapsize;
push @args, '--vmdisk-filesystem', $vmdisk_filesystem if
$vmdisk_filesystem;
+ } elsif ($vm =~ /lxc/) {
+ push @args, '--root', $buildroot;
+ push @args, '--vm-type', $vm;
} else {
push @args, '--root', $buildroot;
}
@@ -1580,7 +1590,7 @@ sub dobuild {
return 1;
}

- if ($vm) {
+ if ($vm =~ /(xen|kvm)/) {
rm_rf("$buildroot/.build.packages");
if (! -d "$buildroot/.mount/.build.packages") {
# old style, call extractbuild


--
Adrian Schroeter
SUSE Linux Products GmbH
email: adrian@xxxxxxx

--
To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-buildservice+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups
References