flatpaker 0.0.1__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.
@@ -0,0 +1,15 @@
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
+
3
+ # top-most EditorConfig file
4
+ root = true
5
+
6
+ [*]
7
+ indent_style = space
8
+ indent_size = 4
9
+ end_of_line = lf
10
+ charset = utf-8
11
+ trim_trailing_whitespace = true
12
+ insert_final_newline = true
13
+
14
+ [*.toml]
15
+ indent_size = 2
@@ -0,0 +1,132 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ .python-version
86
+
87
+ # pipenv
88
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
90
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
91
+ # install all needed dependencies.
92
+ #Pipfile.lock
93
+
94
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95
+ __pypackages__/
96
+
97
+ # Celery stuff
98
+ celerybeat-schedule
99
+ celerybeat.pid
100
+
101
+ # SageMath parsed files
102
+ *.sage.py
103
+
104
+ # Environments
105
+ .env
106
+ .venv
107
+ env/
108
+ venv/
109
+ ENV/
110
+ env.bak/
111
+ venv.bak/
112
+
113
+ # Spyder project settings
114
+ .spyderproject
115
+ .spyproject
116
+
117
+ # Rope project settings
118
+ .ropeproject
119
+
120
+ # mkdocs documentation
121
+ /site
122
+
123
+ # mypy
124
+ .mypy_cache/
125
+ .dmypy.json
126
+ dmypy.json
127
+
128
+ # Pyre type checker
129
+ .pyre/
130
+
131
+ # Flatpak files
132
+ .flatpak-builder
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Dylan Baker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,150 @@
1
+ Metadata-Version: 2.1
2
+ Name: flatpaker
3
+ Version: 0.0.1
4
+ Summary: Utilities to convert various kinds of native binaries into flatpaks.
5
+ Keywords: flatpak,renpy,rpgmaker
6
+ Author-email: Dylan Baker <dylan@pnwbakers.com>
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: System :: Archiving :: Packaging
19
+ Requires-Dist: tomli; python_version<"3.11"
20
+
21
+ # flatpaker
22
+
23
+ Script to mostly automate creating flatpaks from published Ren'Py and Linux
24
+ builds of RPGMaker MV and MZ. open to additional support
25
+
26
+ ## What is it?
27
+
28
+ It's a script that automatically handles much of the task of generating a
29
+ flatpak for pre-built projects, including adding patches or mods. You
30
+ write a small, simple toml file, fetch the sources, and get a ready to publish
31
+ flatpak.
32
+
33
+ It currently automatically does the following automatically:
34
+
35
+ - Generates an appstream xml file
36
+ - Generates a .desktop file
37
+ - Extracts an icon from the game source, and installs it
38
+ - patches the game to honor $XDG_DATA_HOME for storing game data inside the sandbox (instead of needing $HOME access)
39
+ - sets up the sandbox to allow audio and display, but nothing else
40
+ - recompiles the program when mods are applied
41
+ - strips .rpy files to save space (keeping the rpyc files)
42
+ - strips windows and macos specific files
43
+ - allows local install or publishing to a repo
44
+
45
+ ## Why?
46
+
47
+ I like playing Ren'Py games sometimes. I also don't always trust random
48
+ pre-compiled binaries from the internet. Flatpak provides a nice, convenient
49
+ way to sandbox applications. It also makes supporting Steam Deck and Fedora
50
+ immutable a breeze. But generating flatpaks by hand is a lot of work, especially
51
+ when most of the process will be exactly the same for every renpy project.
52
+
53
+ ## How do I use it?
54
+
55
+ 1. Download the compressed project
56
+ 2. Download any mods or addons (optional)
57
+ 3. Write a toml description
58
+ 4. run the program
59
+
60
+ ### Toml Format
61
+
62
+ ```toml
63
+ [common]
64
+ name = 'Game or VN' # use properly formatted name like "The Cool Adventures of Bob", or "Bob's Quest 7: Lawnmower Confusion"
65
+ reverse_url = 'com.example.JDoe' # name will be appended
66
+ # "Game" is added automatically
67
+ # used freedesktop menu categories. see: https://specifications.freedesktop.org/menu-spec/latest/apas02.html
68
+ categories = ['Simulation']
69
+ engine = ['renpy'] # Or 'rpgmaker'
70
+
71
+ [appdata]
72
+ summary = "A short summary, one sentence or so."
73
+ description = """
74
+ A longer description.
75
+
76
+ probably on multiple \
77
+ lines
78
+ """
79
+
80
+ # This is an optional value for the license of the renpy project itself.
81
+ # If unset it defaults to LicenseRef-Proprietary.
82
+ # if you have specific terms which are not an Open Source license, you can use the form:
83
+ # LicenseRef-Proprietary=https://www.example.com/my-license
84
+ # See: https://spdx.org/specifications for more information
85
+ license = "SPDX identifier"
86
+
87
+ [appdata.content_rating]
88
+ # optional
89
+ # Uses OARS specifications. See: https://hughsie.github.io/oars/
90
+ # keys should be ids, and the values are must be a rating (as a string):
91
+ # none, mild, moderate, or intense
92
+ language-profanity = "mild"
93
+
94
+ [appdata.releases]
95
+ # optional
96
+ # in the form "date = version"
97
+ "2023-01-01" = "1.0.0"
98
+
99
+ # Optional, alternatively may be passed on teh command line
100
+ [[sources.archives]]
101
+ # path must be set if this is provided
102
+ path = "relative to toml or absolute path"
103
+
104
+ # Optional, defaults to 1. How many directory levels to remove from this component
105
+ strip_comonents = 2
106
+
107
+ # Optional, cannot be set from command line
108
+ [[sources.patches]]
109
+ # path must be set if this is provided
110
+ path = "relative to toml or absolute path"
111
+
112
+ # Optional, defaults to 1. How many directory levels to remove from this component
113
+ strip_comonents = 2
114
+
115
+ # Optional, cannot be set from command line
116
+ [[sources.files]]
117
+ # path must be set if this is provided
118
+ path = "relative to toml or absolute path"
119
+
120
+ # Optional, if set the file will be installed to this name
121
+ # Does not have to be set for .rpy files that go in the game root directory
122
+ dest = "where to install"
123
+ ```
124
+
125
+ ### Configuration
126
+
127
+ Some options can be given on the command line or via a configuration file.
128
+ That file must be written to `$XDG_CONFIG_HOME/flatpaker/config.toml` (if unset
129
+ `$XDG_CONFIG_HOME` defaults to `~/.config`).
130
+
131
+ ```toml
132
+ [common]
133
+ # A gpg private key to sign with, overwritten by the --gpg option
134
+ gpg-key = "0x123456789"
135
+
136
+ # The absolute path to a repo to write to. overwritten by the --repo option
137
+ repo = "/path/to/a/repo/to/export"
138
+ ```
139
+
140
+
141
+ ## What is required?
142
+
143
+ - python 3.11 or a modern version of python3 with tomli
144
+ - flatpak-builder
145
+
146
+ ### Schema
147
+
148
+ A Json based schema is provided, which can be used with VSCode's EvenBetterToml
149
+ extension. It may be useful elsewhere.
150
+
@@ -0,0 +1,129 @@
1
+ # flatpaker
2
+
3
+ Script to mostly automate creating flatpaks from published Ren'Py and Linux
4
+ builds of RPGMaker MV and MZ. open to additional support
5
+
6
+ ## What is it?
7
+
8
+ It's a script that automatically handles much of the task of generating a
9
+ flatpak for pre-built projects, including adding patches or mods. You
10
+ write a small, simple toml file, fetch the sources, and get a ready to publish
11
+ flatpak.
12
+
13
+ It currently automatically does the following automatically:
14
+
15
+ - Generates an appstream xml file
16
+ - Generates a .desktop file
17
+ - Extracts an icon from the game source, and installs it
18
+ - patches the game to honor $XDG_DATA_HOME for storing game data inside the sandbox (instead of needing $HOME access)
19
+ - sets up the sandbox to allow audio and display, but nothing else
20
+ - recompiles the program when mods are applied
21
+ - strips .rpy files to save space (keeping the rpyc files)
22
+ - strips windows and macos specific files
23
+ - allows local install or publishing to a repo
24
+
25
+ ## Why?
26
+
27
+ I like playing Ren'Py games sometimes. I also don't always trust random
28
+ pre-compiled binaries from the internet. Flatpak provides a nice, convenient
29
+ way to sandbox applications. It also makes supporting Steam Deck and Fedora
30
+ immutable a breeze. But generating flatpaks by hand is a lot of work, especially
31
+ when most of the process will be exactly the same for every renpy project.
32
+
33
+ ## How do I use it?
34
+
35
+ 1. Download the compressed project
36
+ 2. Download any mods or addons (optional)
37
+ 3. Write a toml description
38
+ 4. run the program
39
+
40
+ ### Toml Format
41
+
42
+ ```toml
43
+ [common]
44
+ name = 'Game or VN' # use properly formatted name like "The Cool Adventures of Bob", or "Bob's Quest 7: Lawnmower Confusion"
45
+ reverse_url = 'com.example.JDoe' # name will be appended
46
+ # "Game" is added automatically
47
+ # used freedesktop menu categories. see: https://specifications.freedesktop.org/menu-spec/latest/apas02.html
48
+ categories = ['Simulation']
49
+ engine = ['renpy'] # Or 'rpgmaker'
50
+
51
+ [appdata]
52
+ summary = "A short summary, one sentence or so."
53
+ description = """
54
+ A longer description.
55
+
56
+ probably on multiple \
57
+ lines
58
+ """
59
+
60
+ # This is an optional value for the license of the renpy project itself.
61
+ # If unset it defaults to LicenseRef-Proprietary.
62
+ # if you have specific terms which are not an Open Source license, you can use the form:
63
+ # LicenseRef-Proprietary=https://www.example.com/my-license
64
+ # See: https://spdx.org/specifications for more information
65
+ license = "SPDX identifier"
66
+
67
+ [appdata.content_rating]
68
+ # optional
69
+ # Uses OARS specifications. See: https://hughsie.github.io/oars/
70
+ # keys should be ids, and the values are must be a rating (as a string):
71
+ # none, mild, moderate, or intense
72
+ language-profanity = "mild"
73
+
74
+ [appdata.releases]
75
+ # optional
76
+ # in the form "date = version"
77
+ "2023-01-01" = "1.0.0"
78
+
79
+ # Optional, alternatively may be passed on teh command line
80
+ [[sources.archives]]
81
+ # path must be set if this is provided
82
+ path = "relative to toml or absolute path"
83
+
84
+ # Optional, defaults to 1. How many directory levels to remove from this component
85
+ strip_comonents = 2
86
+
87
+ # Optional, cannot be set from command line
88
+ [[sources.patches]]
89
+ # path must be set if this is provided
90
+ path = "relative to toml or absolute path"
91
+
92
+ # Optional, defaults to 1. How many directory levels to remove from this component
93
+ strip_comonents = 2
94
+
95
+ # Optional, cannot be set from command line
96
+ [[sources.files]]
97
+ # path must be set if this is provided
98
+ path = "relative to toml or absolute path"
99
+
100
+ # Optional, if set the file will be installed to this name
101
+ # Does not have to be set for .rpy files that go in the game root directory
102
+ dest = "where to install"
103
+ ```
104
+
105
+ ### Configuration
106
+
107
+ Some options can be given on the command line or via a configuration file.
108
+ That file must be written to `$XDG_CONFIG_HOME/flatpaker/config.toml` (if unset
109
+ `$XDG_CONFIG_HOME` defaults to `~/.config`).
110
+
111
+ ```toml
112
+ [common]
113
+ # A gpg private key to sign with, overwritten by the --gpg option
114
+ gpg-key = "0x123456789"
115
+
116
+ # The absolute path to a repo to write to. overwritten by the --repo option
117
+ repo = "/path/to/a/repo/to/export"
118
+ ```
119
+
120
+
121
+ ## What is required?
122
+
123
+ - python 3.11 or a modern version of python3 with tomli
124
+ - flatpak-builder
125
+
126
+ ### Schema
127
+
128
+ A Json based schema is provided, which can be used with VSCode's EvenBetterToml
129
+ extension. It may be useful elsewhere.
@@ -0,0 +1,15 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # Copyright © 2024 Dylan Baker
3
+
4
+ """Utilities to convert various kinds of native binaries into flatpaks.
5
+
6
+ Current support includes Ren'Py and some versions of RPGMaker (MV and MZ, when
7
+ they have Linux packages).
8
+
9
+ Attempts to make some optimizations of the packages, such as recompiling
10
+ bytecode, and patches various games to honor XDG variables, so that flatpaks
11
+ don't need access to the user home directory. This increases security and is
12
+ generally beneficial for end users.
13
+ """
14
+
15
+ __version__ = "0.0.1"
@@ -0,0 +1,38 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # Copyright © 2024 Dylan Baker
3
+
4
+ from __future__ import annotations
5
+ import os
6
+ import typing
7
+
8
+ from flatpaker.util import tomllib
9
+
10
+ if typing.TYPE_CHECKING:
11
+
12
+ Common = typing.TypedDict(
13
+ 'Common',
14
+ {
15
+ 'gpg-key': str,
16
+ 'repo': str,
17
+ },
18
+ total=False,
19
+ )
20
+
21
+ class Config(typing.TypedDict):
22
+ common: Common
23
+
24
+
25
+ def load_config() -> Config:
26
+ root = os.environ.get('XDG_CONFIG_HOME', os.path.expanduser('~/.config'))
27
+ conf = os.path.join(root, 'flatpaker', 'config.toml')
28
+ raw: typing.Dict[str, typing.Any]
29
+ if os.path.exists(conf):
30
+ with open(conf, 'rb') as f:
31
+ raw = tomllib.load(f)
32
+ assert isinstance(raw, dict), 'invalid config file?'
33
+ else:
34
+ raw = {}
35
+
36
+ if 'common' not in raw:
37
+ raw['common'] = {}
38
+ return typing.cast('Config', raw)
@@ -0,0 +1,58 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # Copyright © 2022-2024 Dylan Baker
3
+
4
+ from __future__ import annotations
5
+ import argparse
6
+ import importlib
7
+ import pathlib
8
+ import typing
9
+
10
+ import flatpaker.config
11
+ import flatpaker.util
12
+
13
+ if typing.TYPE_CHECKING:
14
+ JsonWriterImpl = typing.Callable[[flatpaker.util.Description, pathlib.Path, str, pathlib.Path, pathlib.Path], None]
15
+
16
+ class ImplMod(typing.Protocol):
17
+
18
+ write_rules: JsonWriterImpl
19
+
20
+
21
+ def select_impl(name: typing.Literal['renpy', 'rpgmaker']) -> JsonWriterImpl:
22
+ mod = typing.cast('ImplMod', importlib.import_module(name, 'flatpaker.impl'))
23
+ assert hasattr(mod, 'write_rules'), 'should be good enough'
24
+ return mod.write_rules
25
+
26
+
27
+ def main() -> None:
28
+ config = flatpaker.config.load_config()
29
+ parser = argparse.ArgumentParser()
30
+ parser.add_argument('description', help="A Toml description file")
31
+ parser.add_argument(
32
+ '--repo',
33
+ default=config['common'].get('repo', 'repo'),
34
+ action='store',
35
+ help='a flatpak repo to put the result in')
36
+ parser.add_argument(
37
+ '--gpg',
38
+ default=config['common'].get('gpg-key'),
39
+ action='store',
40
+ help='A GPG key to sign the output to when writing to a repo')
41
+ parser.add_argument('--export', action='store_true', help='Export to the provided repo')
42
+ parser.add_argument('--install', action='store_true', help="Install for the user (useful for testing)")
43
+ parser.add_argument('--no-cleanup', action='store_false', dest='cleanup', help="don't delete the temporary directory")
44
+ args = typing.cast('flatpaker.util.Arguments', parser.parse_args())
45
+ # Don't use type for this because it swallows up the exception
46
+ description = flatpaker.util.load_description(args.description)
47
+
48
+ # TODO: This could be common
49
+ appid = f"{description['common']['reverse_url']}.{flatpaker.util.sanitize_name(description['common']['name'])}"
50
+
51
+ write_build_rules = select_impl(description['common']['engine'])
52
+
53
+ with flatpaker.util.tmpdir(description['common']['name'], args.cleanup) as d:
54
+ wd = pathlib.Path(d)
55
+ desktop_file = flatpaker.util.create_desktop(description, wd, appid)
56
+ appdata_file = flatpaker.util.create_appdata(description, wd, appid)
57
+ write_build_rules(description, wd, appid, desktop_file, appdata_file)
58
+ flatpaker.util.build_flatpak(args, wd, appid)
File without changes