第 12 章 提示

目录

12.1. 在 UTF-8 环境下构建
12.2. UTF-8 转换
12.3. Hints for Debugging

Please also read insightful pages linked from “Notes on Debian” by Russ Allbery (long time Debian developer) which have best practices for advanced packaging topics.

构建环境的默认语言环境是 C。

某些程序(如 Python3 的 read 函数)会根据区域设置改变行为。

添加以下代码到 debian/rules 文件可以确保程序使用 C.UTF-8 的区域语言设置(locale)进行构建。

LC_ALL := C.UTF-8
export LC_ALL

If upstream documents are encoded in old encoding schemes, converting them to UTF-8 is a good idea.

Use the iconv command in the libc-bin package to convert the encoding of plain text files.

[debhello] $ iconv -f latin1 -t utf8 foo_in.txt > foo_out.txt

使用 w3m(1) 将 HTML 文件转换为 UTF-8 纯文本文件。 执行此操作时,请确保在 UTF-8 语言环境下执行它。

[debhello] $ LC_ALL=C.UTF-8 w3m -o display_charset=UTF-8 \
        -cols 70 -dump -no-graph -T text/html \
        < foo_in.html > foo_out.txt

在 debian/rules 文件的 override_dh_* 目标中运行这些脚本。

当您遇到构建问题或者生成的二进制程序核心转储时,您需要自行解决他们。这就是除错(debug)。

This is too deep a topic to describe here. So, let me just list few pointers and hints for some typical debug tools.

  • Wikipedia: “core dump”

    • “man core”
    • Update the “/etc/security/limits.conf” file to include the following:

      * soft core unlimited
    • “ulimit -c unlimited” in ~/.bashrc
    • “ulimit -a” to check
    • Press Ctrl-\ or “kill -ABRT 'PID'” to make a core dump file
  • gdb - The GNU Debugger

    • “info gdb”
    • “Debugging with GDB” in /usr/share/doc/gdb-doc/html/gdb/index.html
  • strace - 跟踪系统调用和信号

    • 使用 /usr/share/doc/strace/examples/ 中的 strace-graph 脚本来建立一个好看的树形图
    • “man strace”
  • ltrace - 跟踪库调用

    • “man ltrace”
  • “sh -n script.sh” - Syntax check of a Shell script
  • “sh -x script.sh” - Trace a Shell script
  • “python3 -m py_compile script.py” - Syntax check of a Python script
  • “python3 -mtrace --trace script.py” - Trace a Python script
  • “perl -I ../libpath -c script.pl” - Syntax check of a Perl script
  • “perl -d:Trace script.pl” - Trace a Perl script

    • 安装 libterm-readline-gnu-perl 软件包或者同类型软件来添加输入行编辑功能与历史记录支持。
  • lsof - 按进程列出打开的文件

    • “man lsof”
[提示]提示

script 命令能帮助记录控制台输出。

[提示]提示

在 ssh 命令中搭配使用 screen 和 tmux 命令,能够提供安全并且强健的远程连接终端。

[提示]提示

A Python- and Shell-like REPL (=READ + EVAL + PRINT + LOOP) environment for Perl is offered by the reply command from the libreply-perl (new) package and the re.pl command from the libdevel-repl-perl (old) package.

[提示]提示

The rlwrap and rlfe commands add input line editing capability with history support to any interactive commands. E.g. “rlwrap dash -i'” .