# Build recipe for hwids.
#
# Copyright (c) 2017-2020 Matias Fonzo, <selk@dragora.org>.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Exit immediately on any error
set -e

program=hwids
version=20200306
arch=noarch
release=1

# Define a category for the output of the package name
pkgcategory=libs

tarname=${program}-${version}.tar.gz

# Remote source(s)
fetch=http://github.com/gentoo/hwids/archive/$tarname

description="
Hardware identification databases.

This package contain a specially re-packaged copy of the pci.ids
and usb.ids files, as well as a copy of IEEE's databases for the
Organizationally Unique Identifiers (OUI) and Individual Address
Block (IAB).
"

homepage=http://github.com/gentoo/hwids
license="GPLv2+ | 3-clause BSD"

# Source documentation
docs="README.md *.txt"
docsdir="${docdir}/${program}-${version}"

# Custom source directory name
srcdir=hwids-hwids-${version}

build()
{
    unpack "${tardir}/$tarname"

    cd "$srcdir"

    # Set sane permissions
    chmod -R u+w,go-w,a+rX-s .

    mkdir -p "${destdir}/usr/share/hwdata"

    for file in *.ids
    do
        cp -p $file "${destdir}/usr/share/hwdata/"
        chmod 644 "${destdir}/usr/share/hwdata/${file}"
    done

    # Copy documentation
    mkdir -p "${destdir}${docsdir}"
    cp -p $docs "${destdir}${docsdir}"
}

