Skip to content

Commit 9a7eb3e

Browse files
committed
ops/package: More details about debhelper
1 parent dc95a95 commit 9a7eb3e

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

docs/ops/package.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ Hello, world!
865865
Linux
866866
```
867867

868-
**试完记得装回正常的版本哦!**
868+
**试完记得装回正常的版本哦**!如果需要保持自己修改后的版本,可参考前文描述的[固定包的方法](#apt-hold)或[APT 优先级机制](#priority)。
869869

870870
```shell
871871
$ apt-cache policy sudo
@@ -956,22 +956,45 @@ esac
956956

957957
这是一个 Makefile 的通配符规则,表示所有的目标都使用 `dh` 命令来处理。例如,执行 `debian/rules build` 时,Makefile 会将 `build` 作为目标传递给 `dh`,因此等价于执行 `dh build`。
958958

959-
可以使用 `--no-act` 参数来查看 `dh` 会执行哪些操作:
959+
可以使用 `DH_NO_ACT=1` 环境变量来查看 `dh` 会执行哪些操作:
960960

961961
```shell
962-
$ dh clean --no-act
962+
$ DH_NO_ACT=1 debian/rules clean
963+
dh clean
963964
dh_testdir
964965
debian/rules override_dh_auto_clean
965966
dh_autoreconf_clean
966967
dh_clean
968+
$ # 或者使用 dh --no-act 命令
969+
$ # 此时需要阅读 `debian/rules` 确认 dh 是怎么被调用的
967970
```
968971

969-
如果需要覆盖某个 `dh` 的操作,可以在 `debian/rules` 中添加对应的规则,例如:
972+
`dh` 的各项操作细节都有其对应的 `man` 文档可以参考。如果需要覆盖某个 `dh` 的操作,可以在 `debian/rules` 中添加对应的规则,例如:
970973

971974
```makefile
975+
# 在某个操作之前做一些事情
976+
execute_before_dh_auto_clean:
977+
echo "Something before dh_auto_clean"
978+
979+
# 在某个操作之后做一些事情
980+
execute_after_dh_auto_clean:
981+
echo "Something after dh_auto_clean"
982+
983+
# 覆盖某个操作
972984
override_dh_auto_clean:
973985
echo "Custom clean step"
974-
dh_auto_clean
986+
```
987+
988+
在使用 `dpkg-buildpackage` 构建完成后,可以使用 `lintian` 来检查包是否符合 Debian 的规范。在打包的目录执行即可:
989+
990+
```shell
991+
lintian -i -I
992+
```
993+
994+
添加的 `-i``-I` 选项可以显示更多的信息。如果你对打包质量的要求更高,可以开启 lintian 的 pedantic 模式,并且启用实验性质的一些检查:
995+
996+
```shell
997+
lintian --pedantic -E -i -I
975998
```
976999

9771000
#### 使用 `checkinstall` 快速打包 {#checkinstall}

0 commit comments

Comments
 (0)