-
-
Notifications
You must be signed in to change notification settings - Fork 1
docs: content for getting started and development env sections #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,107 @@ | ||
| # Getting Started | ||
|
|
||
| ## Installation | ||
|
|
||
| ### Pip | ||
|
|
||
| ```shell | ||
| pip install debmagic | ||
| ``` | ||
|
|
||
| or directly use uv | ||
|
|
||
| ```shell | ||
| uvx debmagic | ||
| ``` | ||
|
|
||
| ### Debian / Ubuntu - Soon (tm) | ||
|
|
||
| ```shell | ||
| apt install debmagic | ||
| ``` | ||
|
|
||
| ## Example debian/rules.py | ||
|
|
||
| Python `debian/rules.py` equivalent of [Ubuntu 24.04 htop](https://git.launchpad.net/ubuntu/+source/htop/tree/debian/rules?h=ubuntu/noble): | ||
|
|
||
| ```python | ||
| #!/usr/bin/env python3 | ||
|
|
||
| from debmagic.v0 import Build, autotools, dh, package | ||
|
|
||
| pkg = package( | ||
| preset=[dh], | ||
| maint_options="hardening=+all", | ||
| ) | ||
|
|
||
| if pkg.buildflags.DEB_HOST_ARCH_OS == "linux": | ||
| configure_params = ["--enable-affinity", "--enable-delayacct"] | ||
| else: | ||
| configure_params = ["--enable-hwloc"] | ||
|
|
||
| # hurd-i386 can open /proc (nothing there) and /proc/ which works | ||
| if pkg.buildflags.DEB_HOST_ARCH_OS == "hurd": | ||
| configure_params += ["--with-proc=/proc/"] | ||
| else: | ||
| configure_params += ["--enable-sensors"] | ||
|
|
||
|
|
||
| @pkg.stage | ||
| def configure(build: Build): | ||
| autotools.configure( | ||
| build, | ||
| ["--enable-openvz", "--enable-vserver", "--enable-unicode", *configure_params], | ||
| ) | ||
|
|
||
| pkg.pack() | ||
| ``` | ||
TheJJ marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### debhelper compatibility | ||
|
|
||
| Debmagic can use `dh` and provides **dh overrides** as common in `debian/rules` Makefiles: | ||
|
|
||
| ```python | ||
| from debmagic.v0 import dh | ||
|
|
||
| # specify dh arguments: | ||
| dhp = dh.Preset("--with=python3 --builddirectory=build") | ||
| pkg = package(preset=dhp) | ||
|
|
||
| # define optional overrides: | ||
| @dhp.override | ||
| def dh_auto_install(build: Build): | ||
| print("dh override worked :)") | ||
| build.cmd("dh_auto_install --max-parallel=1") | ||
|
|
||
| pkg.pack() | ||
| ``` | ||
|
|
||
| ### Custom functions | ||
|
|
||
| To add custom functions directly usable from CLI (like custom `debian/rules` targets for maintainers): | ||
|
|
||
| ```python | ||
| pkg = package(...) | ||
|
|
||
| @pkg.custom_function | ||
| def something_custom(some_param: int, another_param: str = "some default"): | ||
| print(f"you passed {some_param=} {another_param=}") | ||
|
|
||
| pkg.pack() | ||
| ``` | ||
|
|
||
| This function can be directly called with: | ||
|
|
||
| ```console | ||
| ./debian/rules.py something-custom --another-param=test 1337 | ||
| ``` | ||
|
|
||
| ```text | ||
| you passed some_param=test another_param=1337 | ||
| ``` | ||
|
|
||
| And generates automatic help for: | ||
|
|
||
| ```console | ||
| ./debian/rules.py something-custom --help | ||
| ``` | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # Autotools |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # Debhelper Compatibility |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Modules | ||
|
|
||
| ```{toctree} | ||
| :hidden: | ||
| :caption: Modules | ||
|
|
||
| autotools.md | ||
| dh.md | ||
| ``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.