OpenPrinting / libppd

Apache License 2.0
2 stars 13 forks source link

Build failure -- conflict between libcups ppd.h and libppd ppd.h? #49

Open Prototyped opened 6 days ago

Prototyped commented 6 days ago

I'm attempting to build an OCI container of ghostscript-printer-app using podman/buildah and am stuck at trying to build libppd.

I have:

What have I done wrong? I've largely been following the snap definition for the build, except that I've picked Debian bookworm's prebuilt libcups2-dev and ghostscript packages rather than rebuilding them myself.

$ podman build --platform=linux/arm/v7 -t gurdasani.com/ghostscript-printer-application/ghostscript-printer-application-splix:latest .
[1/4] STEP 1/2: FROM docker.io/library/debian:12-slim AS base_build
[1/4] STEP 2/2: RUN set -eux;     DEBIAN_FRONTEND=noninteractive;     export DEBIAN_FRONTEND;     apt -y update;     apt -y install apt-transport-https ca-certificates;     echo 'deb-src https://cdn-aws.deb.debian.org/debian stable main contrib non-free' > /etc/apt/sources.list.d/stable-sources.list;     apt -y update;     apt -y install build-essential g++ sed quilt
--> Using cache 61d1779678e34149d0fa66f37bb0a31e8f28ef44937673cdfac28a2c9a35add9
--> 61d1779678e
[3/4] STEP 1/2: FROM 61d1779678e34149d0fa66f37bb0a31e8f28ef44937673cdfac28a2c9a35add9 AS libcupsfilters_build
[3/4] STEP 2/2: RUN set -eux;     DEBIAN_FRONTEND=noninteractive;     export DEBIAN_FRONTEND;     apt -y update;     apt -y install git autoconf automake autopoint libtool autotools-dev         pkg-config gettext g++ sharutils liblcms2-dev libpoppler-cpp-dev         libpng-dev libjpeg-dev libtiff5-dev zlib1g-dev libfontconfig1-dev         libdbus-1-dev libexif-dev ghostscript fonts-dejavu-core libcups2-dev         libqpdf-dev;     mkdir -p /root/libcupsfilters-build;     cd /root/libcupsfilters-build;     git clone https://github.com/OpenPrinting/libcupsfilters --depth 1 -b 2.0.0;     cd libcupsfilters;     ./autogen.sh;     ./configure --prefix=/usr         --disable-avahi         --disable-mutool;     make -j$(nproc);     mkdir -p /root/libcupsfilters;     make install DESTDIR=/root/libcupsfilters;     cd /root;     rm -rf /root/libcupsfilters-build /var/lib/apt/lists/* /var/cache/apt/archives/*
--> Using cache b7b942c0e6d5e7046bba9cf6a37ac64eb69df93e7be29cd89bfa7de6c25fbf15
--> b7b942c0e6d
[4/4] STEP 1/3: FROM 61d1779678e34149d0fa66f37bb0a31e8f28ef44937673cdfac28a2c9a35add9 AS libppd_build
[4/4] STEP 2/3: COPY --from=libcupsfilters_build /root/libcupsfilters/. /
--> Using cache 164965bef8f16bd5efb335d4984604b62f6dbc571d862791ef35ef2fa2a320aa
--> 164965bef8f
[4/4] STEP 3/3: RUN set -eux;     DEBIAN_FRONTEND=noninteractive;     export DEBIAN_FRONTEND;     apt -y update;     apt -y install git autoconf automake autopoint libtool autotools-dev         pkg-config g++ sharutils poppler-utils ghostscript libcups2-dev         libqpdf-dev;     mkdir -p /root/libppd-build;     cd /root/libppd-build;     git clone https://github.com/OpenPrinting/libppd --depth 1 -b 2.0.0;     cd libppd;     ./autogen.sh;     ./configure --prefix=/usr         --disable-mutool         --disable-pdftocairo         --disable-acroread         --enable-ppdc-utils;     make -j$(nproc);     make install DESTDIR=/root/libppd;     rm -rf /root/libppd-build /var/lib/apt/lists/* /var/cache/apt/archives/*
+ DEBIAN_FRONTEND=noninteractive
+ export DEBIAN_FRONTEND
+ apt -y update

[... snip ...]

+ apt -y install git autoconf automake autopoint libtool autotools-dev pkg-config g++ sharutils poppler-utils ghostscript libcups2-dev libqpdf-dev

[... snip ...]

The following NEW packages will be installed:
  autoconf automake autopoint autotools-dev dbus dbus-bin dbus-daemon
  dbus-session-bus-common dbus-system-bus-common file fonts-droid-fallback
  fonts-noto-mono fonts-urw-base35 ghostscript git git-man libapparmor1
  libavahi-client3 libavahi-common-data libavahi-common3 libcairo2 libcbor0.8
  libcups2 libcups2-dev libcupsfilters-dev libcupsfilters1 libcupsimage2
  libcupsimage2-dev libcurl3-gnutls libdbus-1-3 libdeflate-dev libedit2
  liberror-perl libexif12 libfido2-1 libfontenc1 libgs-common libgs10
  libgs10-common libice6 libidn12 libijs-0.35 libjbig-dev libjbig2dec0
  libjpeg-dev libjpeg62-turbo-dev liblcms2-2 liblerc-dev libltdl-dev libltdl7
  liblzma-dev libmagic-mgc libmagic1 libnspr4 libnss3 libopenjp2-7
  libpaper-utils libpaper1 libpixman-1-0 libpkgconf3 libpng-dev libpng-tools
  libpoppler126 libqpdf-dev libqpdf29 libsm6 libtiff-dev libtiffxx6 libtool
  libwebp-dev libwebpdemux2 libwebpmux3 libxcb-render0 libxcb-shm0 libxext6
  libxmuu1 libxrender1 libxt6 libzstd-dev m4 openssh-client pkg-config pkgconf
  pkgconf-bin poppler-data poppler-utils sharutils ucf x11-common xauth
  xfonts-encodings xfonts-utils zlib1g-dev
0 upgraded, 93 newly installed, 0 to remove and 0 not upgraded.

[... snip ...]

+ mkdir -p /root/libppd-build
+ cd /root/libppd-build
+ git clone https://github.com/OpenPrinting/libppd --depth 1 -b 2.0.0
Cloning into 'libppd'...
Note: switching to '62666f01b167bdf5975b08fbab5c2f34d9277db3'.

[... snip ...]

+ cd libppd
+ ./autogen.sh

[... snip ...]

+ ./configure --prefix=/usr --disable-mutool --disable-pdftocairo --disable-acroread --enable-ppdc-utils

[... snip ...]

checking for cups-config... /usr/bin/cups-config
checking for libcupsfilters... yes

[... snip ...]

configure: creating ./config.status
config.status: creating libppd.pc
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing po-directories commands
configure:
==============================================================================
Environment settings:
        CFLAGS:                                    -g -O2 -Wall -std=gnu11 -D_GNU_SOURCE
        CXXFLAGS:                                  -g -O2 -Wall  -D_GNU_SOURCE
        LDFLAGS:
Build configuration:
        cups-config:     system
        ghostscript:     yes
        gs-path:         system
        gs ps2write:     yes
        mutool:          no
        mutool-path:
        pdftocairo:      no
        pdftocairo-path:
        acroread:        no
        acroread-path:
        pdftops:         HYBRID
        Poppler's pdftops: yes
        pdftops-path:    system
        testppdfile:     no
        ppdc utilities:  yes
        genstrings:      no
        werror:          no
==============================================================================

+ nproc
+ make -j4
make  all-recursive
make[1]: Entering directory '/root/libppd-build/libppd'
make[2]: Entering directory '/root/libppd-build/libppd'
  CXX      ppd/ppdc.o
  CC       ppd/libppd_la-ppd-attr.lo
  CC       ppd/libppd_la-ppd.lo
  CC       ppd/libppd_la-ppd-cache.lo
In file included from ppd/ppd-cache.c:18:
ppd/ppd.h:102:14: error: redeclaration of 'enum ppd_ui_e'
  102 | typedef enum ppd_ui_e                   // **** UI Types ****
      |              ^~~~~~~~
In file included from ppd/ppd-attr.c:16:
ppd/ppd.h:102:14: error: redeclaration of 'enum ppd_ui_e'
  102 | typedef enum ppd_ui_e                   // **** UI Types ****
      |              ^~~~~~~~
In file included from ppd/ppd.c:20:
ppd/ppd.h:102:14: error: redeclaration of 'enum ppd_ui_e'
  102 | typedef enum ppd_ui_e                   // **** UI Types ****
      |              ^~~~~~~~
In file included from /usr/include/cupsfilters/driver.h:28,
                 from ppd/ppd.h:27:
/usr/include/cups/ppd.h:73:14: note: originally defined here
   73 | typedef enum ppd_ui_e                   /**** UI Types @deprecated@ ****/
      |              ^~~~~~~~
ppd/ppd.h:104:3: error: redeclaration of enumerator 'PPD_UI_BOOLEAN'
  104 |   PPD_UI_BOOLEAN,                       // True or False option
      |   ^~~~~~~~~~~~~~
/usr/include/cups/ppd.h:75:3: note: previous definition of 'PPD_UI_BOOLEAN' with type 'enum ppd_ui_e'
   75 |   PPD_UI_BOOLEAN,                       /* True or False option */
      |   ^~~~~~~~~~~~~~
In file included from /usr/include/cupsfilters/driver.h:28,
                 from ppd/ppd.h:27:
/usr/include/cups/ppd.h:73:14: note: originally defined here
   73 | typedef enum ppd_ui_e                   /**** UI Types @deprecated@ ****/
      |              ^~~~~~~~
ppd/ppd.h:105:3: error: redeclaration of enumerator 'PPD_UI_PICKONE'
  105 |   PPD_UI_PICKONE,                       // Pick one from a list
      |   ^~~~~~~~~~~~~~
/usr/include/cups/ppd.h:76:3: note: previous definition of 'PPD_UI_PICKONE' with type 'enum ppd_ui_e'
   76 |   PPD_UI_PICKONE,                       /* Pick one from a list */
      |   ^~~~~~~~~~~~~~
ppd/ppd.h:104:3: error: redeclaration of enumerator 'PPD_UI_BOOLEAN'
  104 |   PPD_UI_BOOLEAN,                       // True or False option
      |   ^~~~~~~~~~~~~~
ppd/ppd.h:106:3: error: redeclaration of enumerator 'PPD_UI_PICKMANY'
  106 |   PPD_UI_PICKMANY                       // Pick zero or more from a list
      |   ^~~~~~~~~~~~~~~
/usr/include/cups/ppd.h:77:3: note: previous definition of 'PPD_UI_PICKMANY' with type 'enum ppd_ui_e'
   77 |   PPD_UI_PICKMANY                       /* Pick zero or more from a list */
      |   ^~~~~~~~~~~~~~~
/usr/include/cups/ppd.h:75:3: note: previous definition of 'PPD_UI_BOOLEAN' with type 'enum ppd_ui_e'
   75 |   PPD_UI_BOOLEAN,                       /* True or False option */
      |   ^~~~~~~~~~~~~~

[... and loads more ...]
Prototyped commented 6 days ago

Ah, apparently the partial installation of cups is essential to build success. Would it make sense to update INSTALL.md in this repo, where it just says the following in passing, to include explicit details in how to partially install cups as a prerequisite?

Dependencies

  • libcups of CUPS 2.2.2 or newer

This is what I ended up putting in my Dockerfile as an additional build stage:

FROM base_build AS cups_partial_build

RUN set -eux; \
    DEBIAN_FRONTEND=noninteractive; \
    export DEBIAN_FRONTEND; \
    apt -y build-dep cups; \
    apt -y install git autoconf automake autopoint libtool autotools-dev \
        pkg-config gettext libavahi-client-dev libavahi-common-dev \
        libavahi-compat-libdnssd-dev libdbus-1-dev libfontconfig1-dev \
        libfreetype6-dev libgnutls28-dev libjpeg-dev libldap2-dev \
        libkrb5-dev libpam0g-dev libpaper-dev libpng-dev libusb-1.0-0-dev \
        perl-base curl patch sed; \
    mkdir -p /root/cups-build; \
    cd /root/cups-build; \
    git clone https://github.com/OpenPrinting/cups --depth 1 -b v2.4.10; \
    cd cups; \
    curl -fLSs https://raw.githubusercontent.com/OpenPrinting/ghostscript-printer-app/f818c779a81ed35457a82917a45e6addaaaaa640/snap/local/cups-dnssd-backend-socket-only.patch | \
        patch -p1; \
    ./configure --prefix=/usr --with-tls=gnutls; \
    cd cups; \
    make -j$(nproc); \
    cd -; \
    cd filter; \
    make -j$(nproc) rastertoepson rastertohp rastertolabel; \
    cd -; \
    cd backend; \
    sed -i -r 's/"CUPS_DATADIR"/"USB_QUIRK_DIR"/' usb-libusb.c; \
    make -j$(nproc) snmp dnssd socket ipp lpd usb; \
    cd -; \
    mkdir -p /root/cups/usr/lib; \
    install -oroot -groot -m0644 cups/libcups*.a cups/libcups*.so* \
        /root/cups/usr/lib; \
    mkdir -p /root/cups/usr/include/cups; \
    install -oroot -groot -m0644 cups/*.h /root/cups/usr/include/cups; \
    mkdir -p /root/cups/usr/bin; \
    install -oroot -groot -m0755 cups-config /root/cups/usr/bin; \
    mkdir -p /root/cups/usr/lib/ghostscript-printer-app/filter; \
    install -oroot -groot -m0755 \
        filter/rastertoepson \
        filter/rastertohp \
        filter/rastertolabel \
        /root/cups/usr/lib/ghostscript-printer-app/filter; \
    mkdir -p /root/cups/usr/lib/ghostscript-printer-app/backend; \
    cd backend; \
    install -oroot -groot -m0755 snmp dnssd socket ipp ipps lpd usb \
        org.cups.usb-quirks \
        /root/cups/usr/lib/ghostscript-printer-app/backend; \
    cd -; \
    install -oroot -groot -m0644 conf/snmp.conf \
        /root/cups/usr/lib/ghostscript-printer-app/backend; \
    mkdir -p /root/cups/usr/share/ppd; \
    install -oroot -groot -m0644 ppdc/sample.drv \
        /root/cups/usr/share/ppd/cups.drv