From 208d10c919772625bf67cd22b414c9adbd74d747 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Sun, 20 Oct 2013 22:51:06 +0200 Subject: [PATCH] Review and clean the vagrant setup, add tests. --- .gitignore | 4 +++ Makefile | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ Vagrantfile | 5 +++- bootstrap.sh | 72 ++++++++++----------------------------------------- test/Makefile | 9 +++++++ 5 files changed, 99 insertions(+), 60 deletions(-) create mode 100644 Makefile create mode 100644 test/Makefile diff --git a/.gitignore b/.gitignore index 2358c876..e940a57e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ .vagrant local-data +pgloader.1 +pgloader.html +pgloader.pdf +build/ diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..54eee858 --- /dev/null +++ b/Makefile @@ -0,0 +1,69 @@ +# pgloader build tools + +POMO_PATCH = $(realpath patches/postmodern-send-copy-done.patch) +ASDF_CONFD = ~/.config/common-lisp/source-registry.conf.d +ASDF_CONF = $(ASDF_CONFD)/projects.conf + +docs: + pandoc pgloader.1.md -o pgloader.1 + pandoc pgloader.1.md -o pgloader.html + pandoc pgloader.1.md -o pgloader.pdf + +~/quicklisp/local-projects/Postmodern: + git clone https://github.com/marijnh/Postmodern.git $@ + cd ~/quicklisp/local-projects/Postmodern/ && patch -p1 < $(POMO_PATCH) + +postmodern: ~/quicklisp/local-projects/Postmodern ; + +~/quicklisp/local-projects/cl-csv: + git clone -b empty-strings-and-nil https://github.com/dimitri/cl-csv.git $@ + +cl-csv: ~/quicklisp/local-projects/cl-csv ; + +~/quicklisp/setup.lisp: + curl -o ~/quicklisp.lisp http://beta.quicklisp.org/quicklisp.lisp + sbcl --load ~/quicklisp.lisp \ + --eval '(quicklisp-quickstart:install)' \ + --eval '(quit)' + +quicklisp: ~/quicklisp/setup.lisp ; + +$(ASDF_CONF): + mkdir -p $(ASDF_CONFD) + echo '(:tree "/vagrant")' > $@ + +asdf-config: $(ASDF_CONF) ; + +libs: quicklisp $(ASDF_CONF) postmodern cl-csv + # Quicklisp Install needed Common Lisp libs + sbcl --load ~/quicklisp/setup.lisp \ + --eval '(ql:quickload "pgloader")' \ + --eval '(quit)' + +./build/manifest.ql: libs + sbcl --load ~/quicklisp/setup.lisp \ + --eval '(ql:write-asdf-manifest-file "./build/manifest.ql")' \ + --eval '(quit)' + +./build/buildapp: quicklisp + sbcl --load ~/quicklisp/setup.lisp \ + --eval '(ql:quickload "buildapp")' \ + --eval '(buildapp:build-buildapp "./build/buildapp")' \ + --eval '(quit)' + +./build/pgloader.exe: ./build/buildapp ./build/manifest.ql + ./build/buildapp --logfile /tmp/build.log \ + --asdf-tree ~/quicklisp/local-projects \ + --manifest-file ./build/manifest.ql \ + --asdf-tree ~/quicklisp/dists \ + --asdf-path . \ + --load-system pgloader \ + --entry pgloader:main \ + --dynamic-space-size 4096 \ + --compress-core \ + --output build/pgloader.exe + +test: ./build/pgloader.exe + $(MAKE) PGLOADER=build/pgloader.exe -C test all + +check: test ; diff --git a/Vagrantfile b/Vagrantfile index 3a4c3321..5cc42175 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -7,5 +7,8 @@ VAGRANTFILE_API_VERSION = "2" Vagrant.configure("2") do |config| config.vm.box = "wheezy64" - config.vm.provision :shell, :path => "bootstrap.sh" + config.vm.provision "shell" do |s| + s.path = "bootstrap.sh" + s.privileged = false + end end diff --git a/bootstrap.sh b/bootstrap.sh index 8e8ad060..53b64fcc 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,70 +1,24 @@ #!/usr/bin/env bash -echo "deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main" > /etc/apt/sources.list.d/pgdg.list +pgdg=/etc/apt/sources.list.d/pgdg.list +pgdgkey=https://www.postgresql.org/media/keys/ACCC4CF8.asc +echo "deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main" | sudo tee $pgdg -wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - +wget --quiet -O - ${pgdgkey} | sudo apt-key add - -apt-get update -apt-get install -y postgresql-9.3 postgresql-contrib-9.3 -apt-get install -y sbcl libmysqlclient-dev git patch unzip +sudo apt-get update +sudo apt-get install -y postgresql-9.3 postgresql-contrib-9.3 \ + postgresql-9.3-ip4r \ + sbcl \ + git patch unzip \ + libmysqlclient-dev HBA=/etc/postgresql/9.3/main/pg_hba.conf echo "local all all trust" | sudo tee $HBA echo "host all all 127.0.0.1/32 trust" | sudo tee -a $HBA sudo pg_ctlcluster 9.3 main reload -createuser -U postgres -SdR `whoami` -createdb pgloader +sudo createuser -U postgres -SdR `whoami` +sudo createdb -U postgres -O `whoami` pgloader -wget --quiet http://beta.quicklisp.org/quicklisp.lisp -sbcl --load quicklisp.lisp < $REGISTRY/projects.conf - -# echo "BUILDING PGLOADER SELF-CONTAINED BINARY" - -# /home/vagrant/buildapp --logfile /tmp/build.log \ -# --asdf-tree ~/quicklisp/dists \ -# --asdf-tree /vagrant \ -# --load-system pgloader \ -# --entry pgloader:main \ -# --dynamic-space-size 4096 \ -# --output /home/vagrant/pgloader.exe - -echo "TESTING" - -/vagrant/pgloader.lisp --help - -for test in /vagrant/test/*.load -do - echo "# TEST: $test" - echo - /vagrant/pgloader.lisp $test - echo -done +make -C /vagrant test diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 00000000..d0a64ad0 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,9 @@ +TESTS = $(wildcard *.load) +OUT = $(TESTS:.load=.out) + +all: $(OUT) + echo $(OUT) + +%.out: %.load + $(PGLOADER) --verbose $< + @echo