home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / bin / update-pciids < prev    next >
Encoding:
Text File  |  2006-07-12  |  1.1 KB  |  53 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4. SRC="http://pciids.sourceforge.net/v2.2/pci.ids"
  5. DEST=/usr/share/misc/pci.ids
  6.  
  7. if which bzip2 >/dev/null ; then
  8.     DECOMP="bzip2 -d"
  9.     SRC="$SRC.bz2"
  10. elif which gzip >/dev/null ; then
  11.     DECOMP="gzip -d"
  12.     SRC="$SRC.gz"
  13. else
  14.     DECOMP="cat"
  15. fi
  16.  
  17. if which curl >/dev/null ; then
  18.     DL="curl -o $DEST.new $SRC"
  19. elif which wget >/dev/null ; then
  20.     DL="wget -O $DEST.new $SRC"
  21. elif which lynx >/dev/null ; then
  22.     DL="eval lynx -source $SRC >$DEST.new"
  23. else
  24.     echo >&2 "update-pciids: cannot find curl, wget or lynx"
  25.     exit 1
  26. fi
  27.  
  28. if ! $DL ; then
  29.     echo >&2 "update-pciids: download failed"
  30.     rm -f $DEST.new
  31.     exit 1
  32. fi
  33.  
  34. if ! $DECOMP <$DEST.new >$DEST.neww ; then
  35.     echo >&2 "update-pciids: decompression failed, probably truncated file"
  36.     exit 1
  37. fi
  38.  
  39. if ! grep >/dev/null "^C " $DEST.neww ; then
  40.     echo >&2 "update-pciids: missing class info, probably truncated file"
  41.     exit 1
  42. fi
  43.  
  44. if [ -f $DEST ] ; then
  45.     mv $DEST $DEST.old
  46.     # --reference is supported only by chmod from GNU file, so let's ignore any errors
  47.     chmod -f --reference=$DEST.old $DEST.neww 2>/dev/null || true
  48. fi
  49. mv $DEST.neww $DEST
  50. rm $DEST.new
  51.  
  52. echo "Done."
  53.