summaryrefslogtreecommitdiffstats
path: root/bsd-coreutils-port-git/PKGBUILD
blob: fdaa258738d6bfbbb75cb1ac1ef8d060036feb50 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
pkgname=bsd-coreutils-port-git
_pkgname=BSDCoreUtils
pkgver=r545.d2b28e0
pkgrel=1
pkgdesc="A collection of basic BSD utilities ported to GNU/Linux"
arch=('x86_64')
url="https://github.com/DiegoMagdaleno/BSDCoreUtils"
license=('BSD')
depends=('glibc' 'openssl')
makedepends=('cmake' 'git')
source=("git+https://github.com/DiegoMagdaleno/BSDCoreUtils.git")
sha256sums=('SKIP')

pkgver() {
  cd "$_pkgname"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
  cd "$_pkgname"
  cmake -B build -S . \
    -DCMAKE_INSTALL_PREFIX=/opt/bsd-coreutils \
    -DCMAKE_BUILD_TYPE=Release
  make -C build
}

package() {
  cd "$_pkgname"
  make -C build DESTDIR="$pkgdir" install
  install -d "$pkgdir/usr/bin"

  if [ -d "$pkgdir/opt/bsd-coreutils/bin" ]; then
    for bin in $(ls "$pkgdir/opt/bsd-coreutils/bin/"); do
      ln -s "/opt/bsd-coreutils/bin/$bin" "$pkgdir/usr/bin/bsd_$bin"
    done
  fi

  # just move manpages to the correct spot and add a prefix, for now
  # i'll deal with this some other time
  install -d "$pkgdir/usr/share/man"
  for mandir in "$pkgdir"/man*; do
    if [ -d "$mandir" ]; then
      for manfile in "$mandir"/*; do
        if [ -f "$manfile" ]; then
          section=$(basename "$mandir")
          newname="bsd_$(basename "$manfile")"
          install -Dm644 "$manfile" "$pkgdir/usr/share/man/$section/$newname"
        fi
      done
      rm -rf "$mandir"
    fi
  done
}

# vim: set ts=2 sw=2 et: