Files
cupscloudprint/cupscloudprint.spec

234 lines
9.4 KiB
RPMSpec

#
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
Name: cupscloudprint
%define upstream_version 20140814
# Have 'v' as prefix for the upstream version to be future proof
# if upstream might release a '0.0.1' version because
# zypper vcmp 'v.20140814' '0.0.1'
# results "v.20140814 is older than 0.0.1".
# Using "tilde versions" as described at
# https://en.opensuse.org/openSUSE:Package_naming_guidelines#Handling_special_version_strings
# is not possible because "tilde versions" are unsupported in older openSUSE and SLE versions
# and intentionally cupscloudprint should be available for older openSUSE and SLE versions:
Version: v.%upstream_version
Release: 0
License: GPL-3.0+
Group: Hardware/Printing
Summary: Client for Google Cloud Print Service
URL: http://www.niftiestsoftware.com/cups-cloud-print/
# Get Source0 via GIT:
# git clone git://github.com/simoncadman/CUPS-Cloud-Print.git
# results a 20140814.tar.gz file that is used as Source0:
Source0: https://github.com/simoncadman/CUPS-Cloud-Print/archive/20140814.tar.gz
Source1: README.opensuse
Source2: cloudprint.png
Source3: cupscloudprint.rpmlintrc
# SLE12 needs special BuildRequires.
# For suse_version values see https://en.opensuse.org/openSUSE:Build_Service_cross_distribution_howto
%if 0%{?suse_version} == 1315
# For SLE12 by default CUPS 1.7.5 is provided and alternatively CUPS 1.5.4 is provided in the "legacy" module.
# For SLE12 build it with traditional CUPS 1.5.4 to ensure it works on SLE12 both with CUPS 1.7.5 and CUPS 1.5.4
# because libcups and libcupsimage in CUPS 1.7.5 are backward compatible with CUPS 1.5.4 so that applications
# that have been built with CUPS 1.5.4 also work under CUPS 1.7.5 but the libraries in CUPS 1.7.5 provide
# some additional functions so that applications that have been built with CUPS 1.7.5 and use those
# additional functions would not work under CUPS 1.7.5.
# Only in the Printing project for SLE12 use cups154-ddk (a sub package of the cups154-SLE12 source package):
BuildRequires: cups154-devel
%else
# Anything what is not SLE12 (i.e. SLE11 and all openSUSE versions) have "normal" BuildRequires:
BuildRequires: cups-devel
%endif
BuildRequires: make
BuildRequires: python
BuildRequires: python-cups
BuildRequires: python-httplib2
BuildRequires: update-desktop-files
Requires: cups
Requires: python
Requires: python-httplib2
Requires: xdg-utils
# The following have been strict RPM Requires but it seems
# they are not strictly required in any case to use CUPS-Cloud-Print
# so that a weak RPM Recommends should fit better in particular
# when CUPS-Cloud-Print should be used on relatively minimal systems:
Recommends: ImageMagick
Recommends: colord
Recommends: ghostscript
Recommends: system-config-printer-common
# Install into this non-root directory (must be explicitly specified to build for SLE11):
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# python_sitelib is only defined since SLE_11_SP2
# so that the following would make it build also for SLE_11_SP1 and SLE_11
# %%{!?python_sitelib: %%global python_sitelib %%_datadir}
# but then packages for SLE_11_SP1 and SLE_11 would be different
# than those for SLE_11_SP2 and later which is against the rule
# that SLE11 packages should be interchangeable for all service packs.
# The following is used to build same packages for SLE_11 and all service packs.
# For SLE11 (and all service packs) suse_version == 1110,
# see https://en.opensuse.org/openSUSE:Build_Service_cross_distribution_howto
%if 0%{?suse_version} > 1110
%define not_sle11 1
%endif
# Currently CUPS-Cloud-Print does not work when its Python files are
# in /usr/lib/python2.7/site-packages/cloudprint-cups/
# it seems it uses hardcoded /usr/share/cloudprint-cups/
# so that for now to make it work python_sitelib is not used
# until its usage is properly fixed in CUPS-Cloud-Print
# and therefore not_sle11 is for now undefined:
%undefine not_sle11
# A Python package that only contains .py and/or .pyc and/or .pyo files is "noarch"
# provided it installs entirely into python_sitelib
# see https://en.opensuse.org/openSUSE:Packaging_Python
# that reads (excerpt) as of this writing (Thu Oct 16 2014):
# System Architecture
# If your package only contains python sources (.py), bytecode files (.pyc and .pyo) and
# platform-independent data, you should mark it as noarch. Include BuildArchitectures: noarch
# at the start of your spec file. Such module should install entirely into python_sitelib.
# ...
# Compatibility with older distributions
# ...
# If your package is noarch, you must wrap the noarch declaration in a conditional sequence.
# This would build your package as noarch only on openSUSE 11.2 and higher:
# if suse_version >= 1120
# BuildArchitectures: noarch
# endif
# As long as python_sitelib is not used (see above) also "BuildArch: noarch" is not used:
%if 0%{?not_sle11}
BuildArch: noarch
%endif
%description
The Google Cloud Print service allows various ways
to register a printer. Many current generation printers
have support built in. Alternatively, there are software
interfaces that can run on computer and handle the
interaction with Google.
This package provides a CUPS compatible client that allows
an openSUSE computer to send files to Google for printing
on a registered printer.
When files are sent to Google's servers for transmission
to the printer it means that Google has access to them
so that those printed documents are no longer private.
Once CUPS-Cloud-Print is installed it has to be configured
by running as root:
/usr/share/cloudprint-cups/upgrade.py
/usr/share/cloudprint-cups/setupcloudprint.py
setupcloudprint.py only configures the client, so you will need
to have a registered printer at the Google Cloud Print service
prior to running setupcloudprint.py
upgrade.py should be re-run after each time CUPS-Cloud-Print
is updated. Because it accesses the Internet, it has to be run
manually after each update.
%prep
%setup -q -n CUPS-Cloud-Print-%{upstream_version}
cp %{SOURCE1} %{SOURCE2} .
%build
%configure
make %{?_smp_mflags}
cat >cloudprint-upgrade.desktop <<EOF
[Desktop Entry]
Name=CUPS Cloud Print Upgrade
Comment=Upgrade CUPS Cloud Print configuration after package update
Type=Application
Exec=xdg-su -c "%{_datadir}/cloudprint-cups/upgrade.py"
Terminal=true
Icon=cloudprint
Categories=Settings;HardwareSettings;
EOF
cat >cloudprint-setup.desktop <<EOF
[Desktop Entry]
Name=CUPS Cloud Print Setup
Comment=Setup or change configuration of CUPS Cloud Print before first use
Type=Application
Exec=xdg-su -c "%{_datadir}/cloudprint-cups/setupcloudprint.py"
Terminal=true
Icon=cloudprint
Categories=Settings;HardwareSettings;
EOF
%install
# Explicitly use "make install DESTDIR=buildroot..." because
# for SLE the plain RPM macro make_install does not contain DESTDIR=buildroot:
make install DESTDIR=%{buildroot} NOPERMS=1
# Ensure *.pyc files are built and installed,
# there are random build failures associated with these *.pyc files,
# so take care with changes to the next 3 lines:
%py_compile %{buildroot}%{_datadir}/cloudprint-cups/
%if 0%{?not_sle11}
mkdir -p %{buildroot}%{python_sitelib}
mv %{buildroot}%{_datadir}/cloudprint-cups %{buildroot}%{python_sitelib}
%endif
# End of timing sensitive code section. Hopefully *.pyc is well behaved now.
install -d %{buildroot}%{_docdir}/%{name}
install -d %{buildroot}%{_datadir}/pixmaps
install -d %{buildroot}%{_datadir}/applications
install -d %{buildroot}%{_localstatedir}/log/cups
install -d %{buildroot}%{_sysconfdir}
touch %{buildroot}%{_localstatedir}/log/cups/cloudprint_log
touch %{buildroot}%{_sysconfdir}/cloudprint.conf
install -m 0644 cloudprint.png %{buildroot}%{_datadir}/pixmaps
install -m 0644 *.desktop %{buildroot}%{_datadir}/applications
# Make the SLE buildsystem happy with the desktop files:
for desktop_file in %{buildroot}%{_datadir}/applications/*.desktop
do # Let suse_update_desktop_file add X-SuSE-translate key to the desktop files
# so that we can update its translations with translation-only packages:
%suse_update_desktop_file $desktop_file
done
%post
%if 0%{?suse_version} >= 1140
%desktop_database_post
%endif
# upgrade.py accesses the Internet, so it can not be automatically run here.
# Ask the user to run it manually instead:
echo "as root run %{_datadir}/cloudprint-cups/upgrade.py"
%postun
%if 0%{?suse_version} >= 1140
%desktop_database_postun
%endif
%files
%defattr(-,root,root)
%doc COPYING README.md packages/debian/changelog README.opensuse
%if 0%{?not_sle11}
%{python_sitelib}/cloudprint-cups
%else
%{_datadir}/cloudprint-cups
%endif
%{_datadir}/applications/*.desktop
%{_datadir}/pixmaps/*.png
%if 0%{?suse_version} == 1110
# On SLE11 with its CUPS 1.3.9 there is still /usr/lib64/cups/ used on x86_64.
# For suse_version values see https://en.opensuse.org/openSUSE:Build_Service_cross_distribution_howto
# On SLE11 it installs automatically into /usr/lib64/cups/ on x86_64 and into /usr/lib/cups/ on x86:
%dir %_libdir/cups
%dir %_libdir/cups/driver
%_libdir/cups/driver/cupscloudprint
%dir %_libdir/cups/backend
%_libdir/cups/backend/gcp
%else
# Use a plain simple fixed /usr/lib/cups/filter/ according
# to what is actually used by CUPS >= 1.4 on all platforms:
%dir /usr/lib/cups
%dir /usr/lib/cups/driver
/usr/lib/cups/driver/cupscloudprint
%dir /usr/lib/cups/backend
/usr/lib/cups/backend/gcp
%endif
%ghost %attr(0640,root,lp) %{_sysconfdir}/cloudprint.conf
%ghost %attr(0660,root,lp) %{_localstatedir}/log/cups/cloudprint_log
%changelog