#1044140 cyrus-imapd: Fails to build source after successful build

Package:
src:cyrus-imapd
Source:
src:cyrus-imapd
Submitter:
Lucas Nussbaum
Date:
2026-09-01 15:51:02 UTC
Severity:
normal
Tags:
#1044140#5
Date:
2023-08-13 16:56:52 UTC
From:
To:
Hi,

This package fails to build a source package after a successful build
(dpkg-buildpackage ; dpkg-buildpackage -S).

This is probably a clear violation of Debian Policy section 4.9 (clean target),
but this is filed as severity:minor for now, because a discussion on
debian-devel showed that we might want to revisit the requirement of a working
'clean' target.

More information about this class of issues, included common problems and
solutions, is available at
https://wiki.debian.org/qa.debian.org/FTBFS/SourceAfterBuild

Relevant part of the build log:
The full build log is available from:
http://qa-logs.debian.net/2023/08/13/cyrus-imapd_3.8.0-3_unstable.log

If you reassign this bug to another package, please mark it as 'affects'-ing
this package. See https://www.debian.org/Bugs/server-control#affects

If you fail to reproduce this, please provide a build log and diff it with mine
so that we can identify if something relevant changed in the meantime.

#1044140#20
Date:
2026-09-01 15:50:52 UTC
From:
To:
Hi,

(Sending to both #1044140 and #1049814: The source-after-build and
binary-after-build failures have the same root cause, and one change
fixes both.)

This is tagged fixed-upstream. However, the upstream fix
(cyrusimap/cyrus-imapd#5757, closing cyrusimap/cyrus-imapd#4493) is part
of a much larger rewrite of the build system generally, which is
destined for the 3.13 / 3.14 branches.

We ship 3.12.x in unstable/testing, and also in trixie-backports
(3.12.3-1~bpo13+1). Trixie stable is on 3.10.x

Root cause of the issue at hand: debian/rules' override_dh_auto_clean
unconditionally rewrites perl/annotator/Makefile.PL from Makefile.PL.in
on every clean. That works the first time, but on a *second* clean/build
cycle, perl/annotator/Makefile already exists from the prior build, and
rewriting Makefile.PL bumps its mtime past Makefile's.
MakeMaker's generated Makefile then refuses to proceed ("Makefile
out-of-date with respect to Makefile.PL ... Please rerun the make
command") instead of running distclean, which is what dh_auto_clean sees
as a failure.

I confirmed this in isolation (just perl + ExtUtils::MakeMaker, no
building the full package).

Fix: Only rewrite Makefile.PL when its generated content actually
differs from what's on disk, so its mtime isn't touched on a redundant
regeneration. This is done by using a .tmp file.

Prepared for 3.12.3-5; the backport picks it up on its next rebuild.

Merge request:
https://salsa.debian.org/debian/cyrus-imapd/-/merge_requests/28

The change to debian/rules:

   @@ -243,5 +243,11 @@ override_dh_missing:
         dh_missing --fail-missing -X.la

    override_dh_auto_clean:
   -     perl -pe 's#\@top_srcdir\@#../..#'
<perl/annotator/Makefile.PL.in >perl/annotator/Makefile.PL
   +     # Only rewrite Makefile.PL if its content actually changes:
touching its
   +     # mtime when perl/annotator/Makefile already exists (i.e. this
isn't the
   +     # first clean) makes MakeMaker think its Makefile is stale and
refuse to
   +     # run, breaking a second build/clean cycle (#1044140, #1049814).
   +     perl -pe 's#\@top_srcdir\@#../..#'
<perl/annotator/Makefile.PL.in >perl/annotator/Makefile.PL.tmp
   +     cmp -s perl/annotator/Makefile.PL.tmp
perl/annotator/Makefile.PL || mv perl/annotator/Makefile.PL.tmp
perl/annotator/Makefile.PL
   +     rm -f perl/annotator/Makefile.PL.tmp
         dh_auto_clean

Kind regards,

     Edmund