ybox 0.9.8.1__tar.gz → 0.9.11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. {ybox-0.9.8.1/src/ybox.egg-info → ybox-0.9.11}/PKG-INFO +68 -34
  2. {ybox-0.9.8.1 → ybox-0.9.11}/README.md +63 -31
  3. {ybox-0.9.8.1 → ybox-0.9.11}/pyproject.toml +2 -1
  4. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/__init__.py +1 -1
  5. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/cmd.py +17 -1
  6. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/completions/ybox.fish +2 -0
  7. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/arch/init-user.sh +2 -2
  8. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/arch/init.sh +1 -0
  9. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/arch/pkgdeps.py +2 -0
  10. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/deb-generic/pkgdeps.py +2 -1
  11. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/profiles/apps.ini +10 -5
  12. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/profiles/basic.ini +48 -23
  13. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/profiles/dev.ini +4 -6
  14. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/resources/entrypoint-cp.sh +1 -1
  15. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/resources/entrypoint-root.sh +4 -3
  16. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/resources/entrypoint-user.sh +5 -3
  17. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/resources/entrypoint.sh +24 -22
  18. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/resources/prime-run +0 -2
  19. ybox-0.9.11/src/ybox/conf/resources/run-in-dir +74 -0
  20. ybox-0.9.11/src/ybox/conf/resources/run-user-bash-cmd +30 -0
  21. ybox-0.9.11/src/ybox/conf/resources/ybox-systemd.template +24 -0
  22. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/config.py +9 -1
  23. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/env.py +18 -7
  24. ybox-0.9.8.1/src/ybox/migrate/0.9.0-0.9.7:0.9.8.py → ybox-0.9.11/src/ybox/migrate/0.9.0-0.9.10:0.9.11.py +6 -5
  25. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/pkg/clean.py +1 -7
  26. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/pkg/info.py +1 -7
  27. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/pkg/inst.py +40 -22
  28. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/pkg/list.py +1 -6
  29. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/pkg/mark.py +1 -1
  30. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/pkg/repair.py +4 -0
  31. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/pkg/search.py +1 -7
  32. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/run/cmd.py +2 -1
  33. ybox-0.9.11/src/ybox/run/control.py +184 -0
  34. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/run/create.py +254 -63
  35. ybox-0.9.11/src/ybox/run/destroy.py +149 -0
  36. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/run/graphics.py +37 -17
  37. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/run/logs.py +2 -1
  38. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/run/ls.py +2 -1
  39. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/run/pkg.py +49 -7
  40. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/state.py +22 -3
  41. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/util.py +5 -5
  42. {ybox-0.9.8.1 → ybox-0.9.11/src/ybox.egg-info}/PKG-INFO +68 -34
  43. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox.egg-info/SOURCES.txt +3 -1
  44. {ybox-0.9.8.1 → ybox-0.9.11}/tests/create_migration_db.py +1 -0
  45. {ybox-0.9.8.1 → ybox-0.9.11}/tests/functional/distro_base.py +4 -4
  46. {ybox-0.9.8.1 → ybox-0.9.11}/tests/functional/test_create_destroy.py +1 -3
  47. ybox-0.9.11/tests/resources/migration/0.9.0.db.gz +0 -0
  48. ybox-0.9.11/tests/resources/migration/0.9.1.db.gz +0 -0
  49. ybox-0.9.11/tests/resources/migration/0.9.10.db.gz +0 -0
  50. ybox-0.9.11/tests/resources/migration/0.9.2.db.gz +0 -0
  51. ybox-0.9.11/tests/resources/migration/0.9.5.db.gz +0 -0
  52. ybox-0.9.11/tests/resources/migration/0.9.6.db.gz +0 -0
  53. ybox-0.9.11/tests/resources/migration/0.9.7.db.gz +0 -0
  54. {ybox-0.9.8.1 → ybox-0.9.11}/tests/unit/test_cmd.py +48 -1
  55. {ybox-0.9.8.1 → ybox-0.9.11}/tests/unit/test_config.py +2 -1
  56. {ybox-0.9.8.1 → ybox-0.9.11}/tests/unit/test_env.py +7 -1
  57. {ybox-0.9.8.1 → ybox-0.9.11}/tests/unit/test_filelock.py +0 -1
  58. {ybox-0.9.8.1 → ybox-0.9.11}/tests/unit/test_state.py +2 -1
  59. ybox-0.9.8.1/src/ybox/conf/resources/run-in-dir +0 -60
  60. ybox-0.9.8.1/src/ybox/conf/resources/run-user-bash-cmd +0 -14
  61. ybox-0.9.8.1/src/ybox/run/control.py +0 -102
  62. ybox-0.9.8.1/src/ybox/run/destroy.py +0 -64
  63. ybox-0.9.8.1/tests/resources/migration/0.9.0.db.gz +0 -0
  64. ybox-0.9.8.1/tests/resources/migration/0.9.1.db.gz +0 -0
  65. ybox-0.9.8.1/tests/resources/migration/0.9.2.db.gz +0 -0
  66. ybox-0.9.8.1/tests/resources/migration/0.9.5.db.gz +0 -0
  67. ybox-0.9.8.1/tests/resources/migration/0.9.6.db.gz +0 -0
  68. ybox-0.9.8.1/tests/resources/migration/0.9.7.db.gz +0 -0
  69. {ybox-0.9.8.1 → ybox-0.9.11}/LICENSE +0 -0
  70. {ybox-0.9.8.1 → ybox-0.9.11}/MANIFEST.in +0 -0
  71. {ybox-0.9.8.1 → ybox-0.9.11}/setup.cfg +0 -0
  72. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/arch/add-gpg-key.sh +0 -0
  73. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/arch/distro.ini +0 -0
  74. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/arch/init-base.sh +0 -0
  75. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/arch/list_fmt_long.py +0 -0
  76. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/deb-generic/check-package.sh +0 -0
  77. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/deb-generic/distro.ini +0 -0
  78. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/deb-generic/fetch-gpg-key-id.sh +0 -0
  79. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/deb-generic/init-base.sh +0 -0
  80. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/deb-generic/init-user.sh +0 -0
  81. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/deb-generic/init.sh +0 -0
  82. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/deb-generic/list_fmt_long.py +0 -0
  83. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/deb-oldstable/distro.ini +0 -0
  84. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/deb-stable/distro.ini +0 -0
  85. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/supported.list +0 -0
  86. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/ubuntu2204/distro.ini +0 -0
  87. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/distros/ubuntu2404/distro.ini +0 -0
  88. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/profiles/games.ini +0 -0
  89. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/resources/entrypoint-base.sh +0 -0
  90. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/conf/resources/entrypoint-common.sh +0 -0
  91. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/filelock.py +0 -0
  92. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/pkg/__init__.py +0 -0
  93. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/pkg/repo.py +0 -0
  94. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/pkg/uninst.py +0 -0
  95. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/pkg/update.py +0 -0
  96. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/print.py +0 -0
  97. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/run/__init__.py +0 -0
  98. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/schema/0.9.1-added.sql +0 -0
  99. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/schema/0.9.6-added.sql +0 -0
  100. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/schema/init.sql +0 -0
  101. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/schema/migrate/0.9.0:0.9.1.sql +0 -0
  102. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/schema/migrate/0.9.1:0.9.2.sql +0 -0
  103. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/schema/migrate/0.9.2:0.9.3.sql +0 -0
  104. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox/schema/migrate/0.9.5:0.9.6.sql +0 -0
  105. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox.egg-info/dependency_links.txt +0 -0
  106. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox.egg-info/entry_points.txt +0 -0
  107. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox.egg-info/requires.txt +0 -0
  108. {ybox-0.9.8.1 → ybox-0.9.11}/src/ybox.egg-info/top_level.txt +0 -0
  109. {ybox-0.9.8.1 → ybox-0.9.11}/tests/functional/__init__.py +0 -0
  110. {ybox-0.9.8.1 → ybox-0.9.11}/tests/resources/basic_no_shared.ini +0 -0
  111. {ybox-0.9.8.1 → ybox-0.9.11}/tests/resources/containers.json +0 -0
  112. {ybox-0.9.8.1 → ybox-0.9.11}/tests/resources/distro_minimal.ini +0 -0
  113. {ybox-0.9.8.1 → ybox-0.9.11}/tests/resources/packages.json +0 -0
  114. {ybox-0.9.8.1 → ybox-0.9.11}/tests/resources/repos.json +0 -0
  115. {ybox-0.9.8.1 → ybox-0.9.11}/tests/unit/__init__.py +0 -0
  116. {ybox-0.9.8.1 → ybox-0.9.11}/tests/unit/util.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: ybox
3
- Version: 0.9.8.1
3
+ Version: 0.9.11
4
4
  Summary: Securely run Linux distribution inside a container
5
5
  Author-email: Sumedh Wale <sumwale@yahoo.com>, Vishal Rao <vishalrao@gmail.com>
6
6
  License: Copyright (c) 2024-2025 Sumedh Wale and contributors
@@ -25,7 +25,7 @@ License: Copyright (c) 2024-2025 Sumedh Wale and contributors
25
25
 
26
26
  Project-URL: Homepage, https://github.com/sumwale/ybox
27
27
  Project-URL: Issues, https://github.com/sumwale/ybox/issues
28
- Keywords: Linux in container,toolbox
28
+ Keywords: Linux in container,toolbox,distrobox
29
29
  Classifier: Development Status :: 4 - Beta
30
30
  Classifier: Intended Audience :: End Users/Desktop
31
31
  Classifier: License :: OSI Approved :: MIT License
@@ -35,12 +35,14 @@ Classifier: Programming Language :: Python :: 3.9
35
35
  Classifier: Programming Language :: Python :: 3.10
36
36
  Classifier: Programming Language :: Python :: 3.11
37
37
  Classifier: Programming Language :: Python :: 3.12
38
+ Classifier: Programming Language :: Python :: 3.13
38
39
  Requires-Python: >=3.9
39
40
  Description-Content-Type: text/markdown
40
41
  License-File: LICENSE
41
42
  Requires-Dist: packaging
42
43
  Requires-Dist: simple-term-menu
43
44
  Requires-Dist: tabulate>=0.9.0
45
+ Dynamic: license-file
44
46
 
45
47
  ## Introduction
46
48
 
@@ -54,7 +56,17 @@ of the container including directories to be shared, logging etc.
54
56
 
55
57
  Special emphasis is given on security where users can choose to lock down
56
58
  or open up the container as required with reasonable defaults out of the
57
- box. There is no sharing of HOME or no privileged mode container.
59
+ box. There is no sharing of HOME or no privileged mode container. This sets
60
+ it apart from other similar solutions like distrobox/toolbx and the reason
61
+ for starting this project since those other solutions don't care about
62
+ security/sandboxing at all and share the entire HOME while running the
63
+ containers in privileged mode. The other problem with those solutions is that
64
+ the shared HOME means that the user's configuration dot files also get shared
65
+ and can cause all kinds of trouble where container apps can overwrite
66
+ with their own versions (especially for updated apps in the containers)
67
+ breaking the app in the host system. It is, however, possible to share the
68
+ entire HOME if user really wants but that needs to be explcitly configured
69
+ in the ini profile.
58
70
 
59
71
  Expected usage is for users to group similar applications in a container
60
72
  and separate out containers depending on different needs like higher/lower
@@ -88,7 +100,7 @@ So, for example, if you want to run the latest and greatest Intellij IDEA commun
88
100
  to do is:
89
101
 
90
102
  ```sh
91
- # create an Arch Linux based container
103
+ # create an Arch Linux based container and generate systemd service file (if possible)
92
104
  ybox-create arch
93
105
  # then select an appropriate built-in profile e.g. "dev.ini" from the menu
94
106
 
@@ -144,10 +156,11 @@ require you to install in a custom virtual environment which can be done manuall
144
156
  fish: `python3 -m venv ybox-venv && source ybox-env/bin/activate.fish`)
145
157
  or automatically using `pipx`. Alternatively you can add `--break-system-packages`
146
158
  flag to the `pip` command above or add it globally for all future packages using
147
- `python3 -m pip config set global.break-system-packages true`. The alternative
148
- approach works well for `ybox` which has a very minimal set of dependencies but
149
- in the rare case you see any issues due to package conflicts, use `pipx` or
150
- manual virtual environment.
159
+ `python3 -m pip config set global.break-system-packages true`. This alternative
160
+ approach works well for `ybox` which has a very minimal set of dependencies which will
161
+ not conflict with system packages (rather work with whatever system version is installed),
162
+ but if you prefer keeping the installation separate then use `pipx` or
163
+ a manual virtual environment.
151
164
 
152
165
  Now you can run the `ybox-create` and other utilities that are normally installed
153
166
  in your `~/.local/bin` directory which should be in PATH for modern Linux distributions.
@@ -185,6 +198,8 @@ to point to the full path of the podman or docker executable.
185
198
  ybox-create
186
199
  ```
187
200
 
201
+ By default this will also generate a user systemd service if possible (add `-S` or
202
+ `--skip-systemd-service` option to skip creation of a user systemd service).
188
203
  This will allow choosing from supported distributions, then from the available profiles.
189
204
  You can start with the Arch Linux distribution and `apps.ini` profile to try it out. The container
190
205
  will have a name like `ybox-<distribution>_<profile>` by default like `ybox-arch_apps` for the
@@ -209,7 +224,9 @@ does not run properly as root, then you cannot run it when using docker unless y
209
224
  `sudo/su` to the host user in the container command. However, running as host user when running
210
225
  rootless docker will map to a different user ID in the host (as specified in `/etc/subuid` on the
211
226
  host) so files shared with the host, including devices like those in `/dev/dri`, will cause
212
- permission issues that can hinder or break the application.
227
+ permission issues that can hinder or break the application. Hence it is recommended to
228
+ just install podman (even if you already have docker installed) which works out of the
229
+ box in rootless mode in all tested distributions.
213
230
 
214
231
 
215
232
  ### Package management: install/uninstall/list/search/...
@@ -255,7 +272,7 @@ ybox-pkg list -o
255
272
  ```
256
273
  To show more details of the packages (combine with -a/-o as required):
257
274
  ```sh
258
- ybox-pkg list -o
275
+ ybox-pkg list -v
259
276
  ```
260
277
 
261
278
  List all the files installed by the package:
@@ -295,6 +312,8 @@ Clean package cache, temporary downloads etc:
295
312
  ```sh
296
313
  ybox-pkg clean
297
314
  ```
315
+ Add `-q` option to answer yes for any questions automatically if all your containers use
316
+ the same shared root.
298
317
 
299
318
  Mark a package as explicitly installed (also registers with `ybox-pkg` if not present):
300
319
  ```sh
@@ -303,7 +322,7 @@ ybox-pkg mark firefox -e
303
322
 
304
323
  Mark a package as a dependency of another (also registers with `ybox-pkg` if not present):
305
324
  ```sh
306
- ybox-pkg mark qt5ct -D zoom # mark qt5ct as an optional dependency of zoom
325
+ ybox-pkg mark qt5ct -d zoom # mark qt5ct as an optional dependency of zoom
307
326
  ```
308
327
 
309
328
  Repair package installation after a failure or interrupt:
@@ -342,10 +361,10 @@ ybox-destroy ybox-arch_apps
342
361
  ```
343
362
 
344
363
  Will destroy the `apps` container created in the example before. This does not delete the
345
- $HOME files, nor does it delete the shared root directory (if enabled). Hence, if you create
364
+ `$HOME` files, nor does it delete the shared root directory (if enabled). Hence, if you create
346
365
  a new container having the same shared root, then it will inherit everything installed
347
366
  previously. Likewise, if you create the container with the same profile again, then it
348
- will also have the $HOME as before if you do not explicitly delete the directories
367
+ will also have the `$HOME` as before if you do not explicitly delete the directories
349
368
  in `~/.local/share/ybox`.
350
369
 
351
370
 
@@ -374,10 +393,10 @@ ybox-cmd ybox-arch_apps -- ls -l
374
393
  ```
375
394
 
376
395
  The default profiles also link the .bashrc and starship configuration files from your host
377
- $HOME directory by default, so you should see the same bash shell configuration as in your
396
+ `$HOME` directory by default, so you should see the same bash shell configuration as in your
378
397
  host. These are linked in read-only mode, so if you want to change these auto-linked
379
398
  configuration files inside the container, then you will need to create a copy from the symlink
380
- first (but then it will lose the link from the host $HOME).
399
+ first (but then it will lose the link from the host `$HOME`).
381
400
 
382
401
  A shell on a container will act like a native Linux distribution environment for most purposes.
383
402
  The one prominent missing thing is systemd which is not enabled deliberately since it requires
@@ -423,33 +442,39 @@ for a ybox container. See the full set of options with `ybox-control -h/--help`.
423
442
  ### Auto-starting containers
424
443
 
425
444
  Containers can be auto-started as per the usual way for rootless podman/docker services.
426
- This is triggered by systemd on user login which is exactly what we want for ybox
445
+ This is triggered by systemd on user login which is exactly what is required for ybox
427
446
  containers so that the container applications are available on login and are stopped on
428
- session logout. For docker the following should suffice:
429
-
430
- ```sh
431
- systemctl --user enable docker
432
- ```
447
+ session logout. All the tested Linux distributions support this and provide for user
448
+ systemd daemon on user login.
433
449
 
434
- See [docker docs](https://docs.docker.com/engine/security/rootless/#daemon) for details.
450
+ The `ybox-create` command autogenerates the systemd service file (in absence of `-S` or
451
+ `--skip-systemd-service` option) which is also removed by `ybox-destroy` automatically.
452
+ The name of the generated service is `ybox-<NAME>` where `<NAME>` is the name of the
453
+ container if `<NAME>` does not start with `ybox-` prefix, else it is just `<NAME>`.
435
454
 
436
- For podman you will need to explicitly generate systemd service file for each container and
437
- copy to your systemd configuration directory since podman does not use a background daemon.
438
- For the `ybox-arch_apps` container in the examples before:
455
+ With a user service installed, the `systemctl` commands can be used to control the
456
+ ybox container (`<SERVICE_NAME>` is `ybox-<NAME>/<NAME>` mentioned above):
439
457
 
440
458
  ```sh
441
- mkdir -p ~/.config/systemd/user/
442
- podman generate systemd --name ybox-arch_apps > ~/.config/systemd/user/container-ybox-arch_apps.service
443
- systemctl --user enable container-ybox-arch_apps.service
459
+ systemctl --user status <SERVICE_NAME> # show status of the service
460
+ systemctl --user stop <SERVICE_NAME> # stop the service
461
+ systemctl --user start <SERVICE_NAME> # start the service
444
462
  ```
445
463
 
464
+ If your Linux distribution does not use systemd, then the autostart has to be handled
465
+ manually as per the distribution's preferred way. For instance an appropriate desktop
466
+ file can be added to `~/.config/autostart` directory to start a ybox container on
467
+ graphical login, though performing a clean stop can be hard with this approach.
468
+ Note that the preferred way to start/stop a ybox container is using the `ybox-control`
469
+ command rather than directly using podman/docker.
470
+
446
471
 
447
472
  ## Development
448
473
 
449
474
  Virtual environment setup have been provided for consistent development, test and build
450
475
  with multiple python versions. The minimum python version required is 3.9 and tests are
451
- run against all major python versions higher than that (i.e. 3.10, 3.11, 3.12 and others
452
- in future).
476
+ run against all major python versions higher than that (i.e. 3.10, 3.11, 3.12, 3.13 and
477
+ others in future).
453
478
 
454
479
  The setup uses pyenv with venv which can be used for development with IDEA/PyCharm/VSCode
455
480
  or in terminal, running tests against all supported python versions using `tox` etc.
@@ -476,14 +501,23 @@ Next you can install the required python versions and venv environment:
476
501
  pyenv/setup-venv.sh
477
502
  ```
478
503
 
479
- Finally, you can activate it in bash/zsh:
504
+ Finally, you can activate it.
505
+
506
+ bash:
507
+
508
+ ```sh
509
+ source pyenv/activate.bash
510
+ source .venv/bin/activate
511
+ ```
512
+
513
+ zsh:
480
514
 
481
515
  ```sh
482
- source pyenv/activate.sh
516
+ source pyenv/activate.zsh
483
517
  source .venv/bin/activate
484
518
  ```
485
519
 
486
- Or in fish shell:
520
+ fish:
487
521
 
488
522
  ```
489
523
  source pyenv/activate.fish
@@ -10,7 +10,17 @@ of the container including directories to be shared, logging etc.
10
10
 
11
11
  Special emphasis is given on security where users can choose to lock down
12
12
  or open up the container as required with reasonable defaults out of the
13
- box. There is no sharing of HOME or no privileged mode container.
13
+ box. There is no sharing of HOME or no privileged mode container. This sets
14
+ it apart from other similar solutions like distrobox/toolbx and the reason
15
+ for starting this project since those other solutions don't care about
16
+ security/sandboxing at all and share the entire HOME while running the
17
+ containers in privileged mode. The other problem with those solutions is that
18
+ the shared HOME means that the user's configuration dot files also get shared
19
+ and can cause all kinds of trouble where container apps can overwrite
20
+ with their own versions (especially for updated apps in the containers)
21
+ breaking the app in the host system. It is, however, possible to share the
22
+ entire HOME if user really wants but that needs to be explcitly configured
23
+ in the ini profile.
14
24
 
15
25
  Expected usage is for users to group similar applications in a container
16
26
  and separate out containers depending on different needs like higher/lower
@@ -44,7 +54,7 @@ So, for example, if you want to run the latest and greatest Intellij IDEA commun
44
54
  to do is:
45
55
 
46
56
  ```sh
47
- # create an Arch Linux based container
57
+ # create an Arch Linux based container and generate systemd service file (if possible)
48
58
  ybox-create arch
49
59
  # then select an appropriate built-in profile e.g. "dev.ini" from the menu
50
60
 
@@ -100,10 +110,11 @@ require you to install in a custom virtual environment which can be done manuall
100
110
  fish: `python3 -m venv ybox-venv && source ybox-env/bin/activate.fish`)
101
111
  or automatically using `pipx`. Alternatively you can add `--break-system-packages`
102
112
  flag to the `pip` command above or add it globally for all future packages using
103
- `python3 -m pip config set global.break-system-packages true`. The alternative
104
- approach works well for `ybox` which has a very minimal set of dependencies but
105
- in the rare case you see any issues due to package conflicts, use `pipx` or
106
- manual virtual environment.
113
+ `python3 -m pip config set global.break-system-packages true`. This alternative
114
+ approach works well for `ybox` which has a very minimal set of dependencies which will
115
+ not conflict with system packages (rather work with whatever system version is installed),
116
+ but if you prefer keeping the installation separate then use `pipx` or
117
+ a manual virtual environment.
107
118
 
108
119
  Now you can run the `ybox-create` and other utilities that are normally installed
109
120
  in your `~/.local/bin` directory which should be in PATH for modern Linux distributions.
@@ -141,6 +152,8 @@ to point to the full path of the podman or docker executable.
141
152
  ybox-create
142
153
  ```
143
154
 
155
+ By default this will also generate a user systemd service if possible (add `-S` or
156
+ `--skip-systemd-service` option to skip creation of a user systemd service).
144
157
  This will allow choosing from supported distributions, then from the available profiles.
145
158
  You can start with the Arch Linux distribution and `apps.ini` profile to try it out. The container
146
159
  will have a name like `ybox-<distribution>_<profile>` by default like `ybox-arch_apps` for the
@@ -165,7 +178,9 @@ does not run properly as root, then you cannot run it when using docker unless y
165
178
  `sudo/su` to the host user in the container command. However, running as host user when running
166
179
  rootless docker will map to a different user ID in the host (as specified in `/etc/subuid` on the
167
180
  host) so files shared with the host, including devices like those in `/dev/dri`, will cause
168
- permission issues that can hinder or break the application.
181
+ permission issues that can hinder or break the application. Hence it is recommended to
182
+ just install podman (even if you already have docker installed) which works out of the
183
+ box in rootless mode in all tested distributions.
169
184
 
170
185
 
171
186
  ### Package management: install/uninstall/list/search/...
@@ -211,7 +226,7 @@ ybox-pkg list -o
211
226
  ```
212
227
  To show more details of the packages (combine with -a/-o as required):
213
228
  ```sh
214
- ybox-pkg list -o
229
+ ybox-pkg list -v
215
230
  ```
216
231
 
217
232
  List all the files installed by the package:
@@ -251,6 +266,8 @@ Clean package cache, temporary downloads etc:
251
266
  ```sh
252
267
  ybox-pkg clean
253
268
  ```
269
+ Add `-q` option to answer yes for any questions automatically if all your containers use
270
+ the same shared root.
254
271
 
255
272
  Mark a package as explicitly installed (also registers with `ybox-pkg` if not present):
256
273
  ```sh
@@ -259,7 +276,7 @@ ybox-pkg mark firefox -e
259
276
 
260
277
  Mark a package as a dependency of another (also registers with `ybox-pkg` if not present):
261
278
  ```sh
262
- ybox-pkg mark qt5ct -D zoom # mark qt5ct as an optional dependency of zoom
279
+ ybox-pkg mark qt5ct -d zoom # mark qt5ct as an optional dependency of zoom
263
280
  ```
264
281
 
265
282
  Repair package installation after a failure or interrupt:
@@ -298,10 +315,10 @@ ybox-destroy ybox-arch_apps
298
315
  ```
299
316
 
300
317
  Will destroy the `apps` container created in the example before. This does not delete the
301
- $HOME files, nor does it delete the shared root directory (if enabled). Hence, if you create
318
+ `$HOME` files, nor does it delete the shared root directory (if enabled). Hence, if you create
302
319
  a new container having the same shared root, then it will inherit everything installed
303
320
  previously. Likewise, if you create the container with the same profile again, then it
304
- will also have the $HOME as before if you do not explicitly delete the directories
321
+ will also have the `$HOME` as before if you do not explicitly delete the directories
305
322
  in `~/.local/share/ybox`.
306
323
 
307
324
 
@@ -330,10 +347,10 @@ ybox-cmd ybox-arch_apps -- ls -l
330
347
  ```
331
348
 
332
349
  The default profiles also link the .bashrc and starship configuration files from your host
333
- $HOME directory by default, so you should see the same bash shell configuration as in your
350
+ `$HOME` directory by default, so you should see the same bash shell configuration as in your
334
351
  host. These are linked in read-only mode, so if you want to change these auto-linked
335
352
  configuration files inside the container, then you will need to create a copy from the symlink
336
- first (but then it will lose the link from the host $HOME).
353
+ first (but then it will lose the link from the host `$HOME`).
337
354
 
338
355
  A shell on a container will act like a native Linux distribution environment for most purposes.
339
356
  The one prominent missing thing is systemd which is not enabled deliberately since it requires
@@ -379,33 +396,39 @@ for a ybox container. See the full set of options with `ybox-control -h/--help`.
379
396
  ### Auto-starting containers
380
397
 
381
398
  Containers can be auto-started as per the usual way for rootless podman/docker services.
382
- This is triggered by systemd on user login which is exactly what we want for ybox
399
+ This is triggered by systemd on user login which is exactly what is required for ybox
383
400
  containers so that the container applications are available on login and are stopped on
384
- session logout. For docker the following should suffice:
385
-
386
- ```sh
387
- systemctl --user enable docker
388
- ```
401
+ session logout. All the tested Linux distributions support this and provide for user
402
+ systemd daemon on user login.
389
403
 
390
- See [docker docs](https://docs.docker.com/engine/security/rootless/#daemon) for details.
404
+ The `ybox-create` command autogenerates the systemd service file (in absence of `-S` or
405
+ `--skip-systemd-service` option) which is also removed by `ybox-destroy` automatically.
406
+ The name of the generated service is `ybox-<NAME>` where `<NAME>` is the name of the
407
+ container if `<NAME>` does not start with `ybox-` prefix, else it is just `<NAME>`.
391
408
 
392
- For podman you will need to explicitly generate systemd service file for each container and
393
- copy to your systemd configuration directory since podman does not use a background daemon.
394
- For the `ybox-arch_apps` container in the examples before:
409
+ With a user service installed, the `systemctl` commands can be used to control the
410
+ ybox container (`<SERVICE_NAME>` is `ybox-<NAME>/<NAME>` mentioned above):
395
411
 
396
412
  ```sh
397
- mkdir -p ~/.config/systemd/user/
398
- podman generate systemd --name ybox-arch_apps > ~/.config/systemd/user/container-ybox-arch_apps.service
399
- systemctl --user enable container-ybox-arch_apps.service
413
+ systemctl --user status <SERVICE_NAME> # show status of the service
414
+ systemctl --user stop <SERVICE_NAME> # stop the service
415
+ systemctl --user start <SERVICE_NAME> # start the service
400
416
  ```
401
417
 
418
+ If your Linux distribution does not use systemd, then the autostart has to be handled
419
+ manually as per the distribution's preferred way. For instance an appropriate desktop
420
+ file can be added to `~/.config/autostart` directory to start a ybox container on
421
+ graphical login, though performing a clean stop can be hard with this approach.
422
+ Note that the preferred way to start/stop a ybox container is using the `ybox-control`
423
+ command rather than directly using podman/docker.
424
+
402
425
 
403
426
  ## Development
404
427
 
405
428
  Virtual environment setup have been provided for consistent development, test and build
406
429
  with multiple python versions. The minimum python version required is 3.9 and tests are
407
- run against all major python versions higher than that (i.e. 3.10, 3.11, 3.12 and others
408
- in future).
430
+ run against all major python versions higher than that (i.e. 3.10, 3.11, 3.12, 3.13 and
431
+ others in future).
409
432
 
410
433
  The setup uses pyenv with venv which can be used for development with IDEA/PyCharm/VSCode
411
434
  or in terminal, running tests against all supported python versions using `tox` etc.
@@ -432,14 +455,23 @@ Next you can install the required python versions and venv environment:
432
455
  pyenv/setup-venv.sh
433
456
  ```
434
457
 
435
- Finally, you can activate it in bash/zsh:
458
+ Finally, you can activate it.
459
+
460
+ bash:
461
+
462
+ ```sh
463
+ source pyenv/activate.bash
464
+ source .venv/bin/activate
465
+ ```
466
+
467
+ zsh:
436
468
 
437
469
  ```sh
438
- source pyenv/activate.sh
470
+ source pyenv/activate.zsh
439
471
  source .venv/bin/activate
440
472
  ```
441
473
 
442
- Or in fish shell:
474
+ fish:
443
475
 
444
476
  ```
445
477
  source pyenv/activate.fish
@@ -28,8 +28,9 @@ classifiers = [
28
28
  "Programming Language :: Python :: 3.10",
29
29
  "Programming Language :: Python :: 3.11",
30
30
  "Programming Language :: Python :: 3.12",
31
+ "Programming Language :: Python :: 3.13",
31
32
  ]
32
- keywords = ["Linux in container", "toolbox"]
33
+ keywords = ["Linux in container", "toolbox", "distrobox"]
33
34
 
34
35
  [project.urls]
35
36
  Homepage = "https://github.com/sumwale/ybox"
@@ -1,2 +1,2 @@
1
1
  """`ybox` is a tool to easily manage linux distributions in containers"""
2
- __version__ = "0.9.8.1"
2
+ __version__ = "0.9.11"
@@ -10,6 +10,7 @@ import sys
10
10
  from enum import Enum
11
11
  from typing import Callable, Iterable, Optional, Union
12
12
 
13
+ from ybox import __version__ as product_version
13
14
  from ybox.config import Consts
14
15
 
15
16
  from .print import print_error, print_info, print_notice, print_warn
@@ -207,7 +208,7 @@ def run_command(cmd: Union[str, list[str]], capture_output: bool = False,
207
208
  sys.exit(result.returncode)
208
209
  else:
209
210
  return result.returncode
210
- if capture_output and result.stderr:
211
+ if capture_output and result.stderr and error_msg != "SKIP":
211
212
  print_warn(result.stderr.decode("utf-8"), file=sys.stderr)
212
213
  return result.stdout.decode("utf-8") if capture_output else result.returncode
213
214
 
@@ -221,6 +222,21 @@ def _print_subprocess_output(result: subprocess.CompletedProcess[bytes]) -> None
221
222
  print_warn(result.stderr.decode("utf-8"), file=sys.stderr)
222
223
 
223
224
 
225
+ def parser_version_check(parser: argparse.ArgumentParser, argv: list[str]) -> None:
226
+ """
227
+ Update command-line parser to add `--version` option to existing ones that will output the
228
+ ybox product version and exit if specified in the given list of arguments.
229
+
230
+ :param parser: instance of :class:`argparse.ArgumentParser` having the command-line parser
231
+ :param argv: the list of arguments to be parsed
232
+ """
233
+ parser.add_argument("--version", action="store_true", help="output ybox version")
234
+ # argv may have required positional arguments, hence check for --version separately
235
+ if "--version" in argv:
236
+ print(product_version)
237
+ sys.exit(0)
238
+
239
+
224
240
  def parse_opt_deps_args(argv: list[str]) -> argparse.Namespace:
225
241
  """
226
242
  Common command-line parser for `opt_deps` utilities (see [pkgmgr] section of distro.ini)
@@ -29,6 +29,8 @@ end
29
29
  complete -f -c ybox-create -s h -l help -d "show help"
30
30
  complete -c ybox-create -s n -l name -d "name of the ybox container" -r
31
31
  complete -f -c ybox-create -s F -l force-own-orphans -d "force ownership of orphans on shared root"
32
+ complete -f -c ybox-create -s C -l distribution-config -d "path to custom distribution configuration file"
33
+ complete -f -c ybox-create -l distribution-image -d "custom container image"
32
34
  complete -f -c ybox-create -s q -l quiet -d "skip interactive questions"
33
35
  complete -f -c ybox-create -n "not __fish_seen_subcommand_from (__fish_ybox_complete_distributions)" -a "(__fish_ybox_complete_distributions)"
34
36
 
@@ -10,8 +10,8 @@ current_user="$(id -un)"
10
10
  # install binaries for paru from paru-bin (paru takes too long to compile)
11
11
  PARU="paru --noconfirm"
12
12
  echo_color "$fg_cyan" "Installing AUR helper 'paru'" >> $status_file
13
- export HOME="$(eval echo "~$current_user")"
14
- cd ~
13
+ export HOME=$(getent passwd "$current_user" | cut -d: -f6)
14
+ cd "$HOME"
15
15
  rm -rf paru-bin
16
16
  git clone https://aur.archlinux.org/paru-bin.git
17
17
  cd paru-bin
@@ -6,6 +6,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
6
 
7
7
  source "$SCRIPT_DIR/entrypoint-common.sh"
8
8
 
9
+ export HOME=/root
9
10
  # pacman configuration
10
11
  PAC="pacman --noconfirm"
11
12
  echo_color "$fg_cyan" "Configuring pacman" >> $status_file
@@ -17,6 +17,8 @@ where:
17
17
  newlines in the description
18
18
  """
19
19
 
20
+ # TODO: SW: this is returning back installed packages too which should be skipped
21
+
20
22
  import gzip
21
23
  import os
22
24
  import re
@@ -11,7 +11,7 @@ where:
11
11
  and so on; resolution of level > 2 is not required since caller currently ignores those
12
12
  * <order>: this is a simple counter assigned to the dependencies where the value itself is of no
13
13
  significance but if multiple dependencies have the same value then it means that they
14
- are ORed dependencies and only one of them should normlly be selected for installation
14
+ are ORed dependencies and only one of them need to be selected for installation
15
15
  * <installed>: true if the dependency already installed and false otherwise
16
16
  * <description>: detailed description of the dependency; it can contain literal \n to indicate
17
17
  newlines in the description
@@ -69,6 +69,7 @@ class PkgDetail(Enum):
69
69
  OPTIONAL_DEP = 5
70
70
 
71
71
 
72
+ # noinspection PyUnusedLocal
72
73
  def process_next_item(line: str, parse_line: Callable[[str], tuple[PkgDetail, str]],
73
74
  parse_dep: Callable[[str], Iterable[tuple[str, str, Optional[str]]]],
74
75
  installed: Callable[[str], bool], max_level: int,
@@ -1,6 +1,7 @@
1
1
  [base]
2
2
  name = Profile for CLI and GUI apps
3
3
  includes = basic.ini
4
+ ssh_agent = on
4
5
 
5
6
  [security]
6
7
  # SYS_PTRACE may be required by mesa which is invoked indirectly by both firefox and chromium.
@@ -9,6 +10,9 @@ includes = basic.ini
9
10
  caps_add = SYS_PTRACE
10
11
 
11
12
  [mounts]
13
+ # export the host's ssh keys for use by ssh-agent in the container as required ("ro" mode
14
+ # implies that known_hosts and other files within ~/.ssh cannot be changed)
15
+ ssh = $HOME/.ssh:$TARGET_HOME/.ssh:ro
12
16
  music = $HOME/Music:$TARGET_HOME/Music:ro
13
17
  pictures = $HOME/Pictures:$TARGET_HOME/Pictures:ro
14
18
  videos = $HOME/Videos:$TARGET_HOME/Videos:ro
@@ -19,8 +23,9 @@ videos = $HOME/Videos:$TARGET_HOME/Videos:ro
19
23
 
20
24
  [app_flags]
21
25
  # These flags will be added to Exec line of google-chrome.desktop when it is copied to host.
22
- # /dev/shm usage is disabled for chrome because that requires ipc=host or mounting host
23
- # /dev/shm in read-write mode which can be insecure.
24
- google-chrome = !p --disable-dev-shm-usage !a
25
- google-chrome-beta = !p --disable-dev-shm-usage !a
26
- google-chrome-unstable = !p --disable-dev-shm-usage !a
26
+
27
+ # the --disable-dev-shm-usage flag in chrome/chromium based browsers disables use of /dev/shm
28
+ # which can reduce memory footprint at the cost of performance and increased disk activity
29
+ #google-chrome = !p --disable-dev-shm-usage !a
30
+ #google-chrome-beta = !p --disable-dev-shm-usage !a
31
+ #google-chrome-unstable = !p --disable-dev-shm-usage !a