0 | |
From dist.ini to .deb in one go
|
1 | |
===============================
|
2 | |
|
3 | |
Axel Beckert <abe@debian.org>
|
4 | |
|
5 | |
#VSLIDE
|
6 | |
|
7 | |
Some Questions…
|
8 | |
---------------
|
9 | |
|
10 | |
* Who knows debhelper?
|
11 | |
* Who packages Perl modules as `.deb`?
|
12 | |
* Who packages his own Perl modules as `.deb`?
|
13 | |
* Who knows Dist::Zilla?
|
14 | |
* Who uses Dist::Zilla for his own Perl Modules?
|
15 | |
|
16 | |
#HSLIDE
|
17 | |
|
18 | |
### What is Dist::Zilla?
|
19 | |
|
20 | |
* It's "Don't Repeat Yourself" for Perl module authors.
|
21 | |
|
22 | |
* Perl modules on CPAN require a bunch of meta data files which
|
23 | |
describe its contents and relations, e.g. `META.yml`, `META,json`,
|
24 | |
`Makefile.PL` or `Build.PL`. (debhelper relies on them, too.)
|
25 | |
|
26 | |
* In all Perl modules you develop, you always want the same author and
|
27 | |
release tests: Checks for proper style, common errors, POD syntax
|
28 | |
and coverage, etc. (Think Lintian!)
|
29 | |
|
30 | |
#HSLIDE
|
31 | |
|
32 | |
Dist::Zilla generates all these files by gathering information from
|
33 | |
your Perl module code plus a single minimal configuration file called
|
34 | |
`dist.ini`.
|
35 | |
|
36 | |
Dist::Zilla's command is `dzil` and it knows subcommands like `git`:
|
37 | |
|
38 | |
authordeps: list your distribution's author dependencies
|
39 | |
build: build your dist
|
40 | |
clean: clean up after build, test, or install
|
41 | |
cover: code coverage metrics for your distribution
|
42 | |
install: install your dist
|
43 | |
listdeps: print your distribution's prerequisites
|
44 | |
release: release your dist
|
45 | |
run: run stuff in a dir where your dist is built
|
46 | |
smoke: smoke your dist
|
47 | |
test: test your dist
|
48 | |
|
49 | |
#HSLIDE
|
50 | |
|
51 | |
#### Packaging Dist::Zilla based Perl Modules
|
52 | |
|
53 | |
Typical workflow for building a Perl module .deb:
|
54 | |
|
55 | |
1. Build CPAN tar-ball from `master` branch with `dzil build`.
|
56 | |
2. Switch to the `upstream` branch.
|
57 | |
3. Import the CPAN tar-ball's content into Git.
|
58 | |
4. Merge `upstream` branch into `debian` branch.
|
59 | |
5. Update packaging (`debian/changelog`, etc.)
|
60 | |
6. Build `.deb` package
|
61 | |
|
62 | |
#HSLIDE
|
63 | |
|
64 | |
### What we want
|
65 | |
|
66 | |
* Building the `.deb` directly from a VCS checkout
|
67 | |
* Skip manual tar-ball generation and reimport
|
68 | |
* Don't commit generated files to VCS
|
69 | |
|
70 | |
#HSLIDE
|
71 | |
|
72 | |
### dh-dist-zilla's Challenges
|
73 | |
|
74 | |
* `dh-make-perl` (for bootstrapping the Debian packaging) needs CPAN
|
75 | |
meta data.
|
76 | |
|
77 | |
* Solution: Run `dh-make-perl` once manually inside the
|
78 | |
`dzil`-generated build directory, copy `debian/` subdirectory back
|
79 | |
into the project root directory.
|
80 | |
|
81 | |
* debhelper (`dh`) only knows about `Build.PL` and `Makefile.PL`, not
|
82 | |
about `dist.ini`
|
83 | |
|
84 | |
#HSLIDE
|
85 | |
|
86 | |
### Debhelper Sequence Modification
|
87 | |
|
88 | |
* Generate build directory before debhelper looks for the existing of
|
89 | |
`Build.PL` or `Makefile.PL`: Call `dzil build` before
|
90 | |
`dh_auto_configure` and ignore generated tar-ball.
|
91 | |
|
92 | |
* Build package inside the generated build directory: Pass build
|
93 | |
directory option `-D` to `dh_auto_{configure,build,test,install}`.
|
94 | |
|
95 | |
* Easy cleanup: Just delete the build directory by calling `dzil
|
96 | |
clean` before `dh_auto_clean`.
|
97 | |
|
98 | |
#HSLIDE
|
99 | |
|
100 | |
### How do I use dh-dist-zilla in my Debian package?
|
101 | |
|
102 | |
It's as simple as this `debian/rules` file:
|
103 | |
|
104 | |
#!/usr/bin/make -f
|
105 | |
%:
|
106 | |
dh $@ --with dist-zilla
|
107 | |
|
108 | |
Additionally, a build-dependency on `dh-dist-zilla` is needed.
|
109 | |
|
110 | |
#HSLIDE
|
111 | |
|
112 | |
### Untypical Workflow
|
113 | |
|
114 | |
Expected / Traditional:
|
115 | |
|
116 | |
* VCS → `dzil build` → CPAN tar-ball ∈ Debian Source Package → Debian Binary Package
|
117 | |
|
118 | |
dh-dist-zilla:
|
119 | |
|
120 | |
* VCS → `dzil build` → CPAN tar-ball
|
121 | |
* VCS = Debian Source Package → Debian Binary Package
|
122 | |
|
123 | |
#HSLIDE
|
124 | |
|
125 | |
Example Module/Package
|
126 | |
----------------------
|
127 | |
|
128 | |
[Run::Parts](https://metacpan.org/release/Run-Parts) aka librun-parts-perl
|
129 | |
|
130 | |
* [librun-parts-perl from Debian Unstable](https://packages.debian.org/unstable/librun-parts-perl),
|
131 | |
* [master branch in the Git repository](https://github.com/xtaran/run-parts/tree/dh-dist-zilla)
|
132 | |
|
133 | |
#HSLIDE
|
134 | |
|
135 | |
Additional Helpers
|
136 | |
----------------
|
137 | |
|
138 | |
* Call `dh get-orig-source` to create an appropriate `.orig.tar.xz` tar-ball.
|
139 | |
|
140 | |
* Call `dh-dzil-refresh` to call `dh-make-perl refresh` inside a build
|
141 | |
directory.
|
142 | |
|
143 | |
#HSLIDE
|
144 | |
|
145 | |
### Tools
|
146 | |
|
147 | |
* dh-dist-zilla: https://github.com/elmar/dh-dist-zilla
|
148 | |
* Available from Debian 8 Jessie onwards:
|
149 | |
https://tracker.debian.org/pkg/dh-dist-zilla
|
150 | |
* debhelper: https://anonscm.debian.org/cgit/debhelper/debhelper.git
|
151 | |
* Dist::Zilla: http://dzil.org/
|
152 | |
* dh-make-perl: https://metacpan.org/release/DhMakePerl
|
153 | |
|
154 | |
#HSLIDE
|
155 | |
|
156 | |
### Slides
|
157 | |
|
158 | |
https://gitpitch.com/elmar/dh-dist-zilla
|
159 | |
|
160 | |
### Contact
|
161 | |
|
162 | |
* Axel Beckert <abe@debian.org>
|
163 | |
* Elmar Heeb <elmar@heebs.ch>
|