Skip to contentSkip to conversation

package/nss-myhostname: Add package

PATCH New Vincent Prince 3 participants 5 messages May 24, 2018 – May 27, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/nss-myhostname: Add package

Also fix nss-mdns hook to work with nss-myhostname

---
 package/Config.in                          |  1 +
 package/nss-mdns/nss-mdns.mk               |  2 +-
 package/nss-myhostname/Config.in           |  7 +++++++
 package/nss-myhostname/nss-myhostname.hash |  2 ++
 package/nss-myhostname/nss-myhostname.mk   | 20 ++++++++++++++++++++
 5 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100644 package/nss-myhostname/Config.in
 create mode 100644 package/nss-myhostname/nss-myhostname.hash
 create mode 100644 package/nss-myhostname/nss-myhostname.mk
package/Config.in +1 -0
index 3cf53ed..3ac0d63 100644
@@ -1426,6 +1426,7 @@ menu "Networking"
 	source "package/neon/Config.in"
 	source "package/norm/Config.in"
 	source "package/nss-mdns/Config.in"
+	source "package/nss-myhostname/Config.in"
 	source "package/nss-pam-ldapd/Config.in"
 	source "package/omniorb/Config.in"
 	source "package/openldap/Config.in"
package/nss-mdns/nss-mdns.mk +1 -1
index 407b942..ee666c7 100644
@@ -17,6 +17,6 @@ define NSS_MDNS_INSTALL_CONFIG
 		$(TARGET_DIR)/etc/nsswitch.conf
 endef
 
-NSS_MDNS_POST_INSTALL_TARGET_HOOKS += NSS_MDNS_INSTALL_CONFIG
+NSS_MDNS_TARGET_FINALIZE_HOOKS += NSS_MDNS_INSTALL_CONFIG
 
 $(eval $(autotools-package))
package/nss-myhostname/Config.in new file +7 -0
new file mode 100644
index 0000000..968b911
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_NSS_MYHOSTNAME
+	bool "nss-myhostname"
+    depends on !BR2_PACKAGE_SYSTEMD_MYHOSTNAME
+	help
+		Name Service Switch module for resolving the local hostname
+
+		http://0pointer.de/lennart/projects/nss-myhostname
package/nss-myhostname/nss-myhostname.hash new file +2 -0
new file mode 100644
index 0000000..9e33bec
@@ -0,0 +1,2 @@
+# locally computed
+sha256  2ba744ea8d578d1c57c85884e94a3042ee17843a5294434d3a7f6c4d67e7caf2 nss-myhostname-0.3.tar.gz
package/nss-myhostname/nss-myhostname.mk new file +20 -0
new file mode 100644
index 0000000..153e1d0
@@ -0,0 +1,20 @@
+################################################################################
+#
+## nss-myhostname
+#
+#################################################################################
+
+NSS_MYHOSTNAME_VERSION = 0.3
+NSS_MYHOSTNAME_SITE = http://0pointer.de/lennart/projects/nss-myhostname
+NSS_MYHOSTNAME_LICENSE = LGPL-2.1
+NSS_MYHOSTNAME_LICENSE_FILES = LICENSE
+NSS_MYHOSTNAME_AUTORECONF = YES
+
+define MYHOSTNAME_SET_NSSWITCH
+    $(SED) '/^hosts:/s/\s*\<myhostname\>//' \
+		-e 's/\(^hosts:.*\)\(\<files\>\)\(.*\)\(\<dns\>\)\(.*\)/\1\2 myhostname \3\4\5/' -r $(TARGET_DIR)/etc/nsswitch.conf
+endef
+
+NSS_MYHOSTNAME_TARGET_FINALIZE_HOOKS += MYHOSTNAME_SET_NSSWITCH
+
+$(eval $(autotools-package))
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 package/nss-myhostname: Add package

Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Vincent" == Vincent Prince <[email protected]> writes:

Also fix nss-mdns hook to work with nss-myhostname

Thanks for you contribution! Can you please split this in two patches, E.G. one to change nss-mdns and one to add nss-myhostname?

Also please add an entries to the DEVELOPERS file and run ./utils/check-package on your new files, I see a number of strange indentation issues.

While you are at it, please also add a sha256 hash for the license file.

package/nss-myhostname/nss-myhostname.mk line 11

Quoted 6 lines
package/nss-myhostname/nss-myhostname.mk new file +6 -0
+
+NSS_MYHOSTNAME_VERSION = 0.3
+NSS_MYHOSTNAME_SITE = http://0pointer.de/lennart/projects/nss-myhostname
+NSS_MYHOSTNAME_LICENSE = LGPL-2.1
+NSS_MYHOSTNAME_LICENSE_FILES = LICENSE
+NSS_MYHOSTNAME_AUTORECONF = YES

Why? Does the tarball not contain a configure script?

package/nss-myhostname/nss-myhostname.mk line 16

Quoted 5 lines
package/nss-myhostname/nss-myhostname.mk new file +5 -0
+
+define MYHOSTNAME_SET_NSSWITCH
+    $(SED) '/^hosts:/s/\s*\<myhostname\>//' \
+		-e 's/\(^hosts:.*\)\(\<files\>\)\(.*\)\(\<dns\>\)\(.*\)/\1\2 myhostname \3\4\5/' -r $(TARGET_DIR)/etc/nsswitch.conf
+endef

Doesn't nss-myhostname just need to go to the end of the file? E.G. something like:

     grep -qw myhostname $(TARGET_DIR)/etc/nsswwitch.conf || \
          $(SED) '/\(^hosts:.*\)/\1 myhostname/' $(TARGET_DIR)/etc/nsswitch.conf
Signature · 1 line
Bye, Peter Korsgaard
#2 lore raw

PATCH 1/1 package/nss-myhostname: Add package

Hi Peter,

I'll send V2 on monday with:
- patch split
- DEVELOPERS
- fix indentation
- sha256 sig
- AUTORECONF removed

nsswitch.conf resolve hosts in entries order, so it is important that it resides after files and before the other entries.
Sed command comes from Yocto recipe
https://git.yoctoproject.org/cgit.cgi/poky/plain/meta/recipes-support/nss-myhostname/nss-myhostname_0.3.bb

Best regards,
Vincent

2018-05-25 19:02 GMT+02:00 Peter Korsgaard <[email protected]>:

Quoted 35 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Vincent" == Vincent Prince <[email protected]> writes:

Also fix nss-mdns hook to work with nss-myhostname

Thanks for you contribution! Can you please split this in two patches, E.G. one to change nss-mdns and one to add nss-myhostname?

Also please add an entries to the DEVELOPERS file and run ./utils/check-package on your new files, I see a number of strange indentation issues.

While you are at it, please also add a sha256 hash for the license file.

package/nss-myhostname/nss-myhostname.mk

Quoted 3 lines
package/nss-myhostname/nss-myhostname.mk new file +3 -0
+
+NSS_MYHOSTNAME_VERSION = 0.3
+NSS_MYHOSTNAME_SITE = http://0pointer.de/lennart/

projects/nss-myhostname

package/nss-myhostname/nss-myhostname.mk line 11

Quoted 3 lines
package/nss-myhostname/nss-myhostname.mk new file +3 -0
+NSS_MYHOSTNAME_LICENSE = LGPL-2.1
+NSS_MYHOSTNAME_LICENSE_FILES = LICENSE
+NSS_MYHOSTNAME_AUTORECONF = YES

Why? Does the tarball not contain a configure script?

package/nss-myhostname/nss-myhostname.mk

Quoted 4 lines
package/nss-myhostname/nss-myhostname.mk new file +4 -0
+
+define MYHOSTNAME_SET_NSSWITCH
+    $(SED) '/^hosts:/s/\s*\<myhostname\>//' \
+            -e 's/\(^hosts:.*\)\(\<files\>\)\(.*\)\(\<dns\>\)\(.*\)/\1\2

myhostname \3\4\5/' -r $(TARGET_DIR)/etc/nsswitch.conf

Quoted 1 line

+endef

Doesn't nss-myhostname just need to go to the end of the file? E.G. something like:

Quoted 7 lines
     grep -qw myhostname $(TARGET_DIR)/etc/nsswwitch.conf || \
          $(SED) '/\(^hosts:.*\)/\1 myhostname/'

$(TARGET_DIR)/etc/nsswitch.conf

--
Bye, Peter Korsgaard

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180525/c8c9a336/attachment.html>

#3 lore raw

PATCH 1/1 package/nss-myhostname: Add package

Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Vincent" == Vincent Prince <[email protected]> writes:

Hi Peter,
I'll send V2 on monday with:
- patch split
- DEVELOPERS
- fix indentation
- sha256 sig
- AUTORECONF removed

Great, thanks.

Quoted 2 lines

nsswitch.conf resolve hosts in entries order, so it is important that it resides after files and before the other entries.

Before the others?

The example on the website and note seems to show it at the very end, E.G. as a fallback:

http://0pointer.de/lennart/projects/nss-myhostname/

It is recommended to put myhostname last in the nsswitch.conf line to make sure that this mapping is only used as fallback, and any DNS or /etc/hosts based mapping takes precedence.

Quoted 2 lines

Sed command comes from Yocto recipe
https://git.yoctoproject.org/cgit.cgi/poky/plain/meta/recipes-support/nss-myhostname/nss-myhostname_0.3.bb

Ok, please mention that in the commit message - Thanks.

Signature · 1 line
Bye, Peter Korsgaard
#4 lore raw

PATCH 1/1 package/nss-myhostname: Add package

In reply to Vincent Prince

Hi Vincent,

In addition to Peter's comments...

Quoted 3 lines · Vincent Prince

Also fix nss-mdns hook to work with nss-myhostname

[snip]

package/nss-myhostname/Config.in line 3

Quoted 9 lines
package/nss-myhostname/Config.in new file +3 -0
new file mode 100644
index 0000000..968b911
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_NSS_MYHOSTNAME
+	bool "nss-myhostname"
+    depends on !BR2_PACKAGE_SYSTEMD_MYHOSTNAME

My guess is that this will needs nsswitch, right? So I guess it will need

depends on BR2_TOOLCHAIN_USES_GLIBC

like nss-mdns, and also the "nss-myhostname needs a glibc toolchain" comment.

Quoted 18 lines
package/nss-myhostname/Config.in new file +4 -0
+	help
+		Name Service Switch module for resolving the local hostname
+
+		http://0pointer.de/lennart/projects/nss-myhostname
package/nss-myhostname/nss-myhostname.hash new file +2 -0
new file mode 100644
index 0000000..9e33bec
@@ -0,0 +1,2 @@
+# locally computed
+sha256  2ba744ea8d578d1c57c85884e94a3042ee17843a5294434d3a7f6c4d67e7caf2 nss-myhostname-0.3.tar.gz
package/nss-myhostname/nss-myhostname.mk new file +0 -0
new file mode 100644
index 0000000..153e1d0

package/nss-myhostname/nss-myhostname.mk line 9

Quoted 9 lines
package/nss-myhostname/nss-myhostname.mk new file +9 -0
@@ -0,0 +1,20 @@
+################################################################################
+#
+## nss-myhostname
+#
+#################################################################################
+
+NSS_MYHOSTNAME_VERSION = 0.3
+NSS_MYHOSTNAME_SITE = http://0pointer.de/lennart/projects/nss-myhostname
+NSS_MYHOSTNAME_LICENSE = LGPL-2.1

It has the "or later" clause, so LGPL-2.1+

package/nss-myhostname/nss-myhostname.mk line 14

Quoted 5 lines
package/nss-myhostname/nss-myhostname.mk new file +5 -0
+NSS_MYHOSTNAME_LICENSE_FILES = LICENSE
+NSS_MYHOSTNAME_AUTORECONF = YES
+
+define MYHOSTNAME_SET_NSSWITCH
+    $(SED) '/^hosts:/s/\s*\<myhostname\>//' \

If you use -e, use it everywhere for symmetry.

package/nss-myhostname/nss-myhostname.mk line 15

Quoted 1 line
package/nss-myhostname/nss-myhostname.mk new file +1 -0
+		-e 's/\(^hosts:.*\)\(\<files\>\)\(.*\)\(\<dns\>\)\(.*\)/\1\2 myhostname \3\4\5/' -r $(TARGET_DIR)/etc/nsswitch.conf

-r is not what we usually use, we use -E. However, the regex looks wrong to me
with -E, it should then be an unquoted (, no?

Also, if the patterns contain /, use a different delimiter, we usually use ,
So something like:

$(SED) -E -e '/^hosts:/s/\s*\<myhostname\>//' \
-e 's,(^hosts:.*)(\<files\>)(.*)(\<dns\>),\1\2 myhostname \3\4,' \
$(TARGET_DIR)/etc/nsswitch.conf

Regards,
Arnout

Quoted 6 lines
package/nss-myhostname/nss-myhostname.mk new file +5 -0
+endef
+
+NSS_MYHOSTNAME_TARGET_FINALIZE_HOOKS += MYHOSTNAME_SET_NSSWITCH
+
+$(eval $(autotools-package))
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF