home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 6.ddi / usr / bin / displaypkg < prev    next >
Encoding:
Text File  |  1990-12-08  |  2.7 KB  |  107 lines

  1. #!/sbin/sh
  2.  
  3. #    Copyright (c) 1987, 1988 Microsoft Corporation
  4. #      All Rights Reserved
  5.  
  6. #    This Module contains Proprietary Information of Microsoft 
  7. #    Corporation and should be treated as Confidential.
  8. #
  9. #ident    "@(#)/usr/bin/displaypkg.sl 1.1 4.0 12/08/90 59324 AT&T-USL"
  10. #
  11. # PURPOSE: List installed software
  12. # ---------------------------------------------------------------------
  13.  
  14. #  List any xenix packages along with the AT&T packages.  If the 
  15. #  directory /etc/perms is non-empty, then xenix sets exist.  Use
  16. #  fixperm to determine which packages within these sets have been
  17. #  installed.  This code is similar to the code in the custom command.
  18. list_xenix_pkgs()
  19. {
  20.     >$tmp.$sid                #  Empty this file
  21.  
  22.     # List all packages in this directory
  23.     for perm in $perm_files
  24.     do
  25.         #  Call fixperm to list the installed packages for this set
  26.         (cd /; fixperm -iv $ignorepkgs /etc/perms/$perm) |
  27.         sed "s/^\(.*\)    .*$/s:^#!\1[     ][     ]*:    &    :p/" > $tmp.fl
  28.         #  Get the information and reformat it for display
  29.         #  Filter out packages not installed (not Yes or Part)
  30.         sed -n -f $tmp.fl /etc/perms/$perm   |  awk '
  31.             $2=="Part" || $2=="Yes" { 
  32.                     #  For some reason, one line must be
  33.                     #  first be printed or the spacing 
  34.                     #  will be screwed up.
  35.                     printf "\n"
  36.  
  37.                     #  Print the name and status
  38.                     printf "%s\t%s\t", $1, $2
  39.  
  40.                     #  Rest of fields are the description
  41.                     for (i = 4; i <= NF; i++)
  42.                         printf "%s ", $i
  43.                } ' >>$tmp.$sid
  44.     done
  45.  
  46.     #  If the file exists, then there are XENIX packages to list.  Make
  47.     #  a new file suitable for cat'ing alon with the UNIX packages.
  48.     if [ -s $tmp.$sid ]
  49.     then
  50.         echo > $tmp.$sid.2 "\n\n\t\tXENIX  Packages\n\t\t-------------"
  51.         cat $tmp.$sid >>$tmp.$sid.2
  52.  
  53.         #  Add this file to the list of files being cat'ed
  54.         list="$list $tmp.$sid.2"
  55.     fi
  56.  
  57.     rm -f $tmp.$sid $tmp.fl
  58. }
  59.  
  60. tmp=/tmp/CUSLIST            #  Temp file for xenix commands
  61. sid=$$
  62. list=
  63. PATH=/sbin:/usr/sbin:/etc:/usr/bin
  64. export PATH
  65.  
  66. if [ "$1" = XENIX ]
  67. then perm_files=`cd /etc/perms; echo *`
  68.      if [ "/att/msoft/isc/*" != "/att/msoft/isc/$perm_files" ]
  69.      then
  70.     list_xenix_pkgs
  71.      fi
  72.      if [ -n "${list}" ]
  73.      then
  74.     cat ${list} 
  75.     echo
  76.      fi
  77.      rm -f $tmp.$sid.2 $tmp.$fl ${list}
  78.      exit 0
  79. fi
  80.  
  81. if [ -d /usr/options ]
  82. then
  83.     cd /usr/options
  84.     list=`ls *.name 2>/dev/null`
  85. fi
  86.  
  87. #  Use a bogus directory to check if /etc/perms is an empty 
  88. #  directory.  Used to be guaranteed not empty in XENIX.
  89. #  Avoids expansion of '*'.
  90. perm_files=`cd /etc/perms; echo *`
  91. if [ "/att/msoft/isc/*" != "/att/msoft/isc/$perm_files" ]
  92. then
  93.     list_xenix_pkgs
  94. fi
  95.  
  96. if [ -n "$list" ]
  97. then
  98.     echo "\n\tThe following software packages have been installed:\n"
  99.     cat ${list} | pg
  100.  
  101.     rm -f $tmp.$sid.2 $tmp.$fl
  102.     exit 0
  103. fi
  104.  
  105. echo "There are currently no software applications installed."
  106.  
  107.