# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=sed
pkgver=4.8
pkgrel=1
pkgdesc="GNU stream editor"
arch=('i686' 'x86_64')
url="https://www.gnu.org/software/sed"
license=('GPL3')
groups=('base-devel')
depends=('libintl' 'sh')
makedepends=('gettext' 'gettext-devel')
install=sed.install
source=(https://ftp.gnu.org/pub/gnu/sed/${pkgname}-${pkgver}.tar.xz{,.sig}
        sed-4.4-1.src.patch
        sed-4.7-msysize.patch
        sed-4.4-msys-use-text-mode.patch)
sha256sums=('f79b0cfea71b37a8eeec8490db6c5f7ae7719c35587f21edb0617f370eeff633'
            'SKIP'
            '12525e7bf4a1b57913d4047a2313f9127f29468193c2b583cfdfa128b4141032'
            'd25076be5ef7a4128f3d7e5e31125efda4d620c181f7d49919d386aee2fdc0c5'
            '5b25526061d61aaecdec464bccc1e1a78d0e0a64dabdd0eea759399f6c92e0a7')
validpgpkeys=('155D3FC500C834486D1EEA677FD9FCCB000BEEEE')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}

  patch -p1 -i ${srcdir}/sed-4.7-msysize.patch
  patch -p1 -i ${srcdir}/sed-4.4-msys-use-text-mode.patch

  autoreconf -fiv

  patch -p2 -i ${srcdir}/sed-4.4-1.src.patch
}

build() {
  cd ${srcdir}/${pkgname}-${pkgver}
  ./configure --prefix=/usr --build=${CHOST}
  make all html
}

check() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make check
}

package() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make DESTDIR=${pkgdir} install
  rm -f ${pkgdir}/usr/lib/charset.alias
}
