summaryrefslogtreecommitdiff
path: root/pcr/java-jsch-agent-proxy/PKGBUILD
blob: 535d61e8137b75e8fce1cbb242018aad0ecd22c4 (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
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>

_libname=jsch-agent-proxy
_pkgname=jsch.agentproxy
pkgname=java-${_libname}
pkgver=0.0.8
pkgrel=1
pkgdesc="Proxy to ssh-agent and Pageant in Java"
arch=('any')
url='http://www.jcraft.com/jsch-agent-proxy/'
license=('BSD')
depends=('java-runtime')
makedepends=('java-environment' 'java-jsch' 'jh' 'jna')
source=("https://github.com/ymnk/${_libname}/archive/${pkgver}.tar.gz"
        'jsch-agent-proxy-remove_maven3_prerequisite.patch'
        'jsch-agent-proxy-bundles_to_jars.patch'
        'jsch-agent-proxy-poms.patch')
sha1sums=('811eb8d5ff1524bc1b2f9fa94f5ecda958b5dc41'
          '649d1a9fc1eacd125a85d5b9ec42c0ec2f29fa6e'
          '4bdb1f5b2c5367ae66d01857b3d7b501edf20835'
          'ee4112801473130951ed7559caeaf9be48a8dd62')

_artifacts=(core jsch sshagent usocket-nc usocket-jna pageant connector-factory)

prepare() {
  cd "${srcdir}/${_libname}-${pkgver}"
  patch -Np1 -i "${srcdir}/jsch-agent-proxy-remove_maven3_prerequisite.patch"
  patch -Np1 -i "${srcdir}/jsch-agent-proxy-bundles_to_jars.patch"
  patch -Np1 -i "${srcdir}/jsch-agent-proxy-poms.patch"
  mkdir -p {source,dist}

  for artifact in ${_artifacts[@]}; do
    mkdir -p "build/${artifact}/classes"
    cp -rv "${_libname}-${artifact}/src" source
  done
}

build() {
  cd "${srcdir}/${_libname}-${pkgver}"

  CLASSPATH="/usr/share/java/jsch.jar:/usr/share/java/jna.jar:/usr/share/java/jna-platform.jar:dist/*"
  for artifact in ${_artifacts[@]}; do
    javac -cp $CLASSPATH -d "build/${artifact}/classes" -encoding UTF-8 \
      $(find "${_libname}-${artifact}/src/main/java" -name \*.java)
    jar -cvf "dist/${_pkgname}.${artifact}.jar" -C "build/${artifact}/classes" .
  done

  javadoc -classpath $CLASSPATH -d "build/javadoc" -encoding UTF-8 \
    -sourcepath source/src/main/java -subpackages com
}

package() {
  cd "${srcdir}/${_libname}-${pkgver}"

  # Install license file
  install -Dm644 LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.txt"

  # Install documentation
  install -d "${pkgdir}/usr/share/doc/${pkgname}"
  cp -r build/javadoc "${pkgdir}/usr/share/doc/${pkgname}"

  # Install Maven artifacts
  export DESTDIR=${pkgdir}
  jh mvn-install com.jcraft jsch.agentproxy ${pkgver} pom.xml

  for artifact in ${_artifacts[@]}; do
    jh mvn-install com.jcraft "jsch.agentproxy.${artifact}" ${pkgver} \
      "${_libname}-${artifact}/pom.xml" \
      "dist/${_pkgname}.${artifact}.jar" \
      "${_pkgname}.${artifact}-${pkgver}.jar"

    ln -s "/usr/share/java/${_pkgname}.${artifact}-${pkgver}.jar" \
      "${pkgdir}/usr/share/java/${_pkgname}.${artifact}.jar"
  done
}