From 39e5f2ef23a94382b21831983ff8fd4d9cd3bf53 Mon Sep 17 00:00:00 2001
From: Jerome Charaoui <jerome@riseup.net>
Date: Mon, 25 Jan 2021 09:44:36 -0500
Subject: [PATCH] tests: generate buildscript in vagrant test box

---
 README_tests.md |  5 ++++-
 Vagrantfile     | 15 ++++++++++-----
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/README_tests.md b/README_tests.md
index efaef30..556444c 100644
--- a/README_tests.md
+++ b/README_tests.md
@@ -17,13 +17,16 @@ Once the requirements are in place, the test suite may be run in this manner:
     git clone git@0xacab.org:liberate/backupninja.git
     cd backupninja
     vagrant up
-    vagrant rsync
     vagrant ssh -c "sudo /vagrant/test/test.sh"
 
 It's possible to only test a specific handler with:
 
     vagrant ssh -c "sudo /vagrant/test/test.sh rdiff"
 
+To synchronise changes in the source code and rebuild backupninja:
+
+    vagrant rsync local && vagrant ssh -c "build-backupninja.sh"
+
 Please report any problems with the test suite on the issue tracker at:
 
     https://0xacab.org/liberate/backupninja/-/issues
diff --git a/Vagrantfile b/Vagrantfile
index eb824cc..1de10f8 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -41,11 +41,16 @@ Vagrant.configure("2") do |config|
       locale-gen
       apt-get update
       apt-get install -y automake make dialog sshpass
-      cd /vagrant
-      ./autogen.sh
-      ./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib --libexecdir=/usr/lib
-      make
-      make install
+      BUILDSCRIPT="/usr/local/bin/build-backupninja.sh"
+      echo "#!/bin/sh" >> $BUILDSCRIPT
+      echo "cd /vagrant" >> $BUILDSCRIPT
+      echo "make clean" >> $BUILDSCRIPT
+      echo "./autogen.sh" >> $BUILDSCRIPT
+      echo "./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib --libexecdir=/usr/lib" >> $BUILDSCRIPT
+      echo "make" >> $BUILDSCRIPT
+      echo "sudo make install" >> $BUILDSCRIPT
+      chmod +x $BUILDSCRIPT
+      $BUILDSCRIPT
       mkdir -p /root/.ssh
       yes y | ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519 -N ''
       echo "StrictHostKeyChecking accept-new" >> /root/.ssh/config
-- 
GitLab