Subject: [PATCH] community/plan9port: fix default root path

From: Humm <[email-masked]>
Date: Sat, 30 Oct 2021 15:12:23 +0200

---
I do use rc as login shell.

 ...0001-s-usr-local-plan9-usr-lib-plan9.patch | 56 +++++++++++++++++++
 community/plan9port/APKBUILD                  |  4 +-
 2 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100644 community/plan9port/0001-s-usr-local-plan9-usr-lib-plan9.patch

diff --git a/community/plan9port/0001-s-usr-local-plan9-usr-lib-plan9.patch b/community/plan9port/0001-s-usr-local-plan9-usr-lib-plan9.patch
new file mode 100644
index 0000000000..3cd8486561
--- /dev/null
+++ b/community/plan9port/0001-s-usr-local-plan9-usr-lib-plan9.patch
@@ -0,0 +1,56 @@
+From 2c7ac172145b5c831d597a636bd2cf237005684c Mon Sep 17 00:00:00 2001
+From: Humm <[email-masked]>
+Date: Sat, 30 Oct 2021 03:11:39 +0200
+Subject: [PATCH] s,/usr/local/plan9,/usr/lib/plan9,
+
+Since we install plan9port to /usr/lib/plan9, we need to modify the
+default plan9port root directory to that.  If we don't, we get problems
+in situations without the $PLAN9 environment variable, such as with rc
+as login shell.
+---
+ src/cmd/sam/sam.c       | 2 +-
+ src/cmd/upas/nfs/imap.c | 2 +-
+ src/lib9/get9root.c     | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/cmd/sam/sam.c b/src/cmd/sam/sam.c
+index 84e015f5..6933750f 100644
+--- a/src/cmd/sam/sam.c
++++ b/src/cmd/sam/sam.c
+@@ -154,7 +154,7 @@ rescue(void)
+ 			sprint(buf, "nameless.%d", nblank++);
+ 		root = getenv("PLAN9");
+ 		if(root == nil)
+-			root = "/usr/local/plan9";
++			root = "/usr/lib/plan9";
+ 		fprint(io, "#!/bin/sh\n%s/bin/samsave '%s' $* <<'---%s'\n", root, buf, buf);
+ 		addr.r.p1 = 0, addr.r.p2 = f->b.nc;
+ 		writeio(f);
+diff --git a/src/cmd/upas/nfs/imap.c b/src/cmd/upas/nfs/imap.c
+index 5249e2e7..5c587c26 100644
+--- a/src/cmd/upas/nfs/imap.c
++++ b/src/cmd/upas/nfs/imap.c
+@@ -825,7 +825,7 @@ imapdial(char *server, int mode)
+ 		fd[0] = dup(p[0], -1);
+ 		fd[1] = dup(p[0], -1);
+ 		fd[2] = dup(2, -1);
+-		if(threadspawnl(fd, "/usr/local/plan9/bin/rc", "rc", "-c", server, nil) < 0){
++		if(threadspawnl(fd, "/usr/lib/plan9/bin/rc", "rc", "-c", server, nil) < 0){
+ 			close(p[0]);
+ 			close(p[1]);
+ 			close(fd[0]);
+diff --git a/src/lib9/get9root.c b/src/lib9/get9root.c
+index 07e2872c..e58958a2 100644
+--- a/src/lib9/get9root.c
++++ b/src/lib9/get9root.c
+@@ -12,6 +12,6 @@ get9root(void)
+ 	if((s = getenv("PLAN9")) != 0)
+ 		return s;
+ 	/* could do better - search $PATH */
+-	s = "/usr/local/plan9";
++	s = "/usr/lib/plan9";
+ 	return s;
+ }
+-- 
+2.33.1
+
diff --git a/community/plan9port/APKBUILD b/community/plan9port/APKBUILD
index 7578b2a99b..933dac23b1 100644
--- a/community/plan9port/APKBUILD
+++ b/community/plan9port/APKBUILD
@@ -3,7 +3,7 @@
 pkgname=plan9port
 _commit=878b30c0bc1446ba933dc4539438512766183500
 pkgver=0_git20210405
-pkgrel=1
+pkgrel=2
 pkgdesc="Port of many Plan 9 libraries and programs to Unix"
 url="https://9fans.github.io/plan9port/"
 arch="all"
@@ -14,6 +14,7 @@ options="!check" # upstream doesn't have a test suite
 subpackages="$pkgname-doc"
 source="$pkgname-$pkgver-$_commit.tar.gz::https://github.com/9fans/plan9port/archive/$_commit.tar.gz
 	libucontext.patch
+	0001-s-usr-local-plan9-usr-lib-plan9.patch
 	plan9.sh"
 builddir="$srcdir/$pkgname-$_commit"
 
@@ -55,4 +56,5 @@ doc() {
 
 sha512sums="2b56b50276ce54bad5170eea866fa94df680ebada1161b3be2b837d4d309a571b91a50e7d5ba1d2a1962ac3b1f3200e367762040b49788e163bbdd38010aeee0  plan9port-0_git20210405-878b30c0bc1446ba933dc4539438512766183500.tar.gz
 15c3427d36cf9dfaa58c301756d3a8c94ea3acc7edbe3d1b484032acad5c401691e159949844ce277d4bf90b3fc8a38ff8e7c92567b2084c697895f609f11008  libucontext.patch
+a37c786c66954597243ae6a2fa8e23c4752d971fb85abba4ac4016eeaa32e87026ca863644d079029feacdffabe8d79e69e1694839d167ebfaab2b5aeef3934d  0001-s-usr-local-plan9-usr-lib-plan9.patch
 1862807e8c45280fbd3e7827c253de093deb773d846713e3c46256e77c409b2d69cce44a2fe086d2776ebf5204707f84a3577324800173daa2f3d4fb3eae09f0  plan9.sh"
-- 
2.33.1