9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] embed git head hash as /dev/head
@ 2022-06-10  7:32 Jacob Moody
  2022-06-10 14:07 ` ori
  2022-06-10 19:01 ` mkf9
  0 siblings, 2 replies; 7+ messages in thread
From: Jacob Moody @ 2022-06-10  7:32 UTC (permalink / raw)
  To: 9front

This embeds the current commit hash for HEAD
in to devcons as /dev/head. Thought this could be
handy, curious to hear what others think.


thanks,
moody

---
diff 13065e16b3c4fba4d9200ed7fec89ee49338f12a uncommitted
--- a//sys/src/9/port/devcons.c
+++ b//sys/src/9/port/devcons.c
@@ -329,11 +329,13 @@
 	Qzero,
 	Qmordor,
 	Qconfig,
+	Qhead,
 };

 enum
 {
 	VLNUMSIZE=	22,
+	HEADSIZE=	41,
 };

 static Dirtab consdir[]={
@@ -360,6 +362,7 @@
 	"zero",		{Qzero},	0,		0444,
 	"config",	{Qconfig},	0,		0444,
 	"mordor",	{Qmordor},	0,		0666,
+	"head",		{Qhead},	HEADSIZE,	0444,
 };

 int
@@ -466,6 +469,7 @@
 	int i, k, id;
 	vlong offset = off;
 	extern char configfile[];
+	extern char headhash[];

 	if(n <= 0)
 		return n;
@@ -623,6 +627,8 @@
 		snprint(tmp, sizeof tmp, "2000");
 		n = readstr((ulong)offset, buf, n, tmp);
 		return n;
+	case Qhead:
+		return readstr((ulong)offset, buf, n, headhash);

 	default:
 		print("consread %#llux\n", c->qid.path);
@@ -787,6 +793,9 @@
 	
 	case Qmordor:
 		error("one does not simply write into mordor");
+		return 0;
+	case Qhead:
+		error(Eperm);
 		return 0;

 	default:
--- a//sys/src/9/port/portmkfile
+++ b//sys/src/9/port/portmkfile
@@ -55,6 +55,11 @@
 		sed -e 's/^[0-9a-f]+ //' -e 's/ ([0-9a-f][0-9a-f])/0x\1,/g'
 	 echo 0,
 	 echo '};'} >> $CONF.c
+	{echo 'uchar headhash[]={'
+	 xd -1x /dist/plan9front/.git/`{awk '{ print $2 }' /dist/plan9front/.git/HEAD} |
+		sed -e 's/^[0-9a-f]+ //' -e 's/ ([0-9a-f][0-9a-f])/0x\1,/g'
+	 echo 0,
+	 echo '};'} >> $CONF.c

 errstr.h:D:	../port/mkerrstr ../port/error.h
 	rc ../port/mkerrstr > errstr.h

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-06-14 19:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-10  7:32 [9front] [PATCH] embed git head hash as /dev/head Jacob Moody
2022-06-10 14:07 ` ori
2022-06-10 16:03   ` Jacob Moody
2022-06-14 17:32     ` Lyndon Nerenberg (VE7TFX/VE6BBM)
2022-06-14 19:37       ` Jacob Moody
2022-06-10 19:01 ` mkf9
2022-06-10 19:13   ` Jacob Moody

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).