File cockpit.spec of Package cockpit

%define realname cockpit
%define srcext   tar.bz2

%if 0%{?suse_version}
%if %{suse_version} >= 1500
%define npm_pkg npm8
%else
%define npm_pkg npm6
%endif
%else
%define npm_pkg npm
%endif

# Common info
Name:          %{realname}
Version:       0
Release:       wiz%{?extraver:0.}1%{?dist}
License:       LGPL-2.1+
Group:         System/Management
URL:           https://cockpit-project.org/
Summary:       A sysadmin login session in a web browser

# Install-time parameters
Provides:      cockpit-ws = %{version}-%{release}
Obsoletes:     cockpit-ws < %{version}-%{release}
Requires:      systemd
Requires:      polkit
%if 0%{?suse_version}
Requires:      openssh
%else
Requires:      openssh-clients
%endif
# Required for branding
%if 0%{?centos} || 0%{?fedora} || 0%{?rhel}
Requires:      redhat-logos
%endif

# Build-time parameters
BuildRequires: autoconf automake libtool
BuildRequires: %{npm_pkg}
BuildRequires: pkgconfig
BuildRequires: gettext intltool
BuildRequires: pkgconfig(gio-unix-2.0) >= 2.37.4 pkgconfig(gio-2.0) >= 2.37.4
BuildRequires: pkgconfig(glib-2.0) >= 2.34
BuildRequires: pkgconfig(libsystemd) pkgconfig(systemd)
BuildRequires: pkgconfig(json-glib-1.0) >= 0.14.0
BuildRequires: pkgconfig(polkit-agent-1) >= 0.105
BuildRequires: krb5-devel
BuildRequires: pam-devel
BuildRequires: polkit
BuildRequires: sudo
BuildRequires: coreutils
BuildRequires: xmlto
%if 0%{?suse_version}
BuildRequires: pkgconfig(libssh) >= 0.6.0
BuildRequires: shadow
BuildRequires: libpcp-devel libpcp3 libpcp_import1
BuildRequires: openssh
BuildRequires: libxslt-tools
%define nfs_client_pkg "nfs-client"
%define appstream_data_pkg []
%else
BuildRequires: shadow-utils
BuildRequires: pcp-libs-devel pcp-libs
BuildRequires: openssh-clients
BuildRequires: libxslt
%define nfs_client_pkg "nfs-utils"
%define appstream_data_pkg "appstream-data"
%endif
BuildRoot:     %{_tmppath}/%{name}-root
Source0:       %{realname}-%{version}.%{srcext}
# Generated by
#   npm install --no-optional
#   find node_modules -name test | xargs rm -rf
Source1:       node_modules.tar.bz2

%description
Cockpit is an interactive server admin interface. It is easy to use and very
lightweight. Cockpit interacts directly with the operating system from a real
Linux session in a browser.

%package apps
Group:         System/Management
Summary:       Cockpit user interface for Applications
Requires:      cockpit-bridge >= 122
Requires:      python%{?suse_version:3}

%description apps
Cockpit user interface for managing applications using AppStreams.

%package bridge
Group:         System/Management
Summary:       Cockpit host agent

%description bridge
Cockpit-bridge is run on each managed server, with the credentials of the user
that is logged into the Server Console.

%package dashboard
Group:         System/Management
Summary:       Cockpit remote servers and dashboard
Requires:      cockpit-bridge >= 138
Provides:      cockpit-ssh = %{version}-%{release}

%description dashboard
Cockpit support for connecting to remote servers (through ssh),
bastion hosts, and a basic dashboard.

%package docker
Group:         System/Management
Summary:       Cockpit user interface for Docker containers
Requires:      cockpit-bridge >= 122

%description docker
The Cockpit components for interacting with Docker and user interface.

%package kubernetes
Group:         System/Management
Summary:       Cockpit user interface for Kubernetes cluster
Requires:      cockpit-bridge >= 137

%description kubernetes
The Cockpit components for visualizing and configuring a Kubernetes
cluster. Installed on the Kubernetes master.

%package machines
Group:         System/Management
Summary:       Cockpit user interface for virtual machines
Requires:      cockpit-bridge >= 122
Requires:      libvirt-client

%description machines
The Cockpit components for managing virtual machines.

%package ovirt
Group:         System/Management
Summary:       Cockpit user interface for oVirt Machines
Requires:      cockpit-bridge >= 122

%description ovirt
The Cockpit components for managing oVirt virtual machines.

%package pcp
Group:         System/Management
Summary:       Cockpit PCP integration
Requires:      cockpit-bridge >= 134
Requires:      pcp

%description pcp
Cockpit support for reading PCP metrics and loading PCP archives.

%package packagekit
Group:         System/Management
Summary:       Cockpit user interface for package updates
Requires:      cockpit-bridge >= 138
Requires:      PackageKit

%description packagekit
The Cockpit component for installing package updates, via PackageKit.

%package storaged
Group:         System/Management
Summary:       Cockpit user interface for storage, using udisks
Requires:      cockpit-bridge >= 122
Requires:      udisks2
%if 0%{?centos} || 0%{?fedora} || 0%{?rhel}
Requires:      udisks2-iscsi udisks2-lvm2
%endif

%description storaged
The Cockpit component for managing storage. This package uses udisks.

%package system
Group:         System/Management
Summary:       Cockpit admin interface package for configuring and troubleshooting a system
Requires:      cockpit-bridge >= 134
%if 0%{?suse_version}
Requires:      shadow
%else
Requires:      shadow-utils
%endif
%if 0%{?rhel}
Requires:      subscription-manager
%endif
Provides:      cockpit-kdump = %{version}-%{release}
Provides:      cockpit-networkmanager = %{version}-%{release}
Provides:      cockpit-realmd = %{version}-%{release}
Provides:      cockpit-selinux = %{version}-%{release}
Provides:      cockpit-shell = %{version}-%{release}
Provides:      cockpit-sosreport = %{version}-%{release}
Provides:      cockpit-subscriptions = %{version}-%{release}
Provides:      cockpit-systemd = %{version}-%{release}
Provides:      cockpit-tuned = %{version}-%{release}
Provides:      cockpit-users = %{version}-%{release}

%description system
This package contains the Cockpit shell and system configuration interfaces.

%package doc
Group:         Documentation/HTML
Summary:       Cockpit deployment and developer guide
BuildArch:     noarch

%description doc
The Cockpit Deployment and Developer Guide shows sysadmins how to
deploy Cockpit on their machines as well as helps developers who want to
embed or extend Cockpit.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}%{?extraver} -a1
[ -x configure ] || autoreconf -f -i -I tools

# Build step (compile/build binaries, documentation, etc)
%build
_CFLAGS='%{optflags} %{?gcc_lto}'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all %{?gcc_lto}'
%configure \
 --disable-maintainer-mode \
 --enable-asan='no' \
 --enable-debug='no' \
 --with-pamdir='/%{_lib}/security' \
 --with-storaged-iscsi-sessions='yes' \
 --with-appstream-data-packages='%{?appstream_data_pkg}' \
 --with-nfs-client-package='%{?nfs_client_pkg}' \
 PACKAGE_VERSION='%{version}' \
 CFLAGS="$_CFLAGS" \
 LDFLAGS="$_LDFLAGS"
%{__make} V=1 %{?_smp_mflags} libpam_ssh_add_a_CFLAGS='-fPIC'

# Install built stuff
%install
%{__make} install DESTDIR=%{buildroot}
%{__mkdir} -p %{buildroot}%{_rundir}/cockpit
touch %{buildroot}%{_rundir}/cockpit/motd
%{find_lang} %{name}
# Remove unusable branding
if [ "%{buildroot}" != "/" ]; then
%if ! 0%{?centos}
%{__rm} -rf %{buildroot}/%{_datadir}/cockpit/branding/centos
%endif
%{__rm} -rf %{buildroot}/%{_datadir}/cockpit/branding/debian
%if ! 0%{?fedora}
%{__rm} -rf %{buildroot}/%{_datadir}/cockpit/branding/fedora
%endif
%if ! 0%{?rhel}
%{__rm} -rf %{buildroot}/%{_datadir}/cockpit/branding/rhel
%endif
%{__rm} -rf %{buildroot}/%{_datadir}/cockpit/branding/ubuntu
fi

# Cleanup
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

# Files list
%files -f %{name}.lang
%defattr(-,root,root)
%doc AUTHORS COPYING README.md
%dir %{_sysconfdir}/cockpit/ws-certs.d
%dir %{_sysconfdir}/cockpit
%dir %{_sysconfdir}/issue.d
%dir %{_sysconfdir}/motd.d
%config %{_sysconfdir}/issue.d/cockpit.issue
%config %{_sysconfdir}/motd.d/cockpit
%{_sbindir}/remotectl
%{_libexecdir}/cockpit-desktop
%{_libexecdir}/cockpit-session
%{_libexecdir}/cockpit-ws
/%{_lib}/security/pam_ssh_add.so
%dir %{_prefix}/lib/firewalld/services
%dir %{_prefix}/lib/firewalld
%{_prefix}/lib/firewalld/services/cockpit.xml
%{_unitdir}/*
%{_tmpfilesdir}/cockpit-tempfiles.conf
%{_datadir}/cockpit/base1/
%{_datadir}/cockpit/branding/
%{_datadir}/cockpit/motd/
%exclude %{_datadir}/cockpit/playground/
%{_datadir}/cockpit/static/
%dir %{_datadir}/metainfo
%{_datadir}/metainfo/cockpit.appdata.xml
%{_datadir}/pixmaps/cockpit-sosreport.png
%{_datadir}/pixmaps/cockpit.png
%dir %{_datadir}/cockpit
%doc %{_mandir}/man1/cockpit.1*
%doc %{_mandir}/man1/cockpit-desktop.1*
%doc %{_mandir}/man5/*
%doc %{_mandir}/man8/*
%ghost %{_rundir}/cockpit/motd
%ghost %dir %{_rundir}/cockpit
%dir %{_localstatedir}/lib/cockpit
%exclude %{_prefix}/src/debug/

%files apps
%defattr(-,root,root)
%doc AUTHORS COPYING README.md
%{_datadir}/cockpit/apps/

%files bridge
%defattr(-,root,root)
%doc AUTHORS COPYING README.md
%dir %{_sysconfdir}/cockpit/machines.d
%dir %{_sysconfdir}/cockpit
%{_bindir}/cockpit-bridge
%{_libexecdir}/cockpit-askpass
%{_libexecdir}/cockpit-stub
%{_datadir}/polkit-1/actions/org.cockpit-project.cockpit-bridge.policy
%dir %{_datadir}/cockpit
%doc %{_mandir}/man1/cockpit-bridge.1*

%files dashboard
%defattr(-,root,root)
%doc AUTHORS COPYING README.md
%{_libexecdir}/cockpit-ssh
%{_datadir}/cockpit/dashboard/
%{_datadir}/cockpit/ssh/

%files docker
%defattr(-,root,root)
%doc AUTHORS COPYING README.md
%{_datadir}/cockpit/docker/

%files kubernetes
%defattr(-,root,root)
%doc AUTHORS COPYING README.md
%{_datadir}/cockpit/kubernetes/

%files machines
%defattr(-,root,root)
%doc AUTHORS COPYING README.md
%{_datadir}/cockpit/machines/
%{_datadir}/metainfo/org.cockpit-project.cockpit-machines.metainfo.xml

%files ovirt
%defattr(-,root,root)
%doc AUTHORS COPYING README.md
%{_datadir}/cockpit/ovirt/

%files packagekit
%defattr(-,root,root)
%doc AUTHORS COPYING README.md
%{_datadir}/cockpit/packagekit/

%files pcp
%defattr(-,root,root)
%doc AUTHORS COPYING README.md
%{_libexecdir}/cockpit-pcp
%{_datadir}/cockpit/pcp/
%dir %{_localstatedir}/lib/pcp/config/pmlogconf/tools/
%dir %{_localstatedir}/lib/pcp/config/pmlogconf
%dir %{_localstatedir}/lib/pcp/config
%dir %{_localstatedir}/lib/pcp
%{_localstatedir}/lib/pcp/config/pmlogconf/tools/cockpit

%files storaged
%defattr(-,root,root)
%doc AUTHORS COPYING README.md
%{_datadir}/cockpit/storaged/

%files system
%defattr(-,root,root)
%doc AUTHORS COPYING README.md
%{_datadir}/cockpit/kdump/
%{_datadir}/cockpit/networkmanager/
%{_datadir}/cockpit/realmd/
%if %{expand:%_vendor == "redhat"}
%{_datadir}/cockpit/selinux/
%else
%exclude %{_datadir}/cockpit/selinux/
%endif
%{_datadir}/cockpit/shell/
%{_datadir}/cockpit/sosreport/
%if 0%{?rhel}
%{_datadir}/cockpit/subscriptions/
%else
%exclude %{_datadir}/cockpit/subscriptions/
%endif
%{_datadir}/cockpit/systemd/
%{_datadir}/cockpit/tuned/
%{_datadir}/cockpit/users/
%{_datadir}/metainfo/org.cockpit-project.cockpit-kdump.metainfo.xml
%{_datadir}/metainfo/org.cockpit-project.cockpit-selinux.metainfo.xml
%{_datadir}/metainfo/org.cockpit-project.cockpit-sosreport.metainfo.xml

%files doc
%defattr(-,root,root)
%doc AUTHORS COPYING README.md
%docdir %{_datadir}/doc/cockpit
%doc %{_datadir}/doc/cockpit/*

%if %{expand:%_vendor == "suse"}

%pre
%{service_add_pre cockpit-motd.service}
%{service_add_pre cockpit.service}
%{service_add_pre cockpit.socket}

%post
%{service_add_post cockpit-motd.service}
%{service_add_post cockpit.service}
%{service_add_post cockpit.socket}
%{tmpfiles_create %{_tmpfilesdir}/cockpit-tempfiles.conf}

%preun
%{service_del_preun cockpit-motd.service}
%{service_del_preun cockpit.service}
%{service_del_preun cockpit.socket}

%postun
%{service_del_postun cockpit-motd.service}
%{service_del_postun cockpit.service}
%{service_del_postun cockpit.socket}

%endif

%changelog