summaryrefslogtreecommitdiff
path: root/doc/contributing.zh_CN.texi
diff options
context:
space:
mode:
Diffstat (limited to 'doc/contributing.zh_CN.texi')
-rw-r--r--doc/contributing.zh_CN.texi897
1 files changed, 0 insertions, 897 deletions
diff --git a/doc/contributing.zh_CN.texi b/doc/contributing.zh_CN.texi
deleted file mode 100644
index ba8a824cade..00000000000
--- a/doc/contributing.zh_CN.texi
+++ /dev/null
@@ -1,897 +0,0 @@
1@node 贡献
2@chapter 贡献
3
4这个项目是大家合作的成果,我们需要你的帮助以更好地发展。请通过
5@email{guix-devel@@gnu.org} 和 Freenode IRC 上的 @code{#guix} 联系我们。我们欢迎
6您的想法、bug反馈、补丁,以及任何可能对项目有帮助的贡献。我们特别欢迎帮助我们打
7包(@pxref{打包指导})。
8
9@cindex 行为准则和贡献者
10@cindex 贡献者契约
11我们希望提供一个温暖、友好,并且没有骚扰的的环境,这样每个人都能尽最大努力贡献。
12为了这个目的,我们的项目遵循“贡献者契约”,这个契约是根据
13@url{http://contributor-covenant.org/}制定的。你可以在源代码目录里的
14@file{CODE-OF-CONDUCT}文件里找到一份本地版。
15
16贡献者在提交补丁和网上交流时不需要使用法律认可的名字。他们可以使用任何名字或者假
17名。
18
19@menu
20* 从Git编译:: 最新的并且最好的.
21* 在安装之前运行Guix:: 黑客技巧。
22* 完美的配置:: 正确的工具。
23* 打包指导:: Growing the distribution.
24* 代码风格:: 开发者的卫生情况
25* 提交补丁:: 分享你的工作。
26@end menu
27
28@node 从Git编译
29@section 从Git编译
30
31如果你想折腾Guix本身,建议使用Git仓库里最新的版本:
32
33@example
34git clone https://git.savannah.gnu.org/git/guix.git
35@end example
36
37当从Git检出构建Guix时,除安装指导(@pxref{Requirements})里提及的软件包之外还需
38要这些包。
39
40@itemize
41@item @url{http://gnu.org/software/autoconf/, GNU Autoconf};
42@item @url{http://gnu.org/software/automake/, GNU Automake};
43@item @url{http://gnu.org/software/gettext/, GNU Gettext};
44@item @url{http://gnu.org/software/texinfo/, GNU Texinfo};
45@item @url{http://www.graphviz.org/, Graphviz};
46@item @url{http://www.gnu.org/software/help2man/, GNU Help2man (可选)}。
47@end itemize
48
49设置Guix开发环境的最简单的方式当然是使用Guix!下面这些命令启动一个shell,所有的
50依赖和环境变量都为折腾Guix设置好了:
51
52@example
53guix environment guix
54@end example
55
56这个命令更多的信息请参考@xref{Invoking guix environment}。额外的依赖可以通过
57@option{--ad-hoc}选项添加:
58
59@example
60guix environment guix --ad-hoc help2man git strace
61@end example
62
63运行 @command{./bootstrap} 以使用Autoconf和Automake生成编译系统的基础框架。如果
64你的得到这样的错误:
65
66@example
67configure.ac:46: error: possibly undefined macro: PKG_CHECK_MODULES
68@end example
69
70@noindent
71它可能意味着Autoconf无法找到由pkg-config提供的@file{pkg.m4}。请确保@file{pkg.m4}
72可用。由Guile提供的@file{guile.m4}宏也类似。假如你的Automake安装在
73@file{/usr/local},那么它不会从@file{/usr/share}里寻找@file{.m4}文件。这种情况下,
74你必须执行下面这个命令:
75
76@example
77export ACLOCAL_PATH=/usr/share/aclocal
78@end example
79
80参考@xref{Macro Search Path,,, automake, The GNU Automake Manual}.
81
82然后,像正常一样运行@command{./configure}。确保提供
83@code{--localstatedir=@var{directory}}参数,@var{directory}是你当前系统的
84@code{localstatedir}的值。(@pxref{The Store})
85
86最后,用@code{make check}执行测试(@pxref{Running the Test Suite})。如果遇到任
87何错误,请参考“安装指导”(@pxref{Installation})或者给
88@email{guix-devel@@gnu.org, 邮件列表}发邮件。
89
90
91@node 在安装之前运行Guix
92@section 在安装之前运行Guix
93
94为了保持一个合适的工作环境,你会发现在你的本地代码树里测试修改而不用安装它们会很
95有用。TODO: So that you can distinguish between your ``end-user'' hat and your
96``motley'' costume.
97
98这样,即使你没有运行@code{make install},所有的命令行工具都可以使用。为此,你先
99要有一个包含全部依赖的环境(@pxref{从Git编译}),然后,为所有的命令添加
100前缀@command{./pre-inst-env}(@file{pre-inst-env}脚本在Guix编译树的最顶层,它由
101@command{./configure}生成),如@footnote{@command{sudo}命令的@option{-E}参数
102确保@code{GUILE_LOAD_PATH}被正确设置,从而@command{guix-daemon}和它使用的工具可
103以找到它们需要的Guile模块。}:
104
105@example
106$ sudo -E ./pre-inst-env guix-daemon --build-users-group=guixbuild
107$ ./pre-inst-env guix build hello
108@end example
109
110@noindent
111类似的,对于使用Guix模块的Guile会话:
112
113@example
114$ ./pre-inst-env guile -c '(use-modules (guix utils)) (pk (%current-system))'
115
116;;; ("x86_64-linux")
117@end example
118
119@noindent
120@cindex REPL
121@cindex read-eval-print loop
122@dots{} and for a REPL (@pxref{Using Guile Interactively,,, guile, Guile
123Reference Manual}):
124
125@example
126$ ./pre-inst-env guile
127scheme@@(guile-user)> ,use(guix)
128scheme@@(guile-user)> ,use(gnu)
129scheme@@(guile-user)> (define snakes
130 (fold-packages
131 (lambda (package lst)
132 (if (string-prefix? "python"
133 (package-name package))
134 (cons package lst)
135 lst))
136 '()))
137scheme@@(guile-user)> (length snakes)
138$1 = 361
139@end example
140
141@command{pre-inst-env}脚本设置为此好了所有必要的的环境变量,包括@env{PATH}和
142@env{GUILE_LOAD_PATH}。
143
144@command{./pre-inst-env guix pull} @emph{不} 会更新本地源代码树,它只更新符号链
145接@file{~/.config/guix/current} (@pxref{Invoking guix pull})。如果你想更新本地源
146代码树,请运行@command{git pull}。
147
148
149@node 完美的配置
150@section 完美的配置
151
152折腾Guix的完美配置也是折腾Guile的完美配置@pxref{Using Guile in Emacs,,, guile,
153Guile Reference Manual})。首先,你需要的不仅是一个编辑器,你需要
154@url{http://www.gnu.org/software/emacs, Emacs},以及美妙的
155@url{http://nongnu.org/geiser/, Geiser}。为此,请运行:
156
157@example
158guix package -i emacs guile emacs-geiser
159@end example
160
161Geiser允许在Emacs里进行交互式的、增长式的开发:buffer里的代码补全和执行,获取一
162行的文档(docstrings),上下文敏感的补全,@kbd{M-.}跳转到对象定义,测试代码的
163REPL,及更多(@pxref{Introduction,,, geiser, Geiser User Manual})。为了方便的
164Guix开发,请确保修改Guile的加载路径(load path)以使其能从你的项目里找到源代码文
165件。
166
167@lisp
168;; @r{假设Guix项目在 ~/src/guix.}
169(with-eval-after-load 'geiser-guile
170 (add-to-list 'geiser-guile-load-path "~/src/guix"))
171@end lisp
172
173真正编辑代码时别忘了Emacs自带了方便的Scheme模式。而且,一定不要错过
174@url{http://www.emacswiki.org/emacs/ParEdit, Paredit}。它提供了直接操作语法树的
175的功能,例如,用S-表达式替换父节点,为S-表达式添加、删除前后的括号,删除后面的S-
176表达式,等等。
177
178@cindex 代码片段
179@cindex 模板
180@cindex reducing boilerplate
181在@file{etc/snippets}文件夹里,我们还为普通的git commit信息和软件包定义提供模板。
182这些模板可以通过@url{http://joaotavora.github.io/yasnippet/, YASnippet}使用,它
183可以把短的触发字符串扩展成交互式的文字片段。你可能希望将这个文件夹添加到Emacs的
184@var{yas-snippet-dirs}变量里。
185
186@lisp
187;; @r{假设Guix项目在 ~/src/guix.}
188(with-eval-after-load 'yasnippet
189 (add-to-list 'yas-snippet-dirs "~/src/guix/etc/snippets"))
190@end lisp
191
192commit信息片段显示staged文件需要依赖@url{https://magit.vc/, Magit}。编辑commit信
193息时,输入@code{add},然后按@kbd{TAB}就可以插入一段用于新增软件包的模板;输入
194@code{update},然后按@kbd{TAB}可以插入一段更新软件包的模板;输入@code{https}然后
195按@kbd{TAB}可以插入一段修改主页URI为HTTPS的模板。
196
197@code{scheme-mode}最重要的模板可以通过输入@code{package...},然后按@kbd{TAB}触发。
198这个片段还插入了触发字符串@code{origin...},以进一步展开。@code{origin}片段更进
199一步的可能插入其它以@code{...}结尾的触发字符串,它们可以被继续展开。
200
201
202@node 打包指导
203@section 打包指导
204
205@cindex 软件包, 创建
206这个GNU发行版正在开发的早期阶段,可能缺少一些你喜欢的软件。这个章节介绍你可以怎
207样帮助这个发行版成长。
208
209自由软件通常以@dfn{源代码包}的形式分发,通常是包含完整代码的@file{tar.gz}包。添
210加软件包到这个发行版意味着两件事:添加描述如何编译包的@dfn{配方}和一系列依赖软件,
211以及添加配方之外的@dfn{软件包元数据},如一段文字描述和证书信息。
212
213在Guix里所有这些信息都包含在@dfn{软件包定义}里。软件包定义提供了软件包的高层视角。
214它们使用Scheme编程语言编写,事实上,对每个软件包我们都定义一个绑定到软件包定义的
215的变量,并且从模块(@pxref{Package Modules})中导出那个变量。然而,深入的Scheme
216知识@emph{不}是创建软件包的前提条件。若要了解软件包的更多信息,@pxref{Defining
217Packages}。
218
219一旦软件包定义准备好了,并且包存在Guix代码树的一个文件里,你可以用@command{guix
220build} (@pxref{Invoking guix build})命令测试它。假设这个新软件包的名字叫做
221@code{gnew},你可以在Guix编译树里运行这个命令(@pxref{在安装之前运行Guix}):
222
223@example
224./pre-inst-env guix build gnew --keep-failed
225@end example
226
227使用@code{--keep-failed}参数会保留失败的编译树,这可以使调试编译错误更容易。
228@code{--log-file}也是一个调试时很有用的参数,它可以用来访问编译日志。
229
230如果@command{guix}命令找不到这个软件包,那可能是因为源文件包含语法错误,或者缺少
231导出软件包的@code{define-public}语句。为了查找错误,你可以用Guile导入这个模块以
232了解这个错误的详情:
233
234@example
235./pre-inst-env guile -c '(use-modules (gnu packages gnew))'
236@end example
237
238一旦你的软件包可以正确编译,请给我们发送补丁(@pxref{提交补丁})。当然,
239如果你需要帮助,我们也会很乐意帮助你。一旦补丁被提交到Guix仓库里,这个新的软件包
240会被自动地在支持的平台上编译@url{http://hydra.gnu.org/jobset/gnu/master, our
241continuous integration system}。
242
243@cindex substituter
244用户可以通过运行@command{guix pull}命令获取最新的软件包定义(@pxref{Invoking
245guix pull})。当@code{@value{SUBSTITUTE-SERVER}}编译好这些软件包之后,安装这些软
246件包时会自动从服务器(@pxref{Substitutes})上下载编译好的二进制包。唯一需要人工
247干预的地方是评审和应用代码补丁。
248
249
250@menu
251* 软件自由:: 什么可以进入这个发行版。
252* 软件包命名:: 名字里包含什么?
253* 版本号:: 当名字不够时
254* 简介和描述:: 帮助用户寻找合适的软件包
255* Python模块:: 接触英式的喜剧
256* Perl模块:: 小珍珠。
257* Java包:: 喝咖啡休息。
258* 字体:: 字体的乐趣。
259@end menu
260
261@node 软件自由
262@subsection 软件自由
263
264@c ===========================================================================
265@c
266@c This file was generated with po4a. Translate the source file.
267@c
268@c ===========================================================================
269@c Adapted from http://www.gnu.org/philosophy/philosophy.html.
270@cindex 自由软件
271开发GNU操作系统是为了用户拥有计算的自由。GNU是@dfn{自由软件},这意味着它有
272@url{http://www.gnu.org/philosophy/free-sw.html,四项重要的自由}:运行程序的自由,
273以源代码形式学习和修改程序的自由,原样重新分发副本的自由,和分发修改后的版本的自
274由。GNU发行版里包含的软件包只提供遵守这四项自由的软件。
275
276此外,GNU发行版遵循
277@url{http://www.gnu.org/distros/free-system-distribution-guidelines.html,自由软
278件发行版准则}。这些准则拒绝非自由的固件和对非自由软件的推荐,并讨论解决商标和专
279利的方法。
280
281某些上游的软件包源代码包含一小部分违反上述准则的可选的子集,比如这个子集本身就是
282非自由代码。这时,这些讨厌的代码需要用合适的补丁或者软件包定义(@pxref{Defining
283Packages})里的@code{origin}里的代码片段移除。这样,@code{guix build --source}就
284可以返回自由的源代码而不是未经修改的上游源代码。
285
286
287@node 软件包命名
288@subsection 软件包命名
289
290@cindex 软件包名字
291一个软件包事实上有两个名字:第一个是@emph{Scheme变量}的名字,即用
292@code{define-public}定义的名字。通过这个名字,软件包可以被Scheme代码找到,如用作
293其它软件包的输入。第二个名字是软件包定义里的@code{name}属性的字符串值。这个名字
294用于软件包管理命令,如:@command{guix package},@command{guix build}
295
296两个名字通常是相同的,常是上游项目名字转成小写字母并把下划线替换成连字符的结果。
297比如,GNUnet转成@code{gnunet},SDL_net转成@code{sdl-net}。
298
299我们不给库软件包添加@code{lib}前缀,除非它是项目官方名字的一部分。但是
300@pxref{Python模块}和@ref{Perl模块}有关于Python和Perl语言的特殊规则。
301
302字体软件包的名字处理起来不同,@pxref{字体}.
303
304
305@node 版本号
306@subsection 版本号
307
308@cindex 软件包版本
309我们通常只为每个自由软件的最新版本打包。但是有时候,比如对于版本不兼容的库,需要
310有同一个软件包的两个或更多版本。它们需要使用不同的Scheme变量名。我们为最新的版本
311使用@ref{软件包命名}里规定的名字,旧的版本使用加上后缀的名字,后缀是@code{-}
312和可以区分开版本号的版本号的最小前缀。
313
314软件包定义里的名字对于同一个软件包的所有版本都是相同的,并且不含有版本号。
315
316例如,GTK+的2.24.20和3.9.12两个版本可以这样打包:
317
318@example
319(define-public gtk+
320 (package
321 (name "gtk+")
322 (version "3.9.12")
323 ...))
324(define-public gtk+-2
325 (package
326 (name "gtk+")
327 (version "2.24.20")
328 ...))
329@end example
330如果我们还需要GTK+ 3.8.2,就这样打包
331@example
332(define-public gtk+-3.8
333 (package
334 (name "gtk+")
335 (version "3.8.2")
336 ...))
337@end example
338
339@c See <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg00425.html>,
340@c for a discussion of what follows.
341@cindex 用于版本控制快照的版本号
342有时候,我们为软件包上游的版本控制系统(VCS)的快照而不是正式发布版打包。这是特
343殊情况,因为决定哪个是稳定版的权力应该属于上游开发者。然而,有时候这是必须的。那
344么,我们该如何决定写在@code{version}里的版本号呢?
345
346显然,我们需要让VCS快照的commit ID在版本号中体现出来,但是我们也需要确保版本号单
347调递增,以便@command{guix package --upgrade}决定哪个版本号更新。由于commit ID,
348尤其是Git的commit ID,不是单调递增的,我们添加一个每次升级快照时都手动增长的
349revision数字。最后的版本号字符串看起来是这样:
350
351@example
3522.0.11-3.cabba9e
353 ^ ^ ^
354 | | `-- 上游的commit ID
355 | |
356 | `--- Guix软件包的revision
357 |
358最新的上游版本号
359@end example
360
361把@code{版本号}里的commit ID截短,比如只取7个数字,是一个好主意。它避免了美学上
362的烦恼(假设美学在这里很重要),以及操作系统限制引起的问题(比如Linux内核的127字
363节)。尽管如此,在@code{origin}里最好使用完整的commit ID,以避免混淆。
364
365@example
366(define my-package
367 (let ((commit "c3f29bc928d5900971f65965feaae59e1272a3f7")
368 (revision "1")) ;Guix软件包的revision
369 (package
370 (version (git-version "0.9" revision commit))
371 (source (origin
372 (method git-fetch)
373 (uri (git-reference
374 (url "git://example.org/my-package.git")
375 (commit commit)))
376 (sha256 (base32 "1mbikn@dots{}"))
377 (file-name (git-file-name name version))))
378 ;; @dots{}
379 )))
380@end example
381
382@node 简介和描述
383@subsection 简介和描述
384
385@cindex 软件包描述
386@cindex 软件包简介
387我们已经看到,GNU@tie{}Guix里的每个软件包都包含一个简介(synopsis)和一个描述
388(description)(@pxref{Defining Packages})。简介和描述很重要:它们是
389@command{guix package --search}搜索的信息,并且是帮助用户决定一个软件包是否符合
390自己需求的重要信息。因此,打包的人应该关注怎样写它们的内容。
391
392简介必须以大写字母开头,并且不能以句号结尾。它们不能以 ``a'' 或者 ``the'' 等没有
393意义的词开头。例如 ``File-frobbing tool'' 要比 ``A tool that frobs files'' 更好。
394简介需要说明软件包是什么--如 ``Core GNU utilities (file, text, shell)'',或者
395它的用途--如 GNU@tie{}grep 的简介是 ``Print lines matching a pattern''。
396
397Keep in mind that the synopsis must be meaningful for a very wide audience.
398For example, ``Manipulate alignments in the SAM format'' might make sense
399for a seasoned bioinformatics researcher, but might be fairly unhelpful or
400even misleading to a non-specialized audience. It is a good idea to come up
401with a synopsis that gives an idea of the application domain of the
402package. In this example, this might give something like ``Manipulate
403nucleotide sequence alignments'', which hopefully gives the user a better
404idea of whether this is what they are looking for.
405
406Descriptions should take between five and ten lines. Use full sentences,
407and avoid using acronyms without first introducing them. Please avoid
408marketing phrases such as ``world-leading'', ``industrial-strength'', and
409``next-generation'', and avoid superlatives like ``the most
410advanced''---they are not helpful to users looking for a package and may
411even sound suspicious. Instead, try to be factual, mentioning use cases and
412features.
413
414@cindex Texinfo markup, in package descriptions
415Descriptions can include Texinfo markup, which is useful to introduce
416ornaments such as @code{@@code} or @code{@@dfn}, bullet lists, or hyperlinks
417(@pxref{Overview,,, texinfo, GNU Texinfo}). However you should be careful
418when using some characters for example @samp{@@} and curly braces which are
419the basic special characters in Texinfo (@pxref{Special Characters,,,
420texinfo, GNU Texinfo}). User interfaces such as @command{guix package
421--show} take care of rendering it appropriately.
422
423Synopses and descriptions are translated by volunteers
424@uref{http://translationproject.org/domain/guix-packages.html, at the
425Translation Project} so that as many users as possible can read them in
426their native language. User interfaces search them and display them in the
427language specified by the current locale.
428
429To allow @command{xgettext} to extract them as translatable strings,
430synopses and descriptions @emph{must be literal strings}. This means that
431you cannot use @code{string-append} or @code{format} to construct these
432strings:
433
434@lisp
435(package
436 ;; @dots{}
437 (synopsis "This is translatable")
438 (description (string-append "This is " "*not*" " translatable.")))
439@end lisp
440
441Translation is a lot of work so, as a packager, please pay even more
442attention to your synopses and descriptions as every change may entail
443additional work for translators. In order to help them, it is possible to
444make recommendations or instructions visible to them by inserting special
445comments like this (@pxref{xgettext Invocation,,, gettext, GNU Gettext}):
446
447@example
448;; TRANSLATORS: "X11 resize-and-rotate" should not be translated.
449(description "ARandR is designed to provide a simple visual front end
450for the X11 resize-and-rotate (RandR) extension. @dots{}")
451@end example
452
453
454@node Python模块
455@subsection Python模块
456
457@cindex python
458We currently package Python 2 and Python 3, under the Scheme variable names
459@code{python-2} and @code{python} as explained in @ref{版本号}. To
460avoid confusion and naming clashes with other programming languages, it
461seems desirable that the name of a package for a Python module contains the
462word @code{python}.
463
464Some modules are compatible with only one version of Python, others with
465both. If the package Foo compiles only with Python 3, we name it
466@code{python-foo}; if it compiles only with Python 2, we name it
467@code{python2-foo}. If it is compatible with both versions, we create two
468packages with the corresponding names.
469
470If a project already contains the word @code{python}, we drop this; for
471instance, the module python-dateutil is packaged under the names
472@code{python-dateutil} and @code{python2-dateutil}. If the project name
473starts with @code{py} (e.g.@: @code{pytz}), we keep it and prefix it as
474described above.
475
476@subsubsection Specifying Dependencies
477@cindex inputs, for Python packages
478
479Dependency information for Python packages is usually available in the
480package source tree, with varying degrees of accuracy: in the
481@file{setup.py} file, in @file{requirements.txt}, or in @file{tox.ini}.
482
483Your mission, when writing a recipe for a Python package, is to map these
484dependencies to the appropriate type of ``input'' (@pxref{package Reference,
485inputs}). Although the @code{pypi} importer normally does a good job
486(@pxref{Invoking guix import}), you may want to check the following check
487list to determine which dependency goes where.
488
489@itemize
490
491@item
492We currently package Python 2 with @code{setuptools} and @code{pip}
493installed like Python 3.4 has per default. Thus you don't need to specify
494either of these as an input. @command{guix lint} will warn you if you do.
495
496@item
497Python dependencies required at run time go into @code{propagated-inputs}.
498They are typically defined with the @code{install_requires} keyword in
499@file{setup.py}, or in the @file{requirements.txt} file.
500
501@item
502Python packages required only at build time---e.g., those listed with the
503@code{setup_requires} keyword in @file{setup.py}---or only for
504testing---e.g., those in @code{tests_require}---go into
505@code{native-inputs}. The rationale is that (1) they do not need to be
506propagated because they are not needed at run time, and (2) in a
507cross-compilation context, it's the ``native'' input that we'd want.
508
509Examples are the @code{pytest}, @code{mock}, and @code{nose} test
510frameworks. Of course if any of these packages is also required at
511run-time, it needs to go to @code{propagated-inputs}.
512
513@item
514Anything that does not fall in the previous categories goes to
515@code{inputs}, for example programs or C libraries required for building
516Python packages containing C extensions.
517
518@item
519If a Python package has optional dependencies (@code{extras_require}), it is
520up to you to decide whether to add them or not, based on their
521usefulness/overhead ratio (@pxref{提交补丁, @command{guix size}}).
522
523@end itemize
524
525
526@node Perl模块
527@subsection Perl模块
528
529@cindex perl
530Perl programs standing for themselves are named as any other package, using
531the lowercase upstream name. For Perl packages containing a single class,
532we use the lowercase class name, replace all occurrences of @code{::} by
533dashes and prepend the prefix @code{perl-}. So the class @code{XML::Parser}
534becomes @code{perl-xml-parser}. Modules containing several classes keep
535their lowercase upstream name and are also prepended by @code{perl-}. Such
536modules tend to have the word @code{perl} somewhere in their name, which
537gets dropped in favor of the prefix. For instance, @code{libwww-perl}
538becomes @code{perl-libwww}.
539
540
541@node Java包
542@subsection Java包
543
544@cindex java
545Java programs standing for themselves are named as any other package, using
546the lowercase upstream name.
547
548To avoid confusion and naming clashes with other programming languages, it
549is desirable that the name of a package for a Java package is prefixed with
550@code{java-}. If a project already contains the word @code{java}, we drop
551this; for instance, the package @code{ngsjava} is packaged under the name
552@code{java-ngs}.
553
554For Java packages containing a single class or a small class hierarchy, we
555use the lowercase class name, replace all occurrences of @code{.} by dashes
556and prepend the prefix @code{java-}. So the class @code{apache.commons.cli}
557becomes package @code{java-apache-commons-cli}.
558
559
560@node 字体
561@subsection 字体
562
563@cindex fonts
564For fonts that are in general not installed by a user for typesetting
565purposes, or that are distributed as part of a larger software package, we
566rely on the general packaging rules for software; for instance, this applies
567to the fonts delivered as part of the X.Org system or fonts that are part of
568TeX Live.
569
570To make it easier for a user to search for fonts, names for other packages
571containing only fonts are constructed as follows, independently of the
572upstream package name.
573
574The name of a package containing only one font family starts with
575@code{font-}; it is followed by the foundry name and a dash @code{-} if the
576foundry is known, and the font family name, in which spaces are replaced by
577dashes (and as usual, all upper case letters are transformed to lower
578case). For example, the Gentium font family by SIL is packaged under the
579name @code{font-sil-gentium}.
580
581For a package containing several font families, the name of the collection
582is used in the place of the font family name. For instance, the Liberation
583fonts consist of three families, Liberation Sans, Liberation Serif and
584Liberation Mono. These could be packaged separately under the names
585@code{font-liberation-sans} and so on; but as they are distributed together
586under a common name, we prefer to package them together as
587@code{font-liberation}.
588
589In the case where several formats of the same font family or font collection
590are packaged separately, a short form of the format, prepended by a dash, is
591added to the package name. We use @code{-ttf} for TrueType fonts,
592@code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1
593fonts.
594
595
596@node 代码风格
597@section 代码风格
598
599In general our code follows the GNU Coding Standards (@pxref{Top,,,
600standards, GNU Coding Standards}). However, they do not say much about
601Scheme, so here are some additional rules.
602
603@menu
604* Programming Paradigm:: How to compose your elements.
605* Modules:: Where to store your code?
606* Data Types and Pattern Matching:: Implementing data structures.
607* Formatting Code:: Writing conventions.
608@end menu
609
610@node Programming Paradigm
611@subsection Programming Paradigm
612
613Scheme code in Guix is written in a purely functional style. One exception
614is code that involves input/output, and procedures that implement low-level
615concepts, such as the @code{memoize} procedure.
616
617@node Modules
618@subsection Modules
619
620Guile modules that are meant to be used on the builder side must live in the
621@code{(guix build @dots{})} name space. They must not refer to other Guix
622or GNU modules. However, it is OK for a ``host-side'' module to use a
623build-side module.
624
625Modules that deal with the broader GNU system should be in the @code{(gnu
626@dots{})} name space rather than @code{(guix @dots{})}.
627
628@node Data Types and Pattern Matching
629@subsection Data Types and Pattern Matching
630
631The tendency in classical Lisp is to use lists to represent everything, and
632then to browse them ``by hand'' using @code{car}, @code{cdr}, @code{cadr},
633and co. There are several problems with that style, notably the fact that
634it is hard to read, error-prone, and a hindrance to proper type error
635reports.
636
637Guix code should define appropriate data types (for instance, using
638@code{define-record-type*}) rather than abuse lists. In addition, it should
639use pattern matching, via Guile’s @code{(ice-9 match)} module, especially
640when matching lists.
641
642@node Formatting Code
643@subsection Formatting Code
644
645@cindex formatting code
646@cindex coding style
647When writing Scheme code, we follow common wisdom among Scheme programmers.
648In general, we follow the @url{http://mumble.net/~campbell/scheme/style.txt,
649Riastradh's Lisp Style Rules}. This document happens to describe the
650conventions mostly used in Guile’s code too. It is very thoughtful and well
651written, so please do read it.
652
653Some special forms introduced in Guix, such as the @code{substitute*} macro,
654have special indentation rules. These are defined in the
655@file{.dir-locals.el} file, which Emacs automatically uses. Also note that
656Emacs-Guix provides @code{guix-devel-mode} mode that indents and highlights
657Guix code properly (@pxref{Development,,, emacs-guix, The Emacs-Guix
658Reference Manual}).
659
660@cindex indentation, of code
661@cindex formatting, of code
662If you do not use Emacs, please make sure to let your editor knows these
663rules. To automatically indent a package definition, you can also run:
664
665@example
666./etc/indent-code.el gnu/packages/@var{file}.scm @var{package}
667@end example
668
669@noindent
670This automatically indents the definition of @var{package} in
671@file{gnu/packages/@var{file}.scm} by running Emacs in batch mode. To
672indent a whole file, omit the second argument:
673
674@example
675./etc/indent-code.el gnu/services/@var{file}.scm
676@end example
677
678@cindex Vim, Scheme code editing
679If you are editing code with Vim, we recommend that you run @code{:set
680autoindent} so that your code is automatically indented as you type.
681Additionally, @uref{https://www.vim.org/scripts/script.php?script_id=3998,
682@code{paredit.vim}} may help you deal with all these parentheses.
683
684We require all top-level procedures to carry a docstring. This requirement
685can be relaxed for simple private procedures in the @code{(guix build
686@dots{})} name space, though.
687
688Procedures should not have more than four positional parameters. Use
689keyword parameters for procedures that take more than four parameters.
690
691
692@node 提交补丁
693@section 提交补丁
694
695Development is done using the Git distributed version control system. Thus,
696access to the repository is not strictly necessary. We welcome
697contributions in the form of patches as produced by @code{git format-patch}
698sent to the @email{guix-patches@@gnu.org} mailing list.
699
700This mailing list is backed by a Debbugs instance accessible at
701@uref{https://bugs.gnu.org/guix-patches}, which allows us to keep track of
702submissions. Each message sent to that mailing list gets a new tracking
703number assigned; people can then follow up on the submission by sending
704email to @code{@var{NNN}@@debbugs.gnu.org}, where @var{NNN} is the tracking
705number (@pxref{Sending a Patch Series}).
706
707Please write commit logs in the ChangeLog format (@pxref{Change Logs,,,
708standards, GNU Coding Standards}); you can check the commit history for
709examples.
710
711Before submitting a patch that adds or modifies a package definition, please
712run through this check list:
713
714@enumerate
715@item
716If the authors of the packaged software provide a cryptographic signature
717for the release tarball, make an effort to verify the authenticity of the
718archive. For a detached GPG signature file this would be done with the
719@code{gpg --verify} command.
720
721@item
722Take some time to provide an adequate synopsis and description for the
723package. @xref{简介和描述}, for some guidelines.
724
725@item
726Run @code{guix lint @var{package}}, where @var{package} is the name of the
727new or modified package, and fix any errors it reports (@pxref{Invoking guix
728lint}).
729
730@item
731Make sure the package builds on your platform, using @code{guix build
732@var{package}}.
733
734@item
735We recommend you also try building the package on other supported
736platforms. As you may not have access to actual hardware platforms, we
737recommend using the @code{qemu-binfmt-service-type} to emulate them. In
738order to enable it, add the following service to the list of services in
739your @code{operating-system} configuration:
740
741@example
742(service qemu-binfmt-service-type
743 (qemu-binfmt-configuration
744 (platforms (lookup-qemu-platforms "arm" "aarch64" "mips64el"))
745 (guix-support? #t)))
746@end example
747
748Then reconfigure your system.
749
750You can then build packages for different platforms by specifying the
751@code{--system} option. For example, to build the "hello" package for the
752armhf, aarch64, or mips64 architectures, you would run the following
753commands, respectively:
754@example
755guix build --system=armhf-linux --rounds=2 hello
756guix build --system=aarch64-linux --rounds=2 hello
757guix build --system=mips64el-linux --rounds=2 hello
758@end example
759
760@item
761@cindex bundling
762Make sure the package does not use bundled copies of software already
763available as separate packages.
764
765Sometimes, packages include copies of the source code of their dependencies
766as a convenience for users. However, as a distribution, we want to make
767sure that such packages end up using the copy we already have in the
768distribution, if there is one. This improves resource usage (the dependency
769is built and stored only once), and allows the distribution to make
770transverse changes such as applying security updates for a given software
771package in a single place and have them affect the whole system---something
772that bundled copies prevent.
773
774@item
775Take a look at the profile reported by @command{guix size} (@pxref{Invoking
776guix size}). This will allow you to notice references to other packages
777unwillingly retained. It may also help determine whether to split the
778package (@pxref{Packages with Multiple Outputs}), and which optional
779dependencies should be used. In particular, avoid adding @code{texlive} as
780a dependency: because of its extreme size, use @code{texlive-tiny} or
781@code{texlive-union} instead.
782
783@item
784For important changes, check that dependent package (if applicable) are not
785affected by the change; @code{guix refresh --list-dependent @var{package}}
786will help you do that (@pxref{Invoking guix refresh}).
787
788@c See <https://lists.gnu.org/archive/html/guix-devel/2016-10/msg00933.html>.
789@cindex branching strategy
790@cindex rebuild scheduling strategy
791Depending on the number of dependent packages and thus the amount of
792rebuilding induced, commits go to different branches, along these lines:
793
794@table @asis
795@item 300 dependent packages or less
796@code{master} branch (non-disruptive changes).
797
798@item between 300 and 1,200 dependent packages
799@code{staging} branch (non-disruptive changes). This branch is intended to
800be merged in @code{master} every 3 weeks or so. Topical changes (e.g., an
801update of the GNOME stack) can instead go to a specific branch (say,
802@code{gnome-updates}).
803
804@item more than 1,200 dependent packages
805@code{core-updates} branch (may include major and potentially disruptive
806changes). This branch is intended to be merged in @code{master} every 2.5
807months or so.
808@end table
809
810All these branches are @uref{https://hydra.gnu.org/project/gnu, tracked by
811our build farm} and merged into @code{master} once everything has been
812successfully built. This allows us to fix issues before they hit users, and
813to reduce the window during which pre-built binaries are not available.
814
815@c TODO: It would be good with badges on the website that tracks these
816@c branches. Or maybe even a status page.
817Generally, branches other than @code{master} are considered @emph{frozen} if
818there has been a recent evaluation, or there is a corresponding @code{-next}
819branch. Please ask on the mailing list or IRC if unsure where to place a
820patch.
821
822@item
823@cindex determinism, of build processes
824@cindex reproducible builds, checking
825Check whether the package's build process is deterministic. This typically
826means checking whether an independent build of the package yields the exact
827same result that you obtained, bit for bit.
828
829A simple way to do that is by building the same package several times in a
830row on your machine (@pxref{Invoking guix build}):
831
832@example
833guix build --rounds=2 my-package
834@end example
835
836This is enough to catch a class of common non-determinism issues, such as
837timestamps or randomly-generated output in the build result.
838
839Another option is to use @command{guix challenge} (@pxref{Invoking guix
840challenge}). You may run it once the package has been committed and built
841by @code{@value{SUBSTITUTE-SERVER}} to check whether it obtains the same
842result as you did. Better yet: Find another machine that can build it and
843run @command{guix publish}. Since the remote build machine is likely
844different from yours, this can catch non-determinism issues related to the
845hardware---e.g., use of different instruction set extensions---or to the
846operating system kernel---e.g., reliance on @code{uname} or @file{/proc}
847files.
848
849@item
850When writing documentation, please use gender-neutral wording when referring
851to people, such as @uref{https://en.wikipedia.org/wiki/Singular_they,
852singular ``they''@comma{} ``their''@comma{} ``them''}, and so forth.
853
854@item
855Verify that your patch contains only one set of related changes. Bundling
856unrelated changes together makes reviewing harder and slower.
857
858Examples of unrelated changes include the addition of several packages, or a
859package update along with fixes to that package.
860
861@item
862Please follow our code formatting rules, possibly running the
863@command{etc/indent-code.el} script to do that automatically for you
864(@pxref{Formatting Code}).
865
866@item
867When possible, use mirrors in the source URL (@pxref{Invoking guix
868download}). Use reliable URLs, not generated ones. For instance, GitHub
869archives are not necessarily identical from one generation to the next, so
870in this case it's often better to clone the repository. Don't use the
871@command{name} field in the URL: it is not very useful and if the name
872changes, the URL will probably be wrong.
873
874@end enumerate
875
876When posting a patch to the mailing list, use @samp{[PATCH] @dots{}} as a
877subject. You may use your email client or the @command{git send-email}
878command (@pxref{Sending a Patch Series}). We prefer to get patches in plain
879text messages, either inline or as MIME attachments. You are advised to pay
880attention if your email client changes anything like line breaks or
881indentation which could potentially break the patches.
882
883When a bug is resolved, please close the thread by sending an email to
884@email{@var{NNN}-done@@debbugs.gnu.org}.
885
886@unnumberedsubsec Sending a Patch Series
887@anchor{Sending a Patch Series}
888@cindex patch series
889@cindex @code{git send-email}
890@cindex @code{git-send-email}
891
892@c Debbugs bug: https://debbugs.gnu.org/db/15/15361.html
893When sending a patch series (e.g., using @code{git send-email}), please
894first send one message to @email{guix-patches@@gnu.org}, and then send
895subsequent patches to @email{@var{NNN}@@debbugs.gnu.org} to make sure they
896are kept together. See @uref{https://debbugs.gnu.org/Advanced.html, the
897Debbugs documentation} for more information.