Skip to content

Commit 3471178

Browse files
committed
Remove deploy.sh and add ynh-dev init
1 parent 652fb36 commit 3471178

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ In packages like `yunohost`, you have automated non-regression tests at your dis
249249
> In such case, you may initiate or attach the container with a specific name, like:
250250
>
251251
> ```bash
252-
> ./ynh-dev start bookworm ynh-test
252+
> ./ynh-dev -d bookworm -v core-tests -b stable start
253253
> ```
254254
>
255255
> And run `yunohost tools postinstall` like for the other container.
@@ -293,7 +293,8 @@ It could be due to bridge conflict (for example if you have incus installed too)
293293
This [ticket](https://github.com/YunoHost/issues/issues/1664) could help.
294294

295295
If you have docker and incus, and your dns resolution inside incus container does not work at all, you can try:
296-
```
296+
297+
```bash
297298
sudo iptables -I DOCKER-USER -i incusbr0 -o eno1 -j ACCEPT
298299
```
299300

@@ -316,9 +317,9 @@ Depending on what you want to achieve, you might want to run the postinstall rig
316317
Deploy a `ynh-dev` folder at the root of the filesystem with:
317318

318319
```bash
319-
cd /
320-
curl https://raw.githubusercontent.com/yunohost/ynh-dev/master/deploy.sh | bash
320+
git clone https://github.com/yunohost/ynh-dev /ynh-dev
321321
cd /ynh-dev
322+
./ynh-dev init
322323
```
323324

324325
### 3. Develop and test

deploy.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.

ynh_dev/ynh_dev_host.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python3
2+
from check_jsonschema.formats.implementations.iso8601_time import N
23

34
import argparse
45
import grp
@@ -15,10 +16,13 @@
1516
VARIANTS = ["appci", "before-install", "build-and-lint", "core-tests", "demo", "dev"]
1617
BRANCHES = ["stable", "testing", "unstable"]
1718

19+
YNH_DEV_DIR = Path(__file__).parent.parent
20+
1821

1922
def main_host() -> None:
2023
parser = argparse.ArgumentParser()
2124
sub = parser.add_subparsers(title="host actions", required=True, dest="action")
25+
sub.add_parser("init", help="Download source repositories")
2226
sub.add_parser("start", help="(Create and) starts a box")
2327
sub.add_parser("attach", help="Attach an already started box")
2428
sub.add_parser("destroy", help="Destroy the ynh-dev box")
@@ -40,6 +44,8 @@ def main_host() -> None:
4044
incus = Incus()
4145

4246
match args.action:
47+
case "init":
48+
init()
4349
case "start":
4450
if not incus.image_exists(image):
4551
logging.info(f"Downloading {image}...")
@@ -58,7 +64,7 @@ def main_host() -> None:
5864
"ynh-dev-shared-folder",
5965
"disk",
6066
"path=/ynh-dev",
61-
f"source={Path.cwd()}",
67+
f"source={YNH_DEV_DIR}",
6268
)
6369

6470
incus.execute(container, "dhclient")
@@ -72,6 +78,23 @@ def main_host() -> None:
7278
incus.instance_delete(container)
7379

7480

81+
82+
def clone_or_pull(url: str, path: Path) -> None:
83+
if path.exists():
84+
subprocess.check_call(["git", "pull"], cwd=path)
85+
else:
86+
subprocess.check_call(["git", "clone", url, str(path)])
87+
88+
89+
def init() -> None:
90+
clone_or_pull("https://github.com/YunoHost/moulinette", YNH_DEV_DIR / "moulinette")
91+
clone_or_pull("https://github.com/YunoHost/yunohost", YNH_DEV_DIR / "yunohost")
92+
clone_or_pull("https://github.com/YunoHost/yunohost-admin", YNH_DEV_DIR / "yunohost-admin")
93+
clone_or_pull("https://github.com/YunoHost/SSOwat ssowat", YNH_DEV_DIR / "SSOwat ssowat")
94+
clone_or_pull("https://github.com/YunoHost/yunohost-portal", YNH_DEV_DIR / "yunohost-portal")
95+
(YNH_DEV_DIR / "apps").mkdir(exist_ok=True)
96+
97+
7598
def attach(incus: Incus, container: str) -> None:
7699
logging.info(f"Attaching to {container}.")
77100
incus.execute(container, "/bin/bash", cwd="/ynh-dev", exec_=True)

0 commit comments

Comments
 (0)