summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 1435ea3277c14d394b674b02074563af51eb12c0 (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# Partially based on the package `arangodb', from which Christoph Grabo <asaaki at mannaz dot cc> is the maintainer
# Maintainer: helq <linuxero789 \at/ gmail \./ com>

# allow to download a shallow copy of the repository, if not it delegates the
# download to makepkg which downloads the whole repository (slow)
# comment to disable
_shallow_git_copy=true

# enable clang as compiler
# comment to disable
_clang=true

# make build special opts
_make_opts="-j4"

# repository location, name and branch
_pkgname=arangodb
_branch=master
_git="git://github.com/$_pkgname/$_pkgname"

#
pkgname=${_pkgname}-git
pkgver=3.0.3.d20160717_0823.31c6b72
pkgrel=1

pkgdesc="A distributed open-source database with a flexible data model for documents, graphs, and key-values."
arch=("i686" "x86_64")
url="https://www.arangodb.com/"
license=('Apache')

depends=('openssl' 'readline' 'systemd' 'icu')
makedepends=('git' 'go' 'python2' 'cmake')
if [ $_clang ] ; then
    makedepends+=('clang')
fi

provides=("arangodb")
conflicts=("arangodb")

install=arangodb.install
source=(arangodb.service)
sha1sums=('bc2830bd209c7659a7cde5ab8e7f860b62db74c4')
if [ ! $_shallow_git_copy ] ; then
    makedepends+=("$_git:$_branch")
    sha1sums+=('SKIP')
fi

pkgver() {
  cd "$startdir/$_pkgname"

  cmakelists_arangodb=$(git ls-tree HEAD | grep CMakeLists.txt | sed 's/^\S* \S* \(\S*\)\s.*$/\1/')
  arangodb_revision=$(git cat-file blob $cmakelists_arangodb | grep ARANGODB_VERSION | head -n 3 | sed 's/^.*"\(.\)".*$/\1/' | tr '\n' '.')

  commit_date="$(date -d "$(git log -n1 --pretty='format:%ci')" --utc +%Y%m%d_%H%M)"
  commit="$(git rev-parse --short HEAD)"

  printf "%sd%s.%s" "$arangodb_revision" "$commit_date" "$commit"
}

if [ $_shallow_git_copy ] ; then
  # 'prepare' downloads a shallow copy of the repo. A shallow copy
  # only contains few commits of the original repo and not its entire history,
  # which reduces (in some cases, like this) the download's size/time
  prepare() {
    # downloading/updating local repo from $_git
    if [[ -d "$startdir/$_pkgname" ]]; then
      git --git-dir="$startdir/$_pkgname" \
        fetch origin refs/heads/${_branch}:refs/heads/${_branch}
    else
      git clone --mirror --single-branch --branch "$_branch" --depth 1 \
                "$_git" "$startdir/$_pkgname"
    fi
  
    cd "$srcdir"
    # copying/updating repo to $srcdir
    if [[ -d "$_pkgname" ]]; then
      cd "$_pkgname"
      git pull origin "$_branch"
    else
      git clone "$startdir/$_pkgname" "$_pkgname"
    fi
  }
fi

build() {
  cd "$srcdir/$_pkgname"

  # creating a relative link to python2 because v8 needs Python 2 but uses
  # `python' instead of `python2' everywhere
  mkdir -p "$srcdir/python2-path"
  ln -sf /usr/bin/python2 "$srcdir/python2-path/python"
  export PATH="$srcdir/python2-path:$PATH"

  # creating building directory
  mkdir -p build
  cd build

  if [ $_clang ] ; then
    export CC=clang
    export CXX=clang++
  else
    export CC=gcc
    export CXX=g++
  fi

  # configuring compilation and path
  cmake .. \
    -DCMAKE_INSTALL_PREFIX:PATH=/usr \
    -DETCDIR=/etc \
    -DVARDIR=/var \
    -DCMAKE_C_COMPILER=${CC} \
    -DCMAKE_C_FLAGS="${CFLAGS}" \
    -DCMAKE_CXX_COMPILER=${CXX} \
    -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
    -DCMAKE_SKIP_RPATH:BOOL=ON \
    -DCMAKE_BUILD_TYPE=Release

  # replacing all `sbin' instances for `bin'
  sed -i 's/sbin/bin/' arangod/cmake_install.cmake

  make $_make_opts
}

package() {
  cd "$srcdir/$_pkgname/build"
  make DESTDIR="$pkgdir/" install

  # deleting init script
  rm -r "$pkgdir/etc/init.d"

  # installing systemd arango service
  install -Dm644 "$srcdir/arangodb.service" \
                 "$pkgdir/usr/lib/systemd/system/arangodb.service"
}

# vim:set ts=2 sw=2 et: