我需要我的 Debian 规则文件来简单地将文件复制到它的目标 [英] I need my Debian rules file to simply copy files to it's target

查看:32
本文介绍了我需要我的 Debian 规则文件来简单地将文件复制到它的目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大型项目,其中有以下文件:

I have a large project where we have the following files:

  • 一些 3rd 方预编译的二进制文件
  • 我们自己的内部二进制文件
  • Ruby 脚本集合
  • 一个相当大的 Ruby on Rails 项目

该产品将安装在我的雇主已经选择的设备硬件上,使用 Ubuntu Linux (Lucid) 作为目标操作系统,我们的目标是将存档作为 Debian 软件包分发以简化安装和升级.此外,我们有许多 ERB 模板,我们需要根据每个客户使用适当的值填写"这些模板,因此 postinst 脚本的使用对于我们的目的来说特别方便.

This product will be installed on appliance hardware that my employer has already selected, using Ubuntu Linux (Lucid) as the target OS, with our goal of distributing the archive as a Debian package to ease installation and upgrades. Additionally, we have a number of ERB templates that we need to "fill-in" with appropriate values on a per-customer basis, so the use of the postinst script will be particularly handy for our purposes.

附带说明,Debian 软件包将存储在我们内部管理的服务器存储库中.

As a side note, the Debian packages will be stored on a server repository that we manage in-house.

在这个阶段,我已经使用 dh_make 来创建 Debian 目录和相关文件(例如,规则、控件等),但是生成的规则文件对于我的目的来说似乎有点矫枉过正.

At this stage, I have used dh_make to create the Debian directory and related files (e.g., rules, control, etc.), but the rules file that is generated seems like overkill for my purposes.

根据此描述,我真正需要规则"文件做的只是将文件从源目录(或存档中)复制到如下所示的目标目录:

/opt/company_product/3rd_party_binaries/bin
/opt/company_product/3rd_party_binaries/etc
/opt/company_product/in_hourse_binaries/bin
/opt/company_product/in_hourse_binaries/etc
/opt/company_product/ruby
/opt/company_product/rails_project
/opt/company_product/etc
/opt/company_product/shared/logs
/opt/company_product/shared/tmp
/opt/company_product/shared/license

...等等.

我已经阅读了 Debian 政策手册和几个 How-To,它们表明您不应该更改规则文件以使用 mkdir 来创建目录,并且通常有dh_ 应用程序(例如 dh_installdirs 等),几乎可以满足任何安装目的的需求.这些 dh_ 相关应用程序的手册页充其量只是粗略,我是一个示例"类型的人.

I've read the Debian Policy Manual and several How-To's which indicate that you should not alter the rules file to use mkdir to create directories and there is generally a dh_ app (e.g., dh_installdirs, et al) that can suit your needs for nearly any installation purposes. The man pages for these dh_ related apps are cursory at best, and I am an "example" kind of guy.

也就是说,我有点不知道最好的方法是让我的 rules 文件将我的各种预编译二进制文件和 Ruby/Rails 文本文件安装到所需的位置.

That said, I'm a little lost on what the best approach is to getting my rules file to install my various pre-compiled binaries and Ruby/Rails text files to the desired locations.

这是我最初的 rules 文件.它几乎是 dh_make 创建的标准样板规则文件.我的想法是我应该注释掉除 install 之外的所有部分,然后在该部分中找到适当的命令来创建目录、复制文件等.

Here's my initial rules file. It's pretty much a standard boilerplate rules file that dh_make creates. My thinking is that I should comment out all sections except for the install and then find the appropriate command(s) to make directories, copy files, etc. within that section.

非常感谢任何意见或建议.

Any advice or suggestions are greatly appreciated.

#!/usr/bin/make -f

package = testapp

CC = gcc
CFLAGS = -g -Wall

ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
  CFLAGS += -O2
endif

#export DH_VERBOSE=1

clean:
        dh_testdir
        dh_clean
        rm -f build

install: build
        dh_clean
        dh_installdirs
        echo "Place the Install Script here"
        cp $(CURDIR)/testapp-2.0.tar.gz $(CURDIR)/debian/$(package)/opt/testapp-2.0
        echo "Finished copying folders"


build:
        touch build

binary-indep: install
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

binary-arch: install
        dh_testdir -a
        dh_testroot -a
        dh_installdocs -a 
        dh_installchangelogs -a 
        dh_strip -a
        dh_compress -a
        dh_fixperms -a
        dh_installdeb -a
        dh_shlibdeps -a
        dh_gencontrol -a
        dh_md5sums -a
        dh_builddeb -a

binary: binary-indep binary-arch

.PHONY: binary binary-arch binary-indep clean checkroot

推荐答案

虽然你已经有了自己的答案,但我还是要指出几点.

Although you've already got your own answer, I'll point out a couple of things.

您似乎以非常复杂的方式执行此操作.如果您只是需要将文件复制到某些目录中,请使用以下格式编写 debian/mypackagename.install:

You seem to be doing this in a very complicated manner. If you simply need to copy files into certain directories, write a debian/mypackagename.install with the following format:

path/to/file/relative/to/source/root path/to/install/relative/to/system/root

(不要在 /usr/opt 或任何您的目标目录之前添加 /.阅读 man dh_install 了解更多信息)

(do not prepend / before /usr, or /opt, or whatever your target directory is. Read man dh_install for more information)

那么你的 debian/rules 可以是:

#!/usr/bin/make -f

%:
    dh $@

如果您的源根目录中有某种 makefile 等,则将其附加到上述 rules 文件中:

If you have some sort of makefile, etc in your source root, then append this to the above rules file:

override_dh_auto_build:

override_dh_auto_install:

别忘了把 7 放在 debian/compat 中.

Don't forget put 7 in debian/compat.

另外,您不应该将文件安装到 /opt//usr/local/ 等.这些是用于文件 not 由 Debian 软件包安装.Debian 建议安装在 /usr/share/yourcompany/ 中.作为 juzzlin 在下面指出,Ubuntu 软件中心可能有不同的要求.

Also, you shouldn't install files into /opt/ or /usr/local/, etc. Those are meant for files not installed by Debian packages. Debian recommends installing in /usr/share/yourcompany/. As juzzlin points out below, the Ubuntu Software Center may have different requirements.

更具体地说,您的 mypackage.install 文件应如下所示:

More specifically, your mypackage.install file should look like this:

src/bin/* usr/bin
src/etc/* etc/

这篇关于我需要我的 Debian 规则文件来简单地将文件复制到它的目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆