summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 6ab84670bcd310ca05e072962648bee51847a91d (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
_basepgkname=cosmopolitan
pkgname="${_basepgkname}-bin"
pkgver=3.9.3
pkgrel=2
pkgdesc="Build-once run-anywhere c library."
arch=('x86_64' 'aarch64')
url="https://github.com/jart/cosmopolitan"
license=('ISC')
source=(    
            "${pkgname}::https://github.com/jart/cosmopolitan/releases/download/${pkgver}/cosmocc-${pkgver}.zip"
            "ape.conf"
            "ape-jart.conf"
        )

sha256sums=(
            '37cfb39217b980b04dc256dc9a4ae55646c371a1b0e63d5a1e45bed3cc14ceae'
            '0a5d918ef46aaf764293fb18794eac021cb93637fe6abed7c9d3f06b7b2f4cad'
            '9351247b53d34dc584170c435512954b8eb1a69c7b3ff0bee43ce21264b8d467'
          )

provides=(  
        )

conflicts=('cosmopolitan-git' 'wine' 'wine-staging')
options=(!strip)


current_arch=$(uname -m)
current_os=$(uname -s | tr [':upper:'] [':lower:'])

checkBinary() { 
  binary=$1
  if (echo $binary | grep -q $current_arch)  && (echo $binary | grep -q $current_os) && !(echo $binary | grep -q '\.') && !(file "${srcdir}/bin/${binary}" | grep -q 'ASCII')
  then
    return 0
  else
    return 1
  fi
}

cleanBinaryName(){
  binary=$1
  echo $(echo $binary | sed "s/^${current_arch}-${current_os}-//" | sed 's/-//g')
}

build() {

  for binary in $(ls "${srcdir}/bin"); do
    # echo $binary
    if checkBinary $binary;
    then
      # echo $(cleanBinaryName $binary)
      provides+=$(cleanBinaryName $binary)
    fi
  done

}

package() {

  # Install binfmt files 
  install -Dm544 "ape.conf" "${pkgdir}/etc/binfmt.d/ape.conf"
  install -Dm544 "ape-jart.conf" "${pkgdir}/etc/binfmt.d/ape-jart.conf"

  # cd "${srcdir}/bin"
  # Install binaries
  # unzip -l cosmocc-3.9.3.zip | grep linux | grep x86 | grep bin | cut -d'/' -f2 | sed 's/^x86_64-linux-//' | sed 's/-//g'

  install -Dm755 "${srcdir}/bin/ape-${current_arch}.elf" "${pkgdir}/usr/bin/ape" 

  for binary in $(ls "${srcdir}/bin"); do
    if (checkBinary $binary)
    then
      install -Dm755 "${srcdir}/bin/${binary}" "${pkgdir}/usr/bin/$(cleanBinaryName $binary)"
    fi
  done

}