home *** CD-ROM | disk | FTP | other *** search
/ Chip 2008 June / CHIP-2008-06.iso / macos / Baseline / Baseline.app / Contents / SharedSupport / create_package_index.sh
Encoding:
Linux/UNIX/POSIX Shell Script  |  2008-03-31  |  1.5 KB  |  73 lines

  1. #!/bin/bash
  2.  
  3. LANG=C
  4. # FRCODE=/usr/local/libexec/frcode
  5. # DB=~/.pkglocate.database
  6.  
  7. DB="$1"
  8. REBUILD="$2"
  9. LEOPARD=`sw_vers -productVersion | grep 10.5`
  10.  
  11. if [ -z "${DB}" ];
  12. then
  13.     echo "No database specified";
  14.     exit -1;
  15. fi
  16.  
  17.  
  18. if [ ! -z "${LEOPARD}" ];
  19. then
  20.  
  21.     # echo "On 10.5"
  22.  
  23.     if [ -e "${DB}" ] && [ -z "${REBUILD}" ];
  24.     then
  25.  
  26.         #echo Updating
  27.  
  28.         find /Library/Receipts/boms/ -name '*.pkg.*.bom' -newer "${DB}" | while read line; do 
  29.            t=${line#/Library/Receipts/boms//com.apple.pkg.}
  30.            pkgname=${t%.bom}
  31.           lsbom -bcdfls "$line" | perl -pe "s|^|$pkgname\t|"
  32.         done
  33.  
  34.     else
  35.  
  36.         #echo Creating
  37.  
  38.         find /Library/Receipts/boms/ -name '*.pkg.*.bom' | while read line; do 
  39.           t=${line#/Library/Receipts/boms//com.apple.pkg.}
  40.           pkgname=${t%.bom}
  41.           lsbom -bcdfls "$line" | perl -pe "s|^|$pkgname\t|"
  42.         done
  43.  
  44.     fi
  45.  
  46. else
  47.  
  48.     # echo "Not on 10.5"
  49.  
  50.     if [ -e "${DB}" ] && [ -z "${REBUILD}" ];
  51.     then
  52.  
  53.         #echo Updating
  54.  
  55.         find /Library/Receipts -name Archive.bom -newer "${DB}" | while read line; do 
  56.            t=${line#/Library/Receipts/}
  57.            pkgname=${t%.pkg/Contents/Archive.bom}
  58.           lsbom -bcdfls "$line" | perl -pe "s|^|$pkgname\t|"
  59.         done
  60.  
  61.     else
  62.  
  63.         #echo Creating
  64.  
  65.         find /Library/Receipts -name Archive.bom | while read line; do 
  66.           t=${line#/Library/Receipts/}
  67.           pkgname=${t%.pkg/Contents/Archive.bom}
  68.           lsbom -bcdfls "$line" | perl -pe "s|^|$pkgname\t|"
  69.         done
  70.  
  71.     fi
  72.  
  73. fi