aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2023-07-23 15:44:03 +0200
committerMartin Mares <mj@ucw.cz>2023-07-23 15:44:03 +0200
commit7ec58f1c9dc011f334863e07917e349d95748d51 (patch)
tree484cb95d4f00cfc0ec4173f21a5fda2285c09b50
parentb6e558fb75b6e46b9a10d2b1e5c10c346b412331 (diff)
downloadpciutils-7ec58f1c9dc011f334863e07917e349d95748d51.tar.gz
update-pciids: Report itself as an user agent, version included
Unfortunately, this leads to the User-Agent not containing version of curl/wget/lynx we used.
-rw-r--r--Makefile2
-rwxr-xr-xupdate-pciids.sh24
2 files changed, 19 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 0e878a6..228cb56 100644
--- a/Makefile
+++ b/Makefile
@@ -103,7 +103,7 @@ lspci$(EXEEXT): LDLIBS+=$(LIBKMOD_LIBS)
ls-kernel.o: CFLAGS+=$(LIBKMOD_CFLAGS)
update-pciids: update-pciids.sh
- sed <$< >$@ "s@^DEST=.*@DEST=$(if $(IDSDIR),$(IDSDIR)/,)$(PCI_IDS)@;s@^PCI_COMPRESSED_IDS=.*@PCI_COMPRESSED_IDS=$(PCI_COMPRESSED_IDS)@"
+ sed <$< >$@ "s@^DEST=.*@DEST=$(if $(IDSDIR),$(IDSDIR)/,)$(PCI_IDS)@;s@^PCI_COMPRESSED_IDS=.*@PCI_COMPRESSED_IDS=$(PCI_COMPRESSED_IDS)@;s@VERSION=.*@VERSION=$(VERSION)@"
chmod +x $@
# The example of use of libpci
diff --git a/update-pciids.sh b/update-pciids.sh
index 1fa604e..607502a 100755
--- a/update-pciids.sh
+++ b/update-pciids.sh
@@ -6,6 +6,9 @@ SRC="https://pci-ids.ucw.cz/v2.2/pci.ids"
DEST=pci.ids
PCI_COMPRESSED_IDS=
GREP=grep
+VERSION=unknown
+USER_AGENT=update-pciids/$VERSION
+QUIET=
[ "$1" = "-q" ] && quiet=true || quiet=false
@@ -30,19 +33,28 @@ else
fi
if command -v curl >/dev/null 2>&1 ; then
- DL="curl -o $DEST.new $SRC"
- ${quiet} && DL="$DL -s -S"
+ ${quiet} && QUIET="-s -S"
+ dl ()
+ {
+ curl -o $DEST.new --user-agent "$USER_AGENT curl" $QUIET $SRC
+ }
elif command -v wget >/dev/null 2>&1 ; then
- DL="wget --no-timestamping -O $DEST.new $SRC"
- ${quiet} && DL="$DL -q"
+ ${quiet} && QUIET="-q"
+ dl ()
+ {
+ wget --no-timestamping -O $DEST.new --user-agent "$USER_AGENT wget" $QUIET $SRC
+ }
elif command -v lynx >/dev/null 2>&1 ; then
- DL="eval lynx -source $SRC >$DEST.new"
+ dl ()
+ {
+ lynx -source -useragent="$USER_AGENT lynx" $SRC >$DEST.new
+ }
else
echo >&2 "update-pciids: cannot find curl, wget or lynx"
exit 1
fi
-if ! $DL ; then
+if ! dl ; then
echo >&2 "update-pciids: download failed"
rm -f $DEST.new
exit 1