Skip to content

Conversation

@mahdiyehmr
Copy link

Hi,

This PR is trying to download preinstallimage.info when preinstallimage.tar.gz is downloaded and pass it in the package list and allow docker and podman to use preinstallimage as container base image at build time to avoid the extra time that it takes to untar the preinstallimage and install the included packages in build environment.

This change is for my masters thesis. Sorry about not sending an email before starting the process.
I've tried to keep the approach as non invasive as possible. The previous solution still works and if preinstallimage is not found the traditional solution is used even if the option to use preinstallimage as base image for container is enabled.
The last commit should be dropped before merge since it's only for testing purpose.

The combination of this PR and the openSUSE/obs-build#1105 should allow obs to import preinstallimage a container image for docker and podman if the option is enabled.

I've tested it in local obs setup and in local build with osc build for both podman and docker.

The change for osc to support preinstallimage.info is at openSUSE/osc@57bdcf2.

For verifying the change in obs please OBS_VM_TYPE="podman" or OBS_VM_TYPE="docker" and OBS_WORKER_USE_CONTAINER_PREINSTALLIMAGE="yes" in buildhost.config or sysconfig.obs-server.

For verifying the change in osc build please run osc build with --build-opt="--vm-use-container-preinstallimage" and --vm-type of docker or podman.

I checked build timestamps for checking how much the build time is reduces. It of course depends on how big the preinstallimage is. I tested a preinstallimage with a sample specfile that was not doing any significant build.

When the option was disabled the build time was 13 seconds for docker and 96 seconds for podman. After using the option for the first time that image is being imported in the container images in the worker host it took 72s for docker and 45s for podman. In second build where the image was already imported it took 7s for docker and 8s for podman. This option would make sense for cases were the preinstallimage and it's dependencies are not changing frequently but there are frequent builds using that preinstallimage.

You can see the preinstallimage and spec file that I tested in couple of lines. Please let me know if there is anything I need to do or if you have any questions.

preinstallimage:

Name: heavy-base
BuildRequires: bash
BuildRequire: gcc-c++
BuildRequires:  cmake
BuildRequires:  make
BuildRequires:  pkg-config
BuildRequires:  libboost_headers-devel
BuildRequires:  libboost_system-devel
BuildRequires:  libqt5-qtbase-devel
BuildRequires:  libqt5-qttools-devel
BuildRequires:  opencv-devel
BuildRequires:  ffmpeg-4-libavcodec-devel
BuildRequires:  gstreamer-devel
BuildRequires:  gstreamer-plugins-base-devel
BuildRequires:  gtk3-devel
BuildRequires:  libxml2-devel
BuildRequires:  libxslt-devel
BuildRequires:  libopenssl-devel
BuildRequires:  libcurl-devel
BuildRequires:  sqlite3-devel
BuildRequires:  postgresql-devel
BuildRequires:  libmysqlclient-devel
BuildRequires:  python3-devel
BuildRequires:  python3-numpy-devel
BuildRequires:  python3-scipy
BuildRequires:  nodejs-common
BuildRequires:  rust
BuildRequires:  cargo
BuildRequires:  go
BuildRequires:  java-11-openjdk-devel
BuildRequires:  maven
BuildRequires:  gradle
BuildRequires:  texlive-latex-bin
BuildRequires:  ImageMagick-devel
BuildRequires:  libreoffice-sdk
#!BuildIgnore: brp-trim-desktopfiles

spec file:

Name:           heavy-build-test
Version:        1.0
Release:        1
Summary:        Test package with heavy BuildRequires
License:        MIT
URL:            https://example.com
Source0:        %{name}-%{version}.tar.gz

# Heavy BuildRequires that will stress the preinstallimage
BuildRequires:  gcc-c++
BuildRequires:  cmake
BuildRequires:  make
BuildRequires:  pkg-config
BuildRequires:  libboost_headers-devel
BuildRequires:  libboost_system-devel
BuildRequires:  libqt5-qtbase-devel
BuildRequires:  libqt5-qttools-devel
BuildRequires:  opencv-devel
BuildRequires:  ffmpeg-4-libavcodec-devel
BuildRequires:  gstreamer-devel
BuildRequires:  gstreamer-plugins-base-devel
BuildRequires:  gtk3-devel
BuildRequires:  libxml2-devel
BuildRequires:  libxslt-devel
BuildRequires:  libopenssl-devel
BuildRequires:  libcurl-devel
BuildRequires:  sqlite3-devel
BuildRequires:  postgresql-devel
BuildRequires:  libmysqlclient-devel
BuildRequires:  python3-devel
BuildRequires:  python3-numpy-devel
BuildRequires:  python3-scipy
BuildRequires:  nodejs-common
BuildRequires:  rust
BuildRequires:  cargo
BuildRequires:  go
BuildRequires:  java-11-openjdk-devel
BuildRequires:  maven
BuildRequires:  gradle
BuildRequires:  texlive-latex-bin
BuildRequires:  ImageMagick-devel
BuildRequires:  libreoffice-sdk

%description
A test package designed to have many heavy BuildRequires dependencies
to benchmark preinstallimage performance improvements in OBS.

%prep
%setup -q

%build
# Simple build that uses some of the dependencies
echo "Testing heavy dependencies build..."
gcc --version
cmake --version
python3 --version
java -version
go version
rustc --version
node --version

# Create a simple test program
cat > test.cpp << 'EOF'
#include <iostream>
#include <boost/version.hpp>
int main() {
    std::cout << "Boost version: " << BOOST_VERSION << std::endl;
    return 0;
}
EOF

g++ -o test test.cpp -lboost_system

%install
mkdir -p %{buildroot}%{_bindir}
install -m 755 test %{buildroot}%{_bindir}/heavy-build-test

%files
%{_bindir}/heavy-build-test

%changelog
* Sun Sep 01 2024 Test User <[email protected]> - 1.0-1
- Initial package for testing heavy BuildRequires

@github-actions github-actions bot added the Backend Things regarding the OBS backend label Nov 10, 2025
.gitmodules Outdated
path = src/backend/build
url = https://github.com/openSUSE/obs-build.git
path = src/backend/build
url = https://github.com/mahdiyehmr/obs-build.git
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can not merge this part for sure

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not expect that to be merged either. I added it as last commit "Temporarily change submodule" so in review step you can test it. For merge the changes in this PR openSUSE/obs-build#1105 should be merged first then the submodule revision should be updated to point at a revision that contains that commit and then this one can be merged.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the last commit. The test of this PR alone would fail. For testing please test with openSUSE/obs-build#1105

@mahdiyehmr mahdiyehmr force-pushed the master branch 2 times, most recently from e14fce9 to 5995d94 Compare November 27, 2025 09:17
Extend preinstall image handling to include optional image info files:

- Modified getpreinstallimage() to detect and return preinstallimage.info file path
- Updated getbinaries() to store imageinfofile in preinstallimagedata structure
- Added preinstallimageinfo entry to rpmlist in dobuild() when info file exists
Add Podman as supported virtualization type alongside LXC and Docker.
Updates worker scripts to handle Podman containers in cleanup, job
management, and build execution workflows.
Add --vm-use-container-preinstallimage option to enable using
preinstallimage as base container image during builds. Includes
configuration option OBS_WORKER_USE_CONTAINER_PREINSTALLIMAGE
and integration with worker startup scripts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend Things regarding the OBS backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants