distroscript 0.1.0__tar.gz → 0.2.0__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 (56) hide show
  1. {distroscript-0.1.0 → distroscript-0.2.0}/PKG-INFO +25 -18
  2. {distroscript-0.1.0 → distroscript-0.2.0}/README.md +20 -17
  3. {distroscript-0.1.0 → distroscript-0.2.0}/pyproject.toml +7 -0
  4. {distroscript-0.1.0 → distroscript-0.2.0}/src/distroscript.py +30 -4
  5. {distroscript-0.1.0 → distroscript-0.2.0}/src/schema.json +6 -0
  6. {distroscript-0.1.0 → distroscript-0.2.0}/tests/inputs/17-appimage.yml +7 -0
  7. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/fedora/17-appimage.sh +18 -0
  8. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/ubuntu/17-appimage.sh +18 -0
  9. {distroscript-0.1.0 → distroscript-0.2.0}/.gitignore +0 -0
  10. {distroscript-0.1.0 → distroscript-0.2.0}/LICENSE +0 -0
  11. {distroscript-0.1.0 → distroscript-0.2.0}/tests/inputs/01-package.yml +0 -0
  12. {distroscript-0.1.0 → distroscript-0.2.0}/tests/inputs/02-package-default-name.yml +0 -0
  13. {distroscript-0.1.0 → distroscript-0.2.0}/tests/inputs/03-package-type-only.yml +0 -0
  14. {distroscript-0.1.0 → distroscript-0.2.0}/tests/inputs/04-pre-post_install.yml +0 -0
  15. {distroscript-0.1.0 → distroscript-0.2.0}/tests/inputs/05-flags.yml +0 -0
  16. {distroscript-0.1.0 → distroscript-0.2.0}/tests/inputs/06-depends_on.yml +0 -0
  17. {distroscript-0.1.0 → distroscript-0.2.0}/tests/inputs/07-snapd.yml +0 -0
  18. {distroscript-0.1.0 → distroscript-0.2.0}/tests/inputs/08-flatpak.yml +0 -0
  19. {distroscript-0.1.0 → distroscript-0.2.0}/tests/inputs/09-tarball.yml +0 -0
  20. {distroscript-0.1.0 → distroscript-0.2.0}/tests/inputs/10-github.yml +0 -0
  21. {distroscript-0.1.0 → distroscript-0.2.0}/tests/inputs/11-file.yml +0 -0
  22. {distroscript-0.1.0 → distroscript-0.2.0}/tests/inputs/12-pip.yml +0 -0
  23. {distroscript-0.1.0 → distroscript-0.2.0}/tests/inputs/13-shell.yml +0 -0
  24. {distroscript-0.1.0 → distroscript-0.2.0}/tests/inputs/14-zip.yml +0 -0
  25. {distroscript-0.1.0 → distroscript-0.2.0}/tests/inputs/15-transitive-deps.yml +0 -0
  26. {distroscript-0.1.0 → distroscript-0.2.0}/tests/inputs/16-install-first-option.yml +0 -0
  27. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/fedora/01-package.sh +0 -0
  28. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/fedora/02-package-default-name.sh +0 -0
  29. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/fedora/03-package-type-only.sh +0 -0
  30. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/fedora/04-pre-post_install.sh +0 -0
  31. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/fedora/05-flags.sh +0 -0
  32. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/fedora/06-depends_on.sh +0 -0
  33. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/fedora/07-snapd.sh +0 -0
  34. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/fedora/08-flatpak.sh +0 -0
  35. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/fedora/09-tarball.sh +0 -0
  36. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/fedora/10-github.sh +0 -0
  37. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/fedora/11-file.sh +0 -0
  38. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/fedora/12-pip.sh +0 -0
  39. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/fedora/13-shell.sh +0 -0
  40. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/fedora/14-zip.sh +0 -0
  41. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/fedora/15-transitive-deps.sh +0 -0
  42. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/fedora/16-install-first-option.sh +0 -0
  43. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/ubuntu/01-package.sh +0 -0
  44. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/ubuntu/02-package-default-name.sh +0 -0
  45. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/ubuntu/03-package-type-only.sh +0 -0
  46. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/ubuntu/04-pre-post_install.sh +0 -0
  47. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/ubuntu/07-snapd.sh +0 -0
  48. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/ubuntu/08-flatpak.sh +0 -0
  49. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/ubuntu/09-tarball.sh +0 -0
  50. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/ubuntu/10-github.sh +0 -0
  51. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/ubuntu/11-file.sh +0 -0
  52. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/ubuntu/12-pip.sh +0 -0
  53. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/ubuntu/13-shell.sh +0 -0
  54. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/ubuntu/14-zip.sh +0 -0
  55. {distroscript-0.1.0 → distroscript-0.2.0}/tests/outputs/ubuntu/15-transitive-deps.sh +0 -0
  56. {distroscript-0.1.0 → distroscript-0.2.0}/tests/run_tests.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: distroscript
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Generate Bash installation scripts from a declarative YAML config for multiple Linux distros
5
5
  Project-URL: Homepage, https://github.com/RaniAgus/distroscript
6
6
  Project-URL: Repository, https://github.com/RaniAgus/distroscript
@@ -36,6 +36,10 @@ License-File: LICENSE
36
36
  Requires-Python: >=3.10
37
37
  Requires-Dist: jsonschema
38
38
  Requires-Dist: pyyaml
39
+ Provides-Extra: dev
40
+ Requires-Dist: mypy; extra == 'dev'
41
+ Requires-Dist: types-jsonschema; extra == 'dev'
42
+ Requires-Dist: types-pyyaml; extra == 'dev'
39
43
  Description-Content-Type: text/markdown
40
44
 
41
45
  # distroscript
@@ -44,7 +48,7 @@ Generate installation scripts for various Linux distributions based on a
44
48
  declarative YAML configuration file.
45
49
 
46
50
  ```txt
47
- distroscript.py [-h] --os OS [--out OUT] config_path
51
+ distroscript [-h] --os OS [--out OUT] config_path
48
52
 
49
53
  Generate installation scripts from YAML config.
50
54
 
@@ -61,18 +65,18 @@ options:
61
65
  > For now, only `fedora` is fully supported, but I plan to add support for
62
66
  > `ubuntu`, `popos` and `mint` in the future.
63
67
 
64
- ## Dependencies
65
-
66
- - Ubuntu / Debian
68
+ ## Installation
67
69
 
68
70
  ```bash
69
- sudo apt-get install python3 python3-pyyaml python3-jsonschema
71
+ pip install distroscript
70
72
  ```
71
73
 
72
- - Fedora / Red Hat / CentOS
74
+ ## Development
75
+
76
+ Install dev dependencies with:
73
77
 
74
78
  ```bash
75
- sudo dnf install python3 python3-pyyaml python3-jsonschema
79
+ pip install -e ".[dev]"
76
80
  ```
77
81
 
78
82
  - MacOS
@@ -83,10 +87,10 @@ brew install python3 pyyaml jsonschema
83
87
 
84
88
  ## Schema Validation
85
89
 
86
- The configuration files are validated against a JSON Schema specification (`src/schema.json`)
90
+ The configuration files are validated against a JSON Schema specification (`src/schema.json`)
87
91
  that defines the structure and constraints for all supported package types and their properties.
88
92
 
89
- The validation happens automatically after reading the YAML file and before processing begins.
93
+ The validation happens automatically after reading the YAML file and before processing begins.
90
94
  If validation fails, the script will exit with a detailed error message showing:
91
95
  - The path to the invalid field
92
96
  - A description of what's wrong
@@ -405,21 +409,24 @@ oh-my-zsh:
405
409
  **AppImage:**
406
410
 
407
411
  ```yaml
408
- duckstation:
412
+ obsidian:
409
413
  - type: appimage
410
- url: https://github.com/stenzek/duckstation/releases/download/latest/DuckStation-x64.AppImage
411
- name: DuckStation
412
- icon_name: org.duckstation.DuckStation
413
- categories:
414
- - Game
415
- - Emulator
414
+ url: https://github.com/obsidianmd/obsidian-releases/releases/download/v1.8.10/Obsidian-1.8.10.AppImage
415
+ name: Obsidian
416
+ icon_name: obsidian
417
+ mime_types:
418
+ - x-scheme-handler/obsidian
416
419
  ```
417
420
 
418
421
  AppImages are downloaded to `$HOME/.local/bin/`, a desktop entry is created in
419
422
  `$HOME/.local/share/applications/`, and icons are extracted automatically when `icon_name` is specified.
420
423
 
424
+ When `mime_types` is provided, the desktop entry advertises those MIME types and the generated script
425
+ registers the AppImage as their default handler. URL scheme handlers such as `x-scheme-handler/obsidian`
426
+ automatically add `%u` to the generated `Exec` command.
427
+
421
428
  > [!NOTE]
422
- > AppImage packages require the `url` field. The `name`, `icon_name`, and `categories` fields are optional.
429
+ > AppImage packages require the `url` field. The `name`, `icon_name`, `categories`, and `mime_types` fields are optional.
423
430
  > The `name` field defaults to the package name, `icon_name` enables desktop icon extraction when provided,
424
431
  > and `categories` defaults to "Application".
425
432
 
@@ -4,7 +4,7 @@ Generate installation scripts for various Linux distributions based on a
4
4
  declarative YAML configuration file.
5
5
 
6
6
  ```txt
7
- distroscript.py [-h] --os OS [--out OUT] config_path
7
+ distroscript [-h] --os OS [--out OUT] config_path
8
8
 
9
9
  Generate installation scripts from YAML config.
10
10
 
@@ -21,18 +21,18 @@ options:
21
21
  > For now, only `fedora` is fully supported, but I plan to add support for
22
22
  > `ubuntu`, `popos` and `mint` in the future.
23
23
 
24
- ## Dependencies
25
-
26
- - Ubuntu / Debian
24
+ ## Installation
27
25
 
28
26
  ```bash
29
- sudo apt-get install python3 python3-pyyaml python3-jsonschema
27
+ pip install distroscript
30
28
  ```
31
29
 
32
- - Fedora / Red Hat / CentOS
30
+ ## Development
31
+
32
+ Install dev dependencies with:
33
33
 
34
34
  ```bash
35
- sudo dnf install python3 python3-pyyaml python3-jsonschema
35
+ pip install -e ".[dev]"
36
36
  ```
37
37
 
38
38
  - MacOS
@@ -43,10 +43,10 @@ brew install python3 pyyaml jsonschema
43
43
 
44
44
  ## Schema Validation
45
45
 
46
- The configuration files are validated against a JSON Schema specification (`src/schema.json`)
46
+ The configuration files are validated against a JSON Schema specification (`src/schema.json`)
47
47
  that defines the structure and constraints for all supported package types and their properties.
48
48
 
49
- The validation happens automatically after reading the YAML file and before processing begins.
49
+ The validation happens automatically after reading the YAML file and before processing begins.
50
50
  If validation fails, the script will exit with a detailed error message showing:
51
51
  - The path to the invalid field
52
52
  - A description of what's wrong
@@ -365,21 +365,24 @@ oh-my-zsh:
365
365
  **AppImage:**
366
366
 
367
367
  ```yaml
368
- duckstation:
368
+ obsidian:
369
369
  - type: appimage
370
- url: https://github.com/stenzek/duckstation/releases/download/latest/DuckStation-x64.AppImage
371
- name: DuckStation
372
- icon_name: org.duckstation.DuckStation
373
- categories:
374
- - Game
375
- - Emulator
370
+ url: https://github.com/obsidianmd/obsidian-releases/releases/download/v1.8.10/Obsidian-1.8.10.AppImage
371
+ name: Obsidian
372
+ icon_name: obsidian
373
+ mime_types:
374
+ - x-scheme-handler/obsidian
376
375
  ```
377
376
 
378
377
  AppImages are downloaded to `$HOME/.local/bin/`, a desktop entry is created in
379
378
  `$HOME/.local/share/applications/`, and icons are extracted automatically when `icon_name` is specified.
380
379
 
380
+ When `mime_types` is provided, the desktop entry advertises those MIME types and the generated script
381
+ registers the AppImage as their default handler. URL scheme handlers such as `x-scheme-handler/obsidian`
382
+ automatically add `%u` to the generated `Exec` command.
383
+
381
384
  > [!NOTE]
382
- > AppImage packages require the `url` field. The `name`, `icon_name`, and `categories` fields are optional.
385
+ > AppImage packages require the `url` field. The `name`, `icon_name`, `categories`, and `mime_types` fields are optional.
383
386
  > The `name` field defaults to the package name, `icon_name` enables desktop icon extraction when provided,
384
387
  > and `categories` defaults to "Application".
385
388
 
@@ -14,6 +14,13 @@ dependencies = [
14
14
  "jsonschema",
15
15
  ]
16
16
 
17
+ [project.optional-dependencies]
18
+ dev = [
19
+ "mypy",
20
+ "types-pyyaml",
21
+ "types-jsonschema",
22
+ ]
23
+
17
24
  [project.scripts]
18
25
  distroscript = "distroscript:_cli"
19
26
 
@@ -19,7 +19,7 @@ import sys
19
19
  from typing import ClassVar, Generic, TypeVar
20
20
  import yaml
21
21
 
22
- __version__ = "0.1.0"
22
+ __version__ = "0.2.0"
23
23
 
24
24
  def main(args: argparse.Namespace) -> None:
25
25
  """
@@ -863,6 +863,7 @@ class AppImagePackage(Package, type='appimage'):
863
863
  def create(cls, name: str, item: dict, platform: Platform) -> list[Package]:
864
864
  url = item.get('url')
865
865
  icon_name = item.get('icon_name')
866
+ mime_types = item.get('mime_types', [])
866
867
 
867
868
  if not url:
868
869
  raise RuntimeError(f"AppImagePackage requires 'url' field.")
@@ -876,6 +877,19 @@ class AppImagePackage(Package, type='appimage'):
876
877
  # Set up post_install commands for desktop integration
877
878
  app_name = item.get('name', name)
878
879
  destination = f"$HOME/.local/bin/{app_name}.AppImage"
880
+ desktop_file = f"{app_name}.desktop"
881
+ categories = item.get('categories', 'Application')
882
+ if isinstance(categories, str):
883
+ categories = [categories]
884
+ has_scheme_handler = any(
885
+ mime_type.startswith('x-scheme-handler/')
886
+ for mime_type in mime_types
887
+ )
888
+ exec_command = (
889
+ f"sh -c '\"{destination}\" \"$1\"' sh %u"
890
+ if has_scheme_handler
891
+ else f'sh -c "{destination}"'
892
+ )
879
893
 
880
894
  # Desktop file creation
881
895
  desktop_entry = []
@@ -884,20 +898,32 @@ class AppImagePackage(Package, type='appimage'):
884
898
  desktop_entry.append('StartupNotify=true')
885
899
  desktop_entry.append('Type=Application')
886
900
  desktop_entry.append('Terminal=false')
887
- desktop_entry.append(f'Categories={";".join(item.get('categories', 'Application'))};')
901
+ desktop_entry.append(f'Categories={";".join(categories)};')
888
902
  if icon_name:
889
903
  desktop_entry.append(f'Icon={icon_name}')
890
- desktop_entry.append(f'Exec=sh -c "{destination}"')
904
+ if mime_types:
905
+ desktop_entry.append(f'MimeType={";".join(mime_types)};')
906
+ desktop_entry.append(f'Exec={exec_command}')
891
907
  desktop_entry.append('')
892
908
 
893
909
  post_install.append(
894
910
  TeeCommand(
895
911
  '\n'.join(desktop_entry),
896
- destination=f"$HOME/.local/share/applications/{app_name}.desktop",
912
+ destination=f"$HOME/.local/share/applications/{desktop_file}",
897
913
  mkdir=True,
898
914
  )
899
915
  )
900
916
 
917
+ if mime_types:
918
+ post_install.append(
919
+ ShellCommand(
920
+ command='\n'.join(
921
+ f'xdg-mime default {desktop_file} {mime_type}'
922
+ for mime_type in mime_types
923
+ )
924
+ )
925
+ )
926
+
901
927
  # Icon extraction if icon_name is provided
902
928
  if icon_name:
903
929
  extract_icons = []
@@ -544,6 +544,12 @@
544
544
  }
545
545
  ]
546
546
  },
547
+ "mime_types": {
548
+ "type": "array",
549
+ "items": {
550
+ "type": "string"
551
+ }
552
+ },
547
553
  "depends_on": {
548
554
  "$ref": "#/definitions/dependencyList"
549
555
  },
@@ -12,3 +12,10 @@ duckstation:
12
12
  categories:
13
13
  - Game
14
14
  - Emulator
15
+
16
+ obsidian:
17
+ - type: appimage
18
+ url: https://github.com/obsidianmd/obsidian-releases/releases/download/v1.8.10/Obsidian-1.8.10.AppImage
19
+ name: Obsidian
20
+ mime_types:
21
+ - x-scheme-handler/obsidian
@@ -39,3 +39,21 @@ EOF
39
39
  cp -rv squashfs-root/usr/share/icons/hicolor/* "$HOME/.local/share/icons/hicolor/" 2>/dev/null || true
40
40
  rm -rf "$TMP_DIR"
41
41
  )
42
+
43
+ mkdir -p "$(dirname "$HOME/.local/bin/Obsidian.AppImage")"
44
+ curl -fsSL "https://github.com/obsidianmd/obsidian-releases/releases/download/v1.8.10/Obsidian-1.8.10.AppImage" -o "$HOME/.local/bin/Obsidian.AppImage" > /dev/null
45
+ chmod +x "$HOME/.local/bin/Obsidian.AppImage"
46
+
47
+ mkdir -p "$(dirname "$HOME/.local/share/applications/Obsidian.desktop")"
48
+ tee "$HOME/.local/share/applications/Obsidian.desktop" <<'EOF'
49
+ [Desktop Entry]
50
+ Name=Obsidian
51
+ StartupNotify=true
52
+ Type=Application
53
+ Terminal=false
54
+ Categories=Application;
55
+ MimeType=x-scheme-handler/obsidian;
56
+ Exec=sh -c '"$HOME/.local/bin/Obsidian.AppImage" "$1"' sh %u
57
+ EOF
58
+
59
+ xdg-mime default Obsidian.desktop x-scheme-handler/obsidian
@@ -39,3 +39,21 @@ EOF
39
39
  cp -rv squashfs-root/usr/share/icons/hicolor/* "$HOME/.local/share/icons/hicolor/" 2>/dev/null || true
40
40
  rm -rf "$TMP_DIR"
41
41
  )
42
+
43
+ mkdir -p "$(dirname "$HOME/.local/bin/Obsidian.AppImage")"
44
+ curl -fsSL "https://github.com/obsidianmd/obsidian-releases/releases/download/v1.8.10/Obsidian-1.8.10.AppImage" -o "$HOME/.local/bin/Obsidian.AppImage" > /dev/null
45
+ chmod +x "$HOME/.local/bin/Obsidian.AppImage"
46
+
47
+ mkdir -p "$(dirname "$HOME/.local/share/applications/Obsidian.desktop")"
48
+ tee "$HOME/.local/share/applications/Obsidian.desktop" <<'EOF'
49
+ [Desktop Entry]
50
+ Name=Obsidian
51
+ StartupNotify=true
52
+ Type=Application
53
+ Terminal=false
54
+ Categories=Application;
55
+ MimeType=x-scheme-handler/obsidian;
56
+ Exec=sh -c '"$HOME/.local/bin/Obsidian.AppImage" "$1"' sh %u
57
+ EOF
58
+
59
+ xdg-mime default Obsidian.desktop x-scheme-handler/obsidian
File without changes
File without changes