summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7ac01c5ba278db99712513b7d5ecfb76c3802f30 (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
# Maintainer: Hyacinthe Cartiaux <hyacinthe.cartiaux at free.fr>
# Contributor: Ian Watt <ian at ewatt.ca>
# Contributor: Jonathan Steel <jsteel at archlinux.org>

_pkgname=vagrant
pkgname=vagrant-git
pkgver=2.4.10.dev+000759.0b7d460a.0.g0b7d460a4
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'
            'cdrtools: to create cloud-init media')
provides=('vagrant')
conflicts=('vagrant-substrate' 'vagrant-substrate-git' 'vagrant')
source=("git+https://github.com/hashicorp/${_pkgname}.git"
        "git+https://github.com/hashicorp/vagrant-installers.git")
md5sums=('SKIP'
         'SKIP')

pkgver() {
  cd "${_pkgname}"

  git describe --tags --long | sed 's/-/./g;s/^v//'
}

prepare() {
  cd vagrant-installers
  local _gemdir
  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
}

build() {
  (
    cd "${_pkgname}"

    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}"

  VERSION=$(cat "${srcdir}/${_pkgname}/version.txt")
  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}-${VERSION}.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
}