If using systemd, CUPS can be started via socket activation or directly, in any case it is run as user daemon, group lp. The default spool and cache locations were moved to /tmp/cups so we don't need to set up a tmpfs for /var/spool/cups and /var/cache/cups.
sysvinit script is installed from upstream, but untested. Some config files are only created by cupsd on the first start and not at install time, so we supply reasonable defaults in projectroot/ in order to use $(call install_alternative...) on them. Signed-off-by: Roland Hieber <r.hie...@pengutronix.de> --- Notes: changes in v3 -> v4: - remove leftover 2.2.4 patches from last bump, all merged upstream - improve dependency handling for scripting languages: * don't depend on x86-only Oracle Java, remind the user to install Java if needed, and make path to Java interpreter configurable * introduce choices between php5-cli and php5-cgi for CUPS_PHP, and between python2 and python3 for CUPS_PYTHON. This way third-party packages can still depend on CUPS_PYTHON or CUPS_PHP if needed. * make all scripting languages a RUNTIME dependency * wrap everything into a "if CUPS_WEBINTERFACE ... endif" block - improve wording in CUPS_WEBINTERFACE help - install libraries as mode 0644, not 0755 projectroot/etc/cups/classes.conf | 1 + projectroot/etc/cups/client.conf | 2 + projectroot/etc/cups/cups-files.conf | 22 +++ projectroot/etc/cups/mailto.conf | 1 + projectroot/etc/cups/ppd/.createdirectory | 0 projectroot/etc/cups/printers.conf | 1 + projectroot/etc/cups/ssl/.createdirectory | 0 projectroot/etc/printcap | 3 + projectroot/usr/lib/systemd/system/cups.service | 15 ++ projectroot/usr/lib/systemd/system/cups.socket | 14 ++ projectroot/usr/lib/tmpfiles.d/cups.conf | 6 + rules/cups-bbinit.in | 8 + rules/cups.in | 147 +++++++++++++++ rules/cups.make | 241 ++++++++++++++++++++++++ 14 files changed, 461 insertions(+) create mode 100644 projectroot/etc/cups/classes.conf create mode 100644 projectroot/etc/cups/client.conf create mode 100644 projectroot/etc/cups/cups-files.conf create mode 100644 projectroot/etc/cups/mailto.conf create mode 100644 projectroot/etc/cups/ppd/.createdirectory create mode 100644 projectroot/etc/cups/printers.conf create mode 100644 projectroot/etc/cups/ssl/.createdirectory create mode 100644 projectroot/etc/printcap create mode 100644 projectroot/usr/lib/systemd/system/cups.service create mode 100644 projectroot/usr/lib/systemd/system/cups.socket create mode 100644 projectroot/usr/lib/tmpfiles.d/cups.conf create mode 100644 rules/cups-bbinit.in create mode 100644 rules/cups.in create mode 100644 rules/cups.make diff --git a/projectroot/etc/cups/classes.conf b/projectroot/etc/cups/classes.conf new file mode 100644 index 000000000..dea737751 --- /dev/null +++ b/projectroot/etc/cups/classes.conf @@ -0,0 +1 @@ +# classes.conf - class configuration file for cups diff --git a/projectroot/etc/cups/client.conf b/projectroot/etc/cups/client.conf new file mode 100644 index 000000000..f8f0b6832 --- /dev/null +++ b/projectroot/etc/cups/client.conf @@ -0,0 +1,2 @@ +# CUPS client configuration +ServerName localhost diff --git a/projectroot/etc/cups/cups-files.conf b/projectroot/etc/cups/cups-files.conf new file mode 100644 index 000000000..2cc2d5a5b --- /dev/null +++ b/projectroot/etc/cups/cups-files.conf @@ -0,0 +1,22 @@ +# File/directory/user/group configuration file for the CUPS scheduler. +User daemon +Group lp +SystemGroup root + +AccessLog /var/log/cups/access_log +ErrorLog /var/log/cups/error_log +PageLog /var/log/cups/page_log + +CacheDir /tmp/cups/cache +DataDir /usr/share/cups +DocumentRoot /usr/share/doc/cups +RequestRoot /tmp/cups/spool +ServerBin /usr/lib/cups +ServerRoot /etc/cups +StateDir /var/run/cups + +Printcap /etc/printcap +PrintcapFormat bsd + +# SSL/TLS keychain for the scheduler... +#ServerKeychain ssl diff --git a/projectroot/etc/cups/mailto.conf b/projectroot/etc/cups/mailto.conf new file mode 100644 index 000000000..4502adaee --- /dev/null +++ b/projectroot/etc/cups/mailto.conf @@ -0,0 +1 @@ +# mailto.conf - configuration file for cups email notifier diff --git a/projectroot/etc/cups/ppd/.createdirectory b/projectroot/etc/cups/ppd/.createdirectory new file mode 100644 index 000000000..e69de29bb diff --git a/projectroot/etc/cups/printers.conf b/projectroot/etc/cups/printers.conf new file mode 100644 index 000000000..bf9879904 --- /dev/null +++ b/projectroot/etc/cups/printers.conf @@ -0,0 +1 @@ +# printers.conf - printer configuration file for cups diff --git a/projectroot/etc/cups/ssl/.createdirectory b/projectroot/etc/cups/ssl/.createdirectory new file mode 100644 index 000000000..e69de29bb diff --git a/projectroot/etc/printcap b/projectroot/etc/printcap new file mode 100644 index 000000000..e74f358e1 --- /dev/null +++ b/projectroot/etc/printcap @@ -0,0 +1,3 @@ +# This file was automatically generated by cupsd(8) from the +# /etc/cups/printers.conf file. All changes to this file +# will be lost. diff --git a/projectroot/usr/lib/systemd/system/cups.service b/projectroot/usr/lib/systemd/system/cups.service new file mode 100644 index 000000000..ff94f69d2 --- /dev/null +++ b/projectroot/usr/lib/systemd/system/cups.service @@ -0,0 +1,15 @@ +[Unit] +Description=CUPS Scheduler service +Documentation=man:cupsd(8) +Requires=systemd-tmpfiles-setup.service +Requires=cups.socket + +[Service] +User=daemon +Group=lp +ExecStart=/usr/sbin/cupsd -l -c /etc/cups/cupsd.conf -s /etc/cups/cups-files.conf +Type=simple + +[Install] +Also=cups.socket +WantedBy=printer.target diff --git a/projectroot/usr/lib/systemd/system/cups.socket b/projectroot/usr/lib/systemd/system/cups.socket new file mode 100644 index 000000000..de9f43b6b --- /dev/null +++ b/projectroot/usr/lib/systemd/system/cups.socket @@ -0,0 +1,14 @@ +[Unit] +Description=CUPS Scheduler socket +PartOf=cups.service + +[Socket] +ListenStream=/run/cups.sock +ListenStream=[::1]:631 +ListenStream=127.0.0.1:631 +BindIPv6Only=No +SocketUser=daemon +SocketGroup=lp + +[Install] +WantedBy=sockets.target diff --git a/projectroot/usr/lib/tmpfiles.d/cups.conf b/projectroot/usr/lib/tmpfiles.d/cups.conf new file mode 100644 index 000000000..c000cf255 --- /dev/null +++ b/projectroot/usr/lib/tmpfiles.d/cups.conf @@ -0,0 +1,6 @@ +#Type Path Mode UID GID Age Argument +d /var/log/cups 750 daemon lp - +d /tmp/cups/cache/ 750 daemon lp - +d /tmp/cups/spool/ 750 daemon lp - +d /tmp/cups/spool/tmp/ 750 daemon lp - +d /var/run/cups 750 daemon lp - diff --git a/rules/cups-bbinit.in b/rules/cups-bbinit.in new file mode 100644 index 000000000..86b6f649a --- /dev/null +++ b/rules/cups-bbinit.in @@ -0,0 +1,8 @@ +## SECTION=initmethod_bbinit + +config CUPS_BBINIT_LINK + string "cups" + depends on CUPS_STARTSCRIPT + default "S90cups" + +# vim: ft=kconfig ts=8 noet tw=80 diff --git a/rules/cups.in b/rules/cups.in new file mode 100644 index 000000000..f7696468a --- /dev/null +++ b/rules/cups.in @@ -0,0 +1,147 @@ +## SECTION=applications + +menuconfig CUPS + tristate + prompt "cups " + + select ROOTFS_VAR_LOG + select ROOTFS_VAR_RUN + select LIBC_M + select LIBC_CRYPT + select ZLIB + + select LIBC_PTHREAD if CUPS_THREADING + select SYSTEMD if CUPS_SYSTEMD_UNIT + select LIBPAPER if CUPS_LIBPAPER + select LIBUSB if CUPS_LIBUSB + select DBUS if CUPS_DBUS + select GNUTLS if CUPS_SSL + select AVAHI if CUPS_AVAHI + select AVAHI_LIBAVAHI_CLIENT if CUPS_AVAHI + select PERL if CUPS_PERL && RUNTIME + select PHP5 if CUPS_PHP && RUNTIME + select PHP5_SAPI_CLI if CUPS_PHP5_CLI && RUNTIME + select PHP5_SAPI_CGI if CUPS_PHP5_CGI && RUNTIME + select PYTHON if CUPS_PYTHON && CUPS_PYTHON2 && RUNTIME + select PYTHON3 if CUPS_PYTHON && CUPS_PYTHON3 && RUNTIME + + help + CUPS is the standards-based, open source printing system. It uses the + Internet Printing Protocol (IPP) to support printing to local and + network printers. + +if CUPS + +comment "--- CUPS Features ---" + +config CUPS_WEBINTERFACE + bool "enable web interface" + help + Enable CUPS printer management via HTTP(S). Useful for hosts which + should act as a print server, but can also serve as a GUI for CUPS. + + If you overwrite /etc/cups/cupsd.conf in your projectroot, be sure to + set "WebInterface Yes" to enable it. + +if CUPS_WEBINTERFACE + +config CUPS_JAVA + bool "enable Java support for web interface" + +if CUPS_JAVA + comment "Please remember to install a suitable Java interpreter!" + +config CUPS_JAVA_PATH + string "path to Java interpreter" + default "/usr/bin/java" +endif + +config CUPS_PERL + bool "enable Perl support for web interface" + +config CUPS_PHP + bool "enable PHP support for web interface" + +if CUPS_PHP +choice + prompt "PHP interpreter" + default CUPS_PHP5_CLI + +config CUPS_PHP5_CLI + bool "php5-cli" + +config CUPS_PHP5_CGI + bool "php5-cgi" + +endchoice +endif # CUPS_PHP + +config CUPS_PYTHON + bool "enable Python support for web interface" + +if CUPS_PYTHON +choice + prompt "Python interpreter" + default CUPS_PYTHON3 + +config CUPS_PYTHON2 + bool "python2" + +config CUPS_PYTHON3 + bool "python3" + +endchoice +endif # CUPS_PYTHON + +endif # CUPS_WEBINTERFACE + +config CUPS_SYSTEMD_UNIT + bool "install systemd unit file" + default y + depends on INITMETHOD_SYSTEMD + help + Installs a systemd service file so that CUPS can be started as a + systemd service. + +config CUPS_STARTSCRIPT + bool "install init.d script" + depends on INITMETHOD_BBINIT + help + Install /etc/init.d/cups + +config CUPS_TEST_TOOLS + bool "install cupstest* tools" + default n + help + Install cupstestdsc and cupstestppd on the target. + +comment "--- External Libraries ---" + +config CUPS_LIBPAPER + bool "libpaper support" + help + Build with support for libpaper's collection of paper sizes + +config CUPS_LIBUSB + bool "libusb support" + help + Build with libusb support. This is needed for the usb backend in order + to use USB printers. + +config CUPS_DBUS + bool "dbus support" + help + Builds CUPS with support for sending event notifications over DBUS + +config CUPS_SSL + bool "enable TLS support" + help + Enables SSL support over IPP and HTTP, also for the web interface. + +config CUPS_AVAHI + bool "enable Avahi support" + help + Enables support for discovery of network printers over Avahi/zeroconf. + +endif # CUPS +# vim: ft=kconfig ts=8 noet tw=80 diff --git a/rules/cups.make b/rules/cups.make new file mode 100644 index 000000000..7eb209e25 --- /dev/null +++ b/rules/cups.make @@ -0,0 +1,241 @@ +# -*-makefile-*- +# +# Copyright (C) 2017 by Roland Hieber <r.hie...@pengutronix.de> +# +# See CREDITS for details about who has contributed to this project. +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +# +# We provide this package +# +PACKAGES-$(PTXCONF_CUPS) += cups + +# +# Paths and names +# +CUPS_VERSION := 2.2.5 +CUPS := cups-$(CUPS_VERSION) +CUPS_MD5 := 76294dff74c3baf3fdf7c626cd48b873 +CUPS_SUFFIX := tar.gz +CUPS_URL := https://github.com/apple/cups/releases/download/v$(CUPS_VERSION)/$(CUPS)-source.$(CUPS_SUFFIX) +CUPS_SOURCE := $(SRCDIR)/$(CUPS)-source.$(CUPS_SUFFIX) +CUPS_DIR := $(BUILDDIR)/cups-$(CUPS_VERSION) +CUPS_LICENSE := LGPL-2.0 AND GPL-2.0 + +# ---------------------------------------------------------------------------- +# Prepare +# ---------------------------------------------------------------------------- + +CUPS_CONF_ENV := \ + $(CROSS_ENV) \ + DSTROOT=$(CUPS_PKGDIR) + +# +# autoconf +# +# The --with-* options are only used to specify strings, --without-* does +# mostly nothing. So we're omitting them here. +# +# --enable-mallinfo is currently broken, see +# https://github.com/apple/cups/issues/5051 +# +# libtool support is unsupported upstream. Don't enable it, it will break +# things, until https://github.com/apple/cups/pull/5062 is merged. +# +# --disable-dnssd only refers to Apple's mDNSResponder, not Avahi. +# +# Java, PHP, Perl and Python support for the webinterface is only a runtime +# option, there are no real bindings for it except calling the interpreters. +# +CUPS_CONF_TOOL := autoconf +CUPS_CONF_OPT := \ + $(CROSS_AUTOCONF_USR) \ + --disable-static \ + --disable-mallinfo \ + --$(call ptx/endis,PTXCONF_CUPS_LIBPAPER)-libpaper \ + --$(call ptx/endis,PTXCONF_CUPS_LIBUSB)-libusb \ + --disable-tcp-wrappers \ + --disable-acl \ + --$(call ptx/endis,PTXCONF_CUPS_DBUS)-dbus \ + --enable-shared \ + --disable-libtool-unsupported \ + --disable-debug \ + --disable-debug-guards \ + --disable-debug-printfs \ + --disable-unit-tests \ + --$(call ptx/endis,PTXCONF_TARGET_HARDEN_RELRO)-relro \ + --disable-gssapi \ + --enable-threads \ + --$(call ptx/endis,PTXCONF_CUPS_SSL)-ssl \ + --disable-cdsassl \ + --$(call ptx/endis,PTXCONF_CUPS_SSL)-gnutls \ + --disable-pam \ + $(GLOBAL_LARGE_FILE_OPTION) \ + --$(call ptx/endis,PTXCONF_CUPS_AVAHI)-avahi \ + --disable-dnssd \ + --disable-launchd \ + --$(call ptx/endis,PTXCONF_CUPS_SYSTEMD_UNIT)-systemd \ + --disable-upstart + +# Default config file settings (probably overwritten via projectroot anyways...) +CUPS_CONF_OPT += \ + --disable-page-logging \ + --disable-browsing \ + --disable-default-shared \ + --disable-raw-printing \ + --$(call ptx/endis,PTXCONF_CUPS_WEBINTERFACE)-webif \ + --with-components=all \ + --with-cachedir=/var/cache \ + --with-logdir=/var/log \ + --with-rundir=/run \ + --with-rcdir=/etc \ + --with-languages=none \ + --with-cups-user=daemon \ + --with-cups-group=lp + +# Scripting languages integrations +CUPS_PHP_PATH := \ + $(if PTXCONF_CUPS_PHP5_CLI,/usr/bin/php, \ + $(if PTXCONF_CUPS_PHP5_CGI,/usr/bin/php-cgi)) +CUPS_PYTHON_PATH := \ + $(if PTXCONF_CUPS_PYTHON2,/usr/bin/python2, \ + $(if PTXCONF_CUPS_PYTHON3,/usr/bin/python3)) + +CUPS_CONF_OPT += \ + $(call ptx/ifdef,PTXCONF_CUPS_JAVA,--with-java=$(PTXCONF_CUPS_JAVA_PATH),--without-java) \ + $(call ptx/ifdef,PTXCONF_CUPS_PERL,--with-perl=/usr/bin/perl,--without-perl) \ + $(call ptx/ifdef,PTXCONF_CUPS_PHP,--with-php=$(CUPS_PHP_PATH),--without-php) \ + $(call ptx/ifdef,PTXCONF_CUPS_PYTHON,--with-python=$(CUPS_PYTHON_PATH),--without-python) + +# ---------------------------------------------------------------------------- +# Compile & Install +# ---------------------------------------------------------------------------- + +CUPS_MAKE_ENV := \ + DSTROOT=$(CUPS_PKGDIR) + +# ---------------------------------------------------------------------------- +# Target-Install +# ---------------------------------------------------------------------------- + +# CUPS drops many files into its PKGDIR, but instead of patching the build +# system, be explicitly picky about what to install. + +$(STATEDIR)/cups.targetinstall: + @$(call targetinfo) + + @$(call install_init, cups) + @$(call install_fixup, cups,PRIORITY,optional) + @$(call install_fixup, cups,SECTION,base) + @$(call install_fixup, cups,AUTHOR,"Roland Hieber <r.hie...@pengutronix.de>") + @$(call install_fixup, cups,DESCRIPTION,missing) + +# ----- config files, install as daemon:lp + @$(call install_copy, cups, daemon, lp, 750, /etc/cups) + @$(call install_alternative, cups, daemon, lp, 0640, /etc/cups/cups-files.conf) + @$(call install_alternative, cups, daemon, lp, 0640, /etc/cups/cupsd.conf) + @$(call install_alternative, cups, daemon, lp, 0600, /etc/cups/classes.conf) + @$(call install_alternative, cups, daemon, lp, 0600, /etc/cups/client.conf) + @$(call install_alternative, cups, daemon, lp, 0640, /etc/cups/mailto.conf) + @$(call install_copy, cups, daemon, lp, 0750, /etc/cups/ppd/) + @$(call install_alternative_tree, cups, daemon, lp, /etc/cups/ppd/) + @$(call install_alternative, cups, daemon, lp, 0600, /etc/cups/printers.conf) + @$(call install_alternative, cups, daemon, lp, 0640, /etc/cups/snmp.conf) + @$(call install_alternative, cups, daemon, lp, 0640, /etc/printcap) + @$(call install_alternative, cups, root, root, 0644, /usr/share/cups/mime/mime.convs) + @$(call install_alternative, cups, root, root, 0644, /usr/share/cups/mime/mime.types) + +ifdef PTXCONF_CUPS_SSL + @$(call install_copy, cups, daemon, lp, 0750, /etc/cups/ssl/) + @$(call install_alternative_tree, cups, daemon, lp, /etc/cups/ssl/) +endif + +ifdef PTXCONF_CUPS_DBUS + @$(call install_alternative, cups, root, root, 0644, /etc/dbus-1/system.d/cups.conf) +endif + +# ----- libraries + @$(call install_lib, cups, root, root, 0644, libcups) + @$(call install_lib, cups, root, root, 0644, libcupsimage) + @$(call install_lib, cups, root, root, 0644, libcupsmime) + @$(call install_lib, cups, root, root, 0644, libcupsppdc) + +# ----- user and system binaries, with the correct access rights + @$(call install_copy, cups, root, root, 0755, -, /usr/bin/cancel) + @$(call install_copy, cups, root, root, 0755, -, /usr/bin/cups-config) + @$(call install_copy, cups, root, root, 0755, -, /usr/bin/ipptool) + @$(call install_copy, cups, root, root, 0755, -, /usr/bin/lp) + @$(call install_copy, cups, root, root, 0755, -, /usr/bin/lpoptions) + @$(call install_copy, cups, root, root, 0755, -, /usr/bin/lpq) + @$(call install_copy, cups, root, root, 0755, -, /usr/bin/lpr) + @$(call install_copy, cups, root, root, 0755, -, /usr/bin/lprm) + @$(call install_copy, cups, root, root, 0755, -, /usr/bin/lpstat) + + @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/cupsaccept) + @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/cupsaddsmb) + @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/cupsctl) + @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/cupsd) + @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/cupsfilter) + @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/lpadmin) + @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/lpc) + @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/lpinfo) + @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/lpmove) + + @$(call install_link, cups, cupsaccept, /usr/sbin/accept) + @$(call install_link, cups, cupsaccept, /usr/sbin/cupsdisable) + @$(call install_link, cups, cupsaccept, /usr/sbin/cupsenable) + @$(call install_link, cups, cupsaccept, /usr/sbin/cupsreject) + @$(call install_link, cups, cupsaccept, /usr/sbin/reject) + +ifdef PTXCONF_CUPS_TEST_TOOLS + @$(call install_copy, cups, root, root, 0755, -, /usr/bin/cupstestdsc) + @$(call install_copy, cups, root, root, 0755, -, /usr/bin/cupstestppd) +endif + +# ----- backends, filters, cgi-bin (if enabled), etc. + @$(call install_tree, cups, root, root, -, /usr/lib/cups/backend) + @$(call install_tree, cups, root, root, -, /usr/lib/cups/daemon) + @$(call install_tree, cups, root, root, -, /usr/lib/cups/filter) + @$(call install_tree, cups, root, root, -, /usr/lib/cups/monitor) + @$(call install_tree, cups, root, root, -, /usr/lib/cups/notifier) + +ifdef PTXCONF_CUPS_LIBUSB + @$(call install_alternative, cups, root, root, 0644, \ + /usr/share/cups/usb/org.cups.usb-quirks) +endif + +ifdef PTXCONF_CUPS_WEBINTERFACE + @$(call install_lib, cups, root, root, 0644, libcupscgi) + @$(call install_tree, cups, root, root, -, /usr/lib/cups/cgi-bin) + @$(call install_tree, cups, root, root, -, /usr/share/cups/templates) + @$(call install_tree, cups, root, root, -, /usr/share/doc/cups) +endif + +# ----- startup files +ifdef PTXCONF_CUPS_SYSTEMD_UNIT + @$(call install_alternative, cups, root, root, 0644, \ + /usr/lib/tmpfiles.d/cups.conf) + @$(call install_alternative, cups, root, root, 0644, \ + /usr/lib/systemd/system/cups.service) + @$(call install_alternative, cups, root, root, 0644, \ + /usr/lib/systemd/system/cups.socket) + @$(call install_link, cups, ../cups.service, \ + /usr/lib/systemd/system/printer.target.wants/cups.service) + @$(call install_link, cups, ../cups.socket, \ + /usr/lib/systemd/system/sockets.target.wants/cups.socket) +endif + +ifdef PTXCONF_CUPS_STARTSCRIPT + @$(call install_alternative, cups, root, root, 0755, /etc/init.d/cups) + @$(call install_link, cups, ../init.d/cups, \ + /etc/rc.d/$(PTXCONF_CUPS_BBINIT_LINK)) +endif + + @$(call install_finish, cups) + + @$(call touch) + +# vim: ft=make ts=8 tw=80 -- 2.11.0 _______________________________________________ ptxdist mailing list ptxdist@pengutronix.de