File altimagebuild.spec of Package altimagebuild

# spec file for package altimagebuild
# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# needsrootforbuild
# --userootforbuild
%define x11	0
%define kernel  1
%define debug	0
%define cloud   0

Name:           altimagebuild
Version:        1
Release:        0
License:        MIT
Summary:        alternative image building
#Url:            x
Group:          Metapackages
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if %{kernel}
BuildRequires:  kernel-default
#BuildRequires:  syslinux,dosfstools
BuildRequires:  grub2
BuildRequires:  kexec-tools
BuildRequires:  -kernel-default
BuildRequires:  kpartx,-gcc,-gcc7
BuildRequires:	zypper, zypper-aptitude
BuildRequires:	nano,less
BuildRequires:	vim
BuildRequires:	wicked, dbus-1
BuildRequires:	mingetty,iputils,curl,ncurses-utils,iproute2
BuildRequires:  openSUSE-release
BuildRequires:  patterns-openSUSE-base, -rpmlint-mini,-rpmlint-Factory
%if 0%{?suse_version} >= 1500
BuildRequires:  patterns-base-minimal_base
BuildRequires:  patterns-base-base
BuildRequires:  rpm-build, sudo, rsync, e2fsprogs
# to avoid the -mini variants:
BuildRequires:	systemd,udev,krb5,gettext-tools,gettext-runtime
%if %{debug}
BuildRequires:	gdb,strace,binutils
%if %{x11}
BuildRequires:  xinit,xorg-x11-server,xf86-video-fbdev,xf86-input-evdev,-xf86-video-vesa,xterm,icewm-gnome,xdm
BuildRequires:  -libX11-6
%if %{cloud}
BuildRequires:  cloud-init-config-suse
BuildRequires:  cloud-init
BuildRequires:  qemu-tools
BuildRequires:  qemu-guest-agent

this package is intended to setup a suitable build-root dir
and produce a bootable system image
as an alternative to kiwi image building


%if %{cloud}
for s in init init-local config final ; do
    systemctl enable cloud-$s
sed -i 's/^disable_root: true/disable_root: false/' /etc/cloud/cloud.cfg

# to dracut add hv_storsvc ata_piix ata_generic virtio_blk virtio_pci virtio_scsi
echo hostonly=no > /etc/dracut.conf.d/40-hostonly.conf
test -r $(readlink /boot/initrd) || dracut --force
rm /etc/dracut.conf.d/40-hostonly.conf

cd %{buildroot}
export sle_version=%{sle_version}
bash -x %SOURCE1
bash -x %SOURCE2 /
mkdir -p %buildroot/var/lib/
%if %{debug}
exit 1 # for faster debugging
%if %{cloud}
qemu-img convert -c -O qcow2 /.img %buildroot/var/lib/altimagebuild-$(uname -m).qcow2
mv /.img %buildroot/var/lib/altimagebuild-$(uname -m).img
echo "We are done"


openSUSE Build Service is sponsored by