Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to run package check via Vagrant in a VirtualBox #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.*
*.swp
*~
Notes
Expand All @@ -10,4 +11,7 @@ config
*.log
curl_print

*.lock
*.lock

vagrant/repos/
!vagrant/repos/.gitkeep
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ Then test your packages :
./package_check.sh your_app_ynh
```

## Run package check in a VirtualBox VM via Vagrant

We add script to run package check in a VirtualBox. More information here:

* [vagrant/README.md](https://github.com/YunoHost/package_check/tree/master/vagrant)


## You can start a container on a different architecture with some hacks

Install the package `qemu-user-static` and `binfmt-support`, then list of all available images :
Expand Down
75 changes: 75 additions & 0 deletions vagrant/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# "package check" via Vagrant

Run [package check](https://github.com/YunoHost/package_check) in a [VirtualBox](https://www.virtualbox.org/) VM by using [Vagrant](https://www.vagrantup.com/).

## prepare

install VirtualBox and Vagrant:

```
sudo apt install virtualbox vagrant
```

Directory overview:
```
~$ tree package_check/ -dA
package_check/
├── lib
└── vagrant <<< main directory to setup/start package check via Vagrant
├── repos <<< clone your YunoHost apps here
│ └── pyinventory_ynh <<< just a clone example
│ ├── conf
│ ├── scripts
│ └── tests
└── scripts
```

Startup, e.g.:
```
# Clone package check:
~$ git clone https://github.com/YunoHost/package_check.git

# Clone the YunoHost app that you would like to ckec into "repos":
~$ cd package_check/vagrant/repos
~/package_check/vagrant/repos$ git clone https://github.com/YunoHost-Apps/pyinventory_ynh.git

# Start the VirtualBox VM anr run the check:
~/package_check/vagrant$ ./run_package_check.sh repos/pyinventory_ynh/
```

## update

Quick update can look like:
```
# Update package check:
~$ cd package_check
~/package_check$ git pull origin master

# quick update the VM:
~$ cd package_check/vagrant
~/package_check/vagrant$ vagrant reload --provision
```

To get everything completely fresh: destroy the VM and recreate it, e.g.:

```
~$ cd package_check/vagrant
~/package_check/vagrant$ vagrant destroy --force

# Just recreate the VM by run the check, e.g.:
~/package_check/vagrant$ ./run_package_check.sh repos/pyinventory_ynh/
```

## uninstall/cleanup

To remove the VM, just destroy it, e.g.:

```
~$ cd package_check/vagrant
~/package_check/vagrant$ vagrant destroy --force
```

## Links

* Vagrant docs: https://docs.vagrantup.com
* YunoHost "package check": https://github.com/YunoHost/package_check
25 changes: 25 additions & 0 deletions vagrant/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# https://docs.vagrantup.com
# https://github.com/YunoHost/package_check


Vagrant.configure("2") do |config|

# https://app.vagrantup.com/ubuntu/boxes/focal64
config.vm.box = "ubuntu/focal64"

config.vm.provider "virtualbox" do |vb|
vb.name = "package_check"
vb.cpus = 4
vb.memory = "2048"
end

# https://www.vagrantup.com/docs/synced-folders/basic_usage
config.vm.synced_folder "../", "/home/vagrant/package_check/"

# https://www.vagrantup.com/docs/provisioning/shell
config.vm.provision "shell", inline: <<-SHELL
pwd
id
./package_check/vagrant/scripts/provision.sh
SHELL
end
22 changes: 22 additions & 0 deletions vagrant/run_package_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

if [ "$1" == "" ]; then
echo "ERROR: Missing repro name as argument!"
echo "e.g.:"
echo "~$ cd package_check/vagrant/repos"
echo "~/package_check/vagrant/repos$ git clone https://github.com/YunoHost-Apps/pyinventory_ynh.git"
echo "~/package_check/vagrant/repos$ cd .."
echo "~/package_check/vagrant$ ./run_package_check.sh repos/pyinventory_ynh"
exit -1
fi

echo "Package check: '${1}'"
if [ ! -d "${1}" ]; then
echo "ERROR: Repro '${1}' not found !"
exit -1
fi

set -x

vagrant up
vagrant ssh -c "/home/vagrant/package_check/vagrant/scripts/run.sh ${1}"
22 changes: 22 additions & 0 deletions vagrant/scripts/provision.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -x

apt-get update
apt-get dist-upgrade

apt-get install -y python3-pip git snapd lynx jq

snap install core
snap refresh lxd

ln -sf /snap/bin/lxc /usr/local/bin/lxc
ln -sf /snap/bin/lxd /usr/local/bin/lxd

gpasswd -a vagrant lxd

lxd init --auto

lxc remote add yunohost https://devbaseimgs.yunohost.org --public --accept-certificate

exit 0
16 changes: 16 additions & 0 deletions vagrant/scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

cd /home/vagrant/package_check/vagrant/

echo "Package check: '${1}'"

if [ ! -d "${1}" ]; then
echo "ERROR: Repro '${1}' not found!"
exit -1
fi

set -x

lxd init --auto

/home/vagrant/package_check/package_check.sh "${1}"