From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD84k-0000oH-Gm for guix-patches@gnu.org; Tue, 23 May 2017 07:34:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dD84g-0005Xg-9l for guix-patches@gnu.org; Tue, 23 May 2017 07:34:06 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:59653) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dD84g-0005XY-79 for guix-patches@gnu.org; Tue, 23 May 2017 07:34:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dD84g-0007YK-2a for guix-patches@gnu.org; Tue, 23 May 2017 07:34:02 -0400 Subject: bug#26941: New font-build-system Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <87bbe3e5.AEAAKL2r-KIAAAAAAAAAAAOtUOAAAAACwQwAAAAAAAW9WABZGcQo@mailjet.com> <87y3tw4kw3.fsf@gnu.org> Date: Tue, 23 May 2017 13:33:18 +0200 In-Reply-To: (Arun Isaac's message of "Sat, 20 May 2017 02:11:05 +0530") Message-ID: <87r2zfx0xt.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Arun Isaac Cc: 26941@debbugs.gnu.org Arun Isaac skribis: >> It would be nice to install README, COPYING, and LICENSE if they exist. >> It=E2=80=99s 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=E2=80=99s 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 =E2=80=9Cdocumentation=E2=80=9D of bags is in (guix build-systems)= I=E2=80=99m 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=E2=80=99d avoid abbreviations in identifiers. So =E2=80=9Csource=E2= =80=9D or >> =E2=80=9Csource-directory=E2=80=9D, 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=E2=80=99m not sure = it=E2=80=99s useful for something as simple as =E2=80=98install-file=E2=80=99. 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 > 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. > +@defvr {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=E2=80=99d write: =E2=80=A6 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=E2=80=99s called today) source. > + ,@(let ((compression (resolve-module '(gnu packages c= ompression)))) > + (map (match-lambda > + ((name package) > + (list name (module-ref compression packag= e)))) > + `(("tar" tar) > + ("gzip" gzip) > + ("bzip2" bzip2) > + ("xz" xz)))))) This works, but since =E2=80=98tar=E2=80=99 is defined in (gnu packages bas= e), it=E2=80=99s better to take it from there. Also, prefer =E2=80=98resolve-interface=E2=80=99 over =E2=80=98resolve-modu= le=E2=80=99: 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=E2=80=99.