0x0
  #   'ˆl–äY>”ÊC]ŠqAã.ÜmÕ1hßÍ„/<ßÃË ?÷     '#!/usr/bin/sh
#
# smartmontools drive database update script
#
# Home page of code is: https://www.smartmontools.org
#
# Copyright (C) 2010-20 Christian Franke
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# $Id: update-smart-drivedb.in 5153 2020-12-30 14:09:46Z chrfranke $
#

set -e

# Set by config.status
export PATH="/usr/local/bin:/usr/bin:/bin"
PACKAGE="smartmontools"
VERSION="7.2"
prefix="/usr"
exec_prefix="/usr"
sbindir="/usr/sbin"
datarootdir="${prefix}/share"
datadir="/usr/share"
drivedbdir="${datadir}/${PACKAGE}"

# Download tools
os_dltools="curl wget lynx svn"

# drivedb.h update branch
BRANCH="RELEASE_7_2_DRIVEDB"

# Default drivedb location
DRIVEDB="$drivedbdir/drivedb.h"

# GnuPG used to verify signature (disabled if empty)
GPG="gpg"

# Smartctl used for syntax check
SMARTCTL="$sbindir/smartctl"

# PATH information for help and error messages
#pathinfo='$PATH'
pathinfo="'$PATH'"

myname=$0

usage()
{
  pathinfo="
                   $pathinfo"
  cat <<EOF
smartmontools $VERSION drive database update script

Usage: $myname [OPTIONS] [DESTFILE]

  -s SMARTCTL     Use SMARTCTL for syntax check ('-s -' to disable)
                  [default: $SMARTCTL]
  -t TOOL         Use TOOL for download: $os_dltools
                  [default: first one found in $pathinfo]
  -u LOCATION     Use URL of LOCATION for download:
                    github (GitHub mirror of SVN repository)
                    sf (Sourceforge code browser)
                    svn (SVN repository) [default]
                    svni (SVN repository via HTTP instead of HTTPS)
                    trac (Trac code browser)
  --trunk         Download from SVN trunk (may require '--no-verify')
  --branch X.Y    Download from branches/RELEASE_X_Y_DRIVEDB
  --cacert FILE   Use CA certificates from FILE to verify the peer
  --capath DIR    Use CA certificate files from DIR to verify the peer
  --insecure      Don't abort download if certificate verification fails
  --no-verify     Don't verify signature
  --export-key    Print the OpenPGP/GPG public key block
  --dryrun        Print download commands only
  -v              Verbose output

Updates $DRIVEDB
or DESTFILE from branches/$BRANCH of smartmontools
SVN repository.
EOF
  exit 1
}

error()
{
  echo "$myname: $*" >&2
  exit 1
}

err_notfound()
{
  case $1 in
    */*) error "$1: not found $2" ;;
    *)   error "$1: not found in $pathinfo $2" ;;
  esac
}

warning()
{
  echo "$myname: (Warning) $*" >&2
}

selecturl()
{
  case $1 in
    github)  # https://github.com/smartmontools/smartmontools/raw/origin/$BRANCH/smartmontools/drivedb.h
             # https://github.com/smartmontools/smartmontools/raw/master/smartmontools/drivedb.h
          # redirected to:
          url='https://raw.githubusercontent.com/smartmontools/smartmontools/master/smartmontools/drivedb.h' ;;
    sf)   url='https://sourceforge.net/p/smartmontools/code/HEAD/tree/trunk/smartmontools/drivedb.h?format=raw' ;;
    svn)  url='https://svn.code.sf.net/p/smartmontools/code/trunk/smartmontools/drivedb.h' ;;
    svni) url='http://svn.code.sf.net/p/smartmontools/code/trunk/smartmontools/drivedb.h' ;;
    trac) url='https://www.smartmontools.org/export/HEAD/trunk/smartmontools/drivedb.h' ;;
    *) usage ;;
  esac
}

inpath()
{
  local d rc save
  rc=1
  save=$IFS
  IFS=':'
  for d in $PATH; do
    test -f "$d/$1" || continue
    test -x "$d/$1" || continue
    rc=0
    break
  done
  IFS=$save
  return $rc
}

vecho()
{
  test -n "$q" || echo "$*"
}

# vrun COMMAND ARGS...
vrun()
{
  if [ -n "$dryrun" ]; then
    echo "$*"
  elif [ -n "$q" ]; then
    "$@" 2>/dev/null
  else
    echo "$*"
    "$@"
  fi
}

# vrun2 OUTFILE COMMAND ARGS...
vrun2()
{
  local f err rc
  f=$1; shift
  rc=0
  if [ -n "$dryrun" ]; then
    echo "$* > $f"
  else
    vecho "$* > $f"
    err=`"$@" 2>&1 > $f` || rc=$?
    if [ -n "$err" ]; then
      vecho "$err" >&2
      test $rc != 0 || rc=42
    fi
  fi
  return $rc
}

# download URL FILE
download()
{
  local f u rc
  u=$1; f=$2
  rc=0

  case $tool in
    curl)
