Skip to contentSkip to conversation

scripts/setlocalversion on readonly source

PATCH New Christian Kujau 3 participants 5 messages Jun 9, 2009 – Jun 14, 2009 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/setlocalversion on readonly source

Hi,

I'm building kernels with O=/some/dir and at some point scripts/setlocalversion is being called, doing:

+ git update-index --refresh --unmerged
fatal: Unable to create '.git/index.lock': Read-only file system

Not only does it throw this error but it takes quite a long time to run, only to fail anyway because the kernel source dir is located on a read-only NFS mount.

The following patch makes the error go away:

home/dummy/tmp/scripts/setlocalversion.edited renamed from scripts/setlocalversion +2 -2
@@ -39,8 +39,8 @@
 	        printf -- '-svn%s' "`git svn find-rev $head`"
 	fi
 
-	# Are there uncommitted changes?
-	git update-index --refresh --unmerged > /dev/null
+	# Are there uncommitted changes? (and can we update the repo?)
+	touch . 2>/dev/null && git update-index --refresh --unmerged > /dev/null
 	if git diff-index --name-only HEAD | grep -v "^scripts/package" \
 	    | read dummy; then
 		printf '%s' -dirty

Thanks,
Christian.

Signature · 3 lines
BOFH excuse #426:

internet is needed to catch the etherbunny

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

Hello everybody,

Christian Kujau [Tue, Jun 09, 2009 at 01:30:18PM -0700]:

Quoted 6 lines

[...]
+ git update-index --refresh --unmerged
fatal: Unable to create '.git/index.lock': Read-only file system

[...] throw this error [...] takes quite a long time to run, [...] on a read-only NFS mount.

Agreed, one can spent time better.

But

Review

Quoted 3 lines

The following patch makes the error go away:
[...]

(quoted diff) +1 -0
+	touch . 2>/dev/null && git update-index --refresh --unmerged > /dev/null

changing stuff (mtime here) where it is not necessary is maybe not the best thing todo. I suggest instead checking for a writable directory (which is what you want todo anyway):

[ -w . ] && git update-index --refresh --unmerged > /dev/null

Full patch including comment cleanup is attached below.

Sincerly,

Nico

Do not update index on read only media.
Idea published by Christian Kujau <[email protected]>.

scripts/setlocalversion +4 -2
index 0079047..46989b8 100755
@@ -39,8 +39,10 @@ if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
 	        printf -- '-svn%s' "`git svn find-rev $head`"
 	fi
 
-	# Are there uncommitted changes?
-	git update-index --refresh --unmerged > /dev/null
+	# Update index only on r/w media
+	[ -w . ] && git update-index --refresh --unmerged > /dev/null
+
+	# Check for uncommitted changes
 	if git diff-index --name-only HEAD | grep -v "^scripts/package" \
 	    | read dummy; then
 		printf '%s' -dirty
Signature · 3 lines
Currently moving *.schottelius.org to http://www.nico.schottelius.org/ ...

PGP: BFE4 C736 ABE5 406F 8F42  F7CF B8BE F92A 9885 188C
#4 lore raw
Quoted 5 lines · Nico Schottelius

changing stuff (mtime here) where it is not necessary is maybe not the best thing todo. I suggest instead checking for a writable directory (which is what you want todo anyway):

[ -w . ] && git update-index --refresh --unmerged > /dev/null

Even better, thanks!

Christian.

Signature · 3 lines
BOFH excuse #187:

Reformatting Page. Wait...
#5 lore raw
In reply to Nico Schottelius
Quoted 12 lines

Do not update index on read only media.
Idea published by Christian Kujau <[email protected]>.

scripts/setlocalversion +0 -0
index 0079047..46989b8 100755
@@ -39,8 +39,10 @@ if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
 	        printf -- '-svn%s' "`git svn find-rev $head`"
 	fi

scripts/setlocalversion if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then · line 48

Quoted 10 lines
scripts/setlocalversion +4 -2
 
-	# Are there uncommitted changes?
-	git update-index --refresh --unmerged > /dev/null
+	# Update index only on r/w media
+	[ -w . ] && git update-index --refresh --unmerged > /dev/null
+
+	# Check for uncommitted changes
 	if git diff-index --name-only HEAD | grep -v "^scripts/package" \
 	    | read dummy; then
 		printf '%s' -dirty

Please sign-off future patches.
I applied this with no signoff - but this is an exception.

Sam

author Tested-by
#6 lore raw
Quoted 11 lines · Sam Ravnborg
Quoted 11 lines

Do not update index on read only media.
Idea published by Christian Kujau <[email protected]>.

scripts/setlocalversion +0 -0
index 0079047..46989b8 100755
@@ -39,8 +39,10 @@ if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
 	        printf -- '-svn%s' "`git svn find-rev $head`"
 	fi
 
Quoted 12 lines

scripts/setlocalversion if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then · line 48

Quoted 9 lines
scripts/setlocalversion +4 -2
-	# Are there uncommitted changes?
-	git update-index --refresh --unmerged > /dev/null
+	# Update index only on r/w media
+	[ -w . ] && git update-index --refresh --unmerged > /dev/null
+
+	# Check for uncommitted changes
 	if git diff-index --name-only HEAD | grep -v "^scripts/package" \
 	    | read dummy; then
 		printf '%s' -dirty

Please sign-off future patches.
I applied this with no signoff - but this is an exception.

I'm not sure if we want to have patches w/o a signoff in the tree; but I could only add a

since it's Nico's patch now.

Thanks,
Christian.

Signature · 3 lines
BOFH excuse #446:

Mailer-daemon is busy burning your message in hell.