Skip to content

Commit dddc573

Browse files
committed
docs: content for getting started and development env sections
1 parent 6966a3a commit dddc573

File tree

9 files changed

+157
-39
lines changed

9 files changed

+157
-39
lines changed

README.md

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<img align="right" style="float: right; width: 25%;" src="assets/debmagic-logo.svg" alt="debmagic logo"/>
44

55
Debmagic is for [Debian](https://debian.org)/[Ubuntu](https://ubuntu.com):
6+
67
- create packages **build instructions** in Python with `debian/rules.py`
78
- tooling do perform packaging itself: **building** and **testing** in isolated container environments
89

9-
1010
[![GitHub Actions Status](https://github.com/SFTtech/debmagic/actions/workflows/ci.yml/badge.svg)](https://github.com/SFTtech/debmagic/actions/workflows/ci.yml)
1111

1212
> [!IMPORTANT]
@@ -21,7 +21,6 @@ Included features:
2121
- maintainer tools
2222
- `debmagic build` - isolated package building
2323

24-
2524
## Example debian/rules.py
2625

2726
Python `debian/rules.py` equivalent of [Ubuntu 24.04 htop](https://git.launchpad.net/ubuntu/+source/htop/tree/debian/rules?h=ubuntu/noble):
@@ -82,7 +81,7 @@ pkg.pack()
8281

8382
To add custom functions directly usable from CLI (like custom `debian/rules` targets for maintainers):
8483

85-
``` python
84+
```python
8685
pkg = package(...)
8786

8887
@pkg.custom_function
@@ -94,54 +93,30 @@ pkg.pack()
9493

9594
This function can be directly called with:
9695

97-
``` console
96+
```console
9897
./debian/rules.py something-custom --another-param=test 1337
9998
```
100-
``` text
99+
100+
```text
101101
you passed some_param=test another_param=1337
102102
```
103103

104104
And generates automatic help for:
105-
``` console
106-
./debian/rules.py something-custom --help
107-
```
108-
109-
110-
## Developing
111-
112-
Prerequisites:
113105

114-
- Debian >= trixie, either roll your own environment or to get started faster use the [devcontainer](https://containers.dev/)
115-
- Python >= 3.12
116-
- [UV](https://docs.astral.sh/uv/)
117-
118-
Setup:
119-
120-
```bash
121-
uv sync
122-
uv run pre-commit install
123-
```
124-
125-
Build the documentation
126-
127-
```bash
128-
# oneshot build
129-
uv run sphinx-build docs docs/_build
130-
# continous serving
131-
uv run sphinx-autobuild docs docs/_build
106+
```console
107+
./debian/rules.py something-custom --help
132108
```
133109

134-
135110
## Documentation
136111

137112
To do packaging with debmagic, please **[read the documentation!](https://debmagic.readthedocs.io)**.
138113

139-
140114
## Contributing
141115

142116
Debmagic can always use more features and modules!
143117
You can also just request features or report bugs - this project is happy about your contributions!
144118

119+
- [Contributor documentation](https://debmagic.readthedocs.io/en/latest/develop/index.html)
145120
- [Issue tracker](https://github.com/SFTtech/debmagic/issues)
146121
- [Code contributions](https://github.com/SFTtech/debmagic/pulls)
147122
- [Development roadmap](https://github.com/SFTtech/debmagic/projects)
@@ -152,12 +127,11 @@ To directly reach developers and other users, we have chat rooms.
152127
For questions, suggestions, problem support, please join and just ask!
153128

154129
| Contact | Where? |
155-
|---------------|------------------------------------------------------------------------------------------------|
130+
| ------------- | ---------------------------------------------------------------------------------------------- |
156131
| Issue Tracker | [SFTtech/debmagic](https://github.com/SFTtech/debmagic/issues) |
157132
| Matrix Chat | [`#sfttech:matrix.org`](https://app.element.io/#/room/#sfttech:matrix.org) |
158133
| Support us | [![donations](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/SFTtech) |
159134

160-
161135
## License
162136

163137
Released under the **GNU General Public License** version 2 or later, [LICENSE](legal/GPL-2) for details.

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
]
2121
myst_enable_extensions = [
2222
"colon_fence",
23+
"html_image",
24+
"attrs_inline",
2325
]
2426

2527
templates_path = ["_templates"]

docs/develop/index.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,30 @@
33
This section covers documentation relevant to developing and maintaining the debmagic
44
codebase, and some guidelines for how you can contribute.
55

6+
## Getting started with development
7+
8+
Prerequisites:
9+
10+
- Debian >= trixie, either roll your own environment or to get started faster use the [devcontainer](https://containers.dev/)
11+
- Python >= 3.12
12+
- [UV](https://docs.astral.sh/uv/)
13+
14+
Setup:
15+
16+
```shell
17+
uv sync
18+
uv run pre-commit install
19+
```
20+
21+
Build the documentation
22+
23+
```shell
24+
# oneshot build
25+
uv run sphinx-build docs docs/_build
26+
# continous serving
27+
uv run sphinx-autobuild docs docs/_build
28+
```
29+
630
```{toctree}
7-
```
31+
32+
```

docs/index.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# debmagic
22

3+
![debmagic image](../assets/debmagic-logo.svg){width=250px align=center}
4+
35
```{toctree}
46
:hidden:
57
:caption: Usage
68
79
usage/getting-started.md
8-
usage/installation.md
10+
usage/modules/index.md
911
```
1012

1113
```{toctree}
@@ -20,4 +22,4 @@ develop/index.md
2022
:caption: 📖 Reference
2123
2224
develop/_changelog.md
23-
```
25+
```

docs/usage/getting-started.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,107 @@
11
# Getting Started
22

3+
## Installation
4+
5+
### Pip
6+
7+
```shell
8+
pip install debmagic
9+
```
10+
11+
or directly use uv
12+
13+
```shell
14+
uvx debmagic
15+
```
16+
17+
### Debian / Ubuntu - Soon (tm)
18+
19+
```shell
20+
apt install debmagic
21+
```
22+
23+
## Example debian/rules.py
24+
25+
Python `debian/rules.py` equivalent of [Ubuntu 24.04 htop](https://git.launchpad.net/ubuntu/+source/htop/tree/debian/rules?h=ubuntu/noble):
26+
27+
```python
28+
#!/usr/bin/env python3
29+
30+
from debmagic.v0 import Build, autotools, dh, package
31+
32+
pkg = package(
33+
preset=[dh],
34+
maint_options="hardening=+all",
35+
)
36+
37+
if pkg.buildflags.DEB_HOST_ARCH_OS == "linux":
38+
configure_params = ["--enable-affinity", "--enable-delayacct"]
39+
else:
40+
configure_params = ["--enable-hwloc"]
41+
42+
# hurd-i386 can open /proc (nothing there) and /proc/ which works
43+
if pkg.buildflags.DEB_HOST_ARCH_OS == "hurd":
44+
configure_params += ["--with-proc=/proc/"]
45+
else:
46+
configure_params += ["--enable-sensors"]
47+
48+
49+
@pkg.stage
50+
def configure(build: Build):
51+
autotools.configure(
52+
build,
53+
["--enable-openvz", "--enable-vserver", "--enable-unicode", *configure_params],
54+
)
55+
56+
pkg.pack()
57+
```
58+
59+
### debhelper compatibility
60+
61+
Debmagic can use `dh` and provides **dh overrides** as common in `debian/rules` Makefiles:
62+
63+
```python
64+
from debmagic.v0 import dh
65+
66+
# specify dh arguments:
67+
dhp = dh.Preset("--with=python3 --builddirectory=build")
68+
pkg = package(preset=dhp)
69+
70+
# define optional overrides:
71+
@dhp.override
72+
def dh_auto_install(build: Build):
73+
print("dh override worked :)")
74+
build.cmd("dh_auto_install --max-parallel=1")
75+
76+
pkg.pack()
77+
```
78+
79+
### Custom functions
80+
81+
To add custom functions directly usable from CLI (like custom `debian/rules` targets for maintainers):
82+
83+
```python
84+
pkg = package(...)
85+
86+
@pkg.custom_function
87+
def something_custom(some_param: int, another_param: str = "some default"):
88+
print(f"you passed {some_param=} {another_param=}")
89+
90+
pkg.pack()
91+
```
92+
93+
This function can be directly called with:
94+
95+
```console
96+
./debian/rules.py something-custom --another-param=test 1337
97+
```
98+
99+
```text
100+
you passed some_param=test another_param=1337
101+
```
102+
103+
And generates automatic help for:
104+
105+
```console
106+
./debian/rules.py something-custom --help
107+
```

docs/usage/installation.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/usage/modules/autotools.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Autotools

docs/usage/modules/dh.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Debhelper Compatibility

docs/usage/modules/index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Modules
2+
3+
```{toctree}
4+
:hidden:
5+
:caption: Modules
6+
7+
autotools.md
8+
dh.md
9+
```

0 commit comments

Comments
 (0)