Vagrantfile 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. require 'date'
  2. Vagrant.configure(2) do |config|
  3. # We use Ubuntu instead of Debian because the image comes with two-way
  4. # shared folder support by default.
  5. UBUNTU = 'ubuntu/xenial64'
  6. # The main VM is the one used for development and testing.
  7. config.vm.define(:exa, primary: true) do |config|
  8. config.vm.provider :virtualbox do |v|
  9. v.name = 'exa'
  10. v.memory = 1024
  11. v.cpus = 1
  12. end
  13. config.vm.box = UBUNTU
  14. config.vm.hostname = 'exa'
  15. # Make sure we know the VM image’s default user name. The ‘cassowary’ user
  16. # (specified later) is used for most of the test *output*, but we still
  17. # need to know where the ‘target’ and ‘.cargo’ directories go.
  18. developer = 'ubuntu'
  19. # Install the dependencies needed for exa to build, as quietly as
  20. # apt can do.
  21. config.vm.provision :shell, privileged: true, inline: <<-EOF
  22. set -xe
  23. apt-get update
  24. apt-get install -qq -o=Dpkg::Use-Pty=0 -y \
  25. git cmake curl attr libgit2-dev zip \
  26. fish zsh bash bash-completion
  27. EOF
  28. # Guarantee that the timezone is UTC -- some of the tests
  29. # depend on this (for now).
  30. config.vm.provision :shell, privileged: true, inline:
  31. %[timedatectl set-timezone UTC]
  32. # Install Rust.
  33. # This is done as vagrant, not root, because it’s vagrant
  34. # who actually uses it. Sent to /dev/null because the progress
  35. # bar produces a ton of output.
  36. config.vm.provision :shell, privileged: false, inline:
  37. %[hash rustc &>/dev/null || curl -sSf https://static.rust-lang.org/rustup.sh | sh &> /dev/null]
  38. # Use a different ‘target’ directory on the VM than on the host.
  39. # By default it just uses the one in /vagrant/target, which can
  40. # cause problems if it has different permissions than the other
  41. # directories, or contains object files compiled for the host.
  42. config.vm.provision :shell, privileged: true, inline: <<-EOF
  43. echo 'PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/#{developer}/.cargo/bin"' > /etc/environment
  44. echo 'CARGO_TARGET_DIR="/home/#{developer}/target"' >> /etc/environment
  45. EOF
  46. # Create a variety of misc scripts.
  47. config.vm.provision :shell, privileged: true, inline: <<-EOF
  48. set -xe
  49. echo -e "#!/bin/sh\n/home/#{developer}/target/debug/exa \"\\$*\"" > /usr/bin/exa
  50. echo -e "#!/bin/sh\n/home/#{developer}/target/release/exa \"\\$*\"" > /usr/bin/rexa
  51. echo -e "#!/bin/sh\ncargo build --manifest-path /vagrant/Cargo.toml" > /usr/bin/build-exa
  52. ln -sf /usr/bin/build-exa /usr/bin/b
  53. echo -e "#!/bin/sh\ncargo test --manifest-path /vagrant/Cargo.toml --lib -- --quiet" > /usr/bin/test-exa
  54. ln -sf /usr/bin/test-exa /usr/bin/t
  55. echo -e "#!/bin/sh\n/vagrant/xtests/run.sh" > /usr/bin/run-xtests
  56. ln -sf /usr/bin/run-xtests /usr/bin/x
  57. echo -e "#!/bin/sh\nbuild-exa && test-exa && run-xtests" > /usr/bin/compile-exa
  58. ln -sf /usr/bin/compile-exa /usr/bin/c
  59. echo -e "#!/bin/sh\nbash /vagrant/devtools/dev-package-for-linux.sh" > /usr/bin/package-exa
  60. chmod +x /usr/bin/{exa,rexa,b,t,x,c,build-exa,test-exa,run-xtests,compile-exa,package-exa}
  61. EOF
  62. # Download my patched version of git2-rs.
  63. # This is basically a hack and we should get rid of it as soon as
  64. # a better solution comes along.
  65. # See https://github.com/ogham/exa/issues/194
  66. config.vm.provision :shell, privileged: false, inline: <<-EOF
  67. set -xe
  68. if [ -d /home/ubuntu/git2-rs ]; then
  69. cd /home/ubuntu/git2-rs
  70. git pull https://github.com/ogham/git2-rs.git || echo "Failed to update git2-rs fork"
  71. else
  72. git clone https://github.com/ogham/git2-rs.git /home/ubuntu/git2-rs
  73. fi
  74. mkdir -p /home/ubuntu/.cargo
  75. echo 'paths = ["/home/ubuntu/git2-rs/libgit2-sys"]' > /home/ubuntu/.cargo/config
  76. EOF
  77. # This fix is applied by changing the VM rather than changing the
  78. # Cargo.toml file so it works for everyone because it’s such a niche
  79. # build issue, it’s not worth specifying a non-crates.io dependency
  80. # and losing the ability to `cargo publish` the exa crate there!
  81. # It also isolates the hackiness to the one place I can test it
  82. # actually works.
  83. # Configure the welcoming text that gets shown.
  84. config.vm.provision :shell, privileged: true, inline: <<-EOF
  85. rm -f /etc/update-motd.d/*
  86. # Capture the help text so it gets displayed first
  87. bash /vagrant/devtools/dev-help.sh > /etc/motd
  88. # Tell bash to execute a bunch of stuff when a session starts
  89. echo "source /vagrant/devtools/dev-bash.sh" > /home/ubuntu/.bash_profile
  90. # Disable last login date in sshd
  91. sed -i '/PrintLastLog yes/c\PrintLastLog no' /etc/ssh/sshd_config
  92. systemctl restart sshd
  93. EOF
  94. # Link the completion files so they’re “installed”.
  95. config.vm.provision :shell, privileged: true, inline: <<-EOF
  96. set -xe
  97. test -h /etc/bash_completion.d/exa \
  98. || ln -s /vagrant/contrib/completions.bash /etc/bash_completion.d/exa
  99. test -h /usr/share/zsh/vendor-completions/_exa \
  100. || ln -s /vagrant/contrib/completions.zsh /usr/share/zsh/vendor-completions/_exa
  101. test -h /usr/share/fish/completions/exa.fish \
  102. || ln -s /vagrant/contrib/completions.fish /usr/share/fish/completions/exa.fish
  103. EOF
  104. # We create two users that own the test files.
  105. # The first one just owns the ordinary ones, because we don’t want the
  106. # test outputs to depend on “vagrant” or “ubuntu” existing.
  107. user = "cassowary"
  108. config.vm.provision :shell, privileged: true, inline:
  109. %[id -u #{user} &>/dev/null || useradd #{user}]
  110. # The second one has a long name, to test that the file owner column
  111. # widens correctly. The benefit of Vagrant is that we don’t need to
  112. # set this up on the *actual* system!
  113. longuser = "antidisestablishmentarienism"
  114. config.vm.provision :shell, privileged: true, inline:
  115. %[id -u #{longuser} &>/dev/null || useradd #{longuser}]
  116. # Because the timestamps are formatted differently depending on whether
  117. # they’re in the current year or not (see `details.rs`), we have to make
  118. # sure that the files are created in the current year, so they get shown
  119. # in the format we expect.
  120. current_year = Date.today.year
  121. some_date = "#{current_year}01011234.56" # 1st January, 12:34:56
  122. # We also need an UID and a GID that are guaranteed to not exist, to
  123. # test what happen when they don’t.
  124. invalid_uid = 666
  125. invalid_gid = 616
  126. # Delete old testcases if they exist already, then create a
  127. # directory to house new ones.
  128. test_dir = "/testcases"
  129. config.vm.provision :shell, privileged: true, inline: <<-EOF
  130. set -xe
  131. rm -rfv #{test_dir}
  132. mkdir #{test_dir}
  133. chmod 777 #{test_dir}
  134. EOF
  135. # Awkward file size testcases.
  136. # This needs sudo to set the files’ users at the very end.
  137. config.vm.provision :shell, privileged: false, inline: <<-EOF
  138. set -xe
  139. mkdir "#{test_dir}/files"
  140. for i in {1..13}; do
  141. fallocate -l "$i" "#{test_dir}/files/$i"_bytes
  142. fallocate -l "$i"KiB "#{test_dir}/files/$i"_KiB
  143. fallocate -l "$i"MiB "#{test_dir}/files/$i"_MiB
  144. done
  145. touch -t #{some_date} "#{test_dir}/files/"*
  146. chmod 644 "#{test_dir}/files/"*
  147. sudo chown #{user}:#{user} "#{test_dir}/files/"*
  148. EOF
  149. # File name extension testcases.
  150. # These aren’t tested in details view, but we set timestamps on them to
  151. # test that various sort options work.
  152. config.vm.provision :shell, privileged: false, inline: <<-EOF
  153. set -xe
  154. mkdir "#{test_dir}/file-names-exts"
  155. touch "#{test_dir}/file-names-exts/Makefile"
  156. touch "#{test_dir}/file-names-exts/IMAGE.PNG"
  157. touch "#{test_dir}/file-names-exts/image.svg"
  158. touch "#{test_dir}/file-names-exts/VIDEO.AVI"
  159. touch "#{test_dir}/file-names-exts/video.wmv"
  160. touch "#{test_dir}/file-names-exts/music.mp3"
  161. touch "#{test_dir}/file-names-exts/MUSIC.OGG"
  162. touch "#{test_dir}/file-names-exts/lossless.flac"
  163. touch "#{test_dir}/file-names-exts/lossless.wav"
  164. touch "#{test_dir}/file-names-exts/crypto.asc"
  165. touch "#{test_dir}/file-names-exts/crypto.signature"
  166. touch "#{test_dir}/file-names-exts/document.pdf"
  167. touch "#{test_dir}/file-names-exts/DOCUMENT.XLSX"
  168. touch "#{test_dir}/file-names-exts/COMPRESSED.ZIP"
  169. touch "#{test_dir}/file-names-exts/compressed.tar.gz"
  170. touch "#{test_dir}/file-names-exts/compressed.tgz"
  171. touch "#{test_dir}/file-names-exts/compressed.tar.xz"
  172. touch "#{test_dir}/file-names-exts/compressed.txz"
  173. touch "#{test_dir}/file-names-exts/compressed.deb"
  174. touch "#{test_dir}/file-names-exts/backup~"
  175. touch "#{test_dir}/file-names-exts/#SAVEFILE#"
  176. touch "#{test_dir}/file-names-exts/file.tmp"
  177. touch "#{test_dir}/file-names-exts/compiled.class"
  178. touch "#{test_dir}/file-names-exts/compiled.o"
  179. touch "#{test_dir}/file-names-exts/compiled.js"
  180. touch "#{test_dir}/file-names-exts/compiled.coffee"
  181. EOF
  182. # File name testcases.
  183. # bash really doesn’t want you to create a file with escaped characters
  184. # in its name, so we have to resort to the echo builtin and touch!
  185. #
  186. # The double backslashes are not strictly necessary; without them, Ruby
  187. # will interpolate them instead of bash, but because Vagrant prints out
  188. # each command it runs, your *own* terminal will go “ding” from the alarm!
  189. config.vm.provision :shell, privileged: false, inline: <<-EOF
  190. set -xe
  191. mkdir "#{test_dir}/file-names"
  192. echo -ne "#{test_dir}/file-names/ascii: hello" | xargs -0 touch
  193. echo -ne "#{test_dir}/file-names/emoji: [🆒]" | xargs -0 touch
  194. echo -ne "#{test_dir}/file-names/utf-8: pâté" | xargs -0 touch
  195. echo -ne "#{test_dir}/file-names/bell: [\\a]" | xargs -0 touch
  196. echo -ne "#{test_dir}/file-names/backspace: [\\b]" | xargs -0 touch
  197. echo -ne "#{test_dir}/file-names/form-feed: [\\f]" | xargs -0 touch
  198. echo -ne "#{test_dir}/file-names/new-line: [\\n]" | xargs -0 touch
  199. echo -ne "#{test_dir}/file-names/return: [\\r]" | xargs -0 touch
  200. echo -ne "#{test_dir}/file-names/tab: [\\t]" | xargs -0 touch
  201. echo -ne "#{test_dir}/file-names/vertical-tab: [\\v]" | xargs -0 touch
  202. echo -ne "#{test_dir}/file-names/escape: [\\033]" | xargs -0 touch
  203. echo -ne "#{test_dir}/file-names/ansi: [\\033[34mblue\\033[0m]" | xargs -0 touch
  204. echo -ne "#{test_dir}/file-names/invalid-utf8-1: [\\xFF]" | xargs -0 touch
  205. echo -ne "#{test_dir}/file-names/invalid-utf8-2: [\\xc3\\x28]" | xargs -0 touch
  206. echo -ne "#{test_dir}/file-names/invalid-utf8-3: [\\xe2\\x82\\x28]" | xargs -0 touch
  207. echo -ne "#{test_dir}/file-names/invalid-utf8-4: [\\xf0\\x28\\x8c\\x28]" | xargs -0 touch
  208. echo -ne "#{test_dir}/file-names/new-line-dir: [\\n]" | xargs -0 mkdir
  209. echo -ne "#{test_dir}/file-names/new-line-dir: [\\n]/subfile" | xargs -0 touch
  210. echo -ne "#{test_dir}/file-names/new-line-dir: [\\n]/another: [\\n]" | xargs -0 touch
  211. echo -ne "#{test_dir}/file-names/new-line-dir: [\\n]/broken" | xargs -0 touch
  212. mkdir "#{test_dir}/file-names/links"
  213. ln -s "#{test_dir}/file-names/new-line-dir"*/* "#{test_dir}/file-names/links"
  214. echo -ne "#{test_dir}/file-names/new-line-dir: [\\n]/broken" | xargs -0 rm
  215. EOF
  216. # Special file testcases.
  217. config.vm.provision :shell, privileged: false, inline: <<-EOF
  218. set -xe
  219. mkdir "#{test_dir}/specials"
  220. sudo mknod "#{test_dir}/specials/block-device" b 3 60
  221. sudo mknod "#{test_dir}/specials/char-device" c 14 40
  222. sudo mknod "#{test_dir}/specials/named-pipe" p
  223. sudo touch -t #{some_date} "#{test_dir}/specials/"*
  224. EOF
  225. # Awkward symlink testcases.
  226. config.vm.provision :shell, privileged: false, inline: <<-EOF
  227. set -xe
  228. mkdir "#{test_dir}/links"
  229. ln -s / "#{test_dir}/links/root"
  230. ln -s /usr "#{test_dir}/links/usr"
  231. ln -s nowhere "#{test_dir}/links/broken"
  232. ln -s /proc/1/root "#{test_dir}/links/forbidden"
  233. touch "#{test_dir}/links/some_file"
  234. ln -s "#{test_dir}/links/some_file" "#{test_dir}/links/some_file_absolute"
  235. (cd "#{test_dir}/links"; ln -s "some_file" "some_file_relative")
  236. (cd "#{test_dir}/links"; ln -s "." "current_dir")
  237. (cd "#{test_dir}/links"; ln -s ".." "parent_dir")
  238. (cd "#{test_dir}/links"; ln -s "itself" "itself")
  239. EOF
  240. # Awkward passwd testcases.
  241. # sudo is needed for these because we technically aren’t a member
  242. # of the groups (because they don’t exist), and chown and chgrp
  243. # are smart enough to disallow it!
  244. config.vm.provision :shell, privileged: false, inline: <<-EOF
  245. set -xe
  246. mkdir "#{test_dir}/passwd"
  247. touch -t #{some_date} "#{test_dir}/passwd/unknown-uid"
  248. chmod 644 "#{test_dir}/passwd/unknown-uid"
  249. sudo chown #{invalid_uid}:#{user} "#{test_dir}/passwd/unknown-uid"
  250. touch -t #{some_date} "#{test_dir}/passwd/unknown-gid"
  251. chmod 644 "#{test_dir}/passwd/unknown-gid"
  252. sudo chown #{user}:#{invalid_gid} "#{test_dir}/passwd/unknown-gid"
  253. EOF
  254. # Awkward permission testcases.
  255. # Differences in the way ‘chmod’ handles setting ‘setuid’ and ‘setgid’
  256. # when you don’t already own the file mean that we need to use ‘sudo’
  257. # to change permissions to those.
  258. config.vm.provision :shell, privileged: false, inline: <<-EOF
  259. set -xe
  260. mkdir "#{test_dir}/permissions"
  261. mkdir "#{test_dir}/permissions/forbidden-directory"
  262. chmod 000 "#{test_dir}/permissions/forbidden-directory"
  263. touch -t #{some_date} "#{test_dir}/permissions/forbidden-directory"
  264. sudo chown #{user}:#{user} "#{test_dir}/permissions/forbidden-directory"
  265. for perms in 000 001 002 004 010 020 040 100 200 400 644 755 777 1000 1001 2000 2010 4000 4100 7666 7777; do
  266. touch "#{test_dir}/permissions/$perms"
  267. sudo chown #{user}:#{user} "#{test_dir}/permissions/$perms"
  268. sudo chmod $perms "#{test_dir}/permissions/$perms"
  269. sudo touch -t #{some_date} "#{test_dir}/permissions/$perms"
  270. done
  271. EOF
  272. old = '200303030000.00'
  273. med = '200606152314.29' # the june gets used for fr_FR locale tests
  274. new = '200912221038.53' # and the december for ja_JP local tests
  275. # Awkward date and time testcases.
  276. config.vm.provision :shell, privileged: false, inline: <<-EOF
  277. set -xe
  278. mkdir "#{test_dir}/dates"
  279. # there's no way to touch the created date of a file...
  280. # so we have to do this the old-fashioned way!
  281. # (and make sure these don't actually get listed)
  282. touch -t #{old} "#{test_dir}/dates/peach"; sleep 1
  283. touch -t #{med} "#{test_dir}/dates/plum"; sleep 1
  284. touch -t #{new} "#{test_dir}/dates/pear"
  285. # modified dates
  286. touch -t #{old} -m "#{test_dir}/dates/pear"
  287. touch -t #{med} -m "#{test_dir}/dates/peach"
  288. touch -t #{new} -m "#{test_dir}/dates/plum"
  289. # accessed dates
  290. touch -t #{old} -a "#{test_dir}/dates/plum"
  291. touch -t #{med} -a "#{test_dir}/dates/pear"
  292. touch -t #{new} -a "#{test_dir}/dates/peach"
  293. sudo chown #{user}:#{user} -R "#{test_dir}/dates"
  294. EOF
  295. # Awkward extended attribute testcases.
  296. # We need to test combinations of various numbers of files *and*
  297. # extended attributes in directories. Turns out, the easiest way to
  298. # do this is to generate all combinations of files with “one-xattr”
  299. # or “two-xattrs” in their name and directories with “empty” or
  300. # “one-file” in their name, then just give the right number of
  301. # xattrs and children to those.
  302. config.vm.provision :shell, privileged: false, inline: <<-EOF
  303. set -xe
  304. mkdir "#{test_dir}/attributes"
  305. mkdir "#{test_dir}/attributes/files"
  306. touch "#{test_dir}/attributes/files/"{no-xattrs,one-xattr,two-xattrs}{,_forbidden}
  307. mkdir "#{test_dir}/attributes/dirs"
  308. mkdir "#{test_dir}/attributes/dirs/"{no-xattrs,one-xattr,two-xattrs}_{empty,one-file,two-files}{,_forbidden}
  309. setfattr -n user.greeting -v hello "#{test_dir}/attributes"/**/*{one-xattr,two-xattrs}*
  310. setfattr -n user.another_greeting -v hi "#{test_dir}/attributes"/**/*two-xattrs*
  311. for dir in "#{test_dir}/attributes/dirs/"*one-file*; do
  312. touch $dir/file-in-question
  313. done
  314. for dir in "#{test_dir}/attributes/dirs/"*two-files*; do
  315. touch $dir/this-file
  316. touch $dir/that-file
  317. done
  318. find "#{test_dir}/attributes" -exec touch {} -t #{some_date} \\;
  319. # I want to use the following to test,
  320. # but it only works on macos:
  321. #chmod +a "#{user} deny readextattr" "#{test_dir}/attributes"/**/*_forbidden
  322. sudo chmod 000 "#{test_dir}/attributes"/**/*_forbidden
  323. sudo chown #{user}:#{user} -R "#{test_dir}/attributes"
  324. EOF
  325. # A sample Git repository
  326. # This uses cd because it's easier than telling Git where to go each time
  327. config.vm.provision :shell, privileged: false, inline: <<-EOF
  328. set -xe
  329. mkdir "#{test_dir}/git"
  330. cd "#{test_dir}/git"
  331. git init
  332. mkdir edits additions moves
  333. echo "original content" | tee edits/{staged,unstaged,both}
  334. echo "this file gets moved" > moves/hither
  335. git add edits moves
  336. git commit -m "Automated test commit"
  337. echo "modifications!" | tee edits/{staged,both}
  338. touch additions/{staged,edited}
  339. mv moves/{hither,thither}
  340. git add edits moves additions
  341. echo "more modifications!" | tee edits/unstaged edits/both additions/edited
  342. touch additions/unstaged
  343. find "#{test_dir}/git" -exec touch {} -t #{some_date} \\;
  344. sudo chown #{user}:#{user} -R "#{test_dir}/git"
  345. EOF
  346. # A second Git repository
  347. # for testing two at once
  348. config.vm.provision :shell, privileged: false, inline: <<-EOF
  349. set -xe
  350. mkdir -p "#{test_dir}/git2/deeply/nested/directory"
  351. cd "#{test_dir}/git2"
  352. git init
  353. touch "deeply/nested/directory/upd8d"
  354. git add "deeply/nested/directory/upd8d"
  355. git commit -m "Automated test commit"
  356. echo "Now with contents" > "deeply/nested/directory/upd8d"
  357. touch "deeply/nested/directory/l8st"
  358. echo -e "target\n*.mp3" > ".gitignore"
  359. mkdir "ignoreds"
  360. touch "ignoreds/music.mp3"
  361. touch "ignoreds/music.m4a"
  362. mkdir "ignoreds/nested"
  363. touch "ignoreds/nested/70s grove.mp3"
  364. touch "ignoreds/nested/funky chicken.m4a"
  365. mkdir "target"
  366. touch "target/another ignored file"
  367. mkdir "deeply/nested/repository"
  368. cd "deeply/nested/repository"
  369. git init
  370. touch subfile
  371. find "#{test_dir}/git2" -exec touch {} -t #{some_date} \\;
  372. sudo chown #{user}:#{user} -R "#{test_dir}/git2"
  373. EOF
  374. # Hidden and dot file testcases.
  375. # We need to set the permissions of `.` and `..` because they actually
  376. # get displayed in the output here, so this has to come last.
  377. config.vm.provision :shell, privileged: false, inline: <<-EOF
  378. set -xe
  379. shopt -u dotglob
  380. GLOBIGNORE=".:.."
  381. mkdir "#{test_dir}/hiddens"
  382. touch "#{test_dir}/hiddens/visible"
  383. touch "#{test_dir}/hiddens/.hidden"
  384. touch "#{test_dir}/hiddens/..extra-hidden"
  385. # ./hiddens/
  386. touch -t #{some_date} "#{test_dir}/hiddens/"*
  387. chmod 644 "#{test_dir}/hiddens/"*
  388. sudo chown #{user}:#{user} "#{test_dir}/hiddens/"*
  389. # .
  390. touch -t #{some_date} "#{test_dir}/hiddens"
  391. chmod 755 "#{test_dir}/hiddens"
  392. sudo chown #{user}:#{user} "#{test_dir}/hiddens"
  393. # ..
  394. sudo touch -t #{some_date} "#{test_dir}"
  395. sudo chmod 755 "#{test_dir}"
  396. sudo chown #{user}:#{user} "#{test_dir}"
  397. EOF
  398. # Set up some locales
  399. config.vm.provision :shell, privileged: false, inline: <<-EOF
  400. set -xe
  401. # uncomment these from the config file
  402. sudo sed -i '/fr_FR.UTF-8/s/^# //g' /etc/locale.gen
  403. sudo sed -i '/ja_JP.UTF-8/s/^# //g' /etc/locale.gen
  404. sudo locale-gen
  405. EOF
  406. # Install kcov for test coverage
  407. # This doesn’t run coverage over the xtests so it’s less useful for now
  408. if ENV.key?('INSTALL_KCOV')
  409. config.vm.provision :shell, privileged: false, inline: <<-EOF
  410. set -xe
  411. test -e ~/.cargo/bin/cargo-kcov \
  412. || cargo install cargo-kcov
  413. sudo apt-get install -qq -o=Dpkg::Use-Pty=0 -y \
  414. cmake g++ pkg-config \
  415. libcurl4-openssl-dev libdw-dev binutils-dev libiberty-dev
  416. cargo kcov --print-install-kcov-sh | sudo sh
  417. EOF
  418. end
  419. end
  420. # Remember that problem that exa had where the binary wasn’t actually
  421. # self-contained? Or the problem where the Linux binary was actually the
  422. # macOS binary in disguise?
  423. #
  424. # This is a “fresh” VM that intentionally downloads no dependencies and
  425. # installs nothing so that we can check that exa still runs!
  426. config.vm.define(:fresh) do |config|
  427. config.vm.box = UBUNTU
  428. config.vm.hostname = 'fresh'
  429. config.vm.provider :virtualbox do |v|
  430. v.name = 'exa-fresh'
  431. v.memory = 384
  432. v.cpus = 1
  433. end
  434. # Well, we do need *one* dependency...
  435. config.vm.provision :shell, privileged: true, inline: <<-EOF
  436. set -xe
  437. apt-get install -qq -o=Dpkg::Use-Pty=0 -y unzip
  438. EOF
  439. # This thing also has its own welcoming text.
  440. config.vm.provision :shell, privileged: true, inline: <<-EOF
  441. rm -f /etc/update-motd.d/*
  442. # Capture the help text so it gets displayed first
  443. bash /vagrant/devtools/dev-help-testvm.sh > /etc/motd
  444. # Disable last login date in sshd
  445. sed -i '/PrintLastLog yes/c\PrintLastLog no' /etc/ssh/sshd_config
  446. systemctl restart sshd
  447. EOF
  448. # Make the checker script a command.
  449. config.vm.provision :shell, privileged: true, inline: <<-EOF
  450. set -xe
  451. echo -e "#!/bin/sh\nbash /vagrant/devtools/dev-download-and-check-release.sh \"\\$*\"" > /usr/bin/check-release
  452. chmod +x /usr/bin/check-release
  453. EOF
  454. end
  455. end