Bug 52064 - build fails with "git_sha1.h.tmp": permission denied
Summary: build fails with "git_sha1.h.tmp": permission denied
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Other (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-13 18:03 UTC by Brian Paterni
Modified: 2012-08-24 07:28 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
[PATCH] build: remove git_sha1.h.tmp after install (670 bytes, patch)
2012-08-23 01:10 UTC, Vadim Girlin
Details | Splinter Review
patch (395 bytes, patch)
2012-08-23 01:25 UTC, Matt Turner
Details | Splinter Review
[PATCH] build: don't leave git_sha1.h.tmp after build/install (747 bytes, patch)
2012-08-23 15:13 UTC, Vadim Girlin
Details | Splinter Review

Description Brian Paterni 2012-07-13 18:03:52 UTC
This happens sometimes when building mesa. Somehow src/mesa/main/git_sha1.h.tmp gets created with root user (necessary?) Then on a later build, Makefile can no longer "touch" it:

Making all in mesa
make[2]: Entering directory `/home/bpaterni/usr/src/mesa/src/mesa'
touch: cannot touch `main/git_sha1.h.tmp': Permission denied
make[2]: *** [main/git_sha1.h.tmp] Error 1
make[2]: Leaving directory `/home/bpaterni/usr/src/mesa/src/mesa'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/bpaterni/usr/src/mesa/src'
make: *** [all-recursive] Error 1
Comment 1 Brian Paterni 2012-07-13 18:05:40 UTC
"Fix" I'm using now is to remove git_sha1.h.tmp which allows the build process to continue.
Comment 2 Brian Paterni 2012-07-18 03:14:04 UTC
I've managed to come up with a solution to this on my own. I'm no automake expert and it's a bit of a hack IMO, but it works for me. Let me know what you think.

[PATCH] automake: build git_sha1.h without BUILT_SOURCES

BUILT_SOURCES are applied to 'all', 'check', and 'install' targets. So
when make install is run as root, git_sha1.h.tmp is generated again as
root for some reason(?) which causes the next build to fail with
'Permission denied' error.
---
 src/mesa/Makefile.am |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am
index 2b023d7..e459ac0 100644
--- a/src/mesa/Makefile.am
+++ b/src/mesa/Makefile.am
@@ -35,7 +35,7 @@ main/git_sha1.h.tmp:
 		fi \
 	fi
 
-main/git_sha1.h: main/git_sha1.h.tmp
+main/git_sha1.h: Makefile main/git_sha1.h.tmp
 	@echo "updating main/git_sha1.h"
 	@if ! cmp -s main/git_sha1.h.tmp main/git_sha1.h; then \
 		mv main/git_sha1.h.tmp main/git_sha1.h ;\
@@ -47,7 +47,6 @@ GLAPI = $(TOP)/src/mapi/glapi/gen
 include $(GLAPI)/glapi_gen.mk
 
 BUILT_SOURCES = \
-	main/git_sha1.h \
 	main/api_exec_es1_dispatch.h \
 	main/api_exec_es1_remap_helper.h \
 	main/api_exec_es2_dispatch.h \
@@ -59,7 +58,7 @@ BUILT_SOURCES = \
 	program/lex.yy.c
 CLEANFILES = \
 	$(BUILT_SOURCES) \
-	git_sha1.h.tmp
+	main/git_sha1.h.tmp
 
 main/api_exec_es1_dispatch.h: $(GLAPI)/gl_and_es_API.xml $(glapi_gen_dispatch_deps)
 	$(call glapi_gen_dispatch,$<,es1)
@@ -115,11 +114,18 @@ if HAVE_SPARC_ASM
 MESA_ASM_FILES_FOR_ARCH += $(SPARC_FILES)
 endif
 
+nodist_libmesa_la_SOURCES = \
+	main/git_sha1.h
+noinst_libmesa_la_SOURCES = \
+	main/git_sha1.h
+
 libmesa_la_SOURCES = \
 	$(MESA_FILES) \
 	$(MESA_CXX_FILES) \
         $(MESA_ASM_FILES_FOR_ARCH)
 
+$(SRCDIR)/main/version.c: main/git_sha1.h
+
 libmesa_la_LIBADD = $(top_builddir)/src/glsl/libglsl.la
 libmesa_la_LDFLAGS =
 
-- 
1.7.10.4
Comment 3 Vadim Girlin 2012-08-23 01:10:19 UTC
Created attachment 65987 [details] [review]
[PATCH] build: remove git_sha1.h.tmp after install

Yeah, this file is really annoying...

I'm not an automake expert too but the attached patch seems to work for me.
Comment 4 Matt Turner 2012-08-23 01:25:12 UTC
Created attachment 65990 [details] [review]
patch

Is this attached patch sufficient?
Comment 5 Vadim Girlin 2012-08-23 01:56:01 UTC
(In reply to comment #4)
> Created attachment 65990 [details] [review] [review]
> patch
> 
> Is this attached patch sufficient?

AFAICS it requires 'make clean' between 'make install' and 'make'.
Comment 6 Brian Paterni 2012-08-23 02:09:23 UTC
(In reply to comment #3)
> Created attachment 65987 [details] [review] [review]
> [PATCH] build: remove git_sha1.h.tmp after install
> 
> Yeah, this file is really annoying...
> 
> I'm not an automake expert too but the attached patch seems to work for me.

That looks much simpler! I was originally hoping for something like that when I began perusing the docs, but it never really jumped out at me.

Regardless, I haven't been keeping up with git master for ~a month, and so I don't have a build environment to test these things on (the graphics stack that made it into the debian for the freeze is not sufficiently up-to-date anymore...) nor do I have the time to set one up right now... You guys have an OK from me (as reporter) to decide what is best.

(In reply to comment #4)
> Created attachment 65990 [details] [review] [review]
> patch
> 
> Is this attached patch sufficient?

IIRC, that was one of the first things I tried, and it did not work for me. I think due being chown'ed (or whatever) to root on install. Then later the clean target can't delete since it's being run with user privileges. Also, what Vadim said
Comment 7 Vadim Girlin 2012-08-23 02:50:54 UTC
Just to clarify how mesa build with and without these patches works for me:

With current mesa 'make install' (as root) creates that file, and then I have to remove it manually before running 'make' (as non-root) again - 'make clean' doesn't help.

Patch from comment #4 allows 'make clean' to remove the file, but it still means that I have to run 'make clean' after every 'make install'. Also I noticed that sometimes the file is not (re)created - not sure why it happens, but in typical scenario it's still there breaking the build.

My patch from comment #3 allows me to use 'make' (as non-root) after 'make install' (as root) without 'make clean'. That's the behavior I'd like to see in mesa. If my patch isn't a correct solution - I'm OK with any other solution providing the similar result.
Comment 8 Alex Deucher 2012-08-23 13:14:47 UTC
(In reply to comment #7)
> My patch from comment #3 allows me to use 'make' (as non-root) after 'make
> install' (as root) without 'make clean'. That's the behavior I'd like to see in
> mesa. If my patch isn't a correct solution - I'm OK with any other solution
> providing the similar result.

I'd like those semantics as well.  Patch looks good to me.
Comment 9 Knut Petersen 2012-08-23 13:34:14 UTC
(In reply to comment #0)
> This happens sometimes when building mesa. Somehow src/mesa/main/git_sha1.h.tmp
> gets created with root user (necessary?) Then on a later build, Makefile can no
> longer "touch" it:
> 
> Making all in mesa
> make[2]: Entering directory `/home/bpaterni/usr/src/mesa/src/mesa'
> touch: cannot touch `main/git_sha1.h.tmp': Permission denied
> make[2]: *** [main/git_sha1.h.tmp] Error 1
> make[2]: Leaving directory `/home/bpaterni/usr/src/mesa/src/mesa'
> make[1]: *** [all-recursive] Error 1
> make[1]: Leaving directory `/home/bpaterni/usr/src/mesa/src'
> make: *** [all-recursive] Error 1


Run "make clean" and "make distclean", then "git clean -dfx".
You´ll see that git finds more than 100 files missed by the
cleaning targets.

Maye you could extend your patch a bit ...

cu,
 Knut
Comment 10 Vadim Girlin 2012-08-23 15:13:09 UTC
Created attachment 66020 [details] [review]
[PATCH] build: don't leave git_sha1.h.tmp after build/install

Probably this patch is a bit more clean and simple.
Comment 11 Vadim Girlin 2012-08-24 07:28:58 UTC
Fixed with commit e84d45fdb73687019a6798cfb37b01291b212f4d.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.