Vagrantfile 19 KB

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