# Maintainer: Martell Malone <martellmalone@gmail.com>

pkgname=busybox
pkgver=1.36.1
pkgrel=1
pkgdesc="BusyBox: The Swiss Army Knife of Embedded Linux"
arch=('i686' 'x86_64')
url="https://busybox.net/"
msys2_references=(
  "cpe: cpe:/a:busybox:busybox"
  "cpe: cpe:/a:rob_landley:busybox"
)
license=('GPL2')
install=busybox.install
makedepends=('make' 'gcc' 'libxcrypt-devel')
source=("https://busybox.net/downloads/${pkgname}-${pkgver}.tar.bz2"
        "cygwin-busybox-1.36.1-2.patch")
sha256sums=('b8cc24c9574d809e7279c3be349795c5d5ceb6fdf19ca709f80cde50e47de314'
            '0840c162e629991bff902f1b0d807e23fd3af42e2f5b349c1c4f5c7a43bebc01')

prepare() {
  cd "${pkgname}-${pkgver}"
  patch -p2 -i ../cygwin-busybox-1.36.1-2.patch
}

build() {
  cd "${pkgname}-${pkgver}"

  make cygwin_defconfig
  make
  mv -v busybox_unstripped.exe busybox.exe
}

package() {
  cd "${pkgname}-${pkgver}"

  #install busybox
  mkdir -p "${pkgdir}/usr/bin"
  install -Dm755 busybox.exe -t "${pkgdir}"/usr/bin

  # manpage
  install -Dm644 docs/busybox.1 -t "${pkgdir}"/usr/share/man/man1

  # license
  install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}
