@@ -367,4 +367,104 @@ ppdpo_CFLAGS = \
367367distclean-local :
368368 rm -rf * .cache * ~
369369
370+ clean-local :
371+ rm -rf $(CIROOT )
372+
370373SUBDIRS =
374+
375+ # ============================================================
376+ # Staged-install downstream autopkgtests (DESTDIR staging)
377+ # ============================================================
378+ # Install the just-built tree into an ephemeral root ($(CIROOT)) with
379+ # `make install DESTDIR=`, top up the bits that `make install` does not ship
380+ # but the downstream Debian autopkgtests require, fix up the staged .pc, then
381+ # run the unmodified downstream scripts against that tree.
382+ CIROOT = $(abs_top_builddir ) /_ciroot
383+
384+ EXTRA_DIST += \
385+ ci/autopkgtest/run.sh \
386+ ci/autopkgtest/debian-tests/control \
387+ ci/autopkgtest/debian-tests/libppd-2-dev \
388+ ci/autopkgtest/debian-tests/libppd-2-ppd-handling
389+
390+ # Fix A: check_PROGRAMS are build-only under Automake and are never copied by
391+ # `make install`. The downstream PPD-handling test executes the test driver
392+ # as an *installed* binary (/usr/bin/testppd), so build it and stage it into
393+ # $(CIROOT)$(bindir). Uses libtool --mode=install so the binary is relinked
394+ # cleanly against $(libdir) (LD_LIBRARY_PATH then forces the staged library).
395+ STAGED_TEST_BINARIES = testppd
396+
397+ install-test-programs : $(STAGED_TEST_BINARIES )
398+ $(MKDIR_P ) " $( CIROOT) $( bindir) "
399+ @for p in $(STAGED_TEST_BINARIES ) ; do \
400+ echo " STAGE $$ p -> $( CIROOT) $( bindir) /$$ p" ; \
401+ $(LIBTOOL ) --mode=install $(INSTALL_PROGRAM ) " $$ p" " $( CIROOT) $( bindir) /$$ p" || exit 1; \
402+ done
403+
404+ # Fix C (data seeding): the downstream PPD-handling test copies its PPDs from
405+ # the installed $(datadir)/ppd/testppd directory, which upstream `make install`
406+ # does not ship. Seed every test PPD the current testppd binary opens
407+ # (test.ppd, test2.ppd, sbo_test.ppd) so the unmodified script finds them.
408+ STAGED_TEST_PPDS = \
409+ ppd/test.ppd \
410+ ppd/test2.ppd \
411+ ppd/sbo_test.ppd
412+
413+ install-test-data :
414+ $(MKDIR_P ) " $( CIROOT) $( datadir) /ppd/testppd"
415+ @for f in $(STAGED_TEST_PPDS ) ; do \
416+ echo " STAGE $$ f -> $( CIROOT) $( datadir) /ppd/testppd/" ; \
417+ $(INSTALL_DATA ) " $( srcdir) /$$ f" " $( CIROOT) $( datadir) /ppd/testppd/" || exit 1; \
418+ done
419+
420+ # Build everything, DESTDIR-install it, top up the test-only programs/data,
421+ # then rewrite the staged libppd.pc prefix so a downstream consumer resolves
422+ # THIS build (not a system copy) while the system dependency .pc files
423+ # (libcupsfilters, cups) keep resolving normally.
424+ stage-ciroot : all
425+ rm -rf " $( CIROOT) "
426+ $(MAKE ) $(AM_MAKEFLAGS ) install DESTDIR=" $( CIROOT) "
427+ $(MAKE ) $(AM_MAKEFLAGS ) install-test-programs install-test-data
428+ @pc=" $( CIROOT) $( libdir) /pkgconfig/libppd.pc" ; \
429+ if [ -f " $$ pc" ]; then \
430+ sed -i.bak -E " s#^(prefix|exec_prefix|libdir|includedir)=(/.*)#\1=$( CIROOT) \2#" " $$ pc" ; \
431+ rm -f " $$ pc.bak" ; \
432+ echo " stage-ciroot: rewrote staged-tree paths in $$ pc" ; \
433+ fi
434+
435+ # Common environment for the wrapper. PPDC_DATADIR / CUPS_DATADIR point ppdc
436+ # at the staged *.defs so `ppdc test.drv` resolves <font.defs> / <media.defs>
437+ # from the staging tree. LIBPPD_TESTPPD / LIBPPD_PPDDIR point the PPD-handling
438+ # test at the staged binary and data instead of the system /usr paths, so it
439+ # needs no absolute-path redirection (no root, no proot) and runs identically
440+ # on native and QEMU-emulated architectures.
441+ # NB: libppd configures with a split prefix (prefix=/ but exec_prefix=/usr and
442+ # everything installs under /usr), so the staging root the wrapper points at is
443+ # $(CIROOT)$(exec_prefix), not $(CIROOT)$(prefix).
444+ CIROOT_ENV = \
445+ CIROOT="$(CIROOT ) " \
446+ CIPREFIX="$(exec_prefix ) " \
447+ TOP_BUILDDIR="$(abs_top_builddir ) " \
448+ PPDC_DATADIR="$(CIROOT )$(datadir ) /ppdc" \
449+ CUPS_DATADIR="$(CIROOT )$(datadir ) " \
450+ LIBPPD_TESTPPD="$(CIROOT )$(bindir ) /testppd" \
451+ LIBPPD_PPDDIR="$(CIROOT )$(datadir ) /ppd/testppd"
452+
453+ # Full downstream suite in a single wrapper invocation, so the run produces one
454+ # aggregate PASS/FAIL summary across both tests. Neither test needs privilege
455+ # or path redirection, so this is identical on every architecture.
456+ test-autopkgtest : stage-ciroot
457+ $(CIROOT_ENV ) \
458+ $(SHELL ) $(srcdir ) /ci/autopkgtest/run.sh libppd-2-dev libppd-2-ppd-handling
459+
460+ # Single-test convenience targets (handy for debugging one case in isolation).
461+ test-autopkgtest-dev : stage-ciroot
462+ $(CIROOT_ENV ) \
463+ $(SHELL ) $(srcdir ) /ci/autopkgtest/run.sh libppd-2-dev
464+
465+ test-autopkgtest-ppd : stage-ciroot
466+ $(CIROOT_ENV ) \
467+ $(SHELL ) $(srcdir ) /ci/autopkgtest/run.sh libppd-2-ppd-handling
468+
469+ .PHONY : stage-ciroot install-test-programs install-test-data \
470+ test-autopkgtest test-autopkgtest-dev test-autopkgtest-ppd
0 commit comments