# $Id: PKGBUILD 142807 2015-10-02 18:28:10Z 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=20152002
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-7500.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs7501-latest.tar.gz)
md5sums=('898ec7c0bd48844efdf7af53916715cb'
         '06a779406b45edddbd19fda96696ab4a'
         'd5e62446ff3db57bbc944c7255a9f41d'
         '35ffa7c53272a850bc35d4bff83d6407'
         '2ccbe4668538c5d49d0301b466cbdf25'
         '49533185c2b96421ec2bf3ac39ad8dde'
         '07e05caabe06cbaae11fc77d821e1ba9'
         'f6a807f8ee27e45fccdba64bda813bf1'
         '451783845c87af514ca954b8f755f2e1'
         '2a91fcb0200805122e3e9ee28821854f'
         '2a73f4e42589161377145a724349bd3f'
         '4d32ed0d39c5dfcae2d83be786944c85'
         'd70ed62e883251594132fc0d6b655862'
         'a5c7928eee531cf26a2f5036cf811a3b'
         'f31b5f57186925311f1071a295932b68'
         '4c08d7994d9e1a1771fa300ca37611b4'
         '39d3fb97171472f553fbac02990b6b74'
         'bd2f40beeb664ae9fa5bd061c10df177')

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
}
