summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5216ff834baedacc5286bac47139edd40745a053 (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
# Maintainer: Benjamin Denhartog <ben@sudoforge.com>

# For ISSUES, REQUESTS, and QUESTIONS:
# https://github.com/sudoforge/pkgbuilds

pkgname=copybara-git
pkgver=0.0.0.r2390.g44ca710c
pkgrel=1
pkgdesc='A tool for transforming and moving code between repositories'
arch=('x86_64')
url="https://github.com/google/${pkgname%-git}"
license=('Apache')
depends=(
  'java-environment'
  'git'
)
makedepends=('git')
provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}")
_bazelisk_pkgver=1.8.1
source=(
  "bazelisk-bin-${_bazelisk_pkgver}::https://github.com/bazelbuild/bazelisk/releases/download/v${_bazelisk_pkgver}/bazelisk-linux-amd64"
  "git+${url}.git"
  "copybara.sh"
)
sha256sums=('4a7652ffe904ccb064aaa7db41c456e742e507e574f58a602edbbc32920ed79b'
            'SKIP'
            '53d9cd732ecf7267c883a5f5e304429548b6aa8ce8d1038966c5cf83929d52d1')

pkgver() {
  cd "${srcdir}/${pkgname%-git}"

  # Get a count of all commits in HEAD
  _count=$(git rev-list --count HEAD)

  # Use the latest hash for versioning, formatting as 0.0.0.r<count>.g<hash>
  git log -1 --format='%h' | sed -e 's/\(.*\)/0.0.0.r'$_count'.g\1/'
}

prepare() {
  chmod +x "${srcdir}/${source[0]%%::*}"
}

build() {
  cd "${srcdir}/${pkgname%-git}"

  # Build the "uberjar"
  "${srcdir}/${source[0]%%::*}" build //java/com/google/copybara:copybara_deploy.jar
  "${srcdir}/${source[0]%%::*}" shutdown
}

package() {
  # Install the wrapper script
  install -D -m 755 \
    "${srcdir}/${source[2]}" \
    "${pkgdir}/usr/bin/copybara"

  # Install the uberjar
  install -D -m 655 \
    "${srcdir}/${pkgname%-git}/bazel-bin/java/com/google/copybara/copybara_deploy.jar" \
    "${pkgdir}/usr/bin/copybara-real"

  # Install the license
  install -D -m 644 \
    "${srcdir}/${pkgname%-git}/LICENSE" \
    "${pkgdir}/usr/share/licenses/${pkgname%-git}/LICENSE"
}