From: Danny Milosavljevic <dannym@scratchpost.org>
To: Andy Wingo <wingo@igalia.com>
Cc: guix-devel@gnu.org
Subject: cups-service
Date: Wed, 23 Mar 2016 00:51:01 +0100 [thread overview]
Message-ID: <20160323005101.62b537c9@scratchpost.org> (raw)
In-Reply-To: <20160322201207.790bd384@scratchpost.org>
I added a cups-service to actually enable printing eventually, see below.
What it should do (and doesn't do yet) is union together several directories of other packages.
The generated cups-files.conf should contain as "DataDir" (usually /usr/share) the data directory that cupsd should use, which should contain all those merged-together configs (as subdirs), and as "ServerBin" (usually /usr/lib/cups) the actual executables. It is possible to pass the location of cups-files.conf when starting up cupsd.
The subdirs in datadir are especially:
- drv/ for the driver infos. These contain ppd basenames, among lots of other things. These are a variable number of files, but flat hierarchy.
- mime/ for mime types. These are a constant number of files (flat dir hierarchy), to be concatenated each.
The PPDs are kinda difficult. A possibility is to put them into the directory specified as "ServerRoot" (usually /etc/cups) as subdir "ppd" but I think that's supposed to be for user customizations. Cups ppds are usually in /usr/share/ppd . Cupsfilters ppds are usually in /usr/share/ppd/cupsfilters . hplip ppds are usually in /usr/share/hplip (not yet sure how they get there in the first place, though). cups-driverd get_file actually hard-codes /usr/share/ppd sometimes but usually uses (string-append DataDir subdir name) - but my Debian installation has none of the latter.
The subdirs in serverbin are:
- backend/ (flat dir hierarchy). Overwhelmingly ELF; one Python (what version?) script.
- filter/ (flat dir hierarchy). Overwhelmingly ELF; a few Python (what version?) scripts, one shell script.
- driver/ for the actual drivers (flat dir hierarchy). Most of those (all but 1) are python3 scripts. One ELF.
How do I find out where the cupsd executable is / ensure that it's actually there?
Sources to be merged should be the packages:
- cups-filters
- cups
- hplip
- eventually foomatic
diff --git a/gnu/services/printing.scm b/gnu/services/printing.scm
new file mode 100644
index 0000000..4bc33a2
--- /dev/null
+++ b/gnu/services/printing.scm
@@ -0,0 +1,109 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu services printing)
+ #:use-module (gnu services)
+ #:use-module (gnu services shepherd)
+ #:use-module (gnu packages cups)
+ #:use-module (guix gexp)
+ #:use-module (guix records)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-9)
+ #:use-module (srfi srfi-26)
+ #:use-module (ice-9 match)
+ #:export (cups-service))
+
+; TODO or just fetch the one from cups and modify it a bit.
+(define (default-cups-files-config data-dir)
+ ;; generate cups-files.conf [for cupsd -s ...], especially dynamically set DataDir.
+ (mixed-text-file "cups-files.conf"
+ "AccessLog syslog\n"
+ "ErrorLog syslog\n"
+ "PageLog syslog\n"
+ "FatalErrors all\n"
+ "SyncOnClose Yes\n"
+ "User nobody\n"
+ "Group lp\n"
+ ; FIXME SystemGroup lpadmin sys system root
+ ; FIXME ConfigFilePerm
+ ;; DataDir /var/lib/cupsd/data
+ (string-append "DataDir " data-dir "\n") ; /gnu/store/1h53jmsx7gm7b2sfk0h0k6bgmp8fhv0i-cups-2.1.0/share/cups
+ (string-append "DocumentRoot" /gnu/store/1h53jmsx7gm7b2sfk0h0k6bgmp8fhv0i-cups-2.1.0 "/share/doc/cups\n")
+ "CacheDir /var/cache/cups\n"
+ "StateDir /var/run/cups\n"
+ ; FIXME FontPath /zzz
+ "Printcap /etc/printcap\n"
+ "PrintcapFormat bsd\n"
+ "RequestRoot /var/spool/cups\n"
+ ;;/gnu/store/1h53jmsx7gm7b2sfk0h0k6bgmp8fhv0i-cups-2.1.0/lib/cups
+ "ServerBin /home/dannym/.guix-profile/lib/cups\n" ; FIXME
+ "ServerRoot /etc/cups\n" ; FIXME
+))
+
+(define-record-type* <cups>
+ cups make-cups
+ cups?
+ (printers cups-printers)
+ (provision cups-provision))
+
+; TODO cupsd -c /etc/cupsd.conf -s /etc/cups-files.conf -f
+; TODO what user should cupsd run as? (Debian: root)
+; TODO cups-browsed (Debian: also as root)
+; TODO list of printers; paper size, printer vendor and model, interface (if necessary).
+; TODO binding to network interface; running the config html page; auth there; auth in general?
+; TODO support scanners and hpaio thing as sane dll
+
+; FIXME extensions (list (service-extension ...
+; FIXME compose concatenate
+; FIXME extend (lambda (config actions)
+; merge: /var/lib/hp ? no.
+; merge: /etc/hp ? no.
+; merge: /usr/share/hal/fdi ? useless.
+; merge: /etc/udev/rules.d ? done.
+; merge: /lib/systemd/system ? useless.
+; TODO merge: /lib/cups/filter
+; TODO merge: /lib/cups/backend
+; TODO merge: mime.types
+; TODO merge: /share/applications
+; TODO merge: /usr/share/ppd/HP via DRV?
+; TODO merge: drv into DataDir
+
+(define cups-service-type
+ (shepherd-service-type
+ 'cups
+ (match-lambda
+ (($ <cups> printers provision)
+ (let ((loopback? (memq 'loopback provision)))
+ (shepherd-service
+ (requirement '(udev networking)) ; TODO check actual config and reduce
+ (documentation "Bring up printing services.")
+ (provision provision)
+ (start #~(make-forkexec-constructor
+ (list (string-append "/sbin/cupsd") ; FIXME #$cups
+ "-s" (default-cups-files-config "/tmp") ; FIXME pass merged datadir
+ ; FIXME "-c" cups config
+ "-f")))
+ (stop #~(make-kill-destructor))))))))
+
+(define* (cups-service #:key printers (provision '(printing)) )
+ "Return a printing service that starts cups."
+ (service cups-service-type
+ (cups (printers printers)
+ (provision provision))))
+
next prev parent reply other threads:[~2016-03-22 23:51 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-12 18:12 Using cups Danny Milosavljevic
2016-03-13 22:10 ` Ludovic Courtès
2016-03-15 20:05 ` Danny Milosavljevic
2016-03-15 21:19 ` hplip package (work in progress) Danny Milosavljevic
2016-03-16 8:19 ` Andy Wingo
2016-03-16 8:45 ` Andy Wingo
2016-03-20 0:19 ` Danny Milosavljevic
2016-03-21 22:07 ` [PATCH v2] Add hplip Danny Milosavljevic
2016-03-22 8:28 ` Andy Wingo
2016-03-22 10:30 ` [PATCH v3] " Danny Milosavljevic
2016-03-22 10:56 ` Andy Wingo
2016-03-22 19:12 ` [PATCH v4] " Danny Milosavljevic
2016-03-22 23:51 ` Danny Milosavljevic [this message]
2016-03-23 0:40 ` cups-service Danny Milosavljevic
2016-03-23 9:07 ` cups-service v2 Danny Milosavljevic
2016-04-29 15:09 ` Ludovic Courtès
2016-03-23 8:45 ` [PATCH v4] Add hplip Andy Wingo
2016-03-23 9:39 ` [PATCH v5] " Danny Milosavljevic
2016-03-23 11:36 ` [PATCH v6] " Danny Milosavljevic
2016-03-23 20:46 ` Efraim Flashner
2016-03-23 23:56 ` [PATCH v7] " Danny Milosavljevic
2016-04-04 21:45 ` Ludovic Courtès
2016-04-10 20:57 ` Danny Milosavljevic
2016-04-29 15:07 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160323005101.62b537c9@scratchpost.org \
--to=dannym@scratchpost.org \
--cc=guix-devel@gnu.org \
--cc=wingo@igalia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.