summaryrefslogtreecommitdiff
path: root/java/jna/PKGBUILD
blob: f7248a637657976e5880c6a60e070af21bd163f8 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Maintainer: Luke Shumaker <lukeshu@sbcglobal.net>

pkgname=jna
pkgver=3.4.2

pkgdesc="Provides Java programs easy access to native shared libraries"
url="https://github.com/twall/jna"
license=('LGPL')
source=("git://github.com/twall/jna.git#tag=${pkgver}"
  'libre-without-clover.patch'
  'bugfix-type-inference.patch'
  'webstart-test.keystore')

####

pkgrel=2
arch=('i686' 'x86_64')
depends=('java-environment' 'libffi')
makedepends=('apache-ant' 'zip' 'makepkg-git' 'git')
checkdepends=('icedtea-web-java7' 'junit' 'libxtst')
options=('!makeflags')

unset _JAVA_OPTIONS
_M2_LOCALREPO='/usr/share/maven/repository'

_ant_options=(
  '-Ddynlink.native=true' # use the system install of libffi
)

####

prepare() {
  cd "$srcdir/jna"
  find . -name '*.jar' -delete
  rm -rf dist
  rm -rf native/libffi # make sure it doesn't cheat
  rm lib/clover.license
  rm w32ce-test.lnk

  ln -s /usr/share/java/junit.jar lib/

  # Create an emtpy zip (jar) file
  cd "$srcdir"
  touch file
  zip empty.zip file
  zip -d empty.zip file
  rm file
}

####

build() {
  cd "$srcdir/jna"

  # Because JNA's release process is ridiculous, it wants a jar file for every
  # architecture to be present.  So let's just dump in an empty jar file!
  sed -n 's|\s*<zipfileset src="${lib\.native}/\(.*\)"|\1|p' build.xml \
    | while read jarfile; do
    cp "$srcdir/empty.zip" lib/native/$jarfile
  done

  patch -p1 -i "$srcdir/libre-without-clover.patch"
  patch -p1 -i "$srcdir/bugfix-type-inference.patch"

  # Disable tests that intermittently fail
  # crashes vm (segfault)
  sed -i -e 's|testRegisterMethods|no&|' test/com/sun/jna/DirectTest.java
  # crashes vm, java 7 only (icedtea-7, oracle-jdk-bin-1.7)
  sed -i -e 's|testGCCallbackOnFinalize|no&|' test/com/sun/jna/CallbacksTest.java

  # Actually build
  ant "${_ant_options[@]}" dist
}

check() {
  cd "$srcdir/jna"

  # Create a foke home directory to trash
  mkdir "$srcdir/user.home"
  export _JAVA_OPTIONS="-Duser.home=$srcdir/user.home -Djava.awt.headless=true"

  # The webstart test looks for this config file
  mkdir -p "$srcdir/user.home/.java/deployment"
  touch "$srcdir/user.home/.java/deployment/deployment.properties"

  # Trust the cert used for the webstart test
  mkdir -p "$srcdir/user.home/.icedtea/security"
  cp "$srcdir/webstart-test.keystore" "$srcdir/user.home/.icedtea/security/trusted.certs"

  _ant_options+=('-Dtests.exclude-patterns=**/DirectTest.java')

  # Run the tests
  ant "${_ant_options[@]}" test
}

package() {
  cd "$srcdir/jna"

  install -d "$pkgdir/usr/share/java/jna"

  for pkg in jna platform; do
   dir="$_M2_LOCALREPO"/net/java/dev/jna/$pkg/$pkgver
   install -d "$pkgdir$dir"
   cp dist/$pkg.jar "$pkgdir$dir/$pkg-$pkgver.jar"
   cp pom-$pkg.xml  "$pkgdir$dir/$pkg-$pkgver.pom"
   ln -s "$dir/$pkg-$pkgver.jar" "$pkgdir/usr/share/java/jna/$pkg.jar"
  done

  ln -s jna/jna.jar "$pkgdir/usr/share/java/jna.jar"
}

md5sums=('SKIP'
         '3a2f96b868f49ca125b677779e846484'
         '932d9cb2da1531a2315ae132480683fa'
         'b704c7d2cb1fe7a93f8cad8d321d16f8')