From 79b2c1c62638f073a832e1520b29bf139b391518 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Mon, 31 Dec 2018 21:53:07 +0100 Subject: [PATCH 1/3] fontconfig: Avoid access of fonts outside of gub. Note that this commit needs lilypond issue #5450 so that we can set up gub-specific fontconfig configuration files. As a consequence you can't test older lilypond versions anymore without patching the created file `.../target/.../root/usr/etc/relocate/fontconfig.reloc', replacing `set?' with `set' (this undoes the use of a special fontconfig setup). Another minor change is that we no longer generate file `98-gub-fonts-dir.conf' but `08-gub-fonts-dir.conf', following fontconfig's recommendation of include file names. --- gub/installer.py | 3 +- gub/specs/fontconfig.py | 107 +++++++++++++++++++++++++++++++++++----- 2 files changed, 97 insertions(+), 13 deletions(-) diff --git a/gub/installer.py b/gub/installer.py index d407c9986..708bbdfc9 100644 --- a/gub/installer.py +++ b/gub/installer.py @@ -224,7 +224,8 @@ def strip_unnecessary_files (self): 'share/mkspecs', 'share/terminfo', # GUB's internal fonts directory settings - 'etc/fonts/conf.d/98-gub-fonts-dir.conf', + 'etc/fonts-gub', + 'var/cache/fontconfig-gub' ] # FIXME: why are we removing these, we need these in a root image. diff --git a/gub/specs/fontconfig.py b/gub/specs/fontconfig.py index 2b6da644b..0c0cf65a4 100644 --- a/gub/specs/fontconfig.py +++ b/gub/specs/fontconfig.py @@ -98,19 +98,33 @@ def compile (self): target.AutoBuild.compile (self) def install (self): target.AutoBuild.install (self) - self.dump ('''set FONTCONFIG_FILE=$INSTALLER_PREFIX/etc/fonts/fonts.conf -set FONTCONFIG_PATH=$INSTALLER_PREFIX/etc/fonts -''', + self.dump ('''\ +set? FONTCONFIG_FILE=$INSTALLER_PREFIX/etc/fonts/fonts.conf +set? FONTCONFIG_PATH=$INSTALLER_PREFIX/etc/fonts +''', '%(install_prefix)s/etc/relocate/fontconfig.reloc') - self.dump (''' + # Stuff for using fontconfig within gub. We simply make fontconfig + # load the configuration from `tools' and add another font + # directory. Note that fontconfig's cache files are platform + # dependent and can't be shared across architectures. + self.system (''' +mkdir -p %(install_prefix)s/etc/fonts-gub \ +&& mkdir -p %(install_prefix)s/var/cache/fontconfig-gub +''') + self.dump ('''\ + - - %(system_prefix)s/share/fonts - %(tools_prefix)s/share/fonts + %(tools_prefix)s/etc/fonts-gub/fonts.conf + + + %(system_prefix)s/share/fonts + + %(system_prefix)s/var/cache/fontconfig-gub + ''', - '%(install_prefix)s/etc/fonts/conf.d/98-gub-fonts-dir.conf') + '%(install_prefix)s/etc/fonts-gub/fonts.conf') class Fontconfig__mingw (Fontconfig): def patch (self): @@ -170,11 +184,80 @@ def patch (self): + ' DOCSRC="" ') def install (self): tools.AutoBuild.install (self) - self.dump (''' + # For reproducible builds we must not access files outside of the + # gub directory tree. We thus set up a separate configuration in + # the `tools' tree for fontconfig, to be activated by appropriately + # adjusting the environment variables FONTCONFIG_FILE and + # FONTCONFIG_PATH (which are defined with `set?' instead of `set' in + # the `fontconfig.reloc' file to make this possible). + self.system ('''\ +mkdir -p %(install_prefix)s/etc/fonts-gub \ +&& cd %(install_prefix)s/etc/fonts-gub \ +&& mkdir -p conf.d \ +&& cd conf.d \ +&& for f in 10-hinting-slight.conf \ + 30-metric-aliases.conf \ + 40-nonlatin.conf \ + 45-latin.conf \ + 49-sansserif.conf \ + 60-latin.conf \ + 65-fonts-persian.conf \ + 65-nonlatin.conf \ + 69-unifont.conf \ + 70-no-bitmaps.conf \ + 80-delicious.conf \ + 90-synthetic.conf; do \ + ln -sr %(install_prefix)s/share/fontconfig/conf.avail/$f $f; \ + done +''') + self.dump ('''\ + + + + + + + mono + + + monospace + + + + + + sans serif + + + sans-serif + + + + + + sans + + + sans-serif + + + + conf.d + + + + 30 + + + +''', + '%(install_prefix)s/etc/fonts-gub/fonts.conf') + self.dump ('''\ + - - %(tools_prefix)s/share/fonts + + %(tools_prefix)s/share/fonts ''', - '%(install_prefix)s/etc/fonts/conf.d/98-gub-fonts-dir.conf') + '%(install_prefix)s/etc/fonts-gub/conf.d/08-gub-fonts-dir.conf') From 9e4d37f536e738bef26e3dd7951329007e7fc18e Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Thu, 3 Jan 2019 07:31:14 +0100 Subject: [PATCH 2/3] lilypond: Avoid access of fonts outside of gub. Activate the gub-specific fontconfig setup as added in the previous commit. The patch also simplifies `local.conf': avoiding bitmap fonts is part of the previous commit, too. --- gub/specs/lilypond.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/gub/specs/lilypond.py b/gub/specs/lilypond.py index 949963c4b..20838f602 100644 --- a/gub/specs/lilypond.py +++ b/gub/specs/lilypond.py @@ -125,19 +125,12 @@ def installer_install_stuff (self): locals ()) self.system ('mkdir -p %(install_prefix)s/etc/fonts/') - self.dump (''' + self.dump ('''\ - - - - false - - - - -~/.lilypond-fonts.cache-2 + ~/.lilypond-fonts.cache-2 -''', '%(install_prefix)s/etc/fonts/local.conf', 'w', locals ()) +''', + '%(install_prefix)s/etc/fonts/local.conf', 'w', locals ()) class LilyPond__smart (LilyPond__simple): configure_binary = '%(srcdir)s/smart-configure.sh' @@ -295,6 +288,9 @@ def doc_limits (self): return 'ulimit -m 524288 && ulimit -d 524288 && ulimit -v 1048576' @context.subst_method def doc_relocation (self): + # These environment variables control lilypond while being run + # within gub to build documentation. In particular, we use a + # special fontconfig setup that doesn't use fonts outside of gub. return misc.join_lines (''' LILYPOND_EXTERNAL_BINARY=%(system_prefix)s/bin/lilypond PATH=%(tools_prefix)s/bin:%(system_prefix)s/bin:$PATH @@ -302,6 +298,8 @@ def doc_relocation (self): LD_LIBRARY_PATH=%(tools_prefix)s/lib:%(system_prefix)s/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} GS_FONTPATH=%(system_prefix)s/share/ghostscript/%(ghostscript_version)s/fonts:%(system_prefix)s/share/gs/fonts GS_LIB=%(system_prefix)s/share/ghostscript/%(ghostscript_version)s/Resource/Init:%(system_prefix)s/share/ghostscript/%(ghostscript_version)s/Resource +FONTCONFIG_FILE=%(system_prefix)s/etc/fonts-gub/fonts.conf +FONTCONFIG_PATH=%(tools_prefix)s/etc/fonts-gub ''') compile_command = ('%(doc_limits)s ' '&& %(doc_relocation)s ' From c410c4be6672a8dd9ee49cdedc112d1538824b31 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Thu, 3 Jan 2019 07:36:08 +0100 Subject: [PATCH 3/3] lilypond: Increase 64-bit ulimit settings. This is needed for compilation of gub on openSuSE Leap 42.3. The new values are generous and could be certainly made more tight in case this is useful and/or necessary. --- gub/specs/lilypond.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gub/specs/lilypond.py b/gub/specs/lilypond.py index 20838f602..72117d706 100644 --- a/gub/specs/lilypond.py +++ b/gub/specs/lilypond.py @@ -284,7 +284,7 @@ def srcdir (self): @context.subst_method def doc_limits (self): if '64' in self.settings.build_platform: - return 'ulimit -m 524288 && ulimit -d 524288 && ulimit -v 2097152 ' + return 'ulimit -m 1048576 && ulimit -d 1048576 && ulimit -v 3145728' return 'ulimit -m 524288 && ulimit -d 524288 && ulimit -v 1048576' @context.subst_method def doc_relocation (self):