最近,我一直在为 debian 包构建我的项目。
我已经制作了 my_project.deb 并且安装得很好。
但是,当我重新安装它时,它不能正常工作。
$ sudo dpkg -i my_project_1.0.0.deb
...
Preparing to unpack my_project.deb ...
Unpacking my_project (1.0.0) ...
Setting up my_project (1.0.0) ...
# install success
$ ls /usr/share/my_proejct # run successfully
$ sudo dpkg -i my_project_1.0.1.deb
Preparing to unpack my_project.deb ...
Unpacking my_project (1.0.1) ...
Setting up my_project (1.0.1) ...
# install failed
$ ls /usr/share/my_proejct # No such file or directory
为了找出我的项目文件在哪里,我编写了维护脚本(preinst、postinst、prerm、postrm)和ls
如下文件。
$ cat preinst
echo "I'm preinst
ls /usr/share/my_project
echo "bye preinst"
然后,
$ sudo dpkg -i my_project_1.0.0.deb
# install success
$ sudo dpkg -i my_project_1.0.0.deb
Preparing to unpack my_project_1.0.0.deb ...
I'm prerm
bin doc lib # ls output
bye prerm
I'm preinst
doc lib # ls output. `bin` is removed. Why..?
bye preinst
Unpacking my_project (1.0.0) over (1.0.0) ...
I'm postrm
bin doc lib # ls output. Seems they are unpacked well
bye postrm
Setting up my_project (1.0.0) ...
I'm postinst
ls: cannot access '/usr/share/my_project/': No such file or directory # ls output. They are removed. Why..
bye postinst
我做错了什么吗?我想不出这些发生的原因。