#1066 Refine Vagrantfile
Merged 5 years ago by mprahl. Opened 5 years ago by cqi.
cqi/fm-orchestrator vagrant  into  master

file modified
+50 -12
@@ -1,5 +1,5 @@ 

  # -*- mode: ruby -*-

- # vi: set ft=ruby :

+ # vi: set ft=ruby ts=2 sw=2 ai et:

  

  $script = <<SCRIPT

      grep -q '^127\.0\.0\.1 fedmsg-relay$' /etc/hosts || echo "127.0.0.1 fedmsg-relay" >> /etc/hosts
@@ -38,20 +38,56 @@ 

          redhat-rpm-config \

          redhat-rpm-config \

          rpm-build \

-         swig

-     cd /opt/module_build_service

-     python setup.py develop

-     python setup.py egg_info

-     ln -s /opt/module_build_service/conf /etc/module-build-service

-     pip install -r test-requirements.txt

+         swig \

+         sqlite \

+         glib2-devel \

+         cairo-devel \

+         cairo-gobject-devel \

+         gobject-introspection-devel \

+         bash-completion \

+         wget \

+         which

+ 

+     if [ ! -e /etc/module-build-service ]; then

+         ln -s /opt/module_build_service/conf /etc/module-build-service

+     fi

  SCRIPT

  

+ $make_devenv = <<DEVENV

+   env_dir=~/devenv

+   pip=${env_dir}/bin/pip

+   py=${env_dir}/bin/python

+   code_dir=/opt/module_build_service

+ 

+   test -e $env_dir && rm -rf $env_dir

+ 

+   # solv is not availabe from pypi.org. libsolve has to be installed by dnf.

+   (cd; virtualenv --system-site-packages devenv)

+ 

+   $pip install --upgrade pip

+   $pip install -r $code_dir/test-requirements.txt

+   $pip install ipython

+ 

+   cd $code_dir

+   $py setup.py develop

+   $py setup.py egg_info

+ 

+   if ! grep ". $env_dir/bin/activate" ~/.bashrc >/dev/null; then

+       echo ". $env_dir/bin/activate" >> ~/.bashrc

+   fi

+   if ! grep "^cd $code_dir" ~/.bashrc >/dev/null; then

+       # Go to working directory after login

+       echo "cd $code_dir" >> ~/.bashrc

+   fi

+ DEVENV

+ 

  $script_services = <<SCRIPT_SERVICES

+     bin_dir=~/devenv/bin

      cd /opt/module_build_service

-     mbs-upgradedb > /tmp/mbs-base.out 2>&1

-     fedmsg-relay < /dev/null >& /tmp/fedmsg-relay.out &

-     fedmsg-hub < /dev/null >& /tmp/fedmsg-hub.out &

-     mbs-frontend < /dev/null >& /tmp/mbs-frontend.out &

+     $bin_dir/mbs-upgradedb > /tmp/mbs-base.out 2>&1

+     $bin_dir/fedmsg-relay < /dev/null >& /tmp/fedmsg-relay.out &

+     $bin_dir/fedmsg-hub < /dev/null >& /tmp/fedmsg-hub.out &

+     $bin_dir/mbs-frontend < /dev/null >& /tmp/mbs-frontend.out &

  SCRIPT_SERVICES

  

  Vagrant.configure("2") do |config|
@@ -62,7 +98,9 @@ 

    config.vm.network "forwarded_port", guest_ip: "0.0.0.0", guest: 5000, host: 5000

    config.vm.network "forwarded_port", guest_ip: "0.0.0.0", guest: 13747, host: 13747

    config.vm.provision "shell", inline: $script

-   config.vm.provision "shell", inline: $script_services, run: "always"

+   config.vm.provision "shell", inline: "usermod -a -G mock Vagrant"

+   config.vm.provision "shell", inline: $make_devenv, privileged: false

+   config.vm.provision "shell", inline: $script_services, privileged: false, run: "always"

    config.vm.provider "libvirt" do |v, override|

      override.vm.synced_folder "./", "/opt/module_build_service", type: "sshfs", sshfs_opts_append: "-o nonempty"

      v.memory = 1024

Major change is to create a dedicated Python virtual environment for MBS
instead of installing required packages (listed in requirements) into
system site-packages directory.

This would be convenient for developer to install other Python packages
via package manager, for example to install rhpkg. I found an issue when
I installed rhpkg in original Vagrant machine, that is whole kobo
package is installed via pip, and `dnf install rhpkg' will result in
python2-kobo is installed and then it fails to import module
kobo.rpmlib. The fix is I have to install python2-kobo-rpmlib via dnf
again. With this change, this issue could be avoided. Two environments
are separated rather than mixed together.

Another two minor improvements base on this change are, after logging
into the machine, 1) the virtual environment is activated automatically,
and 2) change working directory to /opt/module_build_service.

Signed-off-by: Chenxiong Qi cqi@redhat.com

rebased onto ad6104ccfa3b38d1eca6fb7fe525297ab6c4e4da

5 years ago

Pretty please pagure-ci rebuild

rebased onto f73115b307f08a439c640c2b5555a8d827f98383

5 years ago

rebased onto eccb239

5 years ago

Looks fine to me. We can always fix any issues that come up later.

Commit fb95b6b fixes this pull-request

Pull-Request has been merged by mprahl

5 years ago

Pull-Request has been merged by mprahl

5 years ago