如何在包 debuild 中包含目录 [英] how to include a directory in the package debuild
问题描述
一个简单的Debian软件包将通过以下步骤创建,以下步骤将是初学者的教程
a Simple Debian package would be created in following steps, the following steps would be tutorial for beginners
考虑我有一个文件,比如说 test.sh,它只会在屏幕上打印测试
consider i have a file lets say test.sh which would just print test on the screen
#!/bin/sh
set -e
echo "this is sample debian package created " >&2
安装 debian 包后的输出应该是什么?A)我想在使用dpkg -i test-1.0.deb"安装软件包后将上面我命名为 test.sh 的文件放在/home/bla/Desktop/中
What should be the output after installing the debian package? A)I want to place the above file which i named as test.sh in /home/bla/Desktop/ after installing the package using "dpkg -i test-1.0.deb"
为了实现上述过程,请按照以下步骤操作
In order to achieve above process follow the below mentioned steps as it
mkdir test-1.0
cd test-1.0
#in order to place test.sh in /home/bla/Desktop, simply create the same directory structure in the test folder using this command
mkdir -p home/bla/Desktop/
cp test.sh home/bla/Desktop/
cd ..
cd ..
cd ..
mkdir DEBIAN
cd DEBIAN
添加控制文件,内容如下
add the control file with following contents
Package: test
Version: 1.0
Section: devel
Priority: optional
Architecture: all
Essential: no
Depends: bash
Pre-Depends: no
Recommends: no
Maintainer: test <test@test.test>
Replaces: no
Provides: no
Description: A sample testpackage in order to demonstrate how to create debian packages
包已经准备好从测试文件夹中出来并输入 dpkg --build test-1.0/
Package is ready come outside of test folder and enter dpkg --build test-1.0/
你的包已经准备好了,你可以使用 dpkg -i test-1.0.deb 来安装它
your package is ready and you can install it by using dpkg -i test-1.0.deb
如果我想对 dh_make 和 debuild 执行相同的过程,我无法添加我希望在安装后放置 test.sh 的目录结构
If i want to do the same process with dh_make and debuild, i was unable to add the directory structure where i wanted my test.sh to be placed after installation
我遵循的步骤:
mkdir test-1.0
复制上面的目录结构
mkdir test-1.0
copy the directory structure as above
cd test-1.0/ && mkdir -p home/bla/Desktop/
cp test.sh home/bla/Desktop/
dh_make -n -s -e test@test.com
不管我的 test.sh 是什么之后根本没有包含在包中,我不知道我从 debian 手册中了解到的原因是什么
no mater what my test.sh is not at all included in the package after, i donot know what is the reason that is what i have understood from debian manual
有人知道怎么做吗,请尽快告诉我..,我只想知道如何在使用 debuild/dpkg-buildpackage 构建 debian 包时将文件包含在包中,就像我在第一个过程中所做的那样这很简单
can any one know to do it, please let me asap.., i just want to know how i can include the files in the package when building debian package using debuild/dpkg-buildpackage like i have done in the first process which is very simple
推荐答案
利用 dh* 和 dpkg-buildpackage 的 AQ/D 示例em>:
A Q/D example utilizing dh* and dpkg-buildpackage:
1) 准备工作目录和测试文件(我们将打包 "foo" 脚本,该脚本应该安装到 "/any/dir") :
1) Pepare working directory and test file (we are going to package "foo" script which should be installed to "/any/dir") :
mkdir test-0.0.1
cd test-0.0.1
echo -e "#!/bin/sh
echo "hi, i'm foo"" > foo
chmod +x foo
2) 创建简单的 Makefile 来处理安装:
2) Create simple Makefile which will handle installation:
binary:
# we are not going to build anything
install:
mkdir -p $(DESTDIR)/any/dir
cp foo $(DESTDIR)/any/dir
3) 生成包骨架:
dh_make -i --createorig
3a) 可选地调整 debian 控制文件
3a) Optionally adjust debian control file
4) 构建包:
dpkg-buildpackage -A -uc
5) 测试生成的包内容:
dpkg-deb -c ../test_0.0.1-1_all.deb | grep any
drwxr-xr-x root/root 0 2012-06-12 20:54 ./any/
drwxr-xr-x root/root 0 2012-06-12 20:54 ./any/dir/
-rwxr-xr-x root/root 30 2012-06-12 20:54 ./any/dir/foo
<小时>
不使用 Makefile 的示例(如果您不打算构建 任何东西):
Example without using Makefile (if you are not going to build anything):
1) 创建测试数据:
mkdir test-0.0.1
cd test-0.0.1
mkdir contents
touch contents/a
touch contents/b
2) 创建包骨架:
dh_make -i --createorig
3) 创建 debian/test.install 文件,内容如下:
3) Create debian/test.install file with following contents:
contents/ /usr/share/mycontents
4) 构建包:
dpkg-buildpackage -A -uc
5) 检查构建的包:
dpkg-deb -c ../test_0.0.1-1_all.deb | grep contents
drwxr-xr-x root/root 0 2012-06-13 11:44 ./usr/share/mycontents/
drwxr-xr-x root/root 0 2012-06-13 11:38 ./usr/share/mycontents/contents/
-rw-r--r-- root/root 0 2012-06-13 11:37 ./usr/share/mycontents/contents/a
-rw-r--r-- root/root 0 2012-06-13 11:38 ./usr/share/mycontents/contents/b
这篇关于如何在包 debuild 中包含目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!