Vagrantfile 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. # -*- mode: ruby -*-
  2. # vi: set ft=ruby :
  3. def packages_prepare_wheezy
  4. return <<-EOF
  5. # debian 7 wheezy does not have lz4, but it is available from wheezy-backports:
  6. echo "deb http://http.debian.net/debian wheezy-backports main" > /etc/apt/sources.list.d/wheezy-backports.list
  7. EOF
  8. end
  9. def packages_prepare_precise
  10. return <<-EOF
  11. # ubuntu 12.04 precise does not have lz4, but it is available from a ppa:
  12. add-apt-repository -y ppa:gezakovacs/lz4
  13. EOF
  14. end
  15. def packages_centos
  16. return <<-EOF
  17. yum install -y epel-release
  18. yum update -y
  19. yum install -y python34 python34-devel
  20. ln -s /usr/bin/python3.4 /usr/bin/python3
  21. yum install -y openssl-devel openssl
  22. yum install -y libacl-devel libacl
  23. yum install -y lz4-devel
  24. yum install -y fuse-devel fuse pkgconfig
  25. yum install -y fakeroot gcc git
  26. yum install -y python-pip
  27. pip install virtualenv
  28. EOF
  29. end
  30. def packages_debianoid
  31. return <<-EOF
  32. apt-get update
  33. apt-get install -y python3-dev python3-setuptools
  34. apt-get install -y libssl-dev libacl1-dev liblz4-dev
  35. apt-get install -y libfuse-dev fuse pkg-config
  36. apt-get install -y fakeroot build-essential git
  37. # this way it works on older dists (like ubuntu 12.04) also:
  38. easy_install3 pip
  39. pip3 install virtualenv
  40. EOF
  41. end
  42. def packages_freebsd
  43. return <<-EOF
  44. pkg install -y python34 py34-setuptools34
  45. ln -s /usr/local/bin/python3.4 /usr/local/bin/python3
  46. pkg install -y openssl liblz4
  47. pkg install -y fusefs-libs pkgconf
  48. pkg install -y fakeroot git
  49. easy_install-3.4 pip
  50. pip3 install virtualenv
  51. # make FUSE work
  52. echo 'fuse_load="YES"' >> /boot/loader.conf
  53. echo 'vfs.usermount=1' >> /etc/sysctl.conf
  54. kldload fuse
  55. sysctl vfs.usermount=1
  56. pw groupmod operator -M vagrant
  57. EOF
  58. end
  59. def packages_openbsd
  60. return <<-EOF
  61. . ~/.profile
  62. mkdir -p /home/vagrant/borg
  63. rsync -aH /vagrant/borg/ /home/vagrant/borg/
  64. rm -rf /vagrant/borg
  65. ln -sf /home/vagrant/borg /vagrant/
  66. pkg_add bash
  67. chsh -s /usr/local/bin/bash vagrant
  68. pkg_add python-3.4.2
  69. pkg_add py3-setuptools
  70. ln -sf /usr/local/bin/python3.4 /usr/local/bin/python3
  71. ln -sf /usr/local/bin/python3.4 /usr/local/bin/python
  72. pkg_add openssl
  73. pkg_add lz4
  74. # pkg_add fuse # does not install, sdl dependency missing
  75. pkg_add git # no fakeroot
  76. easy_install-3.4 pip
  77. pip3 install virtualenv
  78. EOF
  79. end
  80. def packages_darwin
  81. return <<-EOF
  82. ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  83. brew update
  84. # this installs osxfuse 2.8.0 (which is based on libfuse 2.7.3).
  85. # llfuse later complains about needing (libfuse) 2.8.0 at least.
  86. #brew install caskroom/cask/brew-cask
  87. #brew cask install osxfuse # needs cask install because of apple's unsigned kext ban
  88. # get osxfuse 3.0.x pre-release code from github:
  89. curl https://github.com/osxfuse/osxfuse/releases/download/osxfuse-3.0.5/osxfuse-3.0.5.dmg -L >osxfuse.dmg
  90. MOUNTDIR=$(echo `hdiutil mount osxfuse.dmg | tail -1 | awk '{$1="" ; print $0}'` | xargs -0 echo) \
  91. && sudo installer -pkg "${MOUNTDIR}/Extras/FUSE for OS X 3.0.5.pkg" -target /
  92. brew install openssl
  93. brew install lz4
  94. # looks dirty, is there a better way without root?:
  95. mkdir -p /usr/local/opt/lz4
  96. ln -s /usr/local/Cellar/lz4/r*/include /usr/local/opt/lz4/
  97. ln -s /usr/local/Cellar/lz4/r*/lib /usr/local/opt/lz4/
  98. brew install fakeroot
  99. brew install pyenv
  100. if which pyenv > /dev/null; then
  101. eval "$(pyenv init -)"
  102. fi
  103. pyenv install 3.4.3
  104. pyenv global 3.4.3
  105. pyenv rehash
  106. python -m pip install --user virtualenv
  107. EOF
  108. end
  109. def prepare_user(boxname)
  110. return <<-EOF
  111. echo export 'PATH=/usr/local/bin:$PATH' >> ~/.profile
  112. . ~/.profile
  113. # initialize python on darwin
  114. if which pyenv > /dev/null; then
  115. eval "$(pyenv init -)"
  116. fi
  117. cd /vagrant/borg
  118. python -m virtualenv --python=python3 borg-env
  119. . borg-env/bin/activate
  120. cd borg
  121. pip install -U pip setuptools
  122. pip install 'llfuse<0.41' # 0.41 does not install due to UnicodeDecodeError
  123. pip install -r requirements.d/development.txt
  124. pip install -e .
  125. echo
  126. echo "Run:"
  127. echo " vagrant rsync #{boxname}"
  128. echo " vagrant ssh #{boxname} -c 'cd project/path; ...'"
  129. EOF
  130. end
  131. def fix_perms
  132. return <<-EOF
  133. chown -R vagrant /vagrant/borg
  134. EOF
  135. end
  136. Vagrant.configure(2) do |config|
  137. # use rsync to copy content to the folder
  138. config.vm.synced_folder ".", "/vagrant/borg/borg", :type => "rsync"
  139. # do not let the VM access . on the host machine via the default shared folder!
  140. config.vm.synced_folder ".", "/vagrant", disabled: true
  141. # fix permissions on synced folder
  142. config.vm.provision "fix perms", :type => :shell, :inline => fix_perms
  143. config.vm.provider :virtualbox do |v|
  144. #v.gui = true
  145. v.cpus = 2
  146. end
  147. config.vm.define "centos7" do |b|
  148. b.vm.box = "centos/7"
  149. b.vm.provision "packages centos7 64", :type => :shell, :inline => packages_centos
  150. b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("centos7_64")
  151. end
  152. config.vm.define "trusty64" do |b|
  153. b.vm.box = "ubuntu/trusty64"
  154. b.vm.provision "packages debianoid", :type => :shell, :inline => packages_debianoid
  155. b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("trusty64")
  156. end
  157. config.vm.define "precise32" do |b|
  158. b.vm.box = "ubuntu/precise32"
  159. b.vm.provision "packages prepare precise", :type => :shell, :inline => packages_prepare_precise
  160. b.vm.provision "packages debianoid", :type => :shell, :inline => packages_debianoid
  161. b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("precise32")
  162. end
  163. config.vm.define "jessie64" do |b|
  164. b.vm.box = "debian/jessie64"
  165. b.vm.provision "packages debianoid", :type => :shell, :inline => packages_debianoid
  166. b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("jessie64")
  167. end
  168. config.vm.define "wheezy32" do |b|
  169. b.vm.box = "puppetlabs/debian-7.8-32-nocm"
  170. b.vm.provision "packages prepare wheezy", :type => :shell, :inline => packages_prepare_wheezy
  171. b.vm.provision "packages debianoid", :type => :shell, :inline => packages_debianoid
  172. b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("wheezy32")
  173. end
  174. # BSD
  175. config.vm.define "freebsd" do |b|
  176. b.vm.box = "geoffgarside/freebsd-10.2"
  177. b.vm.provision "packages freebsd", :type => :shell, :inline => packages_freebsd
  178. b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("freebsd")
  179. end
  180. config.vm.define "openbsd" do |b|
  181. b.vm.box = "bodgit/openbsd-5.7-amd64"
  182. b.vm.provision "packages openbsd", :type => :shell, :inline => packages_openbsd
  183. b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("openbsd")
  184. end
  185. # OS X
  186. config.vm.define "darwin" do |b|
  187. b.vm.box = "jhcook/yosemite-clitools"
  188. b.vm.provision "packages darwin", :type => :shell, :privileged => false, :inline => packages_darwin
  189. b.vm.provision "prepare user", :type => :shell, :privileged => false, :inline => prepare_user("darwin")
  190. end
  191. end