Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] mkinitcpio-nfs-utils: support NFSv4 roots
@ 2023-01-10 16:00 ahesford
  2023-01-10 17:24 ` [PR PATCH] [Updated] " ahesford
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ahesford @ 2023-01-10 16:00 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 794 bytes --]

There is a new pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages nfsroot
https://github.com/void-linux/void-packages/pull/41560

mkinitcpio-nfs-utils: support NFSv4 roots
The `net` hook for `mkinitcpio` shipped by this package uses a helper to do v2 or v3 mounts that support locking without the need for a local `lockd` in the initramfs. The helper does not support v4 mounts and v4 does not require a local `lockd`, so we can look for an NFS version requirement in the root spec and directly call `mount -t nfs4` instead of `nfsmount` to support v4 roots.

#### Testing the changes
- I tested the changes in this PR: **in progress**

A patch file from https://github.com/void-linux/void-packages/pull/41560.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-nfsroot-41560.patch --]
[-- Type: text/x-diff, Size: 2646 bytes --]

From f38036e6d2d1ba72fe247fbd2f40ae784e38e583 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 10 Jan 2023 10:57:51 -0500
Subject: [PATCH] mkinitcpio-nfs-utils: support NFSv4 roots

---
 .../mkinitcpio-nfs-utils/files/initcpio-hook-net    | 13 ++++++++++++-
 .../mkinitcpio-nfs-utils/files/initcpio-install-net |  2 ++
 srcpkgs/mkinitcpio-nfs-utils/template               |  2 +-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-hook-net b/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-hook-net
index 4d1ebb95605e..33382d95b728 100644
--- a/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-hook-net
+++ b/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-hook-net
@@ -84,7 +84,18 @@ nfs_mount_handler() {
         launch_interactive_shell
         msg "Trying to continue (this will most likely fail) ..."
     fi
-    nfsmount ${nfs_option:+-o ${nfs_option}} "${nfs_server}:${nfs_path}" "$1"
+
+    # nfsmount avoids problems with lockd for v2 and v3 but does not support v4;
+    # to support v4 roots, examine mount options for a v4 version spec and use
+    # the ordinary mount program. v4 doesn't need lockd for file locking anyway.
+    mount_cmd=nfsmount
+    case "${nfs_option}" in
+        nfsvers=4*|*,nfsvers=4*|vers=4*|*,vers=4*)
+            command -v mount.nfs4 >/dev/null 2>&1 && mount_cmd="mount -t nfs4"
+            ;;
+    esac
+
+    ${mount_cmd} ${nfs_option:+-o ${nfs_option}} "${nfs_server}:${nfs_path}" "$1"
 }
 
 # vim: set ft=sh ts=4 sw=4 et:
diff --git a/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-install-net b/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-install-net
index 79b678949c95..153767add8c5 100644
--- a/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-install-net
+++ b/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-install-net
@@ -3,9 +3,11 @@
 build() {
     add_checked_modules '/drivers/net/'
     add_module nfsv3?
+    add_module nfsv4?
 
     add_binary "/usr/lib/initcpio/ipconfig" "/bin/ipconfig"
     add_binary "/usr/lib/initcpio/nfsmount" "/bin/nfsmount"
+    command -v mount.nfs4 >/dev/null 2>&1 && add_binary "mount.nfs4"
 
     add_runscript
 }
diff --git a/srcpkgs/mkinitcpio-nfs-utils/template b/srcpkgs/mkinitcpio-nfs-utils/template
index 7f36e1cf7fdf..05664525ebfe 100644
--- a/srcpkgs/mkinitcpio-nfs-utils/template
+++ b/srcpkgs/mkinitcpio-nfs-utils/template
@@ -1,7 +1,7 @@
 # Template file for 'mkinitcpio-nfs-utils'
 pkgname=mkinitcpio-nfs-utils
 version=0.3
-revision=3
+revision=4
 build_style=gnu-makefile
 depends="mkinitcpio"
 short_desc="Ipconfig and nfsmount tools for NFS root support in mkinitcpio"

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

* Re: [PR PATCH] [Updated] mkinitcpio-nfs-utils: support NFSv4 roots
  2023-01-10 16:00 [PR PATCH] mkinitcpio-nfs-utils: support NFSv4 roots ahesford
@ 2023-01-10 17:24 ` ahesford
  2023-01-10 18:04 ` ahesford
  2023-01-11  2:35 ` [PR PATCH] [Merged]: " ahesford
  2 siblings, 0 replies; 4+ messages in thread
From: ahesford @ 2023-01-10 17:24 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 799 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages nfsroot
https://github.com/void-linux/void-packages/pull/41560

mkinitcpio-nfs-utils: support NFSv4 roots
The `net` hook for `mkinitcpio` shipped by this package uses a helper to do v2 or v3 mounts that support locking without the need for a local `lockd` in the initramfs. The helper does not support v4 mounts and v4 does not require a local `lockd`, so we can look for an NFS version requirement in the root spec and directly call `mount -t nfs4` instead of `nfsmount` to support v4 roots.

#### Testing the changes
- I tested the changes in this PR: **in progress**

A patch file from https://github.com/void-linux/void-packages/pull/41560.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-nfsroot-41560.patch --]
[-- Type: text/x-diff, Size: 4040 bytes --]

From be4d7313fdcb850f5922053d3e43258217281078 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 10 Jan 2023 10:57:51 -0500
Subject: [PATCH] mkinitcpio-nfs-utils: support NFSv4 roots, fix installation

---
 .../files/initcpio-hook-net                   | 13 ++++++-
 .../files/initcpio-install-net                |  2 ++
 srcpkgs/mkinitcpio-nfs-utils/template         | 35 ++++++++++---------
 3 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-hook-net b/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-hook-net
index 4d1ebb95605e..33382d95b728 100644
--- a/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-hook-net
+++ b/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-hook-net
@@ -84,7 +84,18 @@ nfs_mount_handler() {
         launch_interactive_shell
         msg "Trying to continue (this will most likely fail) ..."
     fi
-    nfsmount ${nfs_option:+-o ${nfs_option}} "${nfs_server}:${nfs_path}" "$1"
+
+    # nfsmount avoids problems with lockd for v2 and v3 but does not support v4;
+    # to support v4 roots, examine mount options for a v4 version spec and use
+    # the ordinary mount program. v4 doesn't need lockd for file locking anyway.
+    mount_cmd=nfsmount
+    case "${nfs_option}" in
+        nfsvers=4*|*,nfsvers=4*|vers=4*|*,vers=4*)
+            command -v mount.nfs4 >/dev/null 2>&1 && mount_cmd="mount -t nfs4"
+            ;;
+    esac
+
+    ${mount_cmd} ${nfs_option:+-o ${nfs_option}} "${nfs_server}:${nfs_path}" "$1"
 }
 
 # vim: set ft=sh ts=4 sw=4 et:
diff --git a/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-install-net b/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-install-net
index 79b678949c95..153767add8c5 100644
--- a/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-install-net
+++ b/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-install-net
@@ -3,9 +3,11 @@
 build() {
     add_checked_modules '/drivers/net/'
     add_module nfsv3?
+    add_module nfsv4?
 
     add_binary "/usr/lib/initcpio/ipconfig" "/bin/ipconfig"
     add_binary "/usr/lib/initcpio/nfsmount" "/bin/nfsmount"
+    command -v mount.nfs4 >/dev/null 2>&1 && add_binary "mount.nfs4"
 
     add_runscript
 }
diff --git a/srcpkgs/mkinitcpio-nfs-utils/template b/srcpkgs/mkinitcpio-nfs-utils/template
index 7f36e1cf7fdf..75b8565158ac 100644
--- a/srcpkgs/mkinitcpio-nfs-utils/template
+++ b/srcpkgs/mkinitcpio-nfs-utils/template
@@ -1,7 +1,7 @@
 # Template file for 'mkinitcpio-nfs-utils'
 pkgname=mkinitcpio-nfs-utils
 version=0.3
-revision=3
+revision=4
 build_style=gnu-makefile
 depends="mkinitcpio"
 short_desc="Ipconfig and nfsmount tools for NFS root support in mkinitcpio"
@@ -11,26 +11,27 @@ homepage="http://www.archlinux.org/"
 distfiles="https://sources.archlinux.org/other/mkinitcpio/$pkgname-$version.tar.xz"
 checksum=d290d489844fae100ca7b848b8eef40078124ff373203086bacc07329d1e8939
 
-case "$XBPS_TARGET_MACHINE" in
-*-musl)
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	# musl doesn't set this
 	CFLAGS="-DSYS_NMLN=65"
-	# http://osxr.org/glibc/source/sysdeps/unix/sysv/linux/bits/utsname.h?v=glibc-2.15; fixes musl not having set this variable
-	;;
-esac
+fi
 
+post_patch() {
+	vsed -i '/CC.*-o/s/$/ $(LDFLAGS)/' */Makefile
 
-post_extract() {
-	sed -i '/CC.*-o/s/$/ $(LDFLAGS)/' */Makefile
+	# No RPC in musl for now
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		vsed -i 's|PROGRAMS = ipconfig nfsmount|PROGRAMS = ipconfig|g' Makefile
+	fi
 }
-pre_configure() {
-	case "$XBPS_TARGET_MACHINE" in
-	*-musl)
-		sed -i 's|PROGRAMS = ipconfig nfsmount|PROGRAMS = ipconfig|g' Makefile
-		# No RPC in musl for now
-		;;
-	esac
-}
-post_install() {
+
+do_install() {
+	# Makefile installation is broken, just install the two executables directly
+	vinstall ipconfig/ipconfig 755 usr/lib/initcpio
+	if [ "$XBPS_TARGET_LIBC" != "musl" ]; then
+		vinstall nfsmount/nfsmount 755 usr/lib/initcpio
+	fi
+
 	vinstall ${FILESDIR}/initcpio-install-net 644 usr/lib/initcpio/install net
 	vinstall ${FILESDIR}/initcpio-hook-net 644 usr/lib/initcpio/hooks net
 }

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

* Re: [PR PATCH] [Updated] mkinitcpio-nfs-utils: support NFSv4 roots
  2023-01-10 16:00 [PR PATCH] mkinitcpio-nfs-utils: support NFSv4 roots ahesford
  2023-01-10 17:24 ` [PR PATCH] [Updated] " ahesford
@ 2023-01-10 18:04 ` ahesford
  2023-01-11  2:35 ` [PR PATCH] [Merged]: " ahesford
  2 siblings, 0 replies; 4+ messages in thread
From: ahesford @ 2023-01-10 18:04 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 799 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages nfsroot
https://github.com/void-linux/void-packages/pull/41560

mkinitcpio-nfs-utils: support NFSv4 roots
The `net` hook for `mkinitcpio` shipped by this package uses a helper to do v2 or v3 mounts that support locking without the need for a local `lockd` in the initramfs. The helper does not support v4 mounts and v4 does not require a local `lockd`, so we can look for an NFS version requirement in the root spec and directly call `mount -t nfs4` instead of `nfsmount` to support v4 roots.

#### Testing the changes
- I tested the changes in this PR: **in progress**

A patch file from https://github.com/void-linux/void-packages/pull/41560.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-nfsroot-41560.patch --]
[-- Type: text/x-diff, Size: 4650 bytes --]

From 94d4a1c044592672fdfbbf5e1c30d10ca560609a Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 10 Jan 2023 10:57:51 -0500
Subject: [PATCH] mkinitcpio-nfs-utils: support NFSv4 roots, fix installation

---
 .../files/initcpio-hook-net                   | 23 +++++++++++-
 .../files/initcpio-install-net                | 13 ++++++-
 srcpkgs/mkinitcpio-nfs-utils/template         | 35 ++++++++++---------
 3 files changed, 52 insertions(+), 19 deletions(-)

diff --git a/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-hook-net b/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-hook-net
index 4d1ebb95605e..eee4d7ee150f 100644
--- a/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-hook-net
+++ b/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-hook-net
@@ -84,7 +84,28 @@ nfs_mount_handler() {
         launch_interactive_shell
         msg "Trying to continue (this will most likely fail) ..."
     fi
-    nfsmount ${nfs_option:+-o ${nfs_option}} "${nfs_server}:${nfs_path}" "$1"
+
+    # nfsmount avoids problems with lockd for v2 and v3 but does not support v4;
+    # to support v4 roots, examine mount options for a v4 version spec and use
+    # the ordinary mount program. v4 doesn't need lockd for file locking anyway.
+    mount_cmd=
+    case "${nfs_option}" in
+        nfsvers=4*|*,nfsvers=4*|vers=4*|*,vers=4*)
+            command -v mount.nfs4 >/dev/null 2>&1 && mount_cmd="mount -t nfs4"
+            ;;
+    esac
+
+    # musl installations may not offer nfsmount, so fall back to mount.nfs
+    # when nfsmount does not exist. This probably requires a nolock mount.
+    if [ -z "${mount_cmd}" ]; then
+        if command -v nfsmount >/dev/null 2>&1; then
+            mount_cmd=nfsmount
+        else
+            mount_cmd="mount -t nfs"
+        fi
+    fi
+
+    ${mount_cmd} ${nfs_option:+-o ${nfs_option}} "${nfs_server}:${nfs_path}" "$1"
 }
 
 # vim: set ft=sh ts=4 sw=4 et:
diff --git a/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-install-net b/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-install-net
index 79b678949c95..d4b2d7f0d013 100644
--- a/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-install-net
+++ b/srcpkgs/mkinitcpio-nfs-utils/files/initcpio-install-net
@@ -3,9 +3,20 @@
 build() {
     add_checked_modules '/drivers/net/'
     add_module nfsv3?
+    add_module nfsv4?
 
     add_binary "/usr/lib/initcpio/ipconfig" "/bin/ipconfig"
-    add_binary "/usr/lib/initcpio/nfsmount" "/bin/nfsmount"
+
+    # nfsmount helper might not be available on musl installations
+    if [ -e "/usr/lib/initcpio/nfsmount" ]; then
+        add_binary "/usr/lib/initcpio/nfsmount" "/bin/nfsmount"
+    else
+        add_binary "mount.nfs"
+    fi
+
+    if command -v mount.nfs4 >/dev/null 2>&1; then
+        add_binary "mount.nfs4"
+    fi
 
     add_runscript
 }
diff --git a/srcpkgs/mkinitcpio-nfs-utils/template b/srcpkgs/mkinitcpio-nfs-utils/template
index 7f36e1cf7fdf..75b8565158ac 100644
--- a/srcpkgs/mkinitcpio-nfs-utils/template
+++ b/srcpkgs/mkinitcpio-nfs-utils/template
@@ -1,7 +1,7 @@
 # Template file for 'mkinitcpio-nfs-utils'
 pkgname=mkinitcpio-nfs-utils
 version=0.3
-revision=3
+revision=4
 build_style=gnu-makefile
 depends="mkinitcpio"
 short_desc="Ipconfig and nfsmount tools for NFS root support in mkinitcpio"
@@ -11,26 +11,27 @@ homepage="http://www.archlinux.org/"
 distfiles="https://sources.archlinux.org/other/mkinitcpio/$pkgname-$version.tar.xz"
 checksum=d290d489844fae100ca7b848b8eef40078124ff373203086bacc07329d1e8939
 
-case "$XBPS_TARGET_MACHINE" in
-*-musl)
+if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+	# musl doesn't set this
 	CFLAGS="-DSYS_NMLN=65"
-	# http://osxr.org/glibc/source/sysdeps/unix/sysv/linux/bits/utsname.h?v=glibc-2.15; fixes musl not having set this variable
-	;;
-esac
+fi
 
+post_patch() {
+	vsed -i '/CC.*-o/s/$/ $(LDFLAGS)/' */Makefile
 
-post_extract() {
-	sed -i '/CC.*-o/s/$/ $(LDFLAGS)/' */Makefile
+	# No RPC in musl for now
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		vsed -i 's|PROGRAMS = ipconfig nfsmount|PROGRAMS = ipconfig|g' Makefile
+	fi
 }
-pre_configure() {
-	case "$XBPS_TARGET_MACHINE" in
-	*-musl)
-		sed -i 's|PROGRAMS = ipconfig nfsmount|PROGRAMS = ipconfig|g' Makefile
-		# No RPC in musl for now
-		;;
-	esac
-}
-post_install() {
+
+do_install() {
+	# Makefile installation is broken, just install the two executables directly
+	vinstall ipconfig/ipconfig 755 usr/lib/initcpio
+	if [ "$XBPS_TARGET_LIBC" != "musl" ]; then
+		vinstall nfsmount/nfsmount 755 usr/lib/initcpio
+	fi
+
 	vinstall ${FILESDIR}/initcpio-install-net 644 usr/lib/initcpio/install net
 	vinstall ${FILESDIR}/initcpio-hook-net 644 usr/lib/initcpio/hooks net
 }

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

* Re: [PR PATCH] [Merged]: mkinitcpio-nfs-utils: support NFSv4 roots
  2023-01-10 16:00 [PR PATCH] mkinitcpio-nfs-utils: support NFSv4 roots ahesford
  2023-01-10 17:24 ` [PR PATCH] [Updated] " ahesford
  2023-01-10 18:04 ` ahesford
@ 2023-01-11  2:35 ` ahesford
  2 siblings, 0 replies; 4+ messages in thread
From: ahesford @ 2023-01-11  2:35 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 641 bytes --]

There's a merged pull request on the void-packages repository

mkinitcpio-nfs-utils: support NFSv4 roots
https://github.com/void-linux/void-packages/pull/41560

Description:
The `net` hook for `mkinitcpio` shipped by this package uses a helper to do v2 or v3 mounts that support locking without the need for a local `lockd` in the initramfs. The helper does not support v4 mounts and v4 does not require a local `lockd`, so we can look for an NFS version requirement in the root spec and directly call `mount -t nfs4` instead of `nfsmount` to support v4 roots.

#### Testing the changes
- I tested the changes in this PR: **in progress**

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

end of thread, other threads:[~2023-01-11  2:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10 16:00 [PR PATCH] mkinitcpio-nfs-utils: support NFSv4 roots ahesford
2023-01-10 17:24 ` [PR PATCH] [Updated] " ahesford
2023-01-10 18:04 ` ahesford
2023-01-11  2:35 ` [PR PATCH] [Merged]: " ahesford

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).