Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions dist/obsworker
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ fi
if [ -n "$OBS_WORKER_USE_MKFS_COPYIN" ]; then
OBS_WORKER_USE_MKFS_COPYIN="--vm-use-mkfs-copyin"
fi
if [ -n "$OBS_WORKER_USE_CONTAINER_PREINSTALLIMAGE" ]; then
OBS_WORKER_USE_CONTAINER_PREINSTALLIMAGE="--vm-use-container-preinstallimage"
fi

if [ -n "$OBS_WORKER_SECURITY_LEVEL" ]; then
OBS_WORKER_HOSTLABELS="OBS_WORKER_SECURITY_LEVEL_${OBS_WORKER_SECURITY_LEVEL} $OBS_WORKER_HOSTLABELS"
Expand Down Expand Up @@ -378,6 +381,8 @@ case "$1" in
elif [ "--emulator" == "$vmopt" ]; then echo "System emulated virtual machine"
elif [ "--vm-type qemu" == "$vmopt" ]; then echo "System emulated virtual machine via QEMU"
elif [ "--lxc" == "$vmopt" ]; then echo "LXC container"
elif [ "--podman" == "$vmopt" ]; then echo "Podman container"
elif [ "--docker" == "$vmopt" ]; then echo "Docker container"
elif [ "openstack" == "$OBS_VM_TYPE" ]; then echo "OpenStack virtual machine"
else echo "chroot"
fi
Expand Down Expand Up @@ -484,8 +489,8 @@ case "$1" in
echo "screen -t $WORKERID nice -n $OBS_NICE ./bs_worker --hardstatus $vmopt $port $proto --root $R" \
"--statedir $workerdir/$I --id $WORKERID $REPO_PARAM $HUGETLBFS $HOSTLABELS" \
"$HOSTOWNER $OBS_JOBS $OBS_THREADS $OBS_TEST $OBS_WORKER_OPT $TMPFS $DEVICE $SWAP $MEMORY" \
"$OBS_CLEANUP_CHROOT $OBS_WIPE_AFTER_BUILD $OBS_WORKER_USE_MKFS_COPYIN $ARCH $EMULATOR" \
>> $screenrc
"$OBS_CLEANUP_CHROOT $OBS_WIPE_AFTER_BUILD $OBS_WORKER_USE_MKFS_COPYIN $OBS_WORKER_USE_CONTAINER_PREINSTALLIMAGE" \
"$ARCH $EMULATOR" >> $screenrc
mkdir -p $workerdir/$I
done
detachflag=
Expand Down
10 changes: 10 additions & 0 deletions dist/sysconfig.obs-server
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,16 @@ OBS_VM_DISK_AUTOSETUP_MOUNT_OPTIONS=""
#
OBS_WORKER_USE_MKFS_COPYIN=""

## Path: Applications/OBS
## Description: Enable using preinstallimage as container base image during build
## Type: ("yes" | "")
## Default: ""
## Config: OBS
#
# This is only possible for docker and podman containers
#
OBS_WORKER_USE_CONTAINER_PREINSTALLIMAGE=""

## Path: Applications/OBS
## Description: Enable build in memory
## Type: ("yes" | "")
Expand Down
28 changes: 20 additions & 8 deletions src/backend/bs_worker
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ my $vm_initrd;
my $vm_memory;
my $vm_custom_option;
my $vm_use_mkfs_copyin;
my $use_container_preinstallimage;
my $vm_enable_console;
my $vm_worker_name;
my $vm_worker_instance;
Expand Down Expand Up @@ -206,7 +207,7 @@ sub cleanup_job {
}

# if this is a chroot like case, get rid of it after the build
if ((!$vm || $vm eq 'lxc' || $vm eq 'docker' || $vm eq 'nspwan') && $cleanup_chroot && -d $buildroot) {
if ((!$vm || $vm eq 'lxc' || $vm eq 'docker' || $vm eq 'nspwan' || $vm eq 'podman') && $cleanup_chroot && -d $buildroot) {
print "Removing buildroot $buildroot...";
eval {
rm_rf($buildroot);
Expand All @@ -229,7 +230,7 @@ sub kill_job {
push @args, '--vm-worker-nr', $vm_worker_instance if $vm_worker_instance;
} else {
push @args, '--root', $buildroot;
push @args, '--vm-type', $vm if $vm eq 'lxc' || $vm eq 'docker';
push @args, '--vm-type', $vm if $vm eq 'lxc' || $vm eq 'docker' || $vm eq 'podman';
}
if (system("$statedir/build/build", @args, "--kill")) {
return 0;
Expand Down Expand Up @@ -307,7 +308,7 @@ Usage: $0 [OPTION] --root <directory> --statedir <directory>
--hostlabel : define a host label for build constraints, can be used multiple times

--vm-type : set virtualisation mode to use (kvm, xen, qemu:\$HOSTARCH, zvm, emulator:\$HOSTARCH)
Also possible are lxc or docker, but these are less secure and are not using
Also possible are lxc or docker or podman, but these are less secure and are not using
the specified kernel for the build target.

--vm-kernel : set kernel to use (xen/kvm)
Expand Down Expand Up @@ -336,6 +337,8 @@ Usage: $0 [OPTION] --root <directory> --statedir <directory>

--vm-network: enable network (kvm)

--vm-use-container-preinstallimage: use preinstallimage as container base image (docker|podman)

--emulator-script <script>
: Define the emulator script

Expand Down Expand Up @@ -482,7 +485,7 @@ while (@ARGV) {
$testmode = 1;
next;
}
if ($ARGV[0] =~ /^--(kvm|xen|lxc|emulator|zvm|docker|pvm|openstack)$/) {
if ($ARGV[0] =~ /^--(kvm|xen|lxc|emulator|zvm|docker|pvm|openstack|docker|podman)$/) {
$vm = $1;
shift @ARGV;
next;
Expand Down Expand Up @@ -547,6 +550,11 @@ while (@ARGV) {
$vm_use_mkfs_copyin = 1;
next;
}
if ($ARGV[0] eq '--vm-use-container-preinstallimage') {
shift @ARGV;
$use_container_preinstallimage = 1;
next;
}
if ($ARGV[0] eq '--vmdisk-rootsize') {
shift @ARGV;
$vmdisk_rootsize = shift @ARGV;
Expand Down Expand Up @@ -2459,7 +2467,8 @@ sub getpreinstallimage {
$imagesource =~ s/\/[^\/]*$//; # strip arch
$imagesource .= "/$imageinfo->{'package'}" if $imageinfo->{'package'};
$imagesource .= " [$imageinfo->{'hdrmd5'}]";
return $imagefile, \%imagebins, $imagesource, \%metas, \%imageorigins;
my $imageinfofile = -e "$dir/preinstallimage.info" ? 'preinstallimage.info' : undef;
return $imagefile, \%imagebins, $imagesource, \%metas, \%imageorigins, $imageinfofile;
}

sub getbinaries_buildenv {
Expand Down Expand Up @@ -2879,12 +2888,13 @@ sub getbinaries {
# get a preinstall image if available
my ($imagefile, $imagebins);
if (@todo && $preinstallimagedata && $Build::Features::preinstallimage) {
my ($imagesource, $imagemetas, $imageorigins);
($imagefile, $imagebins, $imagesource, $imagemetas, $imageorigins) = getpreinstallimage($buildinfo, $dir, \@todo, \%bvls);
my ($imagesource, $imagemetas, $imageorigins, $imageinfofile);
($imagefile, $imagebins, $imagesource, $imagemetas, $imageorigins, $imageinfofile) = getpreinstallimage($buildinfo, $dir, \@todo, \%bvls);
if ($imagefile && $imagebins && $imagemetas) {
$preinstallimagedata->{'imagename'} = $imagefile;
$preinstallimagedata->{'imagebins'} = $imagebins;
$preinstallimagedata->{'imagesource'} = $imagesource;
$preinstallimagedata->{'imageinfofile'} = $imageinfofile if $imageinfofile;
$meta{$_} = 1 for keys %$imagemetas;
if ($outbdep) {
# record preinstallimage data
Expand Down Expand Up @@ -4052,6 +4062,7 @@ sub dobuild {
}
push @rpmlist, "preinstallimage: $pkgdir/$preinstallimagedata->{'imagename'}" if $preinstallimagedata->{'imagename'};
push @rpmlist, "preinstallimagesource: $preinstallimagedata->{'imagesource'}" if $preinstallimagedata->{'imagesource'};
push @rpmlist, "preinstallimageinfo: $pkgdir/$preinstallimagedata->{'imageinfofile'}" if $preinstallimagedata->{'imageinfofile'};
push @rpmlist, "localkiwi $localkiwi/localkiwi.rpm" if $localkiwi && -e "$localkiwi/localkiwi.rpm";
push @rpmlist, "preinstall: ".join(' ', map {$_->{'name'}} grep {$_->{'preinstall'}} @bdep);
push @rpmlist, "vminstall: ".join(' ', map {$_->{'name'}} grep {$_->{'vminstall'}} @bdep);
Expand Down Expand Up @@ -4110,10 +4121,11 @@ sub dobuild {
push @args, "--vm-worker", $vm_worker_name;
push @args, "--vm-kernel", $vm_kernel;
push @args, "--openstack-flavor", "$openstack_flavor";
} elsif ($vm eq 'lxc' || $vm eq 'docker') {
} elsif ($vm eq 'lxc' || $vm eq 'docker' || $vm eq 'podman') {
push @args, '--root', $buildroot;
push @args, '--vm-type', $vm;
push @args, '--memory', $vm_memory if $vm_memory;
push @args, '--vm-use-container-preinstallimage' if ($vm eq 'docker' || $vm eq 'podman') && $use_container_preinstallimage;
} else {
print "VM-TYPE $vm not detected" if $vm;
push @args, '--root', $buildroot;
Expand Down