]> git.donarmstrong.com Git - neurodebian.git/blob - sphinx/blog/2011/2011-08-23_getting_stuff_packaged.rst
Final blog post version.
[neurodebian.git] / sphinx / blog / 2011 / 2011-08-23_getting_stuff_packaged.rst
1 :date: 2011-08-20 20:00:00
2 :tags: neuroscience, software, packaging
3
4 .. _chap_faciliate_neurosoftware_packaging:
5
6 What does it take to make packaging easier?
7 ===========================================
8
9 We often get contacted by people who wrote some scientific software and
10 would like to see it being available from the NeuroDebian repository.
11 Most of these developers don't know what it actually means to *package*
12 software, how time-consuming the process is, and who needs to do what to
13 get things done.
14
15 There is already a lot of information about *distribution packaging* on the
16 web, including "best-practices" documentation for upstream_-developers,
17 such as `Debian's upstream guide`_, and it would be pointless to repeat all
18 these bits here. Instead we will focus on a few core aspects that we found
19 to be the most ignored and misunderstood concepts that heavily influence
20 the speed and complexity of the *packaging process*.
21
22 .. _upstream: http://en.wikipedia.org/wiki/Upstream_(software_development)
23 .. _Debian's upstream guide: http://wiki.debian.org/UpstreamGuide
24
25 So what exactly is a *package*? The ultra-short summary: it is first and
26 foremost an executable description of how to build software from source and
27 install the resulting binaries, while ensuring compatibility and
28 interoperability with other parts of a particular system.  Hence, although
29 Debian-based operating systems install packages containing *binaries*, the
30 main focus of the packaging process is on the **source package**.  The
31 end-product of the packaging process is a source package that enables
32 **anybody** to produce binary packages in a *uniform* and *deterministic*
33 fashion, with an exhaustive description of its dependencies.
34
35 To understand how that is done any interested person **needs** to read a
36 fair bit of documentation, for example a `packaging tutorial`_, and the
37 `Debian policy`_ -- the ultimate guidelines for proper Debian packages.
38 But albeit being an interesting read for anyone, it is actually the
39 *package maintainer*'s job to get all this done right. However, there are a
40 few key aspects about packaging that any upstream developer should know, as
41 they will make the difference between getting a package done in a few
42 hours, or only after weeks, months, or years of tedious work. These are:
43
44 .. _packaging tutorial: http://www.lucas-nussbaum.net/blog/?p=640
45 .. _Debian policy: http://www.debian.org/doc/debian-policy/
46
47 * A reliable versioning scheme
48 * Exhaustive documentation of involved licenses
49 * Clear separation of 3rd-party code
50 * An open ear
51
52
53 Have a deterministic version!
54 -----------------------------
55
56 Software needs versions, packages need versions. A version is used to
57 determine whether an update is available, whether a particular package can
58 be used to satisfy a versioned dependency of another package, to associate
59 bug reports with source code, and, of course, to tell users what version
60 of a software they are running.  Surprisingly, there is a lot of scientific
61 software out there that doesn't have a version, or pretends to have one,
62 but the actual source code changes without a corresponding change in the
63 version. This is **wrong**. If you want to have your software packaged, have
64 a reliable versioning scheme:
65
66 * *Increment* the version whenever you make a release of your project, and
67   make a *new* release whenever you want to push out some changes to an
68   existing release (even for tiny changes).
69 * Put the version into the filename of your source or binary download.
70 * And/or use a `version control system`_ (VCS) that helps you track changes
71   and associates them with unique identifiers that could serve as a
72   version (if nothing better is available).
73
74 .. _version control system: http://en.wikipedia.org/wiki/Comparison_of_revision_control_software
75
76 If you don't have a deterministic version, the package maintainer needs to
77 come up with one.  Such custom version could be based on the time-stamp of
78 a download, or the last modification time of any file in the source
79 distribution.  But whatever the maintainer will come up with, it will take
80 time to implement, and it will be different from what you do. This will
81 make packaging more complex, and it will confuse users.
82
83
84 Be conscious about all licenses!
85 --------------------------------
86
87 Licenses are important. They determine whether a 3rd-party, such as a
88 Debian, is legally allowed to redistribute your software. They determine
89 whether a package maintainer is allowed to modify software for improved
90 system integration or bug fixing. They also have an impact on people's
91 motivation to contribute to a project -- many people out there would rather
92 not invest their precious time in software with restrictive licenses.
93
94 Be aware that the collection of *all* licenses in your source code form the
95 legal terms of your software. We often see "open-source" software that is "free"
96 (to use), but depends on, or includes source code that "may not be
97 redistributed".  This is most likely **wrong**. Moreover, we encountered quite a
98 few projects that didn't pick any license at all. If you intend other people
99 to use your tools this is **wrong** too, as no license typically means no
100 permissions at all -- not even to download or to use.
101
102 The package maintainer needs to sort all these things out, needs to
103 make sure that redistribution doesn't impose a legal threat to anyone
104 (including repository mirror operators), and needs to make sure that people
105 expecting free and open-source software only get free and open-source
106 software.
107
108 If you want to facilitate the packaging process: Make sure that you are
109 aware of all licenses covering the source code and other materials (such as
110 documentation and images) in your software. Make sure to document them
111 properly.  Make sure that the licenses covering the source code are
112 compatible to each other (e.g. you cannot release under the GPL_ if the
113 license of some other part of your code says "must not be used on
114 Thursdays"). The easiest way to avoid unnecessary complications is to use a
115 `standard license`_ (such as BSD, or GPL) that are known and have been
116 evaluated by legal experts regarding their implications and their
117 compatibility with each other. For any license, check if your legal terms
118 comply with the `open-source definition`_ or the `Debian free software
119 guidelines`_ (that are the basis of this definition).
120
121 .. keep to details for a dedicated "what license?" post
122
123 .. _GPL: http://www.gnu.org/copyleft/gpl.html
124 .. _standard license: http://www.opensource.org/licenses
125 .. _open-source definition: http://www.opensource.org/docs/osd
126 .. _Debian free software guidelines: http://www.debian.org/social_contract#guidelines
127
128
129 Allow for modularity!
130 ---------------------
131
132 Usually, software authors already have means to build their code for Debian
133 or Ubuntu systems before contacting a potential packager. However, quite
134 often these procedures need to be adjusted (and sometimes even abandoned)
135 for a distribution package. A prominent reason is the inclusion of
136 3rd-party source code. Virtually all software is built on top of some other
137 software -- may it be a GUI toolkit or a numerical library. Occasionally,
138 it makes sense to include the more exotic dependencies into a source
139 distribution of some software, mainly to make building and installing
140 easier for people on less fortunate platforms.
141
142 However, for a distribution package such setup is typically not acceptable.
143 An operating system like Debian is a modular system were duplication needs
144 to be avoided. There should only be a single copy of a particular library
145 or tool in the distribution. All packages that require a piece of 3rd-party
146 software need to declare a dependency on the corresponding package and
147 should not ship their own copy. This has the advantage that bugs in a
148 software can be fixed in a single place and all dependent software
149 automatically benefits from this fix, without further human intervention.
150 Only a modular design like this makes it possible to successfully maintain
151 an integrated system of tens of thousands of software packages with a
152 reasonable amount of manpower.
153
154 So if your source distribution contains 3rd-party software, clearly
155 identify its origin and version (the license as well, of course). This
156 informs the packager which dependencies need to be declared, or potentially
157 which other software still needs to be packaged separately, in order to
158 serve as a dependency.
159
160 As a consequence of the dependency system, you should avoid modifying
161 3rd-party software. If you, for example, take the source of a library and
162 modify it a bit to make it easier for you to do a certain task, there is
163 suddenly the need for having two almost identical libraries in the
164 operating system. The package for your software cannot use the system
165 package for this library, because it is modified. Instead of keeping a
166 modified version forever: if you need to fix bugs in 3rd-party software,
167 make sure to forward the fixes to the original developers. If you need to
168 adapt its behavior, try to do it in a way that is modular, keeping the
169 adaptor separate from the 3rd-party code.  This will make it much easier
170 for *you* to track future developments of this code, as well as help the
171 packager integrate your software into the operating system.
172
173 Also, you will significantly facilitate the packaging process if your
174 build-system allows to optionally build and link against system libraries
175 instead of the convenience copies that may be included in your source code.
176 Keep in mind that anything that is *required* for packaging software for
177 Debian needs to be added or modified by the package maintainer. All
178 modifications can potentially change the behavior of your software and may
179 confuse users and/or result in unnecessary support requests that need to be
180 dealt with. Be assured that it is in the very interest of the package
181 maintainer to keep the differences minimal. If you keep modularity aspects
182 in mind while developing, you can massively facilitate a packaging effort.
183
184
185 Be prepared for feedback!
186 -------------------------
187
188 The package maintainer might send you a few patches during the initial
189 packaging that either fix bugs on the Debian platform or that were added to
190 gain compliance with the Debian policy. Be prepared to evaluate these patches
191 and merge them into your code base or discuss necessary modifications. The
192 package maintainer needs to keep track of all modifications done to your
193 software and needs to refresh them for every new release that is made. If you
194 make it easy for the maintainer to do this work, for example quickly merging
195 modifications, exposing a version control system to track modifications, or at
196 least offering a reliable communication channel that informs the maintainer
197 about the fate of the patches, you will help to streamline long-term package
198 maintenance and contribute to a reliable package. All this will help
199 disseminating your software in an extremely convenient form to a very large
200 audience.
201
202
203 On a final note: If you keep these things in mind you won't only make a
204 packager's life easier. You will also have removed most hurdles for a smooth
205 packaging in general. Now you could actually think about doing the packaging
206 yourself.  Take a look at a `packaging tutorial`_ to get a sense of what it
207 would involve. If you decide to venture down this road, you are very welcome to
208 contact `us@NeuroDebian`_ -- we would be glad to guide you through an efficient
209 packaging process and upload fully packaged software for psychological and
210 neuroscience research into the main Debian archive and the NeuroDebian
211 repository.
212
213 .. _us@NeuroDebian: http://neuro.debian.net/#contacts