gpt4 book ai didi

node.js - 如何使用 grunt-debian-package 填充源包?

转载 作者:太空宇宙 更新时间:2023-11-03 22:14:46 25 4
gpt4 key购买 nike

我使用 NodeJSgrunt + grunt-debian-package 构建 .deb 文件,它可以工作适合创建部署文件 foo_v.v.v_all.deb
我还想在 debian 源包 (foo_v.v.v.tar.xz) 中分发简单且未丑化的源文件,但该文件相当空。

我需要做什么才能正确填充源文件?

我的环境:
当前目录:/home/dev/src/foo
我的 Grunt.js 的相关部分

debian_package: {
options: {
maintainer: {
name: "xxx",
email: "xxx"
},
prefix: "",
name: "foo",
postfix: "",
short_description: "xxx",
long_description: "xxx",
version: "<%=pkg.version%>",
preinst: {
src: "scripts/preinst",
},
postinst: {
src: "scripts/postinst",
},
postrm: {
src: "scripts/postrm",
},
prerm: {
src: "scripts/prerm",
},
dependencies: "xxx",
replaces: "xxx",
conflicts: "xxx"
},
deploy: {
files: [{
expand: true, // enable dynamic expansion
cwd: 'dist', // src matches are relative to this path
src: ['**'],
dest: '/usr/lib/foo'
}, {
src: "scripts/foo",
dest: "/etc/init.d/foo"
}, {
src: 'root-ca.conf',
dest: '/usr/lib/foo/root-ca.conf'
}]

}
}
// ----- snip -----
grunt.registerTask('package', ['debian_package']);

正确执行的命令:

grunt build
grunt package

检查文件结果:

ll tmp/
-rw-r--r-- 1 dev dev 22758744 Sep 16 00:10 foo_0.1.63_all.deb
-rw-r--r-- 1 dev dev 608 Sep 16 00:10 foo_0.1.63.dsc
-rw-r--r-- 1 dev dev 1400 Sep 16 00:10 foo_0.1.63_i386.changes
-rw-r--r-- 1 dev dev 76288 Sep 16 00:10 foo_0.1.63.tar.xz

tar -tJf tmp/foo_0.1.63.tar.xz
packaging/
packaging/debian/
packaging/debian/postinst
packaging/debian/compat
packaging/debian/postrm
packaging/debian/preinst
packaging/debian/dirs
packaging/debian/source/
packaging/debian/source/format
packaging/debian/changelog
packaging/debian/prerm
packaging/debian/copyright
packaging/debian/links
packaging/debian/control
packaging/debian/rules
packaging/Makefile

我希望将目录 /home/dev/src/foo/app 中的所有文件包含在文件 tmp/foo_0.1.63.tar.xz

为此我需要做什么?我应该更新 Makefile 吗?如果是:如何?

最佳答案

我终于明白了。我必须正确更新 Gruntfile.js。

首先,我在 config 部分定义了目标目录:

 grunt.initConfig({
config: {
// [...]
src_pkg: 'node_modules/grunt-debian-package/packaging
},

然后我在 copy 任务中添加了一个源代码部分,将自己的源代码与 node_modules 分开:

    copy: {
// [...]
src_pkg: {
files: [{
expand: true,
dot: true,
dest: '<%= config.src_pkg %>',
src: [
'**',
'!**/tmp/**',
'!**/.tmp/**',
'!**/dist/**',
'!**/.git/**',
'!**/node_modules/**', // node_modules will be copied separately
]
}]
},
src_pkg_modules: {
files: [{
expand: true,
cwd: 'node_modules',
dest: '<%= config.src_pkg %>/node_modules',
src: [
// list all node_modules you want to copy also here
]
}]
},
},

稍后注册任务(此处称为):

grunt.registerTask('package', [
'copy:src_pkg',
'copy:src_pkg_modules',
'debian_package']);

在命令行上通过调用启动打包

grunt package

...并在 ./tmp 中找到完整的 tarball(看看大小!):

ll tmp/
-rw-r--r-- 1 dev dev 22678070 Okt 6 22:09 foo_0.1.78_all.deb
-rw-r--r-- 1 dev dev 617 Okt 6 22:07 foo_0.1.78.dsc
-rw-r--r-- 1 dev dev 1408 Okt 6 22:09 foo_0.1.78_i386.changes
-rw-r--r-- 1 dev dev 38541304 Okt 6 22:07 foo_0.1.78.tar.xz

关于node.js - 如何使用 grunt-debian-package 填充源包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32648866/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com