How can I include a custom command in deb file, to be executed at the end of installation?

Nav*_*een 4 dpkg debian deb

Well, I like to mark /usr/bin/program.sh as executable using following command:

chmod +x /usr/bin/program.sh

I want the above command to be executed at the end of installation of the Debian package.

有没有一种无痛的方法可以将命令注入到 deb 中?

感谢您的关注!

dev*_*av2 7

用于dpkg-deb提取 .deb 文件

创建临时目录

mkdir temp
Run Code Online (Sandbox Code Playgroud)

将 .deb 文件解压到临时目录

dpkg-deb -x file.deb temp/
cd temp/
dpkg-deb -e file.deb
Run Code Online (Sandbox Code Playgroud)

现在更改DEBAIN/postinst文件。安装包后立即调用此脚本。所以添加你需要的代码。

重新构建包

dpkg-deb -b . file.deb 
Run Code Online (Sandbox Code Playgroud)

或者

如果您不想编辑 .deb 文件。创建一个简单的 shell 脚本来调用 .deb 和要运行的命令。

vi test.sh
dpkg -i file.deb
/usr/bin/program.sh
Run Code Online (Sandbox Code Playgroud)

并运行它 ./test.sh

希望这可以帮助