Skip to content

The generated Makefile has a bug #705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lopippo opened this issue Jan 24, 2023 · 3 comments
Open

The generated Makefile has a bug #705

lopippo opened this issue Jan 24, 2023 · 3 comments

Comments

@lopippo
Copy link

lopippo commented Jan 24, 2023

Greetings,

this is the report I had from a Debian Fellow of mine who encountered a build failure due to parallel execution of the Makefile target install:

The make -j2 install DESTDIR=/<>/daps-3.3.2+cleaned1/debian/daps AM_UPDATE_INFO_DIR=no command apparently fails like so:

chmod +x bin/daps-xmlformat
 /usr/bin/mkdir -p '/<<PKGBUILDDIR>>/debian/daps/etc/xml/catalog.d'
 /usr/bin/install -c -m 644 build/catalog.d/daps.xml '/<<PKGBUILDDIR>>/debian/daps/etc/xml/catalog.d'
 /usr/bin/mkdir -p '/<<PKGBUILDDIR>>/debian/daps/etc/daps'
 /usr/bin/install -c -m 644 etc/config etc/docbook-xmlformat.conf etc/docbook-xmlformat-1.04.conf etc/docbook-xmlformat-1.9.conf etc/CatalogManager.properties '/<<PKGBUILDDIR>>/debian/daps/etc/daps'
 /usr/bin/mkdir -p '/<<PKGBUILDDIR>>/debian/daps/etc/daps/fop'
 /usr/bin/install -c -m 644 etc/fop/fop-daps.xml '/<<PKGBUILDDIR>>/debian/daps/etc/daps/fop'
install -m755 autobuild/daps-autobuild /<<PKGBUILDDIR>>/debian/daps/usr/bin
 /usr/bin/mkdir -p '/<<PKGBUILDDIR>>/debian/daps/usr/bin'
install -m644 autobuild/daps-autobuild.rnc /<<PKGBUILDDIR>>/debian/daps/usr/share/xml/daps/schema/
/usr/bin/mkdir: cannot create directory ‘/<<PKGBUILDDIR>>/debian/daps/usr/bin’: File exists
make[4]: *** [Makefile:609: install-dist_binSCRIPTS] Error 1
make[4]: *** Waiting for unfinished jobs....
install -m644 autobuild/daps-autobuild.xml /<<PKGBUILDDIR>>/debian/daps/usr/share/daps/init_templates
make[4]: Leaving directory '/<<PKGBUILDDIR>>'
make[3]: *** [Makefile:1538: install-am] Error 2
make[3]: Leaving directory '/<<PKGBUILDDIR>>'
make[2]: *** [Makefile:1230: install-recursive] Error 1
make[2]: Leaving directory '/<<PKGBUILDDIR>>'
dh_auto_install: error: make -j2 install DESTDIR=/<<BUILDDIR>>/daps-3.3.2\+cleaned1/debian/daps AM_UPDATE_INFO_DIR=no returned exit code 2
make[1]: *** [debian/rules:10: override_dh_auto_install] Error 25
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
make: *** [debian/rules:3: binary-indep] Error 2
dpkg-buildpackage: error: fakeroot debian/rules binary-indep subprocess returned exit status 2

This happened because the line saying:

install -m755 autobuild/daps-autobuild /<<PKGBUILDDIR>>/debian/daps/usr/bin

was executed by "accident" when "debian/daps/usr/bin" did not yet exist,
making "debian/daps/usr/bin" really to be a copy of "autobuild/daps-autobuild".
So, when Makefile tries to create debian/daps/usr/bin as a directory,
it fails because it's already a file.

Apparently, my Debian Fellow suggests this workaround fixes the issue:

--- a/Makefile.in
+++ b/Makefile.in
@@ -1731,6 +1731,7 @@ install-data-local:
          tar c --mode=u+w,go+r-w,a-s -C $$BOOK . | \
                (cd $(DESTDIR)$(docdir)/html; tar xp); \
        done
+       mkdir -p $(DESTDIR)$(bindir)
        install -m755 autobuild/daps-autobuild $(DESTDIR)$(bindir)
        install -m644 autobuild/daps-autobuild.rnc $(DESTDIR)$(datadir)/xml/$(PACKAGE)/schema/
        install -m644 autobuild/daps-autobuild.xml $(DESTDIR)$(templatedir)

But I actually wonder if the best solution would not be to remove the -j2 flag from the make command line.

Sincerely,
Filippo

@fsundermeyer
Copy link
Member

fsundermeyer commented Jan 30, 2023

@lopippo The command that creates the error in line 1 of your listing is mkdir -p , which should work even if a directory already exists.
The error message indicates that a file (not a directory!!) named /<<PKGBUILDDIR>>/debian/daps/usr/bin exists. Could you check for this and where it may come from? (I doubt that it is generated by the Makefile)

@fsundermeyer
Copy link
Member

Does not look like a bugt to me, so closing as INVALID.

@sanvila
Copy link

sanvila commented Apr 18, 2025

Hello. Original reporter here. I still can reproduce the error in "make install", and could even offer a VM to reproduce if necessary. I think the problem is that bindir is missing from INSTALLDIRS. Here is a better patch which makes the change to Makefile.am, where it belongs:

--- daps-3.3.2+cleaned1.orig/Makefile.am
+++ daps-3.3.2+cleaned1/Makefile.am
@@ -208,6 +208,7 @@ all-local: $(USERGUIDE) $(QUICKSTART) $(
 
 INSTALLDIRS = $(DESTDIR)$(docdir)/html $(DESTDIR)$(pkgdatadir) \
        $(DESTDIR)$(datadir)/xml/$(PACKAGE)/schema/ \
+       $(DESTDIR)$(bindir) \
        $(DESTDIR)$(templatedir)

Edit: I have extensively tested the patch above and it fixes the problem.

This seems to be a race condition, where this line could be executed before usr/bin is created:

install -m755 autobuild/daps-autobuild /<<PKGBUILDDIR>>/debian/daps/usr/bin

in which case usr/bin becomes a real file and the mkdir -p which is executed later fails.

Could this issue be reopened, please?

Thanks.

@fsundermeyer fsundermeyer reopened this Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants