File DisplayCAL.spec of Package DisplayCAL

# spec file for package DisplayCAL (SUSE based distributions only)
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2017 Florian Hoech
# 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

%define numpy_version 1.0
%define py_minversion 2.6
%define py_maxversion 2.7
%define wx_minversion 3.0

%global debug_package %{nil}

Summary:        Display calibration and profiling with a focus on accuracy and versatility
License:        GPL-3.0+
Group:          Productivity/Graphics/Other
Name:           DisplayCAL
Release:        0
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires:       p7zip
Obsoletes:      DisplayCAL-0install
Provides:       dispcalGUI = %{version}
Obsoletes:      dispcalGUI <
Obsoletes:      dispcalGUI-0install <
BuildRequires:  gcc
BuildRequires:  python-devel
BuildRequires:  udev
BuildRequires:  update-desktop-files
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(xinerama)
BuildRequires:  pkgconfig(xrandr)
BuildRequires:  pkgconfig(xxf86vm)
Requires:       argyllcms
Requires:       python-xml
Requires:       python-numpy >= %{numpy_version}
Requires:       libSDL2_mixer-2_0-0
Requires:       python-wxGTK >= %{wx_minversion}

This utility calibrates and characterizes display devices using one
of many supported measurement instruments, with support for
multi-display setups and a variety of available options for advanced
users, such as verification and reporting functionality to evaluate
ICC profiles and display devices, creating video 3D LUTs, as well as
optional CIECAM02 gamut mapping to take into account varying viewing

# Convert line endings in LICENSE.txt
%{__python} -c "f = open('LICENSE.txt', 'rb')
d ='\r\n', '\n').replace('\r', '\n')
f = open('LICENSE.txt', 'wb')

%{__python} build --use-distutils

install_lib=`%{__python} -c "from distutils.sysconfig import get_python_lib;print get_python_lib(True)"`
%{__python} install --use-distutils \
	--root=$RPM_BUILD_ROOT \
	--prefix=%_prefix \
	--exec-prefix=%_exec_prefix \
	--install-data=%_datadir \
    --install-lib=${install_lib} \
	--skip-instrument-configuration-files \
	--skip-postinstall \

# Strip extensions
bits=`%{__python} -c "import platform;print platform.architecture()[0][:2]"`
python_shortversion=`%{__python} -c "import sys;print ''.join(map(str, sys.version_info[:2]))"`
strip --strip-unneeded ${RPM_BUILD_ROOT}${install_lib}/%{name}/lib${bits}/python${python_shortversion}/*.so

# Remove doc directory
if [ -e "${RPM_BUILD_ROOT}%_datadir/doc/%{name}-%{version}" ]; then
	rm -rf "${RPM_BUILD_ROOT}%_datadir/doc/%{name}-%{version}"

# Update desktop files to prevent buildservice from complaining
desktopfilenames=`%{__python} -c "import glob
import os
print ' '.join([os.path.splitext(os.path.basename(path))[0] for path in
for desktopfilename in $desktopfilenames ; do
	%suse_update_desktop_file $desktopfilename 2DGraphics
%suse_update_desktop_file "%{buildroot}/etc/xdg/autostart/z-displaycal-apply-profiles.desktop"

# Prepare files list:
# - Remove traces of RPM_BUILD_ROOT
# - Remove unused files from list of installed files and add directories
#   as well as mark files as executable where needed
%{__python} -c "import os
paths = [chr(0x22) + path.replace('$RPM_BUILD_ROOT', '').strip() + chr(0x22) for path in 
		 filter(lambda path: not '/doc/' in path and not '/etc/' in path and
				not '/man/' in path, 
executables = ['Argyll'] + os.listdir('scripts')
for path in list(paths):
	path = path.strip(chr(0x22))
	if os.path.basename(path) in executables:
		paths.remove(chr(0x22) + path + chr(0x22))
		paths.append('%attr(755, root, root) ' + chr(0x22) + path + chr(0x22))
	while True:
		path = os.path.dirname(path)
		if os.path.isdir(path):
			directory = '%dir ' + chr(0x22) + path + chr(0x22)
			if not directory in paths:
f = open('INSTALLED_FILES', 'w')

%config /etc/xdg/autostart/z-displaycal-apply-profiles.desktop
%doc LICENSE.txt
%doc README.html
%doc README-fr.html
%doc screenshots
%doc theme


# Update icon cache and menu
/bin/touch --no-create %{_datadir}/icons/hicolor &> /dev/null || true
which xdg-icon-resource &> /dev/null && xdg-icon-resource forceupdate || true
which xdg-desktop-menu &> /dev/null && xdg-desktop-menu forceupdate || true


# Update icon cache and menu
/bin/touch --no-create %{_datadir}/icons/hicolor &> /dev/null || true
which xdg-desktop-menu &> /dev/null && xdg-desktop-menu forceupdate || true
which xdg-icon-resource &> /dev/null && xdg-icon-resource forceupdate || true