# Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
pkgbase=dotnet-core
pkgname=(
 dotnet-host
 dotnet-runtime
 aspnet-runtime
 dotnet-sdk
 netstandard-targeting-pack
 dotnet-targeting-pack
 aspnet-targeting-pack
)
pkgver=7.0.0
pkgrel=1
_sdkver=7.0.100
arch=(powerpc64le)
url=https://www.microsoft.com/net/core
license=(MIT)
makedepends=(
  bash
  clang
  cmake
  git
  icu
  inetutils
  krb5
  libgit2
  libunwind
  libxml2
  lldb
  llvm
  lttng-ust2.12
  nodejs
  openssl
  systemd
  zlib
)
optdepends=('bash-completion: Bash completion support')
options=(
  !lto
  staticlibs
)
source=(
  https://repo.archlinuxpower.org/distfiles/dotnet/powerpc64le/${pkgver}/dotnet-sdk-${_sdkver}-linux-ppc64le.tar.gz
  dotnet.sh
)
noextract=(dotnet-sdk-7.0.100-linux-ppc64le.tar.gz)
b2sums=('d65494343da8227ecdc36db547af17c3c16d9723e6328dc1194464634d25a4b0639921bff0a91bec84888d2d1215d854c6167945b528b6e5f285f8fdc0031e3d'
        '4a64e3ee550e296bdde894f9202c6f372934cc29154f47d302599b4c368825a96a7b786faa6109a24a1101ff130fd9e4d0ccba094ec91e7f2ca645725bf71b34')

build() {
  #FIXME: actual build from source in PKGBUILD
  true
}


package_dotnet-host() {
  pkgdesc='A generic driver for the .NET Core Command Line Interface'
  depends=(
    gcc-libs
    glibc
  )
  optdepends=('bash-completion: Bash completion support')

  install -dm 755 "${pkgdir}"/{etc/profile.d,usr/{bin,lib,share/{dotnet,licenses/dotnet-host}}}
  bsdtar -xf ${srcdir}/dotnet-sdk-${_sdkver}-linux-ppc64le.tar.gz -C "${pkgdir}"/usr/share/dotnet/ --no-same-owner dotnet host
  bsdtar -xf ${srcdir}/dotnet-sdk-${_sdkver}-linux-ppc64le.tar.gz -C "${pkgdir}"/usr/share/licenses/dotnet-host/ --no-same-owner LICENSE.txt ThirdPartyNotices.txt
  ln -s /usr/share/dotnet/dotnet "${pkgdir}"/usr/bin/dotnet
  ln -s /usr/share/dotnet/host/fxr/${pkgver}/libhostfxr.so "${pkgdir}"/usr/lib/libhostfxr.so
  #FIXME: taken from SDK source?
  #install -Dm 644 ../../../src/sdk/scripts/register-completions.bash "${pkgdir}"/usr/share/bash-completion/completions/dotnet
  #install -Dm 644 ../../../src/sdk/scripts/register-completions.zsh "${pkgdir}"/usr/share/zsh/site-functions/_dotnet
  install -Dm 644 ${srcdir}/dotnet.sh -t "${pkgdir}"/etc/profile.d/
}

package_dotnet-runtime() {
  pkgdesc='The .NET Core runtime'
  depends=(
    dotnet-host
    gcc-libs
    glibc
    icu
    libgssapi_krb5.so
    libunwind
    zlib
    openssl
  )

  optdepends=('lttng-ust2.12: CoreCLR tracing')
  provides=(dotnet-runtime-7.0)
  conflicts=(dotnet-runtime-7.0)

  install -dm 755 "${pkgdir}"/usr/share/{dotnet,licenses}
  bsdtar -xf ${srcdir}/dotnet-sdk-${_sdkver}-linux-ppc64le.tar.gz -C "${pkgdir}"/usr/share/dotnet/ --no-same-owner shared/Microsoft.NETCore.App
  ln -s dotnet-host "${pkgdir}"/usr/share/licenses/dotnet-runtime
}

package_aspnet-runtime() {
  pkgdesc='The ASP.NET Core runtime'
  depends=(dotnet-runtime)
  provides=(aspnet-runtime-7.0)
  conflicts=(aspnet-runtime-7.0)

  install -dm 755 "${pkgdir}"/usr/share/{dotnet,licenses}
  bsdtar -xf ${srcdir}/dotnet-sdk-${_sdkver}-linux-ppc64le.tar.gz -C "${pkgdir}"/usr/share/dotnet/ --no-same-owner shared/Microsoft.AspNetCore.App
  ln -s dotnet-host "${pkgdir}"/usr/share/licenses/aspnet-runtime
}

package_dotnet-sdk() {
  pkgdesc='The .NET Core SDK'
  depends=(
    dotnet-runtime
    dotnet-targeting-pack
    glibc
    gcc-libs
    netstandard-targeting-pack
  )
  optdepends=('aspnet-targeting-pack: Build ASP.NET Core applications')
  provides=(dotnet-sdk-7.0)
  conflicts=(dotnet-sdk-7.0)

  install -dm 755 "${pkgdir}"/usr/share/{dotnet,licenses}
  bsdtar -xf ${srcdir}/dotnet-sdk-${_sdkver}-linux-ppc64le.tar.gz -C "${pkgdir}"/usr/share/dotnet/ --no-same-owner sdk sdk-manifests templates
  ln -s dotnet-host "${pkgdir}"/usr/share/licenses/dotnet-sdk
}

package_netstandard-targeting-pack() {
  pkgdesc='The .NET Standard targeting pack'
  provides=(netstandard-targeting-pack-2.1)
  conflicts=(netstandard-targeting-pack-2.1)

  install -dm 755 "${pkgdir}"/usr/share/{dotnet,licenses}
  bsdtar -xf ${srcdir}/dotnet-sdk-${_sdkver}-linux-ppc64le.tar.gz -C "${pkgdir}"/usr/share/dotnet/ --no-same-owner packs/NETStandard.Library.Ref
  ln -s dotnet-host "${pkgdir}"/usr/share/licenses/netstandard-targeting-pack
}

package_dotnet-targeting-pack() {
  pkgdesc='The .NET Core targeting pack'
  depends=(netstandard-targeting-pack)
  provides=(dotnet-targeting-pack-7.0)
  conflicts=(dotnet-targeting-pack-7.0)

  install -dm 755 "${pkgdir}"/usr/share/{dotnet,licenses}
  bsdtar -xf ${srcdir}/dotnet-sdk-${_sdkver}-linux-ppc64le.tar.gz -C "${pkgdir}"/usr/share/dotnet/ --no-same-owner packs/Microsoft.NETCore.App.{Host.linux-ppc64le,Ref}
  ln -s dotnet-host "${pkgdir}"/usr/share/licenses/dotnet-targeting-pack
}

package_aspnet-targeting-pack() {
  pkgdesc='The ASP.NET Core targeting pack'
  depends=(dotnet-targeting-pack)
  provides=(aspnet-targeting-pack-7.0)
  conflicts=(aspnet-targeting-pack-7.0)

  install -dm 755 "${pkgdir}"/usr/share/{dotnet,licenses}
  bsdtar -xf ${srcdir}/dotnet-sdk-${_sdkver}-linux-ppc64le.tar.gz -C "${pkgdir}"/usr/share/dotnet/ --no-same-owner packs/Microsoft.AspNetCore.App.Ref
  ln -s dotnet-host "${pkgdir}"/usr/share/licenses/aspnet-targeting-pack
}

# vim: ts=2 sw=2 et:
