]> git.ipfire.org Git - thirdparty/pciutils.git/commitdiff
Added update-pciids.
authorMartin Mares <mj@ucw.cz>
Sat, 4 Jan 2003 12:27:51 +0000 (12:27 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 5 May 2006 12:10:56 +0000 (14:10 +0200)
ChangeLog
Makefile
README
lspci.man
update-pciids.man [new file with mode: 0644]
update-pciids.sh [new file with mode: 0755]

index 90ab39e84e196d2a9f861ec762dd1f8eafe0093c..e5fb9e0709696e9e9dbd0431d3f23623c7f25731 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
 2003-01-04  Martin Mares  <mj@ucw.cz>
 
-       * Releasing as 2.1.11.
+       * Released as 2.1.11.
+
+       * Added the update-ids utility.
 
        * lib: Removed partially implemented "syscall" access method which will
        probably never be needed.
index 49931c6600ab779afceeaa8442cc0ebde14fdc5d..c0d639a92fa88f0a46484bd82e6f59dab7c93b2e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.48 2003/01/04 11:33:25 mj Exp $
+# $Id: Makefile,v 1.49 2003/01/04 12:27:51 mj Exp $
 # Makefile for Linux PCI Utilities
 # (c) 1998--2003 Martin Mares <mj@ucw.cz>
 
@@ -39,7 +39,7 @@ DISTTMP=/tmp/pciutils-dist
 
 export
 
-all: lib lspci setpci lspci.8 setpci.8 pci.ids
+all: lib lspci setpci lspci.8 setpci.8 update-pciids update-pciids.8 pci.ids
 
 lib: lib/config.h
        $(MAKE) -C lib all
@@ -54,6 +54,9 @@ lspci.o: lspci.c pciutils.h
 setpci.o: setpci.c pciutils.h
 common.o: common.c pciutils.h
 
+update-pciids: update-pciids.sh
+       sed <$< >$@ "s@^DEST=.*@DEST=$(PREFIX)/share/pci.ids@"
+
 %.8: %.man
        M=`echo $(DATE) | sed 's/-01-/-January-/;s/-02-/-February-/;s/-03-/-March-/;s/-04-/-April-/;s/-05-/-May-/;s/-06-/-June-/;s/-07-/-July-/;s/-08-/-August-/;s/-09-/-September-/;s/-10-/-October-/;s/-11-/-November-/;s/-12-/-December-/;s/\(.*\)-\(.*\)-\(.*\)/\3 \2 \1/'` ; sed <$< >$@ "s/@TODAY@/$$M/;s/@VERSION@/pciutils-$(VERSION)$(SUFFIX)/"
 
@@ -66,12 +69,13 @@ install: all
 # -c is ignored on Linux, but required on FreeBSD
        $(DIRINSTALL) -m 755 $(ROOT)/sbin $(PREFIX)/share $(MANDIR)/man8
        $(INSTALL) -c -m 755 -s lspci setpci $(ROOT)/sbin
+       $(INSTALL) -c -m 755 -s update-pciids $(PREFIX)/sbin
        if [ ! -f $(PREFIX)/share/pci.ids -o pci.ids -nt $(PREFIX)/share/pci.ids ] ; then \
                $(INSTALL) -c -m 644 pci.ids $(PREFIX)/share ; \
        elif [ -f $(PREFIX)/share/pci.ids ] ; then \
                echo "$(PREFIX)/share/pci.ids is same or newer than the version to be installed, skipping." ; \
        fi
-       $(INSTALL) -c -m 644 lspci.8 setpci.8 $(MANDIR)/man8
+       $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(MANDIR)/man8
 # Remove relics from old versions
        rm -f $(ROOT)/etc/pci.ids
 
@@ -80,16 +84,11 @@ uninstall: all
        rm -f $(PREFIX)/share/pci.ids
        rm -f $(PREFIX)/man/man8/lspci.8 $(PREFIX)/man/man8/setpci.8
 
-update-ids:
-       if [ -f pci.ids.orig ] ; then mv pci.ids pci.ids.orig ; fi
-       wget http://pciids.sf.net/pci.ids.bz2
-       bzip2 -d pci.ids.bz2
-
 get-ids:
        cp ~/tree/pciids/pci.ids pci.ids
 
 pci.ids:
-       @ [ -f pci.ids ] || echo >&2 "The pci.ids file is no longer part of the CVS. Please do make update-ids to download them." && false
+       @ [ -f pci.ids ] || echo >&2 "The pci.ids file is no longer part of the CVS. Please do run update-ids.sh to download them." && false
 
 release:
        sed "s/^\\(Version:[    ]*\\)[0-9.]*/\\1$(VERSION)/;s/^\\(Entered-date:[        ]*\\)[0-9]*/\\1`date -d$(DATE) '+%y%m%d'`/;s/\\(pciutils-\\)[0-9.]*/\\1$(VERSION)\\./" <pciutils.lsm >pciutils.lsm.new
diff --git a/README b/README
index 379e0957f7913b62ec27e930daa09b48ccc66afd..7a8b411bc444881dbe85f054af3ddf862378f7d3 100644 (file)
--- a/README
+++ b/README
@@ -26,6 +26,8 @@ The utilities include:  (See manual pages for more details)
     CAUTION: There is a couple of dangerous points and caveats, please read
     the manual page first!
 
+  - update-pciids: download the current version of the pci.ids file.
+
 
 2. Compiling and (un)installing
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -46,8 +48,7 @@ than I release new versions of this package.
 
 If you are missing names for any of your devices or you just want to stay
 on the bleeding edge, download the most recent pci.ids file from
-http://pciids.sf.net/. You can try "make update-ids" to accomplish that
-automatically (requires wget and bzip2).
+http://pciids.sf.net/ (e.g., by running the update-ids utility).
 
 If your devices still appear as unknown, please send us their ID's and
 names, the detailed instructions for submissions are listed on the
index 6719277d06b41effe1ada91f020aadd229b76558..6ac75c7dd837cf483a6573bbf9c1a1205fdaeead 100644 (file)
--- a/lspci.man
+++ b/lspci.man
@@ -146,7 +146,7 @@ kernels. Contains per-bus subdirectories with per-card config space files and a
 file containing a list of all PCI devices.
 
 .SH SEE ALSO
-.BR setpci (8)
+.BR setpci (8), update-pciids (8)
 
 .SH AUTHOR
 The Linux PCI Utilities are maintained by Martin Mares <mj@ucw.cz>.
diff --git a/update-pciids.man b/update-pciids.man
new file mode 100644 (file)
index 0000000..bba92fb
--- /dev/null
@@ -0,0 +1,27 @@
+.TH update-pciids 8 "@TODAY@" "@VERSION@" "Linux PCI Utilities"
+.IX update-pciids
+
+.SH NAME
+update-pciids \- download new version of the PCI ID list
+
+.SH SYNOPSIS
+.B update-pciids
+
+.SH DESCRIPTION
+.B update-pciids
+fetches the current version of the pci.ids file from the primary distribution
+site and installs it.
+
+This utility requires either wget or lynx to be installed. If gzip or bzip2
+are available, it automatically downloads the compressed version of the list.
+
+.SH FILES
+.TP
+.B /usr/share/pci.ids
+Here we install the new list.
+
+.SH SEE ALSO
+.BR lspci (8), setpci (8)
+
+.SH AUTHOR
+The Linux PCI Utilities are maintained by Martin Mares <mj@ucw.cz>.
diff --git a/update-pciids.sh b/update-pciids.sh
new file mode 100755 (executable)
index 0000000..d3c0b1f
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+set -e
+SRC="http://pciids.sourceforge.net/pci.ids"
+DEST=pci.ids
+
+if which bzip2 >/dev/null ; then
+       DECOMP="bzip2 -d"
+       SRC="$SRC.bz2"
+elif which gzip >/dev/null ; then
+       DECOMP="gzip -d"
+       SRC="$SRC.gz"
+else
+       DECOMP="cat"
+fi
+
+if which wget >/dev/null ; then
+       DL="wget -O $DEST.new $SRC"
+elif which lynx >/dev/null ; then
+       DL="eval lynx -source $SRC >$DEST.new"
+else
+       echo >&2 "update-pciids: cannot find wget nor lynx"
+       exit 1
+fi
+
+if ! $DL ; then
+       echo >&2 "update-pciids: download failed"
+       rm -f $DEST.new
+       exit 1
+fi
+
+if ! $DECOMP <$DEST.new >$DEST.neww ; then
+       echo >&2 "update-pciids: decompression failed, probably truncated file"
+       exit 1
+fi
+
+if ! grep >/dev/null "^C " $DEST.neww ; then
+       echo >&2 "update-pciids: missing class info, probably truncated file"
+       exit 1
+fi
+
+if [ -f $DEST ] ; then
+       mv $DEST $DEST.old
+fi
+mv $DEST.neww $DEST
+rm $DEST.new
+
+echo "Done."