From bac8ebad34bcae078a4f167dc6eba1bcf9e1a5da Mon Sep 17 00:00:00 2001 From: nhmall Date: Sat, 27 Jan 2024 18:12:18 -0500 Subject: [PATCH] revisit Makefile sysconf steps Add distinct potential steps into Makefile.top for putting sysconf into place, instead of appending the steps for doing so to the generic POSTINSTALL. SYSCONFINSTALL is used for 'make install' and unconditionally copies sys/unix/sysconf to the install directory. SYSCONFENSURE is used for 'make update' and only copies sys/unix/sysconf to the installation directory if it doesn't already exist. The initial trigger for revisiting this was because of new reports that cp from (GNU coreutils) 9.4 is now issuing a warning during NetHack builds. The warning pertains to deprecated use of the '-n' switch with cp, which is used to only copy the file if the target does not exist. After this update, the shell is used to make that determination, and if the file doesn't exist, cp is now invoked on Linux without the '-n' switch. For the macOS hints file, macOS.370, cp wasn't being used for sysconf anyway, a utility script was being invoked and this doesn't change that. macOS.370 was updated to remain in sync with linux.370 and Makefile.top regarding the use of SYSCONFINSTALL and SYSCONFENSURE. --- sys/unix/Makefile.top | 24 ++++++++++++++++++++++-- sys/unix/hints/linux.370 | 19 +++++++++++++------ sys/unix/hints/macOS.370 | 16 +++++++++++----- 3 files changed, 46 insertions(+), 13 deletions(-) diff --git a/sys/unix/Makefile.top b/sys/unix/Makefile.top index 9c9ae0766..50466d12a 100644 --- a/sys/unix/Makefile.top +++ b/sys/unix/Makefile.top @@ -104,6 +104,21 @@ DATNODLB = $(VARDATND) license symbols DATDLB = $(DATHELP) dungeon.lua tribute $(SPEC_LEVS) $(QUEST_LEVS) $(VARDATD) DAT = $(DATNODLB) $(DATDLB) +# These get set only if they weren't already set above or in a hints file +#CHOWN ?= true +#CHGRP ?= true +#SYSCONFCREATE ?= cp sys/unix/sysconf $(INSTDIR)/sysconf +#SYSCONFINSTALL ?= $(SYSCONFCREATE) && \ +# $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf && \ +# $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf && \ +# chmod $(VARFILEPERM) $(INSTDIR)/sysconf; +#SYSCONFENSURE ?= (if ! test -f $(INSTDIR)/sysconf ; then \ +# $(SYSCONFCREATE) && \ +# $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf && \ +# $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf && \ +# chmod $(VARFILEPERM) $(INSTDIR)/sysconf; fi ); + +# Lua LUAHEADERS = lib/lua-$(LUA_VERSION)/src LUATESTTARGET = $(LUAHEADERS)/lua.h LUATOP = $(LUAHEADERS) @@ -368,7 +383,7 @@ fetch-lua-http: # 'make update' can be used to install a revised version after making # customizations or such. Unlike 'make install', it doesn't delete everything # from the target directory to have a clean start. -update: $(PRECHECK) $(GAME) recover $(VARDAT) spec_levs +update: $(PRECHECK) $(GAME) recover $(VARDAT) spec_levs sys/unix/sysconf # (don't yank the old version out from under people who're playing it) -mv $(INSTDIR)/$(GAME) $(INSTDIR)/$(GAME).old -mv $(INSTDIR)/nhdat $(INSTDIR)/nhdat.old @@ -376,13 +391,15 @@ update: $(PRECHECK) $(GAME) recover $(VARDAT) spec_levs ( $(MAKE) dofiles ) # should already be present, but make sure touch $(VARDIR)/perm $(VARDIR)/record +# sysconf, but only if it does not exist + true; $(SYSCONFENSURE) # and a reminder @echo You may also want to install the man pages via the doc Makefile. rootcheck: @true; $(ROOTCHECK) -install: rootcheck $(PRECHECK) $(GAME) recover $(VARDAT) spec_levs +install: rootcheck $(PRECHECK) $(GAME) recover $(VARDAT) spec_levs sys/unix/sysconf true; $(PREINSTALL) # set up the directories # not all mkdirs have -p; those that don't will create a -p directory @@ -404,6 +421,9 @@ install: rootcheck $(PRECHECK) $(GAME) recover $(VARDAT) spec_levs -( cd $(VARDIR) ; $(CHOWN) $(GAMEUID) perm record logfile xlogfile livelog ; \ $(CHGRP) $(GAMEGRP) perm record logfile xlogfile livelog ; \ chmod $(VARFILEPERM) perm record logfile xlogfile livelog ) +# sysconf + true; $(SYSCONFINSTALL) +# other steps from hints file true; $(POSTINSTALL) # and a reminder @echo You may also want to reinstall the man pages via the doc Makefile. diff --git a/sys/unix/hints/linux.370 b/sys/unix/hints/linux.370 index 7139e9175..508785612 100755 --- a/sys/unix/hints/linux.370 +++ b/sys/unix/hints/linux.370 @@ -295,6 +295,17 @@ override GAME= MOREALL += ( cd src ; $(MAKE) pregame ; $(MAKE) $(TARGETPFX)libnh.a ) endif # WANT_LIBNH +SYSCONFCREATE = cp sys/unix/sysconf $(INSTDIR)/sysconf +SYSCONFINSTALL = $(SYSCONFCREATE) && \ + $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf && \ + $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf && \ + chmod $(VARFILEPERM) $(INSTDIR)/sysconf; +SYSCONFENSURE = (if ! test -f $(INSTDIR)/sysconf ; then \ + $(SYSCONFCREATE) && \ + $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf && \ + $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf && \ + chmod $(VARFILEPERM) $(INSTDIR)/sysconf; fi ); + ifdef WANT_SOURCE_INSTALL PREFIX=$(abspath $(NHSROOT)) #SHELLDIR= @@ -317,14 +328,10 @@ endif #?WANT_SOURCE_INSTALL INSTDIR=$(HACKDIR) VARDIR = $(HACKDIR) -POSTINSTALL+= cp -n sys/unix/sysconf $(INSTDIR)/sysconf; \ - $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf; \ - $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf; \ - chmod $(VARFILEPERM) $(INSTDIR)/sysconf; \ - ( util/makedefs --grep-defined CRASHREPORT && \ +POSTINSTALL+= ( util/makedefs --grep-defined CRASHREPORT && \ ( cp win/share/nhcrashreport.lua $(INSTDIR) ; \ chmod 555 $(INSTDIR)/nhcrashreport.lua ; \ - cp $(LUATOP)/lua $(INSTDIR)/nhlua); true); + cp $(LUATOP)/lua $(INSTDIR)/nhlua); true ); ifneq "$(CCISCLANG)" "" # gdb may not be installed if clang is chosen compiler so the game diff --git a/sys/unix/hints/macOS.370 b/sys/unix/hints/macOS.370 index 26d6b435a..981bf4396 100755 --- a/sys/unix/hints/macOS.370 +++ b/sys/unix/hints/macOS.370 @@ -350,11 +350,7 @@ ROOTCHECK= [[ `id -u` == 0 ]] || ( echo "Must run install with sudo."; exit 1) PREINSTALL= . sys/unix/hints/macosx.sh user2 $(GAMEUID); \ . sys/unix/hints/macosx.sh group2 $(GAMEGRP); \ (mkdir $(SHELLDIR) || true); chown $(GAMEUID) $(SHELLDIR) -POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/sysconf; \ - $(CHOWN) $(GAMEUID) $(HACKDIR)/sysconf; \ - $(CHGRP) $(GAMEGRP) $(HACKDIR)/sysconf; \ - chmod $(VARFILEPERM) $(HACKDIR)/sysconf; \ - util/makedefs --grep-defined CRASHREPORT && \ +POSTINSTALL+= util/makedefs --grep-defined CRASHREPORT && \ ( cp win/macosx/NetHackCrashReport.JavaScript $(HACKDIR) && \ chmod 0500 $(HACKDIR)/NetHackCrashReport.JavaScript ) @@ -414,6 +410,16 @@ endif # !WANT_SHARE_INSTALL INSTDIR=$(HACKDIR) VARDIR=$(HACKDIR) +SYSCONFCREATE = sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/sysconf +SYSCONFINSTALL = $(SYSCONFCREATE) && \ + $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf && \ + $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf && \ + chmod $(VARFILEPERM) $(INSTDIR)/sysconf; +SYSCONFENSURE = (if ! test -f $(INSTDIR)/sysconf ; then \ + $(SYSCONFCREATE) && \ + $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf && \ + $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf && \ + chmod $(VARFILEPERM) $(INSTDIR)/sysconf; fi ); # ~/Library/Preferences/NetHack Defaults # OPTIONS=name:player,number_pad,menustyle:partial,!time,showexp