[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#382454: discover: Add support for install packages based on available hardware



Package:  discover
Version:  2.0.7-3
Severity: wishlist
Tags:     patch

It would be useful to have a tool in Debian mapping from hardware to
debian packages, allowing the user to automatically install the
packages needed to support special hardware like laptops, DVD players,
RAID controllers, scanners, digital cameras etc.

The changes needed in discover to support this are minimal.  One need
to decide which XML structure to use when storing this information,
and then add a script to extract the information.  It would be useful
to add code in an udeb to install these packages at install time.

I suggest storing it like this, using the data path
package/debian/name, and the debian version number to handle different
package names in different versions.  I'm not sure how to list several
packages if there are more than one relevant package for a given piece
of hardware.  Listing several <data class='name' ...> did not work.

  <?xml version='1.0' encoding='UTF-8'?>
  <device_list bus='pci'>
    <device model='2653' vendor='8086' model_name='testmodel'>
      <data class='package'>
        <data class='debian' version='[3.0, 3.1)'>
          <data class='name'>testpackage-woody</data>
        </data>
        <data class='debian' version='[3.1,inf)'>
          <data class='name'>testpackage-sarge</data>
        </data>
      </data>
    </device>
  </device_list>

It can then be extracted using a command like this:

  /sbin/discover --data-path=package/debian/name --data-version=3.1 all

Here is file to store in scripts/discover-aptinstall, which detect all
relevant packages and install them using aptitude install.

#! /bin/sh

# $Progeny$

# Copyright 2002 Hewlett-Packard Company
# Copyright 2004 Progeny Linux Systems, Inc.
# Copyright 2006 Petter Reinholdtsen
#
# Based on discover-modprobe, modified to install debian packages instead
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

# Too bad we don't have something like sysexits.h for POSIX sh...

EX_USAGE=64

# These defaults are only used if discover-config can not be found.
# This is the case if /usr isn't mounted yet.

sysconfdir=/etc
localstatedir=/var
discover=discover
types="all"

if [ -x /usr/bin/discover-config ]; then
    sysconfdir="$(discover-config --sysconfdir)"
    localstatedir="$(discover-config --localstatedir)"
fi

if [ -x /sbin/discover ]; then
    discover=/sbin/discover
elif [ -x /usr/bin/discover ]; then
    discover=/usr/bin/discover
elif [ -x /bin/discover-static ]; then
    discover=/bin/discover-static
fi

conf="${sysconfdir}/discover-aptinstall.conf"

[ -e ${conf} ] && . "${conf}"

usage ()
{
    cat <<EOF
usage: $0 [-nv]
EOF
}

###############################################################################

nop=
verbose=false
while getopts nv ch; do
    case $ch in
    n)
        nop=echo
        ;;
    v)
        verbose=true
        ;;
    ?)
        usage
        exit ${EX_USAGE}
    esac
done
shift $((${OPTIND} - 1))

###############################################################################

${verbose} && printf "Discovering hardware: "

version=3.1 # Debian/sarge

packages=$(${discover} --data-path=package/debian/name \
        --data-version=${version} ${types} | grep -E -v '^ *$' | sort -u)

${verbose} && echo ${packages}

$nop aptitude install $packages

exit 0



Reply to: