From 2105bb4b465df6459cb6afd79bce34fa28649ca4 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Sun, 20 Sep 2020 20:52:02 +0200 Subject: [PATCH 01/17] [fix] Missing binary link in use-git --- ynh-dev | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ynh-dev b/ynh-dev index 50908e6..a690ed4 100755 --- a/ynh-dev +++ b/ynh-dev @@ -230,7 +230,10 @@ function use_git() # bin create_sym_link "/ynh-dev/yunohost/bin/yunohost" "/usr/bin/yunohost" create_sym_link "/ynh-dev/yunohost/bin/yunohost-api" "/usr/bin/yunohost-api" - + create_sym_link "/ynh-dev/yunohost/bin/yunoprompt" "/usr/bin/yunoprompt" + create_sym_link "/ynh-dev/yunohost/bin/yunopaste" "/usr/bin/yunopaste" + create_sym_link "/ynh-dev/yunohost/sbin/yunohost-reset-ldap-password" "/usr/sbin/yunohost-reset-ldap-password" + # data create_sym_link "/ynh-dev/yunohost/data/bash-completion.d/yunohost" "/etc/bash_completion.d/yunohost" create_sym_link "/ynh-dev/yunohost/data/actionsmap/yunohost.yml" "/usr/share/moulinette/actionsmap/yunohost.yml" From 094c4861ebb78f493eb3b5660682939ca1cbb6c6 Mon Sep 17 00:00:00 2001 From: Axolotle Date: Thu, 5 Nov 2020 13:08:35 +0100 Subject: [PATCH 02/17] add use-git for yunohost-admin-vue --- ynh-dev | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/ynh-dev b/ynh-dev index a690ed4..f239518 100755 --- a/ynh-dev +++ b/ynh-dev @@ -166,6 +166,13 @@ function attach_ynhdev() ln -s /var/cache/ynh-dev/yunohost-admin/dist ./yunohost-admin/src/ fi + # Setup symlinks for future .env and nodes_modules/ for yunohost-admin-vue + if [[ ! -L ./yunohost-admin-vue/app/.env ]] + then + ln -s /var/cache/ynh-dev/yunohost-admin/.env ./yunohost-admin-vue/app + ln -s /var/cache/ynh-dev/yunohost-admin/node_modules ./yunohost-admin-vue/app/ + fi + check_lxd_setup local BOX=${1:-ynh-dev-buster} sudo lxc start $BOX 2>/dev/null || true @@ -233,7 +240,7 @@ function use_git() create_sym_link "/ynh-dev/yunohost/bin/yunoprompt" "/usr/bin/yunoprompt" create_sym_link "/ynh-dev/yunohost/bin/yunopaste" "/usr/bin/yunopaste" create_sym_link "/ynh-dev/yunohost/sbin/yunohost-reset-ldap-password" "/usr/sbin/yunohost-reset-ldap-password" - + # data create_sym_link "/ynh-dev/yunohost/data/bash-completion.d/yunohost" "/etc/bash_completion.d/yunohost" create_sym_link "/ynh-dev/yunohost/data/actionsmap/yunohost.yml" "/usr/share/moulinette/actionsmap/yunohost.yml" @@ -310,6 +317,59 @@ function use_git() warn "-------------------------------------------------------- " su ynhdev -c "./node_modules/gulp/bin/gulp.js watch --dev" + ;; + yunohost-admin-vue) + getent passwd ynhdev > /dev/null + if [ $? -eq 2 ]; then + useradd ynhdev + fi + + mkdir -p /var/cache/ynh-dev/yunohost-admin/ + # mkdir -p /var/cache/ynh-dev/yunohost-admin/dist + chown -R ynhdev /var/cache/ynh-dev/yunohost-admin/ + create_sym_link "/ynh-dev/yunohost-admin-vue/app/package.json" "/var/cache/ynh-dev/yunohost-admin/package.json" + create_sym_link "/ynh-dev/yunohost-admin-vue/app/package-lock.json" "/var/cache/ynh-dev/yunohost-admin/package-lock.json" + # create_sym_link "/ynh-dev/yunohost-admin-vue/app" "/usr/share/yunohost/admin" + + cd /var/cache/ynh-dev/yunohost-admin/ + # Create .env file with the vm ip + # Will be used by webpack-dev-server to proxy api requests. + if [[ ! -e .env ]] + then + info "Creating .env file" + IP=$(hostname -I | tr ' ' '\n' | grep "\.") + echo "VUE_APP_IP=$IP" > .env + fi + + # Allow port 8080 in config file or else the dev server will stop working after postinstall + if [[ ! -e /etc/yunohost/installed ]] + then + python2.7 - < Date: Mon, 28 Dec 2020 09:53:04 +0100 Subject: [PATCH 03/17] [mod] trailing space --- ynh-dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ynh-dev b/ynh-dev index a690ed4..fa8301e 100755 --- a/ynh-dev +++ b/ynh-dev @@ -233,7 +233,7 @@ function use_git() create_sym_link "/ynh-dev/yunohost/bin/yunoprompt" "/usr/bin/yunoprompt" create_sym_link "/ynh-dev/yunohost/bin/yunopaste" "/usr/bin/yunopaste" create_sym_link "/ynh-dev/yunohost/sbin/yunohost-reset-ldap-password" "/usr/sbin/yunohost-reset-ldap-password" - + # data create_sym_link "/ynh-dev/yunohost/data/bash-completion.d/yunohost" "/etc/bash_completion.d/yunohost" create_sym_link "/ynh-dev/yunohost/data/actionsmap/yunohost.yml" "/usr/share/moulinette/actionsmap/yunohost.yml" From ce9bb61c8e9f282c24a1858bb410ee852d3b2268 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Mon, 28 Dec 2020 10:09:05 +0100 Subject: [PATCH 04/17] [ux] error message on bad usage of ynh-dev --- ynh-dev | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ynh-dev b/ynh-dev index fa8301e..20ad02b 100755 --- a/ynh-dev +++ b/ynh-dev @@ -310,6 +310,9 @@ function use_git() warn "-------------------------------------------------------- " su ynhdev -c "./node_modules/gulp/bin/gulp.js watch --dev" + ;; + *) + error "Invalid package '$PACKAGE': correct arguments are 'yunohost', 'ssowat', 'moulinette', 'yunohost-admin'" ;; esac done From bed3965013b66e00af8aa05a198066e1de9af777 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Mon, 28 Dec 2020 16:53:25 +0100 Subject: [PATCH 05/17] [enh] default value for packages list if empty --- ynh-dev | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ynh-dev b/ynh-dev index 20ad02b..cddd5ad 100755 --- a/ynh-dev +++ b/ynh-dev @@ -212,10 +212,16 @@ function show_vm_ip() function use_git() { assert_inside_vm - local PACKAGES="$@" - for PACKAGE in "$PACKAGES"; + local PACKAGES=("$@") + + if [ "$PACKAGES" = "" ] + then + PACKAGES=('moulinette' 'ssowat' 'yunohost' 'yunohost-admin') + fi + + for i in ${!PACKAGES[@]}; do - case $PACKAGE in + case ${PACKAGES[i]} in ssowat) create_sym_link "/ynh-dev/ssowat" "/usr/share/ssowat" success "Now using Git repository for SSOwat" @@ -312,7 +318,7 @@ function use_git() ;; *) - error "Invalid package '$PACKAGE': correct arguments are 'yunohost', 'ssowat', 'moulinette', 'yunohost-admin'" + error "Invalid package '${PACKAGES[i]}': correct arguments are 'yunohost', 'ssowat', 'moulinette', 'yunohost-admin' or nothing for all" ;; esac done @@ -373,4 +379,4 @@ function run_tests() done } -main "$@" +main $@ From 4aa959044a0be975684731c212ba417f2beb3250 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Sun, 10 Jan 2021 03:05:26 +0100 Subject: [PATCH 06/17] [enh] Add advice about network issues with lxd --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index d7344c0..c431894 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Please report issues on the following repository: * [4. Testing the web interface](#4-testing-the-web-interface) * [Advanced: using snapshots](#advanced-using-snapshots) * [Alternative: Only Virtualbox](#alternative-using-only-virtualbox) + * [Troubleshooting](#troubleshooting) - [Remote Development Environment](#remote-development-environment) * [1. Setup your VPS and install YunoHost](#1-setup-your-vps-and-install-yunohost) @@ -225,6 +226,13 @@ this repository. This is a known working setup used by some developers. Please see the ["virtualbox" branch](https://github.com/YunoHost/ynh-dev/tree/virtualbox#develop-on-your-local-machine) for more. +## Troubleshooting +If you experiment network issues with your lxd during rebuild container steps. Probably your container are not able to get a local IP with DHCP. + +It could be due to bridge conflict (for example if you have lxc installed too) or dnsmasq port already used. + +This [ticket](https://github.com/YunoHost/issues/issues/1664) could help. + # Remote Development Environment Here is the development flow: From 12fc1ab5d5ffc0fe477ea9cc8780f1d50b11cf39 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Sat, 16 Jan 2021 17:38:50 +0100 Subject: [PATCH 07/17] fix use-git vuejs --- ynh-dev | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ynh-dev b/ynh-dev index f239518..c75995f 100755 --- a/ynh-dev +++ b/ynh-dev @@ -329,6 +329,13 @@ function use_git() chown -R ynhdev /var/cache/ynh-dev/yunohost-admin/ create_sym_link "/ynh-dev/yunohost-admin-vue/app/package.json" "/var/cache/ynh-dev/yunohost-admin/package.json" create_sym_link "/ynh-dev/yunohost-admin-vue/app/package-lock.json" "/var/cache/ynh-dev/yunohost-admin/package-lock.json" + mv "/etc/nginx/conf.d/yunohost_admin.conf.inc" "/etc/nginx/conf.d/yunohost_admin.conf.inc.bkp" + trap 'on_exit' INT + on_exit() + { + mv "/etc/nginx/conf.d/yunohost_admin.conf.inc.bkp" "/etc/nginx/conf.d/yunohost_admin.conf.inc" + systemctl reload nginx + } # create_sym_link "/ynh-dev/yunohost-admin-vue/app" "/usr/share/yunohost/admin" cd /var/cache/ynh-dev/yunohost-admin/ @@ -368,6 +375,24 @@ EOF # Install dependencies npm ci --no-bin-links success "Now using Git repository for yunohost-admin" + cat < /etc/nginx/conf.d/yunohost_admin.conf.inc +location /yunohost/admin { + proxy_pass https://localhost:8080/yunohost/admin; + proxy_redirect off; + proxy_set_header Host \$host; + proxy_set_header X-Real-IP \$remote_addr; + proxy_set_header X-Forwarded-Proto \$scheme; + proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host \$server_name; + proxy_set_header X-Forwarded-Port \$server_port; + + proxy_http_version 1.1; + proxy_set_header Upgrade \$http_upgrade; + proxy_set_header Connection "upgrade"; +} +EOF + + systemctl reload nginx cd /ynh-dev/yunohost-admin-vue/app/ npm run serve ;; From bfb48c25f7337b7cf15ac7ff5322892bb8c8b68f Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 19 Jan 2021 23:36:19 +0100 Subject: [PATCH 08/17] remove legacy yunohost-admin use-git --- ynh-dev | 55 ++++--------------------------------------------------- 1 file changed, 4 insertions(+), 51 deletions(-) diff --git a/ynh-dev b/ynh-dev index 8243005..f34e192 100755 --- a/ynh-dev +++ b/ynh-dev @@ -226,7 +226,7 @@ function use_git() PACKAGES=('moulinette' 'ssowat' 'yunohost' 'yunohost-admin') fi - for i in ${!PACKAGES[@]}; + for i in "${!PACKAGES[@]}"; do case ${PACKAGES[i]} in ssowat) @@ -282,54 +282,6 @@ function use_git() useradd ynhdev fi - mkdir -p /var/cache/ynh-dev/yunohost-admin/ - mkdir -p /var/cache/ynh-dev/yunohost-admin/dist - chown -R ynhdev /var/cache/ynh-dev/yunohost-admin/ - create_sym_link "/ynh-dev/yunohost-admin/src/package.json" "/var/cache/ynh-dev/yunohost-admin/package.json" - create_sym_link "/ynh-dev/yunohost-admin/src/package-lock.json" "/var/cache/ynh-dev/yunohost-admin/package-lock.json" - create_sym_link "/ynh-dev/yunohost-admin/src" "/usr/share/yunohost/admin" - - if [ ! -e /ynh-dev/yunohost-admin/src/dist ] - then - echo "If npm install fails to create the dist and node_modules folder, maybe you need to run the following *in the host!* : " - echo " " - echo "cd /your/dev/env/yunohost-admin/src/" - echo "ln -s /var/cache/ynh-dev/yunohost-admin/dist ./dist" - echo "ln -s /var/cache/ynh-dev/yunohost-admin/node_modules ./node_modules" - echo " " - fi - - # Install npm dependencies if needed - cd /var/cache/ynh-dev/yunohost-admin/ - if [ ! -e node_modules/gulp/bin/gulp.js ] - then - info "Installing dependencies to develop in yunohost-admin ..." - apt install nodejs npm -y - npm install -g npm@latest - fi - - npm ci --no-bin-links - - success "Now using Git repository for yunohost-admin" - - cd /ynh-dev/yunohost-admin/src - su ynhdev -c "./node_modules/gulp/bin/gulp.js build --dev" - warn "-------------------------------------------------------- " - warn "Launching gulp ... " - warn "NB : This command will keep running and watch for changes" - warn " in the folder /ynh-dev/yunohost-admin/src, such that you" - warn "don't need to re-run npm yourself everytime you change " - warn "something ! " - warn "-------------------------------------------------------- " - su ynhdev -c "./node_modules/gulp/bin/gulp.js watch --dev" - - ;; - yunohost-admin-vue) - getent passwd ynhdev > /dev/null - if [ $? -eq 2 ]; then - useradd ynhdev - fi - mkdir -p /var/cache/ynh-dev/yunohost-admin/ # mkdir -p /var/cache/ynh-dev/yunohost-admin/dist chown -R ynhdev /var/cache/ynh-dev/yunohost-admin/ @@ -401,6 +353,7 @@ EOF systemctl reload nginx cd /ynh-dev/yunohost-admin-vue/app/ npm run serve + ;; *) error "Invalid package '${PACKAGES[i]}': correct arguments are 'yunohost', 'ssowat', 'moulinette', 'yunohost-admin' or nothing for all" ;; @@ -412,7 +365,7 @@ function run_tests() { assert_inside_vm local PACKAGES="$@" - for PACKAGE in "$PACKAGES"; + for PACKAGE in $PACKAGES; do TEST_FUNCTION=$(echo "$PACKAGE" | tr '/:' ' ' | awk '{print $3}') TEST_MODULE=$(echo "$PACKAGE" | tr '/:' ' ' | awk '{print $2}') @@ -463,4 +416,4 @@ function run_tests() done } -main $@ +main "$@" From 11efd8de93ba2fd961b8c93196c4fba3b9a1b875 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Fri, 22 Jan 2021 01:24:08 +0100 Subject: [PATCH 09/17] fix use-git yunohost-admin --- ynh-dev | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/ynh-dev b/ynh-dev index f34e192..fe029ab 100755 --- a/ynh-dev +++ b/ynh-dev @@ -155,24 +155,6 @@ function start_ynhdev() function attach_ynhdev() { - # We need those link for the yunohost-admin build to work without r/w - # permission in the shared folder. - # - # The target folders (/var/cache/ynh-dev/...) are then created during the - # './ynh-dev use-git yunohost-admin' - if [[ ! -L ./yunohost-admin/src/dist ]] - then - ln -s /var/cache/ynh-dev/yunohost-admin/node_modules ./yunohost-admin/src/ - ln -s /var/cache/ynh-dev/yunohost-admin/dist ./yunohost-admin/src/ - fi - - # Setup symlinks for future .env and nodes_modules/ for yunohost-admin-vue - if [[ ! -L ./yunohost-admin-vue/app/.env ]] - then - ln -s /var/cache/ynh-dev/yunohost-admin/.env ./yunohost-admin-vue/app - ln -s /var/cache/ynh-dev/yunohost-admin/node_modules ./yunohost-admin-vue/app/ - fi - check_lxd_setup local BOX=${1:-ynh-dev-buster} sudo lxc start $BOX 2>/dev/null || true @@ -277,24 +259,19 @@ function use_git() ;; yunohost-admin) - getent passwd ynhdev > /dev/null - if [ $? -eq 2 ]; then - useradd ynhdev - fi - + rm -r /var/cache/ynh-dev/yunohost-admin mkdir -p /var/cache/ynh-dev/yunohost-admin/ - # mkdir -p /var/cache/ynh-dev/yunohost-admin/dist - chown -R ynhdev /var/cache/ynh-dev/yunohost-admin/ - create_sym_link "/ynh-dev/yunohost-admin-vue/app/package.json" "/var/cache/ynh-dev/yunohost-admin/package.json" - create_sym_link "/ynh-dev/yunohost-admin-vue/app/package-lock.json" "/var/cache/ynh-dev/yunohost-admin/package-lock.json" + create_sym_link "/ynh-dev/yunohost-admin/app/.env" "/var/cache/ynh-dev/yunohost-admin/.env" + create_sym_link "/var/cache/ynh-dev/yunohost-admin/node_modules" "/ynh-dev/yunohost-admin/app/node_modules" + create_sym_link "/ynh-dev/yunohost-admin/app/package.json" "/var/cache/ynh-dev/yunohost-admin/package.json" + create_sym_link "/ynh-dev/yunohost-admin/app/package-lock.json" "/var/cache/ynh-dev/yunohost-admin/package-lock.json" mv "/etc/nginx/conf.d/yunohost_admin.conf.inc" "/etc/nginx/conf.d/yunohost_admin.conf.inc.bkp" - trap 'on_exit' INT + trap 'on_exit' exit on_exit() { mv "/etc/nginx/conf.d/yunohost_admin.conf.inc.bkp" "/etc/nginx/conf.d/yunohost_admin.conf.inc" systemctl reload nginx } - # create_sym_link "/ynh-dev/yunohost-admin-vue/app" "/usr/share/yunohost/admin" cd /var/cache/ynh-dev/yunohost-admin/ # Create .env file with the vm ip @@ -351,7 +328,7 @@ location /yunohost/admin { EOF systemctl reload nginx - cd /ynh-dev/yunohost-admin-vue/app/ + cd /ynh-dev/yunohost-admin/app/ npm run serve ;; *) From a0129600214385fc8a633b894905e214de4b49ca Mon Sep 17 00:00:00 2001 From: Kay0u Date: Fri, 22 Jan 2021 01:55:29 +0100 Subject: [PATCH 10/17] use yunohost lxd remote + add the possibility to choose the yunohost version --- README.md | 6 ++++++ ynh-dev | 46 ++++++++++++++++++++++++---------------------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index c431894..499282a 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,12 @@ answering the default (just pressing enter) to all questions is fine. sudo lxd init ``` +Pre-built images are centralized on `devbaseimgs.yunohost.org` and we'll download them from there to speed things up: + +```bash +sudo lxc remote add yunohost https://devbaseimgs.yunohost.org --public +``` + Then, go into your favorite development folder and deploy `ynh-dev` with: ```bash diff --git a/ynh-dev b/ynh-dev index fe029ab..d0c821e 100755 --- a/ynh-dev +++ b/ynh-dev @@ -6,10 +6,10 @@ function show_usage() { ${BLUE}On the host, to manage the LXC${NORMAL} ${BLUE}==============================${NORMAL} - start [DIST] [NAME] (Create and) starts a LXC (DIST=buster and NAME=ynh-dev by default) - attach [DIST] [NAME] Attach an already started LXC (DIST=buster and NAME=ynh-dev by default) - destroy [DIST] [NAME] Destroy the ynh-dev LXC (DIST=buster and NAME=ynh-dev by default) - rebuild [DIST] [NAME] Rebuild a fresh, up-to-date box (DIST=buster and NAME=ynh-dev by default) + start [DIST] [NAME] [YNH_BRANCH] (Create and) starts a LXC (DIST=buster, NAME=ynh-dev and YNH_BRANCH=unstable by default) + attach [DIST] [NAME] [YNH_BRANCH] Attach an already started LXC (DIST=buster, NAME=ynh-dev and YNH_BRANCH=unstable by default) + destroy [DIST] [NAME] [YNH_BRANCH] Destroy the ynh-dev LXC (DIST=buster, NAME=ynh-dev and YNH_BRANCH=unstable by default) + rebuild [DIST] [NAME] [YNH_BRANCH] Rebuild a fresh, up-to-date box (DIST=buster, NAME=ynh-dev and YNH_BRANCH=unstable by default) ${BLUE}Inside the dev instance${NORMAL} ${BLUE}=======================${NORMAL} @@ -133,30 +133,33 @@ function start_ynhdev() check_lxd_setup local DIST=${1:-buster} - local BOX=${2:-ynh-dev}-${DIST} + local YNH_BRANCH=${3:-unstable} + local BOX=${2:-ynh-dev}-${DIST}-${YNH_BRANCH} if ! sudo lxc info $BOX &>/dev/null then - sudo lxc image info $BOX-base &>/dev/null || critical "You should first build the base YunoHost LXC using ./ynh-dev rebuild" - set -eu - set -x - sudo lxc launch $BOX-base $BOX - sudo lxc config set $BOX security.privileged true - sudo lxc config set $BOX security.nesting true # Need this for apparmor for some reason + if ! sudo lxc image info $BOX-base &>/dev/null + then + LXC_BASE="ynh-dev-$DIST-amd64-$YNH_BRANCH-base" + sudo lxc launch yunohost:$LXC_BASE $BOX -c security.nesting=true -c security.privileged=true || critical "We can't find the image $LXC_BASE in the Yunohost remote. You should first build the base YunoHost LXC using ./ynh-dev rebuild" + else + sudo lxc launch $BOX-base $BOX -c security.nesting=true -c security.privileged=true + fi sudo lxc config device add $BOX ynhdev-shared-folder disk path=/ynh-dev source="$(readlink -f $(pwd))" - set +x info "Now attaching to the container" else info "Attaching to existing container" fi - attach_ynhdev $BOX + attach_ynhdev "$@" } function attach_ynhdev() { check_lxd_setup - local BOX=${1:-ynh-dev-buster} + local DIST=${1:-buster} + local YNH_BRANCH=${3:-unstable} + local BOX=${2:-ynh-dev}-${DIST}-${YNH_BRANCH} sudo lxc start $BOX 2>/dev/null || true sudo lxc exec $BOX --cwd /ynh-dev -- /bin/bash } @@ -165,7 +168,8 @@ function destroy_ynhdev() { check_lxd_setup local DIST=${1:-buster} - local BOX=${2:-ynh-dev}-${DIST} + local YNH_BRANCH=${3:-unstable} + local BOX=${2:-ynh-dev}-${DIST}-${YNH_BRANCH} sudo lxc stop $BOX sudo lxc delete $BOX } @@ -175,18 +179,16 @@ function rebuild_ynhdev() check_lxd_setup local DIST=${1:-buster} - local BOX=${2:-ynh-dev}-${DIST} + local YNH_BRANCH=${3:-unstable} + local BOX=${2:-ynh-dev}-${DIST}-${YNH_BRANCH} set -x sudo lxc info $BOX-rebuild >/dev/null && sudo lxc delete $BOX-rebuild --force - sudo lxc launch images:debian/$DIST/amd64 $BOX-rebuild - sudo lxc config set $BOX-rebuild security.privileged true - sudo lxc config set $BOX-rebuild security.nesting true # Need this for apparmor for some reason - sudo lxc restart $BOX-rebuild + sudo lxc launch images:debian/$DIST/amd64 $BOX-rebuild -c security.nesting=true -c security.privileged=true sleep 5 sudo lxc exec $BOX-rebuild -- apt install curl -y - INSTALL_SCRIPT="https://install.yunohost.org" - sudo lxc exec $BOX-rebuild -- /bin/bash -c "curl $INSTALL_SCRIPT | bash -s -- -a -d unstable" + INSTALL_SCRIPT="https://install.yunohost.org/$DIST" + sudo lxc exec $BOX-rebuild -- /bin/bash -c "curl $INSTALL_SCRIPT | bash -s -- -a -d $YNH_BRANCH" sudo lxc stop $BOX-rebuild sudo lxc publish $BOX-rebuild --alias $BOX-base set +x From bff7e1ba074d547a81c6642398c93509e1340c7a Mon Sep 17 00:00:00 2001 From: Kayou Date: Fri, 22 Jan 2021 10:33:34 +0100 Subject: [PATCH 11/17] Apply suggestions from code review Co-authored-by: Alexandre Aubin --- ynh-dev | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ynh-dev b/ynh-dev index d0c821e..98b5b79 100755 --- a/ynh-dev +++ b/ynh-dev @@ -141,7 +141,8 @@ function start_ynhdev() if ! sudo lxc image info $BOX-base &>/dev/null then LXC_BASE="ynh-dev-$DIST-amd64-$YNH_BRANCH-base" - sudo lxc launch yunohost:$LXC_BASE $BOX -c security.nesting=true -c security.privileged=true || critical "We can't find the image $LXC_BASE in the Yunohost remote. You should first build the base YunoHost LXC using ./ynh-dev rebuild" + sudo lxc launch yunohost:$LXC_BASE $BOX -c security.nesting=true -c security.privileged=true \ + || critical "Failed to launch the container ?" else sudo lxc launch $BOX-base $BOX -c security.nesting=true -c security.privileged=true fi From 2cc7c065f5667d086a18c5a13cea26e4cf5de507 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 26 Jan 2021 00:14:32 +0100 Subject: [PATCH 12/17] python2->3 --- ynh-dev | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ynh-dev b/ynh-dev index 98b5b79..663b7ba 100755 --- a/ynh-dev +++ b/ynh-dev @@ -220,7 +220,7 @@ function use_git() ;; moulinette) create_sym_link "/ynh-dev/moulinette/locales" "/usr/share/moulinette/locale" - create_sym_link "/ynh-dev/moulinette/moulinette" "/usr/lib/python2.7/dist-packages/moulinette" + create_sym_link "/ynh-dev/moulinette/moulinette" "/usr/lib/python3/dist-packages/moulinette" success "Now using Git repository for Moulinette" ;; yunohost) @@ -289,7 +289,7 @@ function use_git() # Allow port 8080 in config file or else the dev server will stop working after postinstall if [[ ! -e /etc/yunohost/installed ]] then - python2.7 - < Date: Wed, 27 Jan 2021 01:47:42 +0100 Subject: [PATCH 13/17] yet another python3 migration --- ynh-dev | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ynh-dev b/ynh-dev index 663b7ba..2904939 100755 --- a/ynh-dev +++ b/ynh-dev @@ -356,14 +356,14 @@ function run_tests() # Pytest and tests dependencies if ! type "pytest" > /dev/null 2>&1; then info "> Installing pytest ..." - apt-get install python-pip -y - pip2 install pytest pytest-sugar + apt-get install python3-pip -y + pip3 install pytest pytest-sugar fi for DEP in "pytest-mock requests-mock mock" do - if [ -z "$(pip show $DEP)" ]; then - info "Installing $DEP with pip" - pip2 install $DEP + if [ -z "$(pip3 show $DEP)" ]; then + info "Installing $DEP with pip3" + pip3 install $DEP fi done From 3065602d68e18b8d04660d6d682c5a5b0d68ba71 Mon Sep 17 00:00:00 2001 From: Paco <> Date: Thu, 18 Feb 2021 20:37:56 +0100 Subject: [PATCH 14/17] Fix POSIX script's compability (due to issues in NixOS) --- ynh-dev | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ynh-dev b/ynh-dev index 2904939..db0d14d 100755 --- a/ynh-dev +++ b/ynh-dev @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash function show_usage() { cat < Date: Tue, 16 Mar 2021 11:15:25 +0100 Subject: [PATCH 15/17] this file doesn't exist, don't link it! --- ynh-dev | 3 --- 1 file changed, 3 deletions(-) diff --git a/ynh-dev b/ynh-dev index db0d14d..0463863 100755 --- a/ynh-dev +++ b/ynh-dev @@ -241,9 +241,6 @@ function use_git() create_sym_link "/ynh-dev/yunohost/data/helpers.d" "/usr/share/yunohost/helpers.d" create_sym_link "/ynh-dev/yunohost/data/other" "/usr/share/yunohost/yunohost-config/moulinette" - # debian - create_sym_link "/ynh-dev/yunohost/debian/conf/pam/mkhomedir" "/usr/share/pam-configs/mkhomedir" - # lib create_sym_link "/ynh-dev/yunohost/lib/metronome/modules/ldap.lib.lua" "/usr/lib/metronome/modules/ldap.lib.lua" create_sym_link "/ynh-dev/yunohost/lib/metronome/modules/mod_auth_ldap2.lua" "/usr/lib/metronome/modules/mod_auth_ldap2.lua" From e18af24e7671d266cf6c26ce1a05eb0a10a2c190 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 16 Mar 2021 14:03:54 +0100 Subject: [PATCH 16/17] generate bash completion file --- ynh-dev | 1 + 1 file changed, 1 insertion(+) diff --git a/ynh-dev b/ynh-dev index 0463863..0c6593b 100755 --- a/ynh-dev +++ b/ynh-dev @@ -233,6 +233,7 @@ function use_git() create_sym_link "/ynh-dev/yunohost/sbin/yunohost-reset-ldap-password" "/usr/sbin/yunohost-reset-ldap-password" # data + python3 "/ynh-dev/yunohost/data/actionsmap/yunohost_completion.py" create_sym_link "/ynh-dev/yunohost/data/bash-completion.d/yunohost" "/etc/bash_completion.d/yunohost" create_sym_link "/ynh-dev/yunohost/data/actionsmap/yunohost.yml" "/usr/share/moulinette/actionsmap/yunohost.yml" create_sym_link "/ynh-dev/yunohost/data/hooks" "/usr/share/yunohost/hooks" From 116bdeff363243441b285a20e05bd86fbd2d96fa Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 19 Apr 2021 19:29:27 +0200 Subject: [PATCH 17/17] No need to rebuild LXC locally anymore --- README.md | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 499282a..d9e15eb 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,16 @@ Pre-built images are centralized on `devbaseimgs.yunohost.org` and we'll downloa sudo lxc remote add yunohost https://devbaseimgs.yunohost.org --public ``` +On Archlinux-based distributions (Arch, Manjaro, ...) it was found that it's needed +that LXC/LXD will throw some error about "newuidmap failed to write mapping / Failed +to set up id mapping" ... It can be [fixed with the following](https://discuss.linuxcontainers.org/t/solved-arch-linux-containers-only-run-when-security-privileged-true/4006/4) : + +``` +# N.B.: this is ONLY for Arch-based distros +$ echo "root:1000000:65536" > /etc/subuid +$ echo "root:1000000:65536" > /etc/subgid +``` + Then, go into your favorite development folder and deploy `ynh-dev` with: ```bash @@ -161,34 +171,15 @@ between the host and the LXC. When ran on the host, the `./ynh-dev` command allows you to manage YunoHost's dev LXCs. -First, you might want to build the base LXC with: +Start your actual dev LXC using : ```bash $ cd ynh-dev # if not already done -$ ./ynh-dev rebuild -# ... This will take some time, grab your favorite beverage ... -``` - -This should create a fresh Debian Stretch LXC, install Yunohost inside and save -the result as `ynh-dev-base` which can then be used to create your actual dev -LXC. (This base can then be used to recreate a fresh Yunohost LXC if you need to -destroy your work LXC) - -On Archlinux-based distributions (Arch, Manjaro, ...) it was found that it's needed -that LXC/LXD will throw some error about "newuidmap failed to write mapping / Failed -to set up id mapping" ... It can be [fixed with the following](https://discuss.linuxcontainers.org/t/solved-arch-linux-containers-only-run-when-security-privileged-true/4006/4) : - -``` -$ echo "root:1000000:65536" > /etc/subuid -$ echo "root:1000000:65536" > /etc/subgid -``` - -Then start your actual dev LXC using : - -```bash $ ./ynh-dev start ``` +This should automatically download from `devbaseimgs.yunohost.org` a pre-build ynh-dev LXC image running Yunohost unstable, and create a fresh container from it. + After starting the LXC, your terminal will automatically be attached to it. If you later disconnect from the LXC, you can go back in with `./ynh-dev attach`. Later, you might want to destroy the LXC. You can do so with `./ynh-dev destroy`. ## 3. Development and container testing