This commit is contained in:
Alexandre Aubin 2018-09-04 00:15:58 +02:00
parent c938674431
commit 99cba1e489
4 changed files with 53 additions and 42 deletions

8
Vagrantfile vendored
View file

@ -4,11 +4,11 @@
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
NETWORK = "192.168.33."
NETWORK = "10.0.3."
HOSTS = {
"ynh-dev" => ["83", "stretch-unstable"],
"ynh-dev-buster" => ["84", "buster-unstable"],
"ynh-dev" => ["83", "ynh-dev"],
"ynh-dev-buster" => ["84", "ynh-dev-buster"],
}
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
@ -25,7 +25,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
machine.vm.guest = :debian
machine.vm.provider "lxc" do |lxc|
config.vm.box_url = "https://build.yunohost.org/yunohost-" + version + "-lxc.box"
config.vm.box_url = "https://build.yunohost.org/" + version + "-lxc.box"
config.vm.synced_folder ".", "/ynh-dev", id: "vagrant-root"
config.vm.network :private_network, ip: NETWORK + ipaddr, lxc__bridge_name: 'lxcbr0'
end

View file

@ -8,7 +8,7 @@ set -x
sudo apt-get install vagrant lxc git -y
git clone https://github.com/YunoHost/ynh-dev
git clone https://github.com/alexAubin/ynh-dev
cd ./ynh-dev
git clone https://github.com/YunoHost/moulinette
git clone https://github.com/YunoHost/yunohost

View file

@ -1,23 +1,19 @@
#!/bin/bash
DEBIAN_VERSION="stretch"
YNH_VERSION="unstable"
PROVIDER="lxc"
# Compute box name
BOX="$DEBIAN_VERSION-$YNH_VERSION"
BOX="ynh-dev"
# Create box
vagrant up $BOX --provider $PROVIDER
vagrant up $BOX
# Package box
vagrant package $BOX --output /tmp/yunohost-$BOX-$PROVIDER.box
vagrant package $BOX --output /tmp/$BOX.box
# Destroy current box
vagrant destroy $BOX
# User message, and exit
echo ""
echo "Your Vagrant box was packaged to /tmp/yunohost-$BOX-$PROVIDER.box"
echo "You might want to run : vagrant box add "yunohost/$BOX" /tmp/yunohost-$BOX-$PROVIDER.box"
echo "Your Vagrant box was packaged to /tmp/$BOX.box"
echo "You might want to run : vagrant box add 'yunohost/ynh-dev' /tmp/$BOX.box"
exit

71
ynh-dev
View file

@ -4,32 +4,21 @@ readonly THISSCRIPT=`basename $0`
function show_usage() {
cat <<EOF
Usage :
On the host
===========
${BLUE}On the host, to manage the LXC${NORMAL}
${BLUE}==============================${NORMAL}
$THISSCRIPT start
(Create and) starts the ynh-dev LXC
start (Create and) starts the ynh-dev LXC
ssh SSH into an already started ynh-dev LXC
destroy Destroy the ynh-dev LXC
rebuild Rebuild a fresh, up-to-date box
$THISSCRIPT ssh
SSH into an already started ynh-dev LXC
${BLUE}Inside the dev instance${NORMAL}
${BLUE}=======================${NORMAL}
$THISSCRIPT destroy
Destroy the ynh-dev LXC
$THISSCRIPT rebuild
Rebuild a fresh, up-to-date box
Inside the vm
=============
$THISSCRIPT ip
Give the ip of the guest container
$THISSCRIPT use-git [PACKAGES [PACKAGES ...]]
Use Git repositories from dev environment path
$THISSCRIPT test [PACKAGES [PACKAGES ...]]
Deploy, update and run tests for some packages
ip Give the ip of the guest container
use-git [PKG] Use Git repositories from dev environment path
test [PKG] Deploy, update and run tests for some packages
EOF
}
@ -39,6 +28,8 @@ function main()
local ACTION="$1"
local ARGUMENTS="${@:2}"
[ -z "$ACTION" ] && show_usage && exit 0
case "${ACTION}" in
help|-h|--help) show_usage $ARGUMENTS ;;
@ -122,25 +113,26 @@ function create_sym_link() {
function start_ynhdev()
{
BOX_NAME="yunohost/strech-unstable"
BOX_URL="https://build.yunohost.org/yunohost-$BOX_NAME-lxc.box"
local BOX_NAME="yunohost/ynh-dev"
local BOX_URL="https://build.yunohost.org/yunohost-$BOX_NAME-lxc.box"
set -eu
# Download box if not available
if ! vagrant box list | grep -qc $BOX_NAME ; then
info "Vagrant box '$BOX_NAME' is missing. Trying to download it"
vagrant box add $BOX_NAME $BOX_URL --provider $PROVIDER
vagrant box add $BOX_NAME $BOX_URL
fi
# Run VM
vagrant up ynh-dev --provider lxc
vagrant up ynh-dev
# Log into the VM
vagrant ssh ynh-dev -c "sudo -i"
ssh_ynhdev
}
function ssh_ynhdev()
{
vagrant ssh ynh-dev -c "sudo -i"
vagrant ssh ynh-dev -c "echo 'You are now inside the LXC !'; cd /ynh-dev; sudo su"
}
function destroy_ynhdev()
@ -148,6 +140,29 @@ function destroy_ynhdev()
vagrant destroy ynh-dev
}
function rebuild_ynhdev()
{
local BOX="ynh-dev"
set -x
cd prebuild
# Create box
vagrant up $BOX
# Package box
vagrant package $BOX --output /tmp/$BOX.box
# Destroy current box
vagrant destroy $BOX
set +x
# User message, and exit
info "The Vagrant box was packaged to /tmp/$BOX.box"
info "You might want to run : vagrant box add 'yunohost/ynh-dev' /tmp/$BOX.box"
}
function show_vm_ip()
{
assert_inside_vm