File python-kiwi.spec of Package python-kiwi.7478

#
# spec file for package kiwi
#
# Copyright (c) 2016 SUSE LINUX 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.
#
# Please submit bugfixes or comments via:
#
#       https://github.com/SUSE/kiwi/issues
#
%{!?python2_sitelib:%global python2_sitelib %{python_sitelib}}

# translate version id to distribution name as it is used in kiwi
# generic approach
%if 0%{?suse_version}
%define distro %(echo `export VER=%{suse_version}; echo "suse-${VER:0:2}.${VER:2:1}"`)
%endif

# SLE12:
%if 0%{?suse_version} == 1315 && !0%{?is_opensuse}
%define distro suse-SLES12
%endif

# SLE15:
%if 0%{?sle_version} == 150000 && !0%{?is_opensuse}
%define distro suse-SLES15
%endif

# Leap 42.1(openSUSE product based on SLE 12SP1):
%if 0%{?is_opensuse} && 0%{?sle_version} == 120100
%define distro suse-leap42.1
%endif

# Leap 42.2:
%if 0%{?is_opensuse} && 0%{?sle_version} == 120200
%define distro suse-leap42.2
%endif

# Leap 42.3:
%if 0%{?is_opensuse} && 0%{?sle_version} == 120300
%define distro suse-leap42.3
%endif

# Leap 15.0:
%if 0%{?is_opensuse} && 0%{?sle_version} == 150000
%define distro suse-leap15.0
%endif

# Leap 15.1:
%if 0%{?is_opensuse} && 0%{?sle_version} == 150100
%define distro suse-leap15.1
%endif

# Leap 15.2:
%if 0%{?is_opensuse} && 0%{?sle_version} == 150200
%define distro suse-leap15.2
%endif

# Leap 15.3:
%if 0%{?is_opensuse} && 0%{?sle_version} == 150300
%define distro suse-leap15.3
%endif

# Tumbleweed:
# Current Tumbleweed version, moving target
%if 0%{?suse_version} == 1330
%define distro suse-tumbleweed
%endif

# SLES with sles_version macro
%if 0%{?sles_version}
%define distro suse-SLES%{sles_version}
%endif

# RHEL // CentOS
# use the rhel templates for CentOS, too
%if 0%{?rhel} == 7
%define distro rhel-07.0
%endif

# Fedora
# use the rhel templates for CentOS, too
%if 0%{?fedora} >= 25
%define distro fedora-25.0
%endif

Name:           python-kiwi
Version:        8.33.3
Provides:       kiwi-schema = 6.6
Release:        0
Url:            https://github.com/SUSE/kiwi
Summary:        KIWI - Appliance Builder Next Generation
License:        GPL-3.0+
Group:          Development/Languages/Python
Source:         %{name}.tar.gz
Source1:        %{name}-boot-packages
Source2:        %{name}-rpmlintrc
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?fedora} || 0%{?suse_version}
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
BuildRequires:  fdupes
%endif
BuildRequires:  python-devel
BuildRequires:  python-setuptools
%if 0%{?suse_version}
BuildRequires:  shadow
BuildRequires:  update-alternatives
%endif
%if 0%{?fedora} || 0%{?rhel}
BuildRequires:  chkconfig
%endif

%description
The KIWI Image System provides an operating system image builder
for Linux supported hardware platforms as well as for virtualization
and cloud systems like Xen, KVM, VMware, EC2 and more.

# python2-kiwi
%package -n python2-kiwi
Summary:        KIWI - Appliance Builder Next Generation
Group:          Development/Languages/Python
Provides:       python-kiwi = %{version}-%{release}
Provides:       kiwi-image:tbz
Provides:       kiwi-image:docker
Provides:       kiwi-image:iso
Provides:       kiwi-image:vmx
Provides:       kiwi-image:pxe
Provides:       kiwi-image:oem
%if 0%{?fedora} || 0%{?suse_version}
Recommends:     jing
%endif
Requires:       python-PyYAML
Requires:       python-docopt
Requires:       python-future
Requires:       python-lxml
Requires:       python-requests
Requires:       python-setuptools
Requires:       python-six
Requires:       python-xattr
# tools used by kiwi
%if 0%{?suse_version}
Requires:       update-alternatives
Requires(post): update-alternatives
Requires(postun): update-alternatives
%ifarch x86_64
Requires:       grub2-x86_64-efi
%endif
Requires:       qemu-tools
Requires:       multipath-tools
Requires:       squashfs
Requires:       gptfdisk
%endif
%if 0%{?fedora} || 0%{?rhel}
Requires:         chkconfig
Requires(post):   chkconfig
Requires(postun): chkconfig
Requires:       qemu-img
Requires:       squashfs-tools
Requires:       device-mapper-multipath
Requires:       gdisk
Requires:       yum
Provides:       kiwi-packagemanager:yum
%if 0%{?fedora} || 0%{?rhel} >= 8
Requires:       dnf
Provides:       kiwi-packagemanager:dnf
%endif
%endif
%if 0%{?fedora} >= 26 || 0%{?suse_version}
Requires:       zypper
Provides:       kiwi-packagemanager:zypper
%endif
Requires:       dosfstools
Requires:       e2fsprogs
Requires:       genisoimage
Requires:       grub2
Requires:       kiwi-man-pages
Requires:       kiwi-tools
Requires:       lvm2
Requires:       mtools
Requires:       parted
Requires:       rsync
Requires:       tar >= 1.2.7
%ifarch %arm aarch64
Requires:       u-boot-tools
%endif
%ifarch s390 s390x
Requires:       s390-tools
%endif

%description -n python2-kiwi
Python 2 library of the KIWI Image System. Provides an operating system
image builder for Linux supported hardware platforms as well as for
virtualization and cloud systems like Xen, KVM, VMware, EC2 and more.

%if 0%{?fedora} || 0%{?suse_version}
# python3-kiwi
%package -n python3-kiwi
Summary:        KIWI - Appliance Builder Next Generation
Group:          Development/Languages/Python
Provides:       kiwi-image:tbz
Provides:       kiwi-image:docker
Provides:       kiwi-image:iso
Provides:       kiwi-image:vmx
Provides:       kiwi-image:pxe
Provides:       kiwi-image:oem
Recommends:     jing
Requires:       python3-PyYAML
Requires:       python3-docopt
Requires:       python3-future
Requires:       python3-lxml
Requires:       python3-requests
Requires:       python3-setuptools
Requires:       python3-six
Requires:       python3-xattr
# tools used by kiwi
%if 0%{?suse_version}
Requires:       update-alternatives
Requires(post): update-alternatives
Requires(postun): update-alternatives
%ifarch x86_64
Requires:       grub2-x86_64-efi
%endif
Requires:       qemu-tools
Requires:       multipath-tools
Requires:       squashfs
Requires:       gptfdisk
%endif
%if 0%{?fedora} || 0%{?rhel}
Requires:         chkconfig
Requires(post):   chkconfig
Requires(postun): chkconfig
Requires:       qemu-img
Requires:       squashfs-tools
Requires:       device-mapper-multipath
Requires:       gdisk
%endif
%if 0%{?rhel} && 0%{?rhel} < 8
Requires:       yum
Provides:       kiwi-packagemanager:yum
%endif
%if 0%{?fedora} || 0%{?rhel} >= 8
Requires:       dnf
Provides:       kiwi-packagemanager:dnf
%endif
%if 0%{?fedora} >= 26 || 0%{?suse_version}
Requires:       zypper
Provides:       kiwi-packagemanager:zypper
%endif
Requires:       dosfstools
Requires:       e2fsprogs
Requires:       genisoimage
Requires:       grub2
Requires:       kiwi-man-pages
Requires:       kiwi-tools
Requires:       lvm2
Requires:       mtools
Requires:       parted
Requires:       rsync
Requires:       tar >= 1.2.7
%ifarch %arm aarch64
Requires:       u-boot-tools
%endif
%ifarch s390 s390x
Requires:       s390-tools
%endif

%description -n python3-kiwi
Python 3 library of the KIWI Image System. Provides an operating system
image builder for Linux supported hardware platforms as well as for
virtualization and cloud systems like Xen, KVM, VMware, EC2 and more.

%endif

%package -n kiwi-tools
Summary:        KIWI - Collection of Boot Helper Tools
License:        GPL-3.0+
Group:          System/Management

%description -n kiwi-tools
This package contains a small set of helper tools used for the
kiwi created initial ramdisk which is used to control the very
first boot of an appliance. The tools are not meant to be used
outside of the scope of kiwi appliance building.

%ifarch %ix86 x86_64
%package -n kiwi-pxeboot
Summary:        KIWI - PXE boot structure
Requires:       syslinux
%if 0%{?fedora} || 0%{?rhel}
Requires(pre):  shadow-utils
%else
Requires(pre):  shadow
%endif
License:        GPL-3.0+
Group:          System/Management

%description -n kiwi-pxeboot
This package contains the basic PXE directory structure which is
needed to serve kiwi built images via PXE.
%endif

%package -n dracut-kiwi-live
Summary:        KIWI - Dracut module for iso(live) image type
BuildRequires:  dracut
Requires:       dialog
Requires:       xfsprogs
Requires:       e2fsprogs
Requires:       util-linux
Requires:       dracut
%if 0%{?fedora} || 0%{?rhel}
Requires:       genisoimage
%else
Requires:       cdrkit-cdrtools-compat
%endif
License:        GPL-3.0+
Group:          System/Management

%description -n dracut-kiwi-live
This package contains the kiwi-live dracut module which is used
for booting iso(live) images built with KIWI

%package -n dracut-kiwi-overlay
Summary:        KIWI - Dracut module for vmx(+overlay) image type
BuildRequires:  dracut
Requires:       util-linux
Requires:       dracut
License:        GPL-3.0+
Group:          System/Management

%description -n dracut-kiwi-overlay
This package contains the kiwi-overlay dracut module which is used
for booting vmx images built with KIWI and configured to use an
overlay root filesystem

%if 0%{?suse_version}
%package -n kiwi-boot-requires
Summary:        KIWI - buildservice package requirements for boot images
Provides:       kiwi-boot:netboot
Provides:       kiwi-boot:oemboot
Provides:       kiwi-filesystem:btrfs
Provides:       kiwi-filesystem:xfs
Provides:       kiwi-filesystem:ext3
Provides:       kiwi-filesystem:ext4
Provides:       kiwi-filesystem:squashfs
Requires:       e2fsprogs
Requires:       xfsprogs
%if 0%{?fedora} || 0%{?rhel}
Requires:       btrfs-progs
%else
Requires:       btrfsprogs
%endif
%if 0%{?fedora} || 0%{?suse_version}
Requires:       python3-kiwi = %{version}
%else
Requires:       python2-kiwi = %{version}
%endif
Requires:       %(echo `cat %{S:1}|grep %{_target_cpu}:%{distro}:|cut -f3- -d:`)
License:        GPL-3.0+
Group:          System/Management

%description -n kiwi-boot-requires
Meta package for the buildservice to pull in all required packages in
order to have them in the buildservice created repositories to allow
kiwi to build the boot image. This package must never be published
nor installed by anybody else except for the buildservice, it is part
of the kiwi - buildservice integration exclusively
%endif

%package -n kiwi-man-pages
Summary:        KIWI - manual pages
License:        GPL-3.0+
Group:          System/Management

%description -n kiwi-man-pages
Provides manual pages to describe the kiwi commands

%prep
%setup -q -n kiwi-%{version}

%build
# Build Python 2 version
python2 setup.py build --cflags="${RPM_OPT_FLAGS}"

%if 0%{?fedora} || 0%{?suse_version}
# Build Python 3 version
python3 setup.py build --cflags="${RPM_OPT_FLAGS}"
%endif

%install
# Install Python 2 version
python2 setup.py install --prefix=%{_prefix} --root=%{buildroot}

%if 0%{?fedora} || 0%{?suse_version}
# Install Python 3 version
python3 setup.py install --prefix=%{_prefix} --root=%{buildroot}
%endif

# init alternatives setup
mkdir -p %{buildroot}%{_sysconfdir}/alternatives

# alternatives setup for kiwi -> kiwi-ng-py_ver binary
touch %{buildroot}%{_sysconfdir}/alternatives/kiwi
ln -s %{_sysconfdir}/alternatives/kiwi \
    %{buildroot}%_bindir/kiwi

# alternatives setup for kiwi-ng -> kiwi-ng-py_ver binary
touch %{buildroot}%{_sysconfdir}/alternatives/kiwi-ng
ln -s %{_sysconfdir}/alternatives/kiwi-ng \
    %{buildroot}%_bindir/kiwi-ng

# alternatives setup for kiwicompat -> kiwicompat-py_ver binary
touch %{buildroot}%{_sysconfdir}/alternatives/kiwicompat
ln -s %{_sysconfdir}/alternatives/kiwicompat \
    %{buildroot}%_bindir/kiwicompat

# kiwi pxeboot directory structure to be packed in kiwi-pxeboot
%ifarch %ix86 x86_64
for i in KIWI pxelinux.cfg image upload boot; do \
    mkdir -p %{buildroot}/srv/tftpboot/$i ;\
done
%endif

%if  0%{?fedora} || 0%{?rhel}
install -m 755 -d %{buildroot}/%{_defaultdocdir}/python-kiwi
mv %{buildroot}/%{_defaultdocdir}/packages/python-kiwi/* %{buildroot}/%{_defaultdocdir}/python-kiwi
rm -rf %{buildroot}/%{_defaultdocdir}/packages
%endif

%if 0%{?fedora} || 0%{?suse_version}
%fdupes %{buildroot}/srv/tftpboot
%fdupes %{buildroot}/%{python3_sitelib}/kiwi/boot
%fdupes %{buildroot}/%{python2_sitelib}/kiwi/boot
%endif

%post -n python2-kiwi
%{_sbindir}/update-alternatives \
    --install %_bindir/kiwi kiwi %_bindir/kiwi-ng-2 10
%{_sbindir}/update-alternatives \
    --install %_bindir/kiwi-ng kiwi-ng %_bindir/kiwi-ng-2 10
%{_sbindir}/update-alternatives \
    --install %_bindir/kiwicompat kiwicompat %_bindir/kiwicompat-2 10

%if 0%{?fedora} || 0%{?suse_version}
%post -n python3-kiwi
%{_sbindir}/update-alternatives \
    --install %_bindir/kiwi kiwi %_bindir/kiwi-ng-3 10
%{_sbindir}/update-alternatives \
    --install %_bindir/kiwi-ng kiwi-ng %_bindir/kiwi-ng-3 10
%{_sbindir}/update-alternatives \
    --install %_bindir/kiwicompat kiwicompat %_bindir/kiwicompat-3 10
%endif

%preun -n python2-kiwi
%{_sbindir}/update-alternatives \
    --remove kiwi %_bindir/kiwi
%{_sbindir}/update-alternatives \
    --remove kiwi %_bindir/kiwi-ng
%{_sbindir}/update-alternatives \
    --remove kiwicompat %_bindir/kiwicompat

%if 0%{?fedora} || 0%{?suse_version}
%preun -n python3-kiwi
%{_sbindir}/update-alternatives \
    --remove kiwi %_bindir/kiwi
%{_sbindir}/update-alternatives \
    --remove kiwi %_bindir/kiwi-ng
%{_sbindir}/update-alternatives \
    --remove kiwicompat %_bindir/kiwicompat
%endif

%ifarch %ix86 x86_64
%pre -n kiwi-pxeboot
#============================================================
# create user and group tftp if they does not exist
if ! /usr/bin/getent group tftp >/dev/null; then
    %{_sbindir}/groupadd -r tftp
fi
if ! /usr/bin/getent passwd tftp >/dev/null; then
    %{_sbindir}/useradd -c "TFTP account" -d /srv/tftpboot -G tftp -g tftp \
        -r -s /bin/false tftp
fi
%endif

%files -n python2-kiwi
%defattr(-,root,root,-)
%{_bindir}/kiwi-ng-2*
%{_bindir}/kiwicompat-2*
%ghost %{_bindir}/kiwi
%ghost %{_bindir}/kiwi-ng
%ghost %{_bindir}/kiwicompat
%ghost %_sysconfdir/alternatives/kiwi
%ghost %_sysconfdir/alternatives/kiwi-ng
%ghost %_sysconfdir/alternatives/kiwicompat
%{python2_sitelib}/*
%config %_sysconfdir/bash_completion.d/kiwi-ng-2*.sh

%if 0%{?fedora} || 0%{?suse_version}
%files -n python3-kiwi
%defattr(-,root,root,-)
%{_bindir}/kiwi-ng-3*
%{_bindir}/kiwicompat-3*
%ghost %{_bindir}/kiwi
%ghost %{_bindir}/kiwi-ng
%ghost %{_bindir}/kiwicompat
%ghost %_sysconfdir/alternatives/kiwi
%ghost %_sysconfdir/alternatives/kiwi-ng
%ghost %_sysconfdir/alternatives/kiwicompat
%{python3_sitelib}/*
%config %_sysconfdir/bash_completion.d/kiwi-ng-3*.sh
%endif

%files -n kiwi-man-pages
%defattr(-, root, root)
%dir %{_defaultdocdir}/python-kiwi
%{_defaultdocdir}/python-kiwi/LICENSE
%{_defaultdocdir}/python-kiwi/README
%doc %{_mandir}/man8/*

%files -n kiwi-tools
%defattr(-, root, root)
%exclude %{_bindir}/kiwi
%exclude %{_bindir}/kiwicompat
%exclude %{_bindir}/kiwi-ng*
%exclude %{_bindir}/kiwicompat-*
%{_bindir}/*

%files -n dracut-kiwi-live
%defattr(-, root, root)
%{_usr}/lib/dracut/modules.d/90kiwi-live

%files -n dracut-kiwi-overlay
%defattr(-, root, root)
%{_usr}/lib/dracut/modules.d/90kiwi-overlay

%ifarch %ix86 x86_64
%files -n kiwi-pxeboot
%defattr(-, root, root)
%dir %attr(0755,tftp,tftp) /srv/tftpboot
%dir /srv/tftpboot/KIWI
%dir /srv/tftpboot/pxelinux.cfg
%dir /srv/tftpboot/image
%dir /srv/tftpboot/upload
%dir /srv/tftpboot/boot
%endif

%if 0%{?suse_version}
%files -n kiwi-boot-requires
%defattr(-, root, root)
%endif

%changelog
openSUSE Build Service is sponsored by