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