summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 618af561e2112880d6fc1248c6a13becdb022538 (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
# Maintainer: Jonathan Steel <jsteel at archlinux.org>
# Contributor: Ido Rosen <ido@kernel.org>
# Contributor: Brett Hoerner <brett@bretthoerner.com>
# Contributor: Jochen Schalanda <jochen+aur@schalanda.name>
# Contributor: Mathieu Clabaut <mathieu.clabaut@gmail.com>
# Contributor: helios <aur@wiresphere.de>
# Contributor: George Ornbo <gornbo@gmail.com>
# Contributor: Niklas Heer <niklas.heer@me.com>
# Contributor: Marcus Andersson <mackilanu@gmail.com>

pkgname=vagrant
pkgver=2.4.5
pkgrel=1
pkgdesc="Build and distribute virtualized development environments"
arch=('x86_64')
url="https://vagrantup.com"
license=('BUSL-1.1')
options=('!emptydirs')
depends=('curl' 'libarchive' 'libssh2' 'libxml2' 'libxslt' 'rsync'
         'ruby' 'xz' 'perl')
makedepends=('git' 'go')
optdepends=('dnsmasq: if using libvirt')
conflicts=('vagrant-substrate')
replaces=('vagrant-substrate')
source=("$pkgname-$pkgver.tar.gz::https://github.com/hashicorp/$pkgname/archive/v$pkgver.tar.gz"
        "git+https://github.com/hashicorp/vagrant-installers.git#commit=7bcf4d4")
sha256sums=('af9c89804296ba3face198ad6a79ba54895b68516bc9e25e2abbcb34b6cc31ce'
            '6a12657a82226a942ca57f5b3a6f3684d312fe1ef6f876dfb6c246b7e757aa26')

prepare() {
  pushd "${pkgname}-${pkgver}"

  # update gemspec/Gemfile to allow newer version of the dependencies
  sed --in-place --regexp-extended 's|~>|>=|g' "${pkgname}.gemspec"

  popd
  pushd vagrant-installers

  local _gemdir="$(gem env gemdir)"

  # Allow Vagrant to see the system gems as these have been de-vendored from the ruby package
  sed -i "s_embeddedDir, \"gems\")_embeddedDir, \"gems:$_gemdir\")_g" substrate/launcher/main.go

  popd
}

build() {
  (
    cd $pkgname-$pkgver
    gem build $pkgname.gemspec
  )

  (
    export CGO_CPPFLAGS="${CPPFLAGS}"
    export CGO_CFLAGS="${CFLAGS}"
    export CGO_CXXFLAGS="${CXXFLAGS}"
    export CGO_LDFLAGS="${LDFLAGS}"
    export GOPATH="${srcdir}"
    export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"

    cd vagrant-installers/substrate/launcher
    go build -o $pkgname -ldflags "-compressdwarf=false -linkmode external -extldflags \"${LDFLAGS}\"" .
  )
}

package() {
  cd $pkgname-$pkgver

  INSTALLERS_DIR="$srcdir"/vagrant-installers/substrate
  EMBEDDED_DIR="$pkgdir"/opt/vagrant/embedded

  install -d "$pkgdir"/usr/{bin,share/bash-completion/completions,share/zsh/site-functions}
  install -Dm644 "$INSTALLERS_DIR"/common/gemrc "$EMBEDDED_DIR"/etc/gemrc

  echo "{ \"vagrant_version\": \"$pkgver\" }" > "$EMBEDDED_DIR"/manifest.json

  gem install $pkgname-$pkgver.gem \
    --no-document --no-user-install --install-dir "$EMBEDDED_DIR"/gems

  install -Dm755 "$INSTALLERS_DIR"/launcher/vagrant \
    "$pkgdir"/opt/$pkgname/bin/$pkgname

  ln -s /opt/$pkgname/bin/$pkgname "$pkgdir"/usr/bin/$pkgname

  install -Dm644 contrib/bash/completion.sh \
    "$pkgdir"/usr/share/bash-completion/completions/$pkgname

  install -Dm644 contrib/zsh/_vagrant \
    "$pkgdir"/usr/share/zsh/site-functions/_vagrant

  install -Dm644 contrib/vim/vagrantfile.vim \
    "$pkgdir"/usr/share/vim/vimfiles/ftdetect/vagrantfile.vim

  install -Dm644 LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE

  find "$pkgdir"/opt/vagrant/embedded/gems -name gem_make.out -delete
}