]>
git.ipfire.org Git - thirdparty/pciutils.git/blob - update-pciids.sh
5 SRC
="https://pci-ids.ucw.cz/v2.2/pci.ids"
10 USER_AGENT
=update-pciids
/$VERSION
13 [ "$1" = "-q" ] && quiet
=true || quiet
=false
15 # if pci.ids is read-only (because the filesystem is read-only),
16 # then just skip this whole process.
17 if ! touch ${DEST} >/dev
/null
2>&1 ; then
18 ${quiet} ||
echo "${DEST} is read-only, exiting." 1>&2
22 if command -v xz
>/dev
/null
2>&1 ; then
25 elif command -v bzip2 >/dev
/null
2>&1 ; then
28 elif command -v gzip >/dev
/null
2>&1 ; then
35 if command -v curl
>/dev
/null
2>&1 ; then
36 ${quiet} && QUIET
="-s -S"
39 curl
-o $DEST.new
--user-agent "$USER_AGENT curl" $QUIET $SRC
41 elif command -v wget
>/dev
/null
2>&1 ; then
42 ${quiet} && QUIET
="-q"
45 wget
--no-timestamping -O $DEST.new
--user-agent "$USER_AGENT wget" $QUIET $SRC
47 elif command -v lynx
>/dev
/null
2>&1 ; then
50 lynx
-source -useragent="$USER_AGENT lynx" $SRC >$DEST.new
53 echo >&2 "update-pciids: cannot find curl, wget or lynx"
58 echo >&2 "update-pciids: download failed"
63 if ! $DECOMP <$DEST.new
>$DEST.new.plain
; then
64 echo >&2 "update-pciids: decompression failed, probably truncated file"
68 if ! $GREP >/dev
/null
"^C " $DEST.new.plain
; then
69 echo >&2 "update-pciids: missing class info, probably truncated file"
73 if [ -f $DEST ] ; then
75 # --reference is supported only by chmod from GNU file, so let's ignore any errors
76 chmod -f --reference=$DEST.old
$DEST.new
$DEST.new.plain
2>/dev
/null || true
79 if [ "$PCI_COMPRESSED_IDS" = 1 ] ; then
80 if [ "${SRC%.gz}" != .gz
] ; then
82 gzip <$DEST.new.plain
>$DEST.new
87 mv $DEST.new.plain
$DEST
91 # Older versions did not compress the ids file, so let's make sure we
93 if [ ${DEST%.gz} != ${DEST} ] ; then
94 rm -f ${DEST%.gz} ${DEST%.gz}.old
97 ${quiet} ||
echo "Done."