# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=debootstrap
pkgver=1.0.115
pkgrel=1
pkgdesc="Bootstrap a basic Debian system"
arch=('any')
license=('GPL')
url="https://tracker.debian.org/pkg/debootstrap"
depends=('wget' 'binutils')
source=("$pkgname-$pkgver.tar.gz::https://github.com/felixonmars/debootstrap/archive/$pkgver.tar.gz"
        arch-detect.patch)
optdepends=('gnupg: check release signatures'
            'debian-archive-keyring: check release signatures for Debian'
            'ubuntu-keyring: check release signatures for Ubuntu')
sha512sums=('36310ae320abce915fa39204a92a90bcbf8ebee864a550097fef2266df64c510304cc220d56bd4a092fa3b3f43864931170f8b25ca7ae585e0018d7a44f3c1df'
            '56e25f48027f99f7e720859a9e14fe769b1cbd6227c7a7e27e14c2fea88520109342d6e5b127dc34ce8cc40f46941a0c5157ad35cf8ef9b3e4323877a4b32d97')

prepare() {
  cd debootstrap-$pkgver

  sed -i 's/sbin/bin/g' Makefile

  # Debian defaults
  sed -i 's|export PATH|export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"|' debootstrap

  # Detect Architecture
  patch -p1 -i ../arch-detect.patch
}

package() {
  cd debootstrap-$pkgver
  make DESTDIR="$pkgdir" install

  install -Dm644 debootstrap.8 "$pkgdir"/usr/share/man/man8/debootstrap.8
}
