fix(alpine): build R with cairo, png, jpeg and tiff graphics devices #9
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/alpine-graphics-capabilities"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Motivation
R on the Alpine images was built without graphics support:
capabilities()reportscairo,png,jpegandtiffasFALSE, while Ubuntu reports all fourTRUE.The images install
R-devbut never the graphics headers, and R'sconfiguretreats those as optional and does not fail when they are absent, so the build succeeds and ships an R that cannot draw.Reproduced in a clean
alpine:3.22container with the old package set:One correction to the original diagnosis:
--with-x=nowas not the cause, and libpng was in fact found.R's bitmap and
pangocairochecks run independently ofR_X11(configure.ac:2604gates onwant_cairo, notuse_X11).capabilities("png")needs a device backend, and with X11 off and cairo absent there was none, which is why all four readFALSEdespite configure listing PNG.So the fix is purely the missing
-devpackages.X11 stays off, which is correct for headless images, and cairo covers
png()/jpeg()/tiff()/svg().Changes
builder/Dockerfile.alpine-{320,321,322,323,324}— installpkgconf cairo-dev pango-dev fontconfig-dev freetype-dev libpng-dev jpeg-dev tiff-dev zlib-dev; pass--with-cairo --with-libpng --with-jpeglib --with-libtiffexplicitly so the intent sits next to--with-x=no; setREQUIRED_CAPABILITIES.builder/build.sh— addverify_capabilities()betweencompile_randpackage_r. A build that loses a graphics device now fails instead of being packaged and uploaded. Opt-in viaREQUIRED_CAPABILITIES, so every non-Alpine platform is untouched..crow/build.yaml— add aFORCE_REBUILDescape hatch to the dedup step. Artifact filenames carry only the R version, so the HEAD probe would otherwise keep skipping every Alpine version and serving the stale broken binaries.CLAUDE.md— record the three gotchas.Verification
Compiled R 4.5.1 in the patched
alpine-322image, through the realbuild.sh:The devices actually render, not just report
TRUE(default bitmapType: cairo):The guard was exercised in both directions against that real build: it passes on the four graphics capabilities, and returns non-zero naming the missing entry when additionally asked for
X11.crow lint .crow/passes andbash -n builder/build.shis clean.Behaviour change
Alpine R binaries gain the cairo, png, jpeg and tiff devices, and link against
libcairo,libpangocairo,libpng,libjpegandlibtiff.The
.apkmetadata already declared those runtime dependencies, so consumer images need no change.Any Alpine build that loses a graphics device now fails the pipeline rather than uploading silently.
Needs a follow-up after merge: the first run must have
FORCE_REBUILDset, otherwise dedup skips every existing Alpine version and the broken artifacts stay in the bucket.The Alpine builder images install R-dev but never the graphics headers. R's configure treats those as optional and does not fail when they are absent, so the build succeeds and ships an R whose capabilities() reports cairo, png, jpeg and tiff as FALSE. Installing the runtime libraries on the target system afterwards cannot bring compiled-out devices back. Note that --with-x=no was not the cause. R's bitmap and pangocairo checks run independently of R_X11, and libpng was in fact found. capabilities("png") needs a device backend, and with X11 off and cairo absent there was none, which is why all four read FALSE. X11 stays off: these are headless images and cairo covers png()/jpeg()/tiff()/svg(). - Install pkgconf, cairo-dev, pango-dev, fontconfig-dev, freetype-dev, libpng-dev, jpeg-dev, tiff-dev and zlib-dev in every Alpine builder image. - Pass --with-cairo, --with-libpng, --with-jpeglib and --with-libtiff explicitly so the intent is visible next to --with-x=no. - Assert REQUIRED_CAPABILITIES after make install, so a build that loses a device fails instead of being packaged and uploaded. Opt-in per Dockerfile, leaving the other platforms untouched. - Add a FORCE_REBUILD escape hatch to the dedup step. Artifact filenames carry only the R version, so the HEAD probe would otherwise keep skipping every Alpine version and serving the stale broken binaries. - Record the three gotchas in CLAUDE.md. Verified by compiling R 4.5.1 in the patched alpine-322 image: jpeg, png, tiff and cairo are TRUE, default bitmapType is cairo, and all four devices render. The guard was exercised in both directions against that build.