3 # update-pciids.sh is licensed under the GNU General Public License
4 # (GPL) version 2 or above.
6 # Copyright (C) 2008 Anibal Monsalve Salazar <anibal@debian.org>
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # Please read the "COPYING" file in the archive root, or visit
19 # http://www.gnu.org/licenses/gpl.html, for information about the GPL.
21 # This scipt is a rewrite of a script with the same name by
26 #URL="http://pci-ids.ucw.cz/pci.ids"
27 URL="http://pciids.sourceforge.net/v2.2/pci.ids"
38 BUNZIP2="/bin/bunzip2"
39 TOUCH="/usr/bin/touch"
54 if ! $TOUCH $NEWFILE > /dev/null 2>&1
56 $ECHO >&2 "update-pciids: $NEWFILE is read-only"
60 [ -f $NEWFILE ] && $RM $NEWFILE
61 [ -f $NEWFILE.bz2 ] && $RM $NEWFILE.bz2
62 [ -f $NEWFILE.gz ] && $RM $NEWFILE.gz
73 $ECHO >&2 "update-pciids: cannot find bunzip2 or gunzip"
79 $WGET -nv -O $NEWFILE$EXT $URL$EXT > /dev/null 2>&1
82 $CURL -o $NEWFILE$EXT $URL$EXT > /dev/null 2>&1
85 $LYNX -source $URL$EXT > $NEWFILE$EXT
87 $ECHO >&2 "update-pciids: cannot find wget, curl or lynx"
91 $UNZIP < $NEWFILE$EXT > $NEWFILE
94 if ! $GREP > /dev/null "^C " $NEWFILE
96 $ECHO >&2 "update-pciids: missing class info, probably truncated file"
100 date=$( $GREP -E "^#[[:space:]]Date:[[:space:]]*" $NEWFILE 2> /dev/null | $SED "s/^#[[:space:]]Date:[[:space:]]*//" )
104 $ECHO >&2 "update-pciids: missing snapshot date, probably truncated file"
110 [ -f $OLDFILE ] && $RM $OLDFILE
115 $TOUCH -d "$date" $FILE
119 [ -f $OLDFILE.gz ] && $RM $OLDFILE.gz
120 $MV $FILE.gz $OLDFILE.gz
125 $ECHO "Downloaded daily snapshot dated $date"