Skip to content

Commit fd9bce1

Browse files
committed
Final command-line tweaks and documentation
1 parent df89024 commit fd9bce1

9 files changed

+408
-57
lines changed

README.md

+58-26
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A portable Python library to generate binary software repositories
1313

1414
Ever needed to build an APT package repository on Fedora? Or perhaps a DNF repository on Debian? How about FreeBSD repository on Windows or Mac? This library allows you to do all these things and more. And yes, you can do it even on Windows if you are so inclined for some reason.
1515

16-
All binary package repositories have their own tools that usually range from being "non-portable" to "portable with lots of effort to limited platforms only". On the other hand it is often convenient to build software packages in a Map/Reduce fashion where a single host collects multiple packages built for different platforms to produce binary repositories. Such host will necessarily need to be able to build repositories for "foreign" packages. This library is an attempt to enable such scenario.
16+
All binary package repositories have their own tools that usually range from being "non-portable" to "portable with lots of effort to limited platforms only". On the other hand it is often convenient to build software packages in a Map/Reduce fashion where a single host collects multiple packages built for different platforms to produce binary repositories. Such host will necessarily need to be able to build repositories for "foreign" packages. This library is an attempt to enable such scenario. It provides both programmatic and command-line access.
1717

1818
## Requirements
1919

@@ -35,23 +35,15 @@ All binary package repositories have their own tools that usually range from bei
3535
pip install repopulator
3636
```
3737

38-
### Documentation
38+
## Documentation
3939

40-
Reference for public API is available at https://gershnik.github.io/repopulator/
40+
Documentation for API and command-line syntax is available at https://gershnik.github.io/repopulator/
4141

42-
### Sample Usage
42+
## Examples
4343

44-
The basic outline of the usage is the same for all repository types:
45-
- Create the repository object
46-
- Add packages to it. These must be files somewhere on your filesystem *which is not their final destination*
47-
- Some repositories like APT have additional subdivisions (distributions for APT). If so you need to create them and assign packages added to repository to them
48-
- Export the repository to the destination folder. This overwrites any repository already there (but not any extra files you might have).
44+
### APT
4945

50-
That's all there is to it. Note that there is no ability to "load" existing repositories and change them. This is deliberate. If you want to do incremental repository maintenance it is far easier to keep necessary info yourself in your own format than to parse it out of various repositories.
51-
52-
Currently repositories are required to be signed and you need to provide signing info for export (see examples below). This requirement might be relaxed in future versions.
53-
54-
#### APT
46+
#### Programmatic
5547

5648
```python
5749
from repopulator import AptRepo, PgpSigner
@@ -61,12 +53,7 @@ repo = AptRepo()
6153
package1 = repo.add_package('/path/to/awesome_3.14_amd64.deb')
6254
package2 = repo.add_package('/path/to/awesome_3.14_arm64.deb')
6355

64-
dist = repo.add_distribution('jammy',
65-
origin='my packages',
66-
label='my apt repo',
67-
suite='jammy',
68-
version='1.2',
69-
description='my awesome repo')
56+
dist = repo.add_distribution('jammy')
7057

7158
repo.assign_package(package1, dist, component='main')
7259
repo.assign_package(package2, dist, component='main')
@@ -77,7 +64,17 @@ repo.export('/path/of/new/repo', signer)
7764

7865
```
7966

80-
#### RPM
67+
#### Command-line
68+
69+
```bash
70+
repopulator apt -o /path/of/new/repo -k name_of_key_to_use -w password_of_that_key \
71+
-d jammy -c main \
72+
-p /path/to/awesome_3.14_amd64.deb /path/to/awesome_3.14_arm64.deb
73+
```
74+
75+
### RPM
76+
77+
#### Programmatic
8178

8279
```python
8380
from repopulator import RpmRepo, PgpSigner
@@ -92,14 +89,21 @@ repo.export('/path/of/new/repo', signer)
9289

9390
```
9491

95-
#### Pacman
92+
#### Command-line
93+
94+
```bash
95+
repopulator rpm -o /path/of/new/repo -k name_of_key_to_use -w password_of_that_key \
96+
-p /path/to/awesome-3.14-1.el9.x86_64.rpm /path/to/awesome-3.14-1.el9.aarch64.rpm
97+
```
98+
99+
### Pacman
100+
101+
#### Programmatic
96102

97103
```python
98104
from repopulator import PacmanRepo, PgpSigner
99105

100106
repo = PacmanRepo('myrepo')
101-
# if .sig file is present next to the .zst file it will be used for signature
102-
# otherwise new signature will be generated at export time
103107
repo.add_package('/path/to/awesome-3.14-1-x86_64.pkg.tar.zst')
104108
repo.add_package('/path/to/another-1.2-1-x86_64.pkg.tar.zst')
105109

@@ -109,7 +113,16 @@ repo.export('/path/of/new/repo', signer)
109113

110114
```
111115

112-
#### Alpine apk
116+
#### Command-line
117+
118+
```bash
119+
repopulator pacman -o /path/of/new/repo -k name_of_key_to_use -w password_of_that_key \
120+
-n myrepo -p /path/to/awesome-3.14-1-x86_64.pkg.tar.zst /path/to/another-1.2-1-x86_64.pkg.tar.zst
121+
```
122+
123+
### Alpine apk
124+
125+
#### Programmatic
113126

114127
```python
115128
from repopulator import AlpineRepo, PkiSigner
@@ -126,7 +139,18 @@ repo.export('/path/of/new/repo', signer, signer_name = '[email protected]
126139

127140
```
128141

129-
#### FreeBSD pkg
142+
#### Command-line
143+
144+
```bash
145+
repopulator alpine -o /path/of/new/repo -d 'my repo description' \
146+
-k /path/to/private/key.rsa -w password_of_that_key \
147+
148+
-p /path/to/awesome-3.14-r0.apk /path/to/another-1.23-r0.apk
149+
```
150+
151+
### FreeBSD pkg
152+
153+
#### Programmatic
130154

131155
```python
132156
from repopulator import FreeBSDRepo, PkiSigner
@@ -141,3 +165,11 @@ repo.export('/path/of/new/repo', signer)
141165

142166
```
143167

168+
#### Command-line
169+
170+
```bash
171+
repopulator freebsd -o /path/of/new/repo \
172+
-k /path/to/private/key -w password_of_that_key \
173+
-p /path/to/awesome-3.14.pkg /path/to/another-1.2.pkg
174+
```
175+

docs/command-line.md

+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# Command-Line Interface
2+
3+
## General
4+
5+
The `repopulator` module provides a simple command-line interface to create repositories.
6+
7+
You can invoke the command-line either via a script
8+
```bash
9+
$ repopulator
10+
```
11+
or as a module
12+
```bash
13+
$ python3 -m repopulator
14+
```
15+
16+
The general form of the command line is:
17+
18+
```bash
19+
$ repopulator TYPE -o DEST [options...] -p package1 package2 ....
20+
```
21+
22+
where `TYPE` is one of: `alpine`, `apt`, `freebsd`, `pacman`, `rpm` and `DEST` is the destination directory for the repository.
23+
24+
You can obtain overall help by using
25+
```bash
26+
$ repopulator -h/--help
27+
```
28+
29+
and a help about available options for each repository via:
30+
```bash
31+
$ repopulator TYPE -h/--help
32+
```
33+
34+
Options and their effect for each repository type are described below
35+
36+
## Alpine
37+
38+
The general command-line form for Alpine pkg repository is:
39+
40+
```bash
41+
$ repopulator alpine -o DEST -d DESC -k KEY_PATH [-w KEY_PASSWORD] [-s SIGNER] \
42+
-p package1 package2 ... \
43+
-a ARCH1 -p package3 package4 ... \
44+
-a ARCH2 -p package5 package6 ...
45+
46+
```
47+
48+
Where:
49+
50+
`-d DESC`, `--desc DESC`
51+
: The repository description
52+
53+
`-k KEY_PATH`, `--key KEY_PATH`
54+
: The path to private key for signing. If `-s/--signer` option is not supplied the stem of the private key filename is used as the name. So for example a key `[email protected]` will result in `[email protected]` being used as a signer name.
55+
56+
`-w KEY_PASSWORD`, `--password KEY_PASSWORD`
57+
: The password for the private key, if needed
58+
59+
`-s SIGNER`, `--signer SIGNER`
60+
: The signer name that overrides automatic deduction from the key filename described above
61+
62+
`-a ARCH`, `--arch ARCH`
63+
: Forces the architecture of the _following_ packages to be `ARCH`.
64+
65+
`-p path ...`, `--package path...`
66+
: `.apk` packages to add
67+
68+
By default, internal architecture of the package is used to decide under which architecture to register it in the repo.
69+
Some packages (such as `-doc-`, `-openrc-` etc.) do not have specific architecture and are marked as `noarch`. All Alpine packages in a repo must belong to some architecture so you need to use `-a ARCH` with them.
70+
71+
If you wish to "stop" the latest `-a ARCH` effect and revert to using architecture of the package use `-a` without an argument.
72+
73+
## APT
74+
75+
The general command-line form for APT repository is:
76+
77+
```bash
78+
$ repopulator apt -o DEST -k KEY_NAME -w KEY_PASSWORD \
79+
-d DISTRO1 \
80+
[--origin ORIGIN] [--label LABEL] [--suite SUITE] \
81+
[--codename CODENAME] [--version VERSION] [--desc DESC] \
82+
[-c COMPONENT1] \
83+
-p package1 package2 ... \
84+
[-c COMPONENT2] \
85+
-p package3 package4 ... \
86+
-d DISTRO2 \
87+
...
88+
```
89+
90+
Where:
91+
92+
`-k KEY_NAME`, `--key KEY_NAME`
93+
: Name or ID of the GPG key for signing
94+
95+
`-w KEY_PASSWORD`, `--password KEY_PASSWORD`
96+
: GPG key password
97+
98+
`-d DISTRO`, `--distro DISTRO`
99+
: Starts a new distribution named `DISTRO` (e.g. `jammy` or `focal`). All subsequent arguments refer to this distribution until the next `-d/--distro` argument. The distribution name can be a path like `stable/updates`
100+
101+
`--origin ORIGIN`
102+
: Optional `Origin` field for the distribution. See https://wiki.debian.org/DebianRepository/Format#Origin
103+
104+
`--label LABEL`
105+
: Optional `Label` field for the distribution. See https://wiki.debian.org/DebianRepository/Format#Label
106+
107+
`--suite SUITE`
108+
: Optional `Suite` field for the distribution. See https://wiki.debian.org/DebianRepository/Format#Suite. If omitted defaults to the last component of distribution path.
109+
110+
`--codename CODENAME`
111+
: Optional `Codename` field for the distribution. See https://wiki.debian.org/DebianRepository/Format#Codename. If omitted defaults to the last component of distribution path.
112+
113+
`--version VERSION`
114+
: Optional `Version` field for the distribution. See https://wiki.debian.org/DebianRepository/Format#Version. If omitted defaults to the last component of distribution path.
115+
116+
`--desc DESC`
117+
: Optional `Description` field for the distribution. See https://wiki.debian.org/DebianRepository/Format#Description. If omitted defaults to the last component of distribution path.
118+
119+
`-c COMPONENT`, `--comp COMPONENT`
120+
: Optional component of the _following_ packages. If not specified or component name is omitted defaults to `main`. You can specify multiple components for a distribution.
121+
122+
`-p path ...`, `--package path...`
123+
: `.deb` (or `.udeb`) packages to add to the current distribution and component
124+
125+
## FreeBSD
126+
127+
The general command-line form for FreeBSD repository is:
128+
129+
```bash
130+
$ repopulator freebsd -o DEST -k KEY_PATH [-w KEY_PASSWORD] \
131+
-p package1 package2 ...
132+
```
133+
134+
Where:
135+
136+
`-k KEY_PATH`, `--key KEY_PATH`
137+
: The path to private key for signing.
138+
139+
`-w KEY_PASSWORD`, `--password KEY_PASSWORD`
140+
: The password for the private key, if needed
141+
142+
`-p path ...`, `--package path...`
143+
: `.pkg` packages to add
144+
145+
146+
## Pacman
147+
148+
The general command-line form for Pacman repository is:
149+
150+
```bash
151+
$ repopulator pacman -o DEST -k KEY_NAME -w KEY_PASSWORD \
152+
-n name -p package1 package2 ...
153+
```
154+
155+
Where:
156+
157+
`-k KEY_NAME`, `--key KEY_NAME`
158+
: Name or ID of the GPG key for signing
159+
160+
`-w KEY_PASSWORD`, `--password KEY_PASSWORD`
161+
: GPG key password
162+
163+
`-n NAME`, `--name NAME`
164+
: Repository name
165+
166+
`-p path ...`, `--package path...`
167+
: `.zst` packages to add. If a matching .sig file with the same name exists next to the package, it will be automatically used to supply the package signature
168+
169+
## RPM
170+
171+
The general command-line form for Pacman repository is:
172+
173+
```bash
174+
$ repopulator rpm -o DEST -k KEY_NAME -w KEY_PASSWORD \
175+
-p package1 package2 ...
176+
```
177+
178+
Where:
179+
180+
`-k KEY_NAME`, `--key KEY_NAME`
181+
: Name or ID of the GPG key for signing
182+
183+
`-w KEY_PASSWORD`, `--password KEY_PASSWORD`
184+
: GPG key password
185+
186+
`-p path ...`, `--package path...`
187+
: `.rpm` packages to add.

docs/index.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ This is done in a portable fashion without relying on any platform and distribut
1818
* Alpine apk
1919
* FreeBSD pkg
2020

21+
## Documentation
2122

22-
## Reference
23-
24-
::: repopulator
25-
options:
26-
summary:
27-
modules: false
23+
* [Usage](usage.md)
24+
* [Reference](reference.md)
25+
* [Command-Line Interface](command-line.md)

docs/license.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License
2+
3+
{!LICENSE.txt!}

docs/reference.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Reference
2+
3+
::: repopulator
4+
options:
5+
summary:
6+
modules: false
7+

0 commit comments

Comments
 (0)