summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 6055166b7eed8e89b8b4705b3e1991e93c26bd43 (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
# Maintainer: e.kovetskiy@gmail.com
# Original author: ebiadsu  <ebiadsu@posteo.de>

pkgname=atlassian-plugin-sdk-latest
_pkgname=atlassian-plugin-sdk
conflicts=($_pkgname)
pkgver=${PKGVER:-autogenerated}
pkgrel=${PKGREL:-1}
pkgdesc="Atlassian plugin software developer kit autogenerated version"
arch=('i686' 'x86_64')
url="https://marketplace.atlassian.com/plugins/atlassian-plugin-sdk-tgz"
license=('Apache License 2.0')
_maven="https://maven.atlassian.com/public/com/atlassian/amps/$_pkgname"
depends=('java-environment')

pkgver() {
    if [[ "$PKGVER" ]]; then
        echo "$PKGVER"
        return
    fi

    _url=${_maven}/maven-metadata.xml
    echo ":: Obtaining latest version from maven-metadata.xml: ${_url}" >&2

    version=$(curl -sL "${_url}" | grep -Po '<latest>\K[^<]+' | sed -r 's/[-:]/./g')

    echo "${version}"
}

package() {
  cd "${srcdir}"
  echo ":: Downloading $_maven/$pkgver/$_pkgname-$pkgver.tar.gz" >&2
  wget "$_maven/$pkgver/$_pkgname-$pkgver.tar.gz"
  tar xvf "$_pkgname-$pkgver.tar.gz"

  cd "$pkgdir"
  mkdir -p opt/atlassian/plugin-sdk

  cp -r "$srcdir"/atlassian-plugin-sdk-$pkgver/* opt/atlassian/plugin-sdk

  # remove executable flag from .bat in bin
  if [[ -n $(find opt/atlassian/plugin-sdk/apache-maven-*/bin/ -type f -name "*.bat") ]]; then
    chmod -x opt/atlassian/plugin-sdk/apache-maven-*/bin/*.bat
  fi

  # add executable flag for every user
  chmod -R +X opt/atlassian/plugin-sdk

  # update PATH
  mkdir -p etc/profile.d
  echo 'export PATH=$PATH:/opt/atlassian/plugin-sdk/bin' > etc/profile.d/$_pkgname.sh
  echo 'setenv PATH ${PATH}:/opt/atlassian/plugin-sdk/bin' > etc/profile.d/$_pkgname.csh
  chmod +x etc/profile.d/*
}