[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#26941: New font-build-system
From: |
Ludovic Courtès |
Subject: |
bug#26941: New font-build-system |
Date: |
Tue, 23 May 2017 13:33:18 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) |
Arun Isaac <address@hidden> skribis:
>> It would be nice to install README, COPYING, and LICENSE if they exist.
>> It’s okay to not do that as a first step though.
>
> I don't see the utility in installing these files. But, if we're not
> doing them in this initial font-build-system, I suppose we can debate
> later.
Yeah no big deal, let’s leave it for later.
>> Also, (standard-packages) is way more than needed (it includes the whole
>> toolchain, etc.; see build-system/gnu.scm). Here all we need is tar,
>> gzip, bzip2, and xz.
>
> I have attempted something for this. I'm not sure I did it the correct
> way. Do let me know.
>
> I actually have very little understanding of what's going on in
> guix/build-system/font.scm. I just copied guix/build-system/emacs.scm
> and modified it a little. Can I find documentation of `bag' fields
> somewhere in the manual?
The only “documentation” of bags is in (guix build-systems) I’m afraid.
In a nutshell, bags are an intermediate representation between packages,
which are abstract and have implicit build inputs for instance, and
derivations, which are very low-level and far away from the concept of a
package.
>> Could you updated it accordingly?
>>
>>> +(define* (install #:key outputs #:allow-other-keys)
>>> + "Install the package contents."
>>> + (let* ((out (assoc-ref outputs "out"))
>>> + (src-dir (getcwd))
>>> + (fonts-dir (string-append out "/share/fonts")))
>>
>> I’d avoid abbreviations in identifiers. So “source” or
>> “source-directory”, etc.
>
> Done!
>
> A side issue: I feel that the `install-file' procedure should print out
> what it's doing to stdout (or some log port). Something like:
>
> (format #t "~a -> ~a~%" source destination)
>
> This would save us the trouble of implementing this log printing
> everywhere `install-file' is called. For example, this could be very
> useful in the 'install' phase of the font-build-sytem. WDYT?
Do we really need to print something in the first place? :-) Some
procedures in (guix build utils) do that, indeed, but I’m not sure it’s
useful for something as simple as ‘install-file’. Thoughts?
> The patches migrating the font packages to the font-build-system are not
> properly complete. I'll send them in after more work. For now, please
> find attached the patch for the font-build-system alone.
OK!
> From 11cd5cf6188316bafd246e64d875e22423227e5e Mon Sep 17 00:00:00 2001
> From: Arun Isaac <address@hidden>
> Date: Mon, 15 May 2017 20:08:57 +0530
> Subject: [PATCH 1/5] build-system: Add 'font-build-system'.
>
> * Makefile.am (MODULES): Add 'guix/build-system/font.scm' and
> 'guix/build/font-build-system.scm'.
> * guix/build-system/font.scm: New file.
> * guix/build/font-build-system.scm: New file.
Please mention guix.texi as well.
> address@hidden {Scheme Variable} font-build-system
> +This variable is exported by @code{(guix build-system font)}. It
> +implements an installation procedure for font packages. It copies font
^
I’d write:
… for font packages where upstream provides pre-compiled TrueType,
OpenType, etc. font files that merely need to be copied into place
This is to distinguish from fonts that we build from a FontForge
(whatever it’s called today) source.
> + ,@(let ((compression (resolve-module '(gnu packages
> compression))))
> + (map (match-lambda
> + ((name package)
> + (list name (module-ref compression package))))
> + `(("tar" tar)
> + ("gzip" gzip)
> + ("bzip2" bzip2)
> + ("xz" xz))))))
This works, but since ‘tar’ is defined in (gnu packages base), it’s
better to take it from there.
Also, prefer ‘resolve-interface’ over ‘resolve-module’: the former
provides access to public/exported bindings only, whereas the latter
provides access to both public and private bindings.
OK with these changes!
> +(define* (unpack #:key source #:allow-other-keys)
> + "Unpack SOURCE into the build directory. SOURCE may be a compressed
> +archive, or a font file."
> + (if (any (cut string-suffix? <> source)
> + (list ".ttf" ".otf"))
> + (begin
> + (mkdir "source")
> + (chdir "source")
> + (copy-file source (strip-store-file-name source))
> + #t)
> + (gnu:unpack #:source source)))
> +
> +(define* (install #:key outputs #:allow-other-keys)
> + "Install the package contents."
> + (let* ((out (assoc-ref outputs "out"))
> + (source (getcwd))
> + (fonts (string-append out "/share/fonts")))
> + (for-each (cut install-file <> (string-append fonts "/truetype/"))
> + (find-files source "\\.ttf$"))
> + (for-each (cut install-file <> (string-append fonts "/opentype"))
> + (find-files source "\\.otf$"))
> + #t))
Do some of the candidate packages provide Type1 fonts? If not, this is
perfect; if we do, then in a future patch we can extend it to support
Type1 as well.
Thank you!
Ludo’.