# $Id: PKGBUILD 123079 2014-11-24 18:03:09Z spupykin $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Peter Simons <simons@cryp.to>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=rfc
pkgver=20141124
pkgrel=1
pkgdesc="RFCs from rfc-editor.org"
arch=('any')
url="http://www.rfc-editor.org/"
license=("custom:as-is")
options=('docs')
source=(rfc-index-$pkgver.txt::http://www.rfc-editor.org/rfc/rfc-index.txt
        license
        http://www.rfc-editor.org/rfc/tar/RFCs0001-0500.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs0501-1000.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs1001-1500.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs1501-2000.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs2001-2500.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs2501-3000.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs3001-3500.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs3501-4000.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs4001-4500.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs4501-5000.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs5001-5500.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs5501-6000.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs6001-6500.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs6501-7000.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs7001-latest.tar.gz)
md5sums=('405f83a3d7e53b14a3c3bbebf68c68fc'
         '06a779406b45edddbd19fda96696ab4a'
         '68b0813a70672bc870c6ae6e349c7ef8'
         'b921083f8ded7ea4a533774edc06bfe8'
         '7166a698861cb03bc56028d4d5f13266'
         'f1ab1795ed79df3611ab83c78563fe6a'
         '6ad76cfe8b9e1247b4835d135035d774'
         '2eac11a7bd62323618a88be292b9a37e'
         '533cffa05b66bbdf14d044d0b136fe75'
         'ba56eaa727fc2b8ba579b4c5bdf129df'
         '63cb9a7456752bfc810a30898d750b17'
         '81ca277d458d025ee94e3438eeb8645d'
         '8dcf9f58356e1e3e3c8f5f311f90ea85'
         '7a17b844234176765af9e6d10f95a1bf'
         '5c386133bbf76a1c55825b918f50d2c8'
         'b7b47166f308d9331e04dfd85c1677a7'
         '92e15c8d61cf4df896582dd89a808965')

package() {
    cd "$srcdir"

    mkdir -p "$pkgdir/usr/share/doc/rfc"
    cp rfc-index-$pkgver.txt "$pkgdir/usr/share/doc/rfc/rfc-index.txt"
    rm -f rfc-index-$pkgver.txt

    tar xf rfc1305.tar
    rm -f rfc1305.tar
    for n in ntpv3*; do
      mv "$n" "rfc1305-$n"
    done

    for fmt in txt ps pdf; do
      mkdir -p "$pkgdir/usr/share/doc/rfc/${fmt}"
      mv *.${fmt} "$pkgdir/usr/share/doc/rfc/${fmt}/"
    done

    cd "$pkgdir/usr/share/doc/rfc"
    find . -type f -exec chmod 444 {} \;
    find . -type d -exec chmod 555 {} \;
    chown -R root:root .
    install -D -m0644 $srcdir/license $pkgdir/usr/share/licenses/$pkgname/license
}
