我一直被这个小问题(我敢肯定)困住了,所以非常感谢任何帮助。我用 dh_make 创建了一个标准的 ubuntu 包。这个包的目的是创建一个包,它将设置系统需要的所有 ldap 相关包,包括它的配置。我尝试执行的步骤之一是在备份现有文件的同时复制/etc/ldap.conf 文件。我该怎么做呢?我试图创建一个基本上类似于以下内容的 postinst 脚本,但我不清楚包如何存储文件,并且我收到一条错误消息,指出缺少 etc/ldap.conf 文件。最好的方法是什么?这是我的 postinst 脚本:
#!/bin/bash -xv
install -v -b etc/ldap.conf /etc/ldap.conf > /tmp/tst 2>&1
这是我的骨架结构:
root@hqd-clientb-16:~/navldapubuntu-0.1/debian# tree ├── changelog ├── compat ├── control ├── copyright ├── docs ├── etc └── ldap.conf ├── install ├── postinst ├── README.Debian ├── README.source ├── rules ├── source └── format ├── navldapubuntu └── etc ├── navldapubuntu.debhelper.log ├── navldapubuntu.dirs └── navldapubuntu.doc-base.EX
这是我创建的包的一些附加信息。
dpkg --contents tnoldapubuntu_0.1-1_all.deb (truncated output) ./usr/ ./usr/share/ ./usr/share/doc
./usr/share/doc/navldapubuntu/ ./usr/share/doc/navldapubuntu/copyright ./usr/share/doc/navldapubuntu/README.Debian ./usr/share/doc/navldapubuntu/changelog.Debian.gz ./etc/ldap.conf
最佳答案
有一个专为创建配置包而设计的特殊工具:http://debathena.mit.edu/config-packages
这是一个有助于快速入门的简单模板。
文件列表
- 模板(目录)
- template/debian(目录)
- 模板/debian/控制
- 模板/debian/更新日志
- 模板/debian/置换
- 模板/debian/规则
- 模板/debian/postinst
- 模板/debian/安装
- 模板/debian/文档
- 模板/debian/兼容
- 模板/自述文件
- 模板/构建
- 模板/文件(目录)
- 模板/文件/etc/ldap.conf.mycompanyname
内容
模板/debian/控制:
Source: PACKAGE_NAME
Section: morpho/misc
Priority: optional
Maintainer: MAINTAINER
Build-Depends: debhelper, config-package-dev (>= 5.0~)
Package: PACKAGE_NAME
Architecture: all
Depends: ${misc:Depends}, DEPENDENCY [, DEPENDENCY ...]
Provides: ${diverted-files}
Conflicts: ${diverted-files}
Description: PACKAGE_DESCRIPTION_SHORT
PACKAGE_DESCRIPTION_LONG.
模板/debian/置换
/etc/ldap/ldap.conf.mycompanyname
模板/debian/安装
files/* /
模板/debian/postinst
#!/bin/sh
set -e
#DEBHELPER#
POSTINST_SCRIPT
模板/debian/规则
#!/usr/bin/make -f
# Exclude *.svn* from building
# you probably don't need this if don't use SVN
export DH_ALWAYS_EXCLUDE=.svn
# Core (check http://debathena.mit.edu/config-packages for more information)
%:
dh $@ --with=config-package
# Prevent dh_installdeb of treating files in /etc as configuration files
# you need this if need configuration files been always rewritten
# even if changed
override_dh_installdeb:
dh_installdeb
rm debian/*/DEBIAN/conffiles
模板/debian/文档
README
BUILD
最后,您可以使用以下命令构建此包:
dpkg-buildpackage -us -uc -I.svn
关于linux - Debian 软件包创建 - 如何安装配置文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15483725/