bash 如何使用 checkinstall 管理多个包依赖项?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18365600/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to manage multiple package dependencies with checkinstall?
提问by Jeff Geisperger
I have a package that I've been building using checkinstall
for a while now, and I wanted to automate it (pass the values in via command line instead of typing the selection, pasting the value in, etc...)
我有一个包,我已经使用checkinstall
了一段时间了,我想自动化它(通过命令行传递值,而不是输入选择,粘贴值等......)
I am not sure if this is a checkinstall bug, or not, but how can I include multiple packages via the command line --requires
option. It seems to barf if I include the minimum version of a package (for exmple --requires="libvte9 (>= 0.28.2)"
), or multiple packages at once (for example --requires "libvte9, libc6"
)
我不确定这是否是 checkinstall 错误,但是如何通过命令行--requires
选项包含多个包。如果我包含一个包的最低版本(例如--requires="libvte9 (>= 0.28.2)"
),或一次包含多个包(例如--requires "libvte9, libc6"
),这似乎很糟糕
Has anyone had better success with the command line arguments for multiple packages? Am I doing something wrong, or is this a bug.
有没有人使用多个包的命令行参数取得更好的成功?我做错了什么,还是这是一个错误。
Note: If I run the script, and choose the requires option (10), and paste my entire line with multiple packages and minimum versions (such as libvte9 (>= 0.28.2), libc6 (>= 2.13)
, it works fine, it just seems to be on the command line that it's having issues. Also this is with building a debian package, using the -D
option.
注意:如果我运行脚本,并选择需要选项 (10),然后将我的整行粘贴到多个包和最低版本(例如libvte9 (>= 0.28.2), libc6 (>= 2.13)
,它工作正常,它似乎只是在命令行上出现问题。这也是使用-D
选项构建 debian 包。
回答by édouard Lopez
After reading Aleks-Daniel Jakimenko-A.'s answer, Reallumpi's oneand doing some tests on a real life case, here is what you should do:
在阅读了Aleks-Daniel Jakimenko-A. 的回答,Reallumpi的回答并对现实生活案例进行了一些测试后,您应该执行以下操作:
- use
,
(comma) without spacesto separate required packages ; - escape
(
and)
parenthesiswhen specifying package's version ; - escape
>
(greater sign)when specifying package's version ;
- 使用
,
(逗号)不带空格分隔所需的包; (
)
指定包版本时的转义和括号;>
指定包的版本时转义(大号);
Example
例子
make && sudo -k checkinstall \
--pkgsource="https://github.com/raboof/nethogs/" \
--pkglicense="GPL2" \
--deldesc=no \
--nodoc \
--maintainer="$USER\<$USER@$HOSTNAME\>" \
--pkgarch=$(dpkg \
--print-architecture) \
--pkgversion="0.8.1" \
--pkgrelease="SNAPSHOT" \
--pkgname=nethogs \
--requires="libc6 \(\>= 2.4\),libgcc1 \(\>= 1:4.1.1\),libncurses5 \(\>= 5.5-5~\),libpcap0.8 \(\>= 0.9.8\),libstdc++6 \(\>= 4.1.1\),libtinfo5" \
make install
Output
输出
*****************************************
**** Debian package creation selected ***
*****************************************
This package will be built according to these values:
0 - Maintainer: [ elopez<elopez@> ]
1 - Summary: [ Net top tool grouping bandwidth per process ]
2 - Name: [ nethogs ]
3 - Version: [ 0.8.1 ]
4 - Release: [ SNAPSHOT ]
5 - License: [ GPL2 ]
6 - Group: [ checkinstall ]
7 - Architecture: [ amd64 ]
8 - Source location: [ https://github.com/raboof/nethogs/ ]
9 - Alternate source location: [ ]
10 - Requires: [ libc6 (>= 2.4),libgcc1 (>= 1:4.1.1),libncurses5 (>= 5.5-5~),libpcap0.8 (>= 0.9.8),libstdc++6 (>= 4.1.1),libtinfo5 ]
11 - Provides: [ nethogs ]
12 - Conflicts: [ ]
13 - Replaces: [ ]
回答by Aleks-Daniel Jakimenko-A.
checkinstall uses ,
to separate multiple packages. That's it, a comma, without any spacesaround it.
checkinstall 用于,
分隔多个包。就是这样,一个逗号,周围没有任何空格。
回答by Reallumpi
You need to escape brackets, e.g. --requires "package \(= 1.0\)"
你需要转义括号,例如 --requires "package \(= 1.0\)"
回答by noabody
This answer elaborates on how to properly format punctuation, within a shell script, to get multiple package dependencies for checkinstall to work.
此答案详细说明了如何在 shell 脚本中正确格式化标点符号,以获取多个包依赖项以使 checkinstall 正常工作。
PAK_USER='. , ? ! : + - ^ _ { } = $ % @ [ ] / ; # & * ~ ( ) < > \ |'
PAK_NEEDS='. , ? ! : + - ^ _ { } = $ % @ [ ] / ; # & * ~ ( ) < > \ |'
PAK_NEEDS=$(echo "$PAK_NEEDS" | perl -pe 's/([[:punct:]])/\/g')
0 - Maintainer: [ . , ? ! : + - ^ _ { } = $ % @ [ ] / ]
1 - Summary: [ This is a punctuation escape test. ]
10 - Requires: [ . , ? ! : + - ^ _ { } = $ % @ [ ] / ; # & * ~ ( ) < > \ | ]
The ones that needs escaping appear to be shell operators ; # & * ~ ( ) < > \ |
Some will return a value * ~
terminate the line ; #
or wipe everything out ( ) < > | &
while \
disappears since it's the escape character.
需要转义的似乎是 shell 运算符; # & * ~ ( ) < > \ |
Some 将返回一个值* ~
终止行; #
或擦除所有内容( ) < > | &
而\
消失,因为它是转义字符。
The regex perl -pe 's/([[:punct:]])/\\\1/g'
escapes all the punctuation characters which is overkill but works quite well. Single and Double Quotes are already problematic, along with $
, which will expand unless surrounded by single-quotes.
正则表达式perl -pe 's/([[:punct:]])/\\\1/g'
转义了所有标点符号,这有点矫枉过正,但效果很好。单引号和双引号已经有问题,$
, 除非被单引号包围,否则会扩展。
If you don't want to think about escaping, use the regex and caution with ' " $
.
如果您不想考虑转义,请使用正则表达式并谨慎使用' " $
.
PAK_NEEDS="libasound2 (>= 1.0.16), libavcodec57 (>= 7:3.4.2) | libavcodec-extra57 (>= 7:3.4.2), libavformat57 (>= 7:3.4.2), libavutil55 (>= 7:3.4.2), libboost-filesystem1.65.1, libboost-system1.65.1, libc6 (>= 2.27), libcurl4 (>= 7.16.2), libexpat1 (>= 2.0.1), libgcc1 (>= 1:3.0), libgl1, libglu1-mesa | libglu1, libmad0 (>= 0.15.1b-3), libsdl2-2.0-0 (>= 2.0.8), libsdl2-image-2.0-0 (>= 2.0.2), libsdl2-net-2.0-0 (>= 2.0.1), libsdl2-ttf-2.0-0 (>= 2.0.14), libsndfile1 (>= 1.0.20), libspeex1 (>= 1.2~beta3-1), libspeexdsp1 (>= 1.2~beta3.2-1), libstdc++6 (>= 5.2), libswscale4 (>= 7:3.4.2), libvorbisfile3 (>= 1.1.2), libzzip-0-13 (>= 0.13.56), zlib1g (>= 1:1.1.4)"
PAK_NEEDS=$(echo "$PAK_NEEDS" | perl -pe 's/([[:punct:]])/\/g')
10 - Requires: [ libasound2 (>= 1.0.16), libavcodec57 (>= 7:3.4.2) | libavcodec-extra57 (>= 7:3.4.2), libavformat57 (>= 7:3.4.2), libavutil55 (>= 7:3.4.2), libboost-filesystem1.65.1, libboost-system1.65.1, libc6 (>= 2.27), libcurl4 (>= 7.16.2), libexpat1 (>= 2.0.1), libgcc1 (>= 1:3.0), libgl1, libglu1-mesa | libglu1, libmad0 (>= 0.15.1b-3), libsdl2-2.0-0 (>= 2.0.8), libsdl2-image-2.0-0 (>= 2.0.2), libsdl2-net-2.0-0 (>= 2.0.1), libsdl2-ttf-2.0-0 (>= 2.0.14), libsndfile1 (>= 1.0.20), libspeex1 (>= 1.2~beta3-1), libspeexdsp1 (>= 1.2~beta3.2-1), libstdc++6 (>= 5.2), libswscale4 (>= 7:3.4.2), libvorbisfile3 (>= 1.1.2), libzzip-0-13 (>= 0.13.56), zlib1g (>= 1:1.1.4) ]