This commit is contained in:
Jens Diemer 2024-08-16 15:22:54 +02:00 committed by GitHub
commit 451cc9c248
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 172 additions and 1 deletions

6
.gitignore vendored
View file

@ -1,3 +1,4 @@
.*
*.swp *.swp
*~ *~
Notes Notes
@ -10,4 +11,7 @@ config
*.log *.log
curl_print curl_print
*.lock *.lock
vagrant/repos/
!vagrant/repos/.gitkeep

View file

@ -114,6 +114,13 @@ Then test your packages :
./package_check.sh your_app_ynh ./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 ## 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 : Install the package `qemu-user-static` and `binfmt-support`, then list of all available images :

75
vagrant/README.md Normal file
View file

@ -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
vagrant/Vagrantfile vendored Normal file
View file

@ -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
vagrant/run_package_check.sh Executable file
View file

@ -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
vagrant/scripts/provision.sh Executable file
View file

@ -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
vagrant/scripts/run.sh Executable file
View file

@ -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}"