]> git.ipfire.org Git - thirdparty/pciutils.git/blame - update-pciids.sh
Squashed compiler warnings about code with no effect
[thirdparty/pciutils.git] / update-pciids.sh
CommitLineData
1b95f396
MM
1#!/bin/sh
2
3set -e
043ebdee 4SRC="http://pciids.sourceforge.net/v2.2/pci.ids"
1b95f396 5DEST=pci.ids
cc062b4a
MM
6PCI_COMPRESSED_IDS=
7GREP=grep
1b95f396 8
cc062b4a
MM
9if [ -n "$PCI_COMPRESSED_IDS" ] ; then
10 DECOMP="cat"
11 SRC="$SRC.gz"
12 GREP=zgrep
13elif which bzip2 >/dev/null ; then
1b95f396
MM
14 DECOMP="bzip2 -d"
15 SRC="$SRC.bz2"
16elif which gzip >/dev/null ; then
17 DECOMP="gzip -d"
18 SRC="$SRC.gz"
19else
20 DECOMP="cat"
21fi
22
1bbdea17
MM
23if which curl >/dev/null ; then
24 DL="curl -o $DEST.new $SRC"
25elif which wget >/dev/null ; then
1b95f396
MM
26 DL="wget -O $DEST.new $SRC"
27elif which lynx >/dev/null ; then
28 DL="eval lynx -source $SRC >$DEST.new"
29else
1bbdea17 30 echo >&2 "update-pciids: cannot find curl, wget or lynx"
1b95f396
MM
31 exit 1
32fi
33
34if ! $DL ; then
35 echo >&2 "update-pciids: download failed"
36 rm -f $DEST.new
37 exit 1
38fi
39
40if ! $DECOMP <$DEST.new >$DEST.neww ; then
41 echo >&2 "update-pciids: decompression failed, probably truncated file"
42 exit 1
43fi
44
cc062b4a 45if ! $GREP >/dev/null "^C " $DEST.neww ; then
1b95f396
MM
46 echo >&2 "update-pciids: missing class info, probably truncated file"
47 exit 1
48fi
49
50if [ -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
54fi
55mv $DEST.neww $DEST
56rm $DEST.new
57
58echo "Done."