home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / next / misc / 21890 < prev    next >
Encoding:
Text File  |  1992-11-11  |  3.2 KB  |  102 lines

  1. Newsgroups: comp.sys.next.misc
  2. Path: sparky!uunet!destroyer!gatech!purdue!mentor.cc.purdue.edu!news
  3. From: ab@nova.cc.purdue.edu (Allen B)
  4. Subject: Re: Distinguishing 3.0 binaries
  5. Message-ID: <BxKMsL.2rv@mentor.cc.purdue.edu>
  6. Keywords: cool sh script
  7. Sender: news@mentor.cc.purdue.edu (USENET News)
  8. Organization: Purdue University
  9. References: <BxKBs1.3yH@mentor.cc.purdue.edu>
  10. Date: Wed, 11 Nov 1992 21:38:44 GMT
  11. Lines: 89
  12.  
  13. Earlier, I said:
  14. > I received several responses that all said about the same
  15. > thing.  Since I have a fantastic collection of old
  16. > NeXTstep releases, I will post a sh script here shortly
  17. > that identifies binaries of as many as I can manage.  This
  18. > should be fun!
  19.  
  20. Here's the script.  It's also on sonata as
  21. pub/next/lore/version.  I'll add some more error
  22. checking and junk later.  Make sure you set the modes right
  23. on it (readable and executable for whomever). 
  24.  
  25. To use, just give it filenames of programs you want to
  26. check, like "version /LocalApps/*" and it does the rest. 
  27. I'm no sh wizard, but I do OK. :-)
  28.  
  29. Thanks for the tips.  I rummaged through my morgue and made
  30. it a little more robust. :-)
  31.  
  32. #!/bin/sh
  33. #
  34. # version       Find the version of the OS a program was created under
  35. #
  36. # by Allen B (ab@nova.cc.purdue.edu) with help from the net.
  37. #
  38. # Uses otool to check version numbers on libraries, then checks those
  39. # against the versions of the OS I had handy.  I've got quite a morgue
  40. # here, but I don't have a lot of 2.x variants.
  41. #
  42. # If it ever says "Version n" instead of printing the OS level, send
  43. # the version number and OS name to me and I'll fix it.
  44.  
  45. for PROGRAM
  46. do
  47.         BINARY=`echo $PROGRAM | sed "s,\([^/]*\)\.app,\1.app/\1,"`
  48.  
  49.         if [ "$BINARY" = "$PROGRAM" ]
  50.         then
  51.                 TYPE="executable"
  52.         else
  53.                 TYPE="App"
  54.         fi
  55.  
  56.         VERSION=`/bin/otool -L "$BINARY" | grep libsys_s...shlib | sed "s/.*  
  57. \([0-9][0-9]*\).*/\1/"`
  58.         if [ ! "$VERSION" ]
  59.         then
  60.                 VERSION=`/bin/otool -L "$BINARY" | grep libappkit | sed "s/.*  
  61. \([0-9][0-9]*\).*/\1/"`
  62.         fi
  63.  
  64.         # OS="I have no idea what kind of"
  65.         OS="Version $VERSION"
  66.         case "$VERSION" in
  67.         14)     # 0.8a26e0.8
  68.                 OS="NeXTStep 0.8"
  69.                 ;;
  70.         1)      # 0.9.49:0.83
  71.                 OS="NeXTStep 0.9"
  72.                 ;;
  73.         10)     # 1.0.63 (also labeled 0.981 physically)
  74.                 OS="NeXTStep 0.981"
  75.                 ;;
  76.         12)     # 1.0.63 (also labeled 0.981 physically)
  77.                 OS="NeXTStep 0.981"
  78.                 ;;
  79.         13)     # 1.0.63/1.067 (also labeled 0.981/0.991 physically)
  80.                 OS="NeXTStep 0.991"
  81.                 ;;
  82.         17)     # 1.067 (also labeled 0.991 physically)
  83.                 OS="NeXTStep 0.991"
  84.                 ;;
  85.         18)     # 1.0.68
  86.                 OS="NextStep 1.0"
  87.                 ;;
  88.         19)     # 1.0.68
  89.                 OS="NextStep 1.0"
  90.                 ;;
  91.         44)     # Whatever I was using
  92.                 OS="NeXTstep 2.x"
  93.                 ;;
  94.         55)     # 3.0 CD Distribution
  95.                 OS="NeXTSTEP 3.0"
  96.                 ;;
  97.         esac
  98.  
  99.         # echo "$PROGRAM: $OS ($VERSION) $TYPE"
  100.         echo "$PROGRAM: $OS $TYPE"
  101. done
  102.