# Maintainer: Developer <dev@opalos.org>
# Maintainer: Developer <dev@opalos.org>

pkgname=os-prober
pkgver=%version%
pkgrel=%release%
pkgdesc='Utility to detect other OSes on a set of drives'
url='https://joeyh.name/code/os-prober/'
arch=('x86_64')
license=('GPL3')
depends=('sh')
source=(https://deb.debian.org/debian/pool/main/o/${pkgname}/${pkgname}_${pkgver}.tar.xz)
sha512sums=('ffb0e618f9e58a7a8e4a265d253bad4e168c220697216684acb38dbfa20680e552eb7c5f3d2186cd750c61a8929bf152527aa85c39318ed8b025a4ffffadde50')
b2sums=('0159870612d265c5e610e093a8839129aa9dc111a6f3abee65a6044b4c997ba65a69f70deca246bde53c1cf5314812312178e82c0893093d9f23ced3b0176f9d')

prepare() {
  cd ${pkgname}-${pkgver}
  # adjust lib dir to allow detection of 64-bit distros
  sed -i -e "s:/lib/ld\*\.so\*:/lib*/ld*.so*:g" os-probes/mounted/common/90linux-distro
  rm -f Makefile
}

build() {
  cd ${pkgname}-${pkgver}
  make newns
}

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

  install -Dm 755 os-prober linux-boot-prober -t "${pkgdir}/usr/bin"
  install -Dm 755 newns -t "${pkgdir}/usr/lib/os-prober"
  install -Dm 755 common.sh -t "${pkgdir}/usr/share/os-prober"

  for dir in os-probes os-probes/mounted os-probes/init linux-boot-probes linux-boot-probes/mounted; do
    install -dm 755 "${pkgdir}/usr/lib/${dir}"
    install -m 755 -t "${pkgdir}/usr/lib/${dir}" "${dir}"/common/*
    [[ -d "${dir}"/x86 ]] && cp -r "${dir}"/x86/* "${pkgdir}/usr/lib/${dir}"
  done

  install -Dm 755 os-probes/mounted/powerpc/20macosx "${pkgdir}"/usr/lib/os-probes/mounted/20macosx
  install -dm 755 "${pkgdir}"/var/lib/os-prober
}

# vim: ts=2 sw=2 et:
