]> git.ipfire.org Git - thirdparty/pciutils.git/blame - update-pciids.sh
Added DESTDIR support.
[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
MM
5DEST=pci.ids
6
7if which bzip2 >/dev/null ; then
8 DECOMP="bzip2 -d"
9 SRC="$SRC.bz2"
10elif which gzip >/dev/null ; then
11 DECOMP="gzip -d"
12 SRC="$SRC.gz"
13else
14 DECOMP="cat"
15fi
16
1bbdea17
MM
17if which curl >/dev/null ; then
18 DL="curl -o $DEST.new $SRC"
19elif which wget >/dev/null ; then
1b95f396
MM
20 DL="wget -O $DEST.new $SRC"
21elif which lynx >/dev/null ; then
22 DL="eval lynx -source $SRC >$DEST.new"
23else
1bbdea17 24 echo >&2 "update-pciids: cannot find curl, wget or lynx"
1b95f396
MM
25 exit 1
26fi
27
28if ! $DL ; then
29 echo >&2 "update-pciids: download failed"
30 rm -f $DEST.new
31 exit 1
32fi
33
34if ! $DECOMP <$DEST.new >$DEST.neww ; then
35 echo >&2 "update-pciids: decompression failed, probably truncated file"
36 exit 1
37fi
38
39if ! grep >/dev/null "^C " $DEST.neww ; then
40 echo >&2 "update-pciids: missing class info, probably truncated file"
41 exit 1
42fi
43
44if [ -f $DEST ] ; then
45 mv $DEST $DEST.old
80b3121a
MM
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
1b95f396
MM
48fi
49mv $DEST.neww $DEST
50rm $DEST.new
51
52echo "Done."