Vagrantfile 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. # -*- mode: ruby -*-
  2. # vi: set ft=ruby :
  3. # Automated creation of testing environments / binaries on misc. platforms
  4. def packages_prepare_wheezy
  5. return <<-EOF
  6. # debian 7 wheezy does not have lz4, but it is available from wheezy-backports:
  7. echo "deb http://http.debian.net/debian wheezy-backports main" > /etc/apt/sources.list.d/wheezy-backports.list
  8. EOF
  9. end
  10. def packages_prepare_precise
  11. return <<-EOF
  12. # ubuntu 12.04 precise does not have lz4, but it is available from a ppa:
  13. add-apt-repository -y ppa:gezakovacs/lz4
  14. EOF
  15. end
  16. def packages_debianoid
  17. return <<-EOF
  18. apt-get update
  19. # for building borgbackup and dependencies:
  20. apt-get install -y libssl-dev libacl1-dev liblz4-dev libfuse-dev fuse pkg-config
  21. usermod -a -G fuse vagrant
  22. apt-get install -y fakeroot build-essential git
  23. apt-get install -y python3-dev python3-setuptools
  24. # for building python:
  25. apt-get install -y zlib1g-dev libbz2-dev libncurses5-dev libreadline-dev liblzma-dev libsqlite3-dev
  26. # this way it works on older dists (like ubuntu 12.04) also:
  27. # for python 3.2 on ubuntu 12.04 we need pip<8 and virtualenv<14 as
  28. # newer versions are not compatible with py 3.2 any more.
  29. easy_install3 'pip<8.0'
  30. pip3 install 'virtualenv<14.0'
  31. touch ~vagrant/.bash_profile ; chown vagrant ~vagrant/.bash_profile
  32. EOF
  33. end
  34. def packages_redhatted
  35. return <<-EOF
  36. yum install -y epel-release
  37. yum update -y
  38. # for building borgbackup and dependencies:
  39. yum install -y openssl-devel openssl libacl-devel libacl lz4-devel fuse-devel fuse pkgconfig
  40. usermod -a -G fuse vagrant
  41. yum install -y fakeroot gcc git patch
  42. # needed to compile msgpack-python (otherwise it will use slow fallback code):
  43. yum install -y gcc-c++
  44. # for building python:
  45. yum install -y zlib-devel bzip2-devel ncurses-devel readline-devel xz-devel sqlite-devel
  46. #yum install -y python-pip
  47. #pip install virtualenv
  48. touch ~vagrant/.bash_profile ; chown vagrant ~vagrant/.bash_profile
  49. EOF
  50. end
  51. def packages_darwin
  52. return <<-EOF
  53. # get osxfuse 3.0.x pre-release code from github:
  54. curl -s -L https://github.com/osxfuse/osxfuse/releases/download/osxfuse-3.0.9/osxfuse-3.0.9.dmg >osxfuse.dmg
  55. MOUNTDIR=$(echo `hdiutil mount osxfuse.dmg | tail -1 | awk '{$1="" ; print $0}'` | xargs -0 echo) \
  56. && sudo installer -pkg "${MOUNTDIR}/Extras/FUSE for OS X 3.0.9.pkg" -target /
  57. sudo chown -R vagrant /usr/local # brew must be able to create stuff here
  58. ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  59. brew update
  60. brew install openssl
  61. brew install lz4
  62. brew install fakeroot
  63. brew install git
  64. brew install pkgconfig
  65. touch ~vagrant/.bash_profile ; chown vagrant ~vagrant/.bash_profile
  66. EOF
  67. end
  68. def packages_freebsd
  69. return <<-EOF
  70. # for building borgbackup and dependencies:
  71. pkg install -y openssl liblz4 fusefs-libs pkgconf
  72. pkg install -y fakeroot git bash
  73. # for building python:
  74. pkg install -y sqlite3
  75. # make bash default / work:
  76. chsh -s bash vagrant
  77. mount -t fdescfs fdesc /dev/fd
  78. echo 'fdesc /dev/fd fdescfs rw 0 0' >> /etc/fstab
  79. # make FUSE work
  80. echo 'fuse_load="YES"' >> /boot/loader.conf
  81. echo 'vfs.usermount=1' >> /etc/sysctl.conf
  82. kldload fuse
  83. sysctl vfs.usermount=1
  84. pw groupmod operator -M vagrant
  85. touch ~vagrant/.bash_profile ; chown vagrant ~vagrant/.bash_profile
  86. EOF
  87. end
  88. def packages_openbsd
  89. return <<-EOF
  90. . ~/.profile
  91. mkdir -p /home/vagrant/borg
  92. rsync -aH /vagrant/borg/ /home/vagrant/borg/
  93. rm -rf /vagrant/borg
  94. ln -sf /home/vagrant/borg /vagrant/
  95. pkg_add bash
  96. chsh -s /usr/local/bin/bash vagrant
  97. pkg_add openssl
  98. pkg_add lz4
  99. # pkg_add fuse # does not install, sdl dependency missing
  100. pkg_add git # no fakeroot
  101. pkg_add python-3.4.2
  102. pkg_add py3-setuptools
  103. ln -sf /usr/local/bin/python3.4 /usr/local/bin/python3
  104. ln -sf /usr/local/bin/python3.4 /usr/local/bin/python
  105. easy_install-3.4 pip
  106. pip3 install virtualenv
  107. touch ~vagrant/.bash_profile ; chown vagrant ~vagrant/.bash_profile
  108. EOF
  109. end
  110. def packages_netbsd
  111. return <<-EOF
  112. hostname netbsd # the box we use has an invalid hostname
  113. PKG_PATH="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/NetBSD/amd64/6.1.5/All/"
  114. export PKG_PATH
  115. pkg_add mozilla-rootcerts lz4 git bash
  116. chsh -s bash vagrant
  117. mkdir -p /usr/local/opt/lz4/include
  118. mkdir -p /usr/local/opt/lz4/lib
  119. ln -s /usr/pkg/include/lz4*.h /usr/local/opt/lz4/include/
  120. ln -s /usr/pkg/lib/liblz4* /usr/local/opt/lz4/lib/
  121. touch /etc/openssl/openssl.cnf # avoids a flood of "can't open ..."
  122. mozilla-rootcerts install
  123. pkg_add pkg-config # avoids some "pkg-config missing" error msg, even without fuse
  124. # pkg_add fuse # llfuse 0.41.1 supports netbsd, but is still buggy.
  125. # https://bitbucket.org/nikratio/python-llfuse/issues/70/perfuse_open-setsockopt-no-buffer-space
  126. pkg_add python34 py34-setuptools
  127. ln -s /usr/pkg/bin/python3.4 /usr/pkg/bin/python
  128. ln -s /usr/pkg/bin/python3.4 /usr/pkg/bin/python3
  129. easy_install-3.4 pip
  130. pip install virtualenv
  131. touch ~vagrant/.bash_profile ; chown vagrant ~vagrant/.bash_profile
  132. EOF
  133. end
  134. def install_pyenv(boxname)
  135. return <<-EOF
  136. curl -s -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
  137. echo 'export PATH="$HOME/.pyenv/bin:/vagrant/borg:$PATH"' >> ~/.bash_profile
  138. echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
  139. echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bash_profile
  140. echo 'export PYTHON_CONFIGURE_OPTS="--enable-shared"' >> ~/.bash_profile
  141. echo 'export LANG=en_US.UTF-8' >> ~/.bash_profile
  142. EOF
  143. end
  144. def fix_pyenv_darwin(boxname)
  145. return <<-EOF
  146. echo 'export PYTHON_CONFIGURE_OPTS="--enable-framework"' >> ~/.bash_profile
  147. EOF
  148. end
  149. def install_pythons(boxname)
  150. return <<-EOF
  151. . ~/.bash_profile
  152. pyenv install 3.3.0 # tests
  153. pyenv install 3.4.0 # tests
  154. pyenv install 3.5.0 # tests
  155. pyenv install 3.5.1 # binary build, use latest 3.5.x release
  156. pyenv rehash
  157. EOF
  158. end
  159. def build_sys_venv(boxname)
  160. return <<-EOF
  161. . ~/.bash_profile
  162. cd /vagrant/borg
  163. virtualenv --python=python3 borg-env
  164. EOF
  165. end
  166. def build_pyenv_venv(boxname)
  167. return <<-EOF
  168. . ~/.bash_profile
  169. cd /vagrant/borg
  170. # use the latest 3.5 release
  171. pyenv global 3.5.1
  172. pyenv virtualenv 3.5.1 borg-env
  173. ln -s ~/.pyenv/versions/borg-env .
  174. EOF
  175. end
  176. def install_borg(boxname)
  177. return <<-EOF
  178. . ~/.bash_profile
  179. cd /vagrant/borg
  180. . borg-env/bin/activate
  181. pip install -U wheel # upgrade wheel, too old for 3.5
  182. cd borg
  183. # clean up (wrong/outdated) stuff we likely got via rsync:
  184. rm -f borg/*.so borg/*.cpy*
  185. rm -f borg/{chunker,crypto,compress,hashindex,platform_linux}.c
  186. rm -rf borg/__pycache__ borg/support/__pycache__ borg/testsuite/__pycache__
  187. pip install 'llfuse<0.41' # 0.41.1 throws UnicodeDecodeError at install time:
  188. # https://bitbucket.org/nikratio/python-llfuse/issues/69/unicode-exception-at-install-time
  189. pip install -r requirements.d/development.txt
  190. pip install -e .
  191. EOF
  192. end
  193. def install_pyinstaller(boxname)
  194. return <<-EOF
  195. . ~/.bash_profile
  196. cd /vagrant/borg
  197. . borg-env/bin/activate
  198. git clone https://github.com/pyinstaller/pyinstaller.git
  199. cd pyinstaller
  200. git checkout v3.1
  201. pip install -e .
  202. EOF
  203. end
  204. def install_pyinstaller_bootloader(boxname)
  205. return <<-EOF
  206. . ~/.bash_profile
  207. cd /vagrant/borg
  208. . borg-env/bin/activate
  209. git clone https://github.com/pyinstaller/pyinstaller.git
  210. cd pyinstaller
  211. git checkout v3.1
  212. # build bootloader, if it is not included
  213. cd bootloader
  214. python ./waf all
  215. cd ..
  216. pip install -e .
  217. EOF
  218. end
  219. def build_binary_with_pyinstaller(boxname)
  220. return <<-EOF
  221. . ~/.bash_profile
  222. cd /vagrant/borg
  223. . borg-env/bin/activate
  224. cd borg
  225. pyinstaller -F -n borg.exe --distpath=/vagrant/borg --clean borg/__main__.py
  226. EOF
  227. end
  228. def run_tests(boxname)
  229. return <<-EOF
  230. . ~/.bash_profile
  231. cd /vagrant/borg/borg
  232. . ../borg-env/bin/activate
  233. if which pyenv > /dev/null; then
  234. # for testing, use the earliest point releases of the supported python versions:
  235. pyenv global 3.3.0 3.4.0 3.5.0
  236. fi
  237. # otherwise: just use the system python
  238. if which fakeroot > /dev/null; then
  239. echo "Running tox WITH fakeroot -u"
  240. fakeroot -u tox --skip-missing-interpreters
  241. else
  242. echo "Running tox WITHOUT fakeroot -u"
  243. tox --skip-missing-interpreters
  244. fi
  245. EOF
  246. end
  247. def fix_perms
  248. return <<-EOF
  249. # . ~/.profile
  250. chown -R vagrant /vagrant/borg
  251. EOF
  252. end
  253. Vagrant.configure(2) do |config|
  254. # use rsync to copy content to the folder
  255. config.vm.synced_folder ".", "/vagrant/borg/borg", :type => "rsync"
  256. # do not let the VM access . on the host machine via the default shared folder!
  257. config.vm.synced_folder ".", "/vagrant", disabled: true
  258. # fix permissions on synced folder
  259. config.vm.provision "fix perms", :type => :shell, :inline => fix_perms
  260. config.vm.provider :virtualbox do |v|
  261. #v.gui = true
  262. v.cpus = 1
  263. end
  264. # Linux
  265. config.vm.define "centos7_64" do |b|
  266. b.vm.box = "centos/7"
  267. b.vm.provider :virtualbox do |v|
  268. v.memory = 768
  269. end
  270. b.vm.provision "install system packages", :type => :shell, :inline => packages_redhatted
  271. b.vm.provision "install pyenv", :type => :shell, :privileged => false, :inline => install_pyenv("centos7_64")
  272. b.vm.provision "install pythons", :type => :shell, :privileged => false, :inline => install_pythons("centos7_64")
  273. b.vm.provision "build env", :type => :shell, :privileged => false, :inline => build_pyenv_venv("centos7_64")
  274. b.vm.provision "install borg", :type => :shell, :privileged => false, :inline => install_borg("centos7_64")
  275. b.vm.provision "run tests", :type => :shell, :privileged => false, :inline => run_tests("centos7_64")
  276. end
  277. config.vm.define "centos6_32" do |b|
  278. b.vm.box = "centos6-32"
  279. b.vm.provision "install system packages", :type => :shell, :inline => packages_redhatted
  280. b.vm.provision "install pyenv", :type => :shell, :privileged => false, :inline => install_pyenv("centos6_32")
  281. b.vm.provision "install pythons", :type => :shell, :privileged => false, :inline => install_pythons("centos6_32")
  282. b.vm.provision "build env", :type => :shell, :privileged => false, :inline => build_pyenv_venv("centos6_32")
  283. b.vm.provision "install borg", :type => :shell, :privileged => false, :inline => install_borg("centos6_32")
  284. b.vm.provision "install pyinstaller", :type => :shell, :privileged => false, :inline => install_pyinstaller("centos6_32")
  285. b.vm.provision "build binary with pyinstaller", :type => :shell, :privileged => false, :inline => build_binary_with_pyinstaller("centos6_32")
  286. b.vm.provision "run tests", :type => :shell, :privileged => false, :inline => run_tests("centos6_32")
  287. end
  288. config.vm.define "centos6_64" do |b|
  289. b.vm.box = "centos6-64"
  290. b.vm.provider :virtualbox do |v|
  291. v.memory = 768
  292. end
  293. b.vm.provision "install system packages", :type => :shell, :inline => packages_redhatted
  294. b.vm.provision "install pyenv", :type => :shell, :privileged => false, :inline => install_pyenv("centos6_64")
  295. b.vm.provision "install pythons", :type => :shell, :privileged => false, :inline => install_pythons("centos6_64")
  296. b.vm.provision "build env", :type => :shell, :privileged => false, :inline => build_pyenv_venv("centos6_64")
  297. b.vm.provision "install borg", :type => :shell, :privileged => false, :inline => install_borg("centos6_64")
  298. b.vm.provision "install pyinstaller", :type => :shell, :privileged => false, :inline => install_pyinstaller("centos6_64")
  299. b.vm.provision "build binary with pyinstaller", :type => :shell, :privileged => false, :inline => build_binary_with_pyinstaller("centos6_64")
  300. b.vm.provision "run tests", :type => :shell, :privileged => false, :inline => run_tests("centos6_64")
  301. end
  302. config.vm.define "trusty64" do |b|
  303. b.vm.box = "ubuntu/trusty64"
  304. b.vm.provider :virtualbox do |v|
  305. v.memory = 768
  306. end
  307. b.vm.provision "packages debianoid", :type => :shell, :inline => packages_debianoid
  308. b.vm.provision "build env", :type => :shell, :privileged => false, :inline => build_sys_venv("trusty64")
  309. b.vm.provision "install borg", :type => :shell, :privileged => false, :inline => install_borg("trusty64")
  310. b.vm.provision "run tests", :type => :shell, :privileged => false, :inline => run_tests("trusty64")
  311. end
  312. config.vm.define "precise32" do |b|
  313. b.vm.box = "ubuntu/precise32"
  314. b.vm.provision "packages prepare precise", :type => :shell, :inline => packages_prepare_precise
  315. b.vm.provision "packages debianoid", :type => :shell, :inline => packages_debianoid
  316. b.vm.provision "build env", :type => :shell, :privileged => false, :inline => build_sys_venv("precise32")
  317. b.vm.provision "install borg", :type => :shell, :privileged => false, :inline => install_borg("precise32")
  318. b.vm.provision "run tests", :type => :shell, :privileged => false, :inline => run_tests("precise32")
  319. end
  320. config.vm.define "jessie64" do |b|
  321. b.vm.box = "debian/jessie64"
  322. b.vm.provider :virtualbox do |v|
  323. v.memory = 768
  324. end
  325. b.vm.provision "packages debianoid", :type => :shell, :inline => packages_debianoid
  326. b.vm.provision "build env", :type => :shell, :privileged => false, :inline => build_sys_venv("jessie64")
  327. b.vm.provision "install borg", :type => :shell, :privileged => false, :inline => install_borg("jessie64")
  328. b.vm.provision "run tests", :type => :shell, :privileged => false, :inline => run_tests("jessie64")
  329. end
  330. config.vm.define "wheezy32" do |b|
  331. b.vm.box = "boxcutter/debian79-i386"
  332. b.vm.provision "packages prepare wheezy", :type => :shell, :inline => packages_prepare_wheezy
  333. b.vm.provision "packages debianoid", :type => :shell, :inline => packages_debianoid
  334. b.vm.provision "install pyenv", :type => :shell, :privileged => false, :inline => install_pyenv("wheezy32")
  335. b.vm.provision "install pythons", :type => :shell, :privileged => false, :inline => install_pythons("wheezy32")
  336. b.vm.provision "build env", :type => :shell, :privileged => false, :inline => build_pyenv_venv("wheezy32")
  337. b.vm.provision "install borg", :type => :shell, :privileged => false, :inline => install_borg("wheezy32")
  338. b.vm.provision "install pyinstaller", :type => :shell, :privileged => false, :inline => install_pyinstaller("wheezy32")
  339. b.vm.provision "build binary with pyinstaller", :type => :shell, :privileged => false, :inline => build_binary_with_pyinstaller("wheezy32")
  340. b.vm.provision "run tests", :type => :shell, :privileged => false, :inline => run_tests("wheezy32")
  341. end
  342. config.vm.define "wheezy64" do |b|
  343. b.vm.box = "boxcutter/debian79"
  344. b.vm.provision "packages prepare wheezy", :type => :shell, :inline => packages_prepare_wheezy
  345. b.vm.provision "packages debianoid", :type => :shell, :inline => packages_debianoid
  346. b.vm.provision "install pyenv", :type => :shell, :privileged => false, :inline => install_pyenv("wheezy64")
  347. b.vm.provision "install pythons", :type => :shell, :privileged => false, :inline => install_pythons("wheezy64")
  348. b.vm.provision "build env", :type => :shell, :privileged => false, :inline => build_pyenv_venv("wheezy64")
  349. b.vm.provision "install borg", :type => :shell, :privileged => false, :inline => install_borg("wheezy64")
  350. b.vm.provision "install pyinstaller", :type => :shell, :privileged => false, :inline => install_pyinstaller("wheezy64")
  351. b.vm.provision "build binary with pyinstaller", :type => :shell, :privileged => false, :inline => build_binary_with_pyinstaller("wheezy64")
  352. b.vm.provision "run tests", :type => :shell, :privileged => false, :inline => run_tests("wheezy64")
  353. end
  354. # OS X
  355. config.vm.define "darwin64" do |b|
  356. b.vm.box = "jhcook/yosemite-clitools"
  357. b.vm.provision "packages darwin", :type => :shell, :privileged => false, :inline => packages_darwin
  358. b.vm.provision "install pyenv", :type => :shell, :privileged => false, :inline => install_pyenv("darwin64")
  359. b.vm.provision "fix pyenv", :type => :shell, :privileged => false, :inline => fix_pyenv_darwin("darwin64")
  360. b.vm.provision "install pythons", :type => :shell, :privileged => false, :inline => install_pythons("darwin64")
  361. b.vm.provision "build env", :type => :shell, :privileged => false, :inline => build_pyenv_venv("darwin64")
  362. b.vm.provision "install borg", :type => :shell, :privileged => false, :inline => install_borg("darwin64")
  363. b.vm.provision "install pyinstaller", :type => :shell, :privileged => false, :inline => install_pyinstaller("darwin64")
  364. b.vm.provision "build binary with pyinstaller", :type => :shell, :privileged => false, :inline => build_binary_with_pyinstaller("darwin64")
  365. b.vm.provision "run tests", :type => :shell, :privileged => false, :inline => run_tests("darwin64")
  366. end
  367. # BSD
  368. config.vm.define "freebsd64" do |b|
  369. b.vm.box = "geoffgarside/freebsd-10.2"
  370. b.vm.provider :virtualbox do |v|
  371. v.memory = 768
  372. end
  373. b.vm.provision "install system packages", :type => :shell, :inline => packages_freebsd
  374. b.vm.provision "install pyenv", :type => :shell, :privileged => false, :inline => install_pyenv("freebsd")
  375. b.vm.provision "install pythons", :type => :shell, :privileged => false, :inline => install_pythons("freebsd")
  376. b.vm.provision "build env", :type => :shell, :privileged => false, :inline => build_pyenv_venv("freebsd")
  377. b.vm.provision "install borg", :type => :shell, :privileged => false, :inline => install_borg("freebsd")
  378. b.vm.provision "install pyinstaller", :type => :shell, :privileged => false, :inline => install_pyinstaller_bootloader("freebsd")
  379. b.vm.provision "build binary with pyinstaller", :type => :shell, :privileged => false, :inline => build_binary_with_pyinstaller("freebsd")
  380. b.vm.provision "run tests", :type => :shell, :privileged => false, :inline => run_tests("freebsd")
  381. end
  382. config.vm.define "openbsd64" do |b|
  383. b.vm.box = "bodgit/openbsd-5.7-amd64"
  384. b.vm.provider :virtualbox do |v|
  385. v.memory = 768
  386. end
  387. b.vm.provision "packages openbsd", :type => :shell, :inline => packages_openbsd
  388. b.vm.provision "build env", :type => :shell, :privileged => false, :inline => build_sys_venv("openbsd64")
  389. b.vm.provision "install borg", :type => :shell, :privileged => false, :inline => install_borg("openbsd64")
  390. b.vm.provision "run tests", :type => :shell, :privileged => false, :inline => run_tests("openbsd64")
  391. end
  392. config.vm.define "netbsd64" do |b|
  393. b.vm.box = "alex-skimlinks/netbsd-6.1.5-amd64"
  394. b.vm.provider :virtualbox do |v|
  395. v.memory = 768
  396. end
  397. b.vm.provision "packages netbsd", :type => :shell, :inline => packages_netbsd
  398. b.vm.provision "build env", :type => :shell, :privileged => false, :inline => build_sys_venv("netbsd64")
  399. b.vm.provision "install borg", :type => :shell, :privileged => false, :inline => install_borg("netbsd64")
  400. b.vm.provision "run tests", :type => :shell, :privileged => false, :inline => run_tests("netbsd64")
  401. end
  402. end