5 SRC="https://pci-ids.ucw.cz/v2.2/pci.ids"
10 [ "$1" = "-q" ] && quiet=true || quiet=false
12 # if pci.ids is read-only (because the filesystem is read-only),
13 # then just skip this whole process.
14 if ! touch ${DEST} >/dev/null 2>&1 ; then
15 ${quiet} || echo "${DEST} is read-only, exiting." 1>&2
19 if command -v xz >/dev/null 2>&1 ; then
22 elif command -v bzip2 >/dev/null 2>&1 ; then
25 elif command -v gzip >/dev/null 2>&1 ; then
32 if command -v curl >/dev/null 2>&1 ; then
33 DL="curl -o $DEST.new $SRC"
34 ${quiet} && DL="$DL -s -S"
35 elif command -v wget >/dev/null 2>&1 ; then
36 DL="wget --no-timestamping -O $DEST.new $SRC"
37 ${quiet} && DL="$DL -q"
38 elif command -v lynx >/dev/null 2>&1 ; then
39 DL="eval lynx -source $SRC >$DEST.new"
41 echo >&2 "update-pciids: cannot find curl, wget or lynx"
46 echo >&2 "update-pciids: download failed"
51 if ! $DECOMP <$DEST.new >$DEST.new.plain ; then
52 echo >&2 "update-pciids: decompression failed, probably truncated file"
56 if ! $GREP >/dev/null "^C " $DEST.new.plain ; then
57 echo >&2 "update-pciids: missing class info, probably truncated file"
61 if [ -f $DEST ] ; then
63 # --reference is supported only by chmod from GNU file, so let's ignore any errors
64 chmod -f --reference=$DEST.old $DEST.new $DEST.new.plain 2>/dev/null || true
67 if [ "$PCI_COMPRESSED_IDS" = 1 ] ; then
68 if [ "${SRC%.gz}" != .gz ] ; then
70 gzip <$DEST.new.plain >$DEST.new
75 mv $DEST.new.plain $DEST
79 # Older versions did not compress the ids file, so let's make sure we
81 if [ ${DEST%.gz} != ${DEST} ] ; then
82 rm -f ${DEST%.gz} ${DEST%.gz}.old
85 ${quiet} || echo "Done."