]> granicus.if.org Git - nethack/commitdiff
mac term packaging code (trunk only)
authorkeni <keni>
Mon, 17 Oct 2011 01:29:20 +0000 (01:29 +0000)
committerkeni <keni>
Mon, 17 Oct 2011 01:29:20 +0000 (01:29 +0000)
: Modified Files:
:  sys/unix/hints/macosx.sh sys/unix/hints/macosx10.5
:  win/macosx/NetHackRecover.applescript win/macosx/recover.pl
: Added Files:
:  win/macosx/NetHackGuidebook.applescript
:  win/macosx/NetHackTerm.applescript

sys/unix/hints/macosx.sh
sys/unix/hints/macosx10.5
win/macosx/NetHackGuidebook.applescript [new file with mode: 0644]
win/macosx/NetHackRecover.applescript
win/macosx/NetHackTerm.applescript [new file with mode: 0644]
win/macosx/recover.pl

index 443f56ed0653ae2902807524340cdbca7ba92d84..3296963b27e1e54be401482f20dd3b4dbfbd2b64 100755 (executable)
@@ -146,7 +146,7 @@ xinfoplist) SVSDOT=`util/makedefs --svs .`
        <key>IFPkgFlagAuthorizationAction</key>
        <string>RootAuthorization</string>
        <key>IFPkgFlagDefaultLocation</key>
-       <string>/usr/games</string>
+       <string>/</string>
        <key>IFPkgFlagInstallFat</key>
        <false/>
        <key>IFPkgFlagIsRequired</key>
index 4bc0c2484b2b2dc5897e05cd987e3823091e72bb..c426629db4581ca8476175a716a3e3d4e388e785 100644 (file)
@@ -191,40 +191,61 @@ ifdef WANT_WIN_TTY
 DEVUTIL=/Developer/Applications/Utilities
 PKGR=$(DEVUTIL)/PackageMaker.app/Contents/MacOS/PackageMaker
 SVS=$(shell $(NHSROOT)/util/makedefs --svs)
+SVSDOT=$(shell $(NHSROOT)/util/makedefs --svs .)
 
+PKGROOT_UG     = PKGROOT/usr/games
+PKGROOT_UGLN   = PKGROOT/usr/games/lib/nethackdir
 build_tty_pkg:
 ifneq (,$(WANT_WIN_X11)$(WANT_WIN_QT))
        -echo build_tty_pkg only works for a tty-only build
        exit 1
 else
+       rm -rf NetHack-$(SVS)-mac-Term.pkg NetHack-$(SVS)-mac-Term.dmg
        $(MAKE) build_package_root
        rm -rf RESOURCES
        mkdir RESOURCES
-       enscript --language=rtf -o - < dat/license >RESOURCES/License.rtf
+       #enscript --language=rtf -o - < dat/license >RESOURCES/License.rtf
        sys/unix/hints/macosx.sh descplist > RESOURCES/Description.plist
        sys/unix/hints/macosx.sh infoplist > Info.plist
 
-       $(PKGR) --root PKGROOT --info Info.plist -e RESOURCES -v -o NetHack-$(SVS)-mac-Term.pkg
-       hdiutil create -verbose -srcfolder NetHack-$(SVS)-mac-Term.pkg Nethack-$(SVS)-mac-Term.dmg
+       mkdir PKGROOT/Applications
+       #osacompile -o NetHackQt/NetHackQt.app/nethackdir/NetHackRecover.app \
+       #        win/macosx/NetHackRecover.applescript
+       #cp win/macosx/recover.pl NetHackQt/NetHackQt.app/nethackdir
+       osacompile -o PKGROOT/Applications/NetHackRecover.app \
+                win/macosx/NetHackRecover.applescript
+       cp win/macosx/recover.pl $(PKGROOT_UGLN)
+
+       osacompile -o PKGROOT/Applications/NetHackTerm.app \
+                win/macosx/NetHackTerm.applescript
 
-SVS=$(shell util/makedefs --svs)
-SVSDOT=$(shell util/makedefs --svs .)
+       # XXX integrate into Makefile.doc
+       (cd doc; cat Guidebook.mn | ../util/makedefs --grep --input - --output - \
+       | tbl tmac.n - | groff |ps2pdf - > Guidebook.pdf)
+       cp doc/Guidebook.pdf $(PKGROOT_UG)/doc/NetHackGuidebook.pdf
+
+       osacompile -o PKGROOT/Applications/NetHackGuidebook.app \
+                win/macosx/NetHackGuidebook.applescript
+
+       $(PKGR) --root PKGROOT --info Info.plist -e RESOURCES -v -o NetHack-$(SVS)-mac-Term.pkg
+       hdiutil create -verbose -srcfolder NetHack-$(SVS)-mac-Term.pkg NetHack-$(SVS)-mac-Term.dmg
 
 build_package_root:
        cd src/..       # make sure we are at TOP
        rm -rf PKGROOT
-       mkdir -p PKGROOT/lib PKGROOT/bin PKGROOT/man/man6 PKGROOT/doc
-       install -p src/nethack PKGROOT/bin
-       install -p util/recover PKGROOT/bin
-       install -p doc/nethack.6 PKGROOT/man/man6
-       install -p doc/recover.6 PKGROOT/man/man6
-       install -p doc/Guidebook PKGROOT/doc
-       install -p dat/nhdat PKGROOT/lib
-       cd dat; install -p $(DATNODLB) ../PKGROOT/lib
+       mkdir -p $(PKGROOT_UG)/lib $(PKGROOT_UG)/bin $(PKGROOT_UG)/man/man6 $(PKGROOT_UG)/doc $(PKGROOT_UGLN)
+       install -p src/nethack $(PKGROOT_UG)/bin
+       # XXX should this be called nethackrecover?
+       install -p util/recover $(PKGROOT_UG)/bin
+       install -p doc/nethack.6 $(PKGROOT_UG)/man/man6
+       install -p doc/recover.6 $(PKGROOT_UG)/man/man6
+       install -p doc/Guidebook $(PKGROOT_UG)/doc
+       install -p dat/nhdat $(PKGROOT_UGLN)
+       cd dat; install -p $(DATNODLB) ../$(PKGROOT_UGLN)
 # XXX these files should be somewhere else for good Mac form
-       touch PKGROOT/perm PKGROOT/record PKGROOT/logfile
+       touch $(PKGROOT_UGLN)/perm $(PKGROOT_UGLN)/record $(PKGROOT_UGLN)/logfile
 # XXX may need postinstall script to get perms right for sgid, etc.
-       mkdir PKGROOT/save
+       mkdir $(PKGROOT_UGLN)/save
 # XXX what about a news file?
 endif  # end of build_tty_pkg
 endif  # WANT_WIN_TTY for packaging
diff --git a/win/macosx/NetHackGuidebook.applescript b/win/macosx/NetHackGuidebook.applescript
new file mode 100644 (file)
index 0000000..0060b6d
--- /dev/null
@@ -0,0 +1,11 @@
+#!/usr/bin/osascript
+# NetHack 3.5.0  NetHackGuidebook.applescript $Date$  $Revision$
+# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2011
+# NetHack may be freely redistributed.  See license for details.
+
+# Display the Guidebook from the GUI.
+
+tell application "Finder"
+        open location "file:///usr/games/doc/NetHackGuidebook.pdf"
+        delay 5
+end tell
index 250b92ed75290d997b7d77371c99e1e7a25c34a1..93d792208080ec66feae1f13a18a10f2deaf87c4 100644 (file)
@@ -15,10 +15,11 @@ if not canceled then
        set hpath to the path to me
        set mpath to the POSIX path of hpath
        considering case
-               set lastpos to offset of "/nethackdir" in mpath
-               set lastpos to lastpos + (length of "/nethackdir")
-               set rawpath to (get text 1 through lastpos of mpath) & "/recover.pl"
-               set safepath to the quoted form of rawpath
+               --set lastpos to offset of "/nethackdir" in mpath
+               --set lastpos to lastpos + (length of "/nethackdir")
+               --set rawpath to (get text 1 through lastpos of mpath) & "/recover.pl"
+               --set safepath to the quoted form of rawpath
+               set safepath to the quoted form of "/usr/games/lib/nethackdir/recover.pl"
        end considering
        do shell script safepath
        display dialog result with title "NetHackRecover Output"
diff --git a/win/macosx/NetHackTerm.applescript b/win/macosx/NetHackTerm.applescript
new file mode 100644 (file)
index 0000000..6481280
--- /dev/null
@@ -0,0 +1,130 @@
+#!/usr/bin/osascript
+# NetHack 3.5.0  NetHackTerm.applescript $Date$  $Revision$
+# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2011
+# NetHack may be freely redistributed.  See license for details.
+
+# Run the terminal port from the GUI.
+
+# BUGS:
+# We close any terminal windows with no processes in them, even if they
+# don't belong to us because we can't really tell which ones do belong to us.
+# Shouldn't be serious since anyone using this is unlikely to be using Terminal
+# for anything else.
+set debug to false
+
+set needshutdown to false
+tell application "Terminal"
+       # see if we're going to have to shut it down at the end because we started it up
+       if it is not running then
+               set needshutdown to true
+       end if
+       
+       activate
+       #open new window and run NetHack in it
+       do script with command "clear;sleep 1;/usr/games/bin/nethack;echo '(press RETURN to exit)';awk '{exit}';exit"
+       set nhresult to result -- class is tab
+       set nhresrec to result as record
+       set nhreslist to result as list
+       set nhwin to item 4 of nhreslist
+       set custom title of nhwin to "NH"
+       #set title displays custom title of nhresult to true
+       set title displays device name of nhresult to false
+       set title displays shell path of nhresult to false
+       set title displays window size of nhresult to false
+       set title displays file name of nhresult to false
+       #set idnum to id of nhresult
+       set xxx to class of nhresrec
+       get class of nhresrec -- record
+       get length of nhresrec -- 4
+       set nhwinname to name of nhwin
+       set nhtab to selected tab of nhwin
+       get processes of nhtab
+       
+       # main loop - wait for all nethack processes to exit
+       set hit to true
+       set nhname to "nethack" as text
+       delay 4
+       repeat while hit
+               set hit to false
+               delay 0.5
+               
+               # don't blow up if the window has gone away
+               try
+                       set procs to get processes of nhtab
+               on error number -1728
+                       exit repeat
+               end try
+               
+               repeat with pname in procs
+                       if debug then
+                               display alert "PNAME=" & pname & "=" & nhname & "="
+                       end if
+                       # XXX this test is odd, but more obvious tests fail
+                       if pname starts with nhname then
+                               #display alert "HIT"  -- dangerous - infinite loop
+                               set hit to true
+                       end if
+                       # yes, this is scary.
+                       if pname starts with ("awk" as text) then
+                               set hit to true
+                       end if
+               end repeat
+       end repeat
+       if debug then
+               display alert "DONE"
+       end if
+       
+       # window may have already closed or dropped its last process (error -1728)
+       try
+               close window nhwinname
+       on error errText number errNum
+               if errNum = -1728 then
+                       if debug then
+                               display alert "close failed (expected)"
+                       end if
+               else
+                       -- unexpected error - show it
+                       display alert "close failed: " & errText & " errnum=" & errNum
+               end if
+       end try
+       
+end tell
+
+# Close all the windows that don't have any live processes in them.
+tell application "Terminal"
+       set wc to count windows
+       set pending to {}
+       if debug then
+               display alert "COUNT is " & wc
+       end if
+       repeat with win in windows
+               if debug then
+                       display alert "WIN: " & (name of win) & " TABS: " & (count of tabs of win) & " PROCS: " & (count of processes of item 1 of tabs of win)
+               end if
+               set pcount to count of processes of item 1 of tabs of win
+               if pcount is 0 then
+                       copy win to the end of pending
+                       set wc to wc - 1
+               end if
+       end repeat
+end tell
+
+if debug then
+       display alert "LATE COUNT is " & wc
+end if
+repeat with win in pending
+       try
+               close win
+       end try
+end repeat
+
+# If we started Terminal.app and the user doesn't have anything else running,
+# shut it down.
+if needshutdown and (wc is 0) then
+       if debug then
+               display alert "trying shutdown"
+       end if
+       tell application "Terminal"
+               quit
+       end tell
+end if
index c573c27a29a70858114fcf8df3b57f0ad0032fbf..65aa68dfc33edfa2110297f1736be4b2d167f9c1 100755 (executable)
@@ -13,7 +13,7 @@ if(! -d $playground){
        print "Cannot find playground $playground.";
        exit 0
 }
-if(! -f "$playground/castle.lev"){
+if(! -f "$playground/castle.lev" && ! -f "$playground/nhdat"){
        print "Failed to find playground $playground.";
        exit 0
 }
@@ -38,9 +38,12 @@ if($try_perm){
 }
 
 # run recover, but only if there is something that looks promising
+$recover = "./recover";
+$recover = "/usr/games/bin/recover" unless(-e $recover);
+
 $uid = $<;
 foreach ( <$uid*.0> ){
-       system ("./recover -d . $_");
+       system ("$recover -d . $_");
 }
 
 print "Done.\n";