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
Source1:        mkrootfs.sh
Source2:        mkimage.sh
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if %{kernel}
BuildRequires:  kernel-default
#BuildRequires:  syslinux,dosfstools
BuildRequires:  grub2
BuildRequires:  kexec-tools
%else
BuildRequires:  -kernel-default
%endif
BuildRequires:  kpartx,-gcc,-gcc7
BuildRequires:	zypper, zypper-aptitude
BuildRequires:	nano,less
BuildRequires:	vim
BuildRequires:	wicked
BuildRequires:	systemd-sysvinit,mingetty,iputils,curl,ncurses-utils,iproute2
BuildRequires:  patterns-openSUSE-base, -rpmlint-mini,-rpmlint-Factory
%if 0%{?suse_version} >= 1500
BuildRequires:  patterns-base-minimal_base
BuildRequires:  patterns-base-base
%endif
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
%endif
%if %{x11}
BuildRequires:  xinit,xorg-x11-server,xf86-video-fbdev,xf86-input-evdev,-xf86-video-vesa,xterm,icewm-gnome,xdm
%else
BuildRequires:  -libX11-6
%endif
%if %{cloud}
BuildRequires:  cloud-init-config-suse
BuildRequires:  cloud-init
BuildRequires:  qemu-tools
%endif
BuildRequires:  qemu-guest-agent

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

%prep

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

# 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) || mkinitrd
rm /etc/dracut.conf.d/40-hostonly.conf

%install
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
%endif
%if %{cloud}
qemu-img convert -c -O qcow2 /.img %buildroot/var/lib/altimagebuild-$(uname -m).qcow2
%else
mv /.img %buildroot/var/lib/altimagebuild-$(uname -m).img
%endif
echo "We are done"

%files
%defattr(-,root,root)
/var/lib/altimagebuild-*

%changelog
openSUSE Build Service is sponsored by