8

我有一个非常简单的命令行程序,它实际上由一个 python 脚本和一些辅助 shell 脚本组成。我想了解如何打包这个程序,虽然它是微不足道的。

根据我收集到的信息,我选择了配置/制作/安装路线。由于我没有任何要配置或制作的东西,我简单地创建了一个 Makefile,只有一个安装部分:

install:
        cp ./myProgram /usr/bin/my-program
        chown root:root /usr/bin/my-program
        chmod 777 /usr/bin/my-program
        cp -r ./ProgramResources /usr/lib/my-program
        chown -hR root:root /usr/lib/my-program
        chmod -R 777 /usr/lib/my-program

此时,我的程序使用 sudo make install 安装并运行良好。

然后,我尝试使用checkinstall创建一个 deb 文件,如下所示:

sudo checkinstall sudo make install

它似乎通过了安装部分,因为它报告它成功,但随后失败:

======================== Installation successful ==========================
cp: cannot stat `//var/tmp/tmp.jKCmESc0v7/newfiles.tmp': No such file or directory

Copying files to the temporary directory...OK

Stripping ELF binaries and libraries...OK

Compressing man pages...OK

Building file list... FAILED!

Building Debian package...OK

Installing Debian package...OK

Erasing temporary files...OK

Deleting temp dir...OK


**********************************************************************

 Done. The new package has been installed and saved to

 ...

该程序已安装,但据我所知,这个新制作的 .deb 文件什么也没做。dpkg -L my-program 只产生

/.

并手动删除它并从 deb 文件安装似乎没有做任何事情 - 它实际上并没有将任何文件放在任何地方。

那么,(1)我的方法有什么问题吗?(2) 如何解决 checkinstall 问题?

非常感谢您的回答,即使我擅长代码,但我对打包/分发一无所知。

4

3 回答 3

7

sudo 的双重使用是问题所在。

使用类似 install.sh 的文件

#! /bin/bash
set -x
touch useless
cp useless /usr/share/useless

命令

sudo checkinstall --pkgname useless -y ./install.sh

工作时

sudo checkinstall --pkgname useless -y sudo ./install.sh
                                       ^^^^

节目

cp: cannot stat ‘//var/tmp/tmp.Au4ympTNlT/newfiles.tmp’: No such file or directory

并产生一个空包。

于 2014-05-21T13:22:55.057 回答
4

I'm not sure if this exactly answers the question, but here's what I got so far (on ubuntu lucid, checkinstall 1.6.1):

I tried to build an open-source project, which built just fine. Then I tried packaging it for debian:

checkinstall -D --install=no --pkgname=$PKGNAME --pkgversion=0.0.1 --pkgrelease="svn-001" --maintainer=test@test.com --strip=no --stripso=no --addso=yes

This basically failed at the same Building file list... FAILED!; and a similar grep: /var/tmp/tmp.NaoiwTHT6F/newfile: No such file or directory was reported.

I also tried with adding make at end of checkinstall command above - that didn't do much either.

Finally, I tried this:

make clean
checkinstall -D --install=no --pkgname=$PKGNAME --pkgversion=0.0.1 --pkgrelease="svn-001" --maintainer=test@test.com --strip=no --stripso=no --addso=yes -d2 make

The switch -d2 is to enable debug; and ... make will rerun make one more time.

The -d2 will print out the temporary directory:

debug: The temporary directory is: [ /var/tmp/tmp.NaoiwTHT6F ]
, so it can be checked by listing... And indeed, I can confirm that a newfile is not generated there in my case (however, there is newfiles, newfiles.installwatch, newfiles-tar, and newfiles.tmp). In fact, turns out checkinstall is a bash script, and so one can confirm that newfile only appears once in it:

$ grep 'newfile ' `which checkinstall`
    grep '^/home' ${TMP_DIR}/newfile > /${TMP_DIR}/unwanted

Also, the debug will point out these files/directories:

debug: INSTW_EXCLUDE=/dev,/path/to/myproject-build,/proc,/tmp,/var/tmp,
debug: INSTW_ROOTPATH=/var/tmp/tmp.NaoiwTHT6F
debug: INSTW_LOGFILE=/var/tmp/tmp.NaoiwTHT6F/newfiles.tmp
debug: INSTW_DBGFILE=/var/tmp/tmp.NaoiwTHT6F/dbgfile

Note that by default, the path to my build folder, /path/to/myproject-build is excluded - and that is where this project also stores the built executables!

 

Apparently, when make within checkinstall goes on building for the first time, it can capture newly generated executable files - they will be listed in ${TMP_DIR}/newfiles; however, in my case, the problem is that the executables end up under the same directory where checkinstall is called; thus, at this dialog:

Some of the files created by the installation are inside the build
directory: /path/to/myproject-build

You probably don't want them to be included in the package,
especially if they are inside your home directory.
Do you want me to list them?  [n]: y
Should I exclude them from the package? (Saying yes is a good idea)  [y]: n

... I must, in fact, answer n - otherwise I'd get nothing included! I can then check the contents with:

dpkg --contents mytest.deb | less

However, then the problem is that checkinstall:

  • also includes .o files, as well as .svn directories
  • counts the absolute path as relative (will not automatically "send" executables to say, /usr/bin, and .sos to /usr/lib

 

In brief - some of the approaches above may get one to have a .deb which is not completely empty; but that doesn't mean one has only the needed files there, or that they would be routed to usual install destinations...

Well, hope this helps at least a bit,
Cheers!

于 2012-07-03T21:58:16.907 回答
1

我有过类似的问题。最后,我遵循了这种非常简单但相当手动的方法。

例如,将要打包的文件放在 debian/usr/bin 中。无需完成通常的configure, make, make install步骤。

于 2014-04-04T12:50:16.580 回答