Why does my hand created deb package fails at install with “unable to create” on files?

StackOverflow https://stackoverflow.com/questions/4564434

  •  14-10-2019
  •  | 
  •  

Question

I made a perl script that creates a deb binary package from scratch. I created the data, control, etc. But when I run dpkg -i on my deb package it complains that it is unable to files from data. Example: unable to create '.dpkg-new'(while processing ''): No such file or directory.

I have downloaded some .deb packages to look at and they do not use the preinst script to create the directory structure.

I am thinking I am doing something wrong, I consider having to create my own directories in preinst but it does not seem right... perhaps I am missing something?

Do I have to create directories where my files from data will be copied in the preinst sh, or should dpkg do it and I am doing something wrong?

Was it helpful?

Solution

You should not attempt to manually create a .deb binary package by hand. The Debian New Maintainers' Guide covers how to get started creating a Debian package using the correct tools.

Your hand created package may look correct to you but because it is not installing it is obviously flawed in either a minor way that you have not noticed or in a more serious way that is not visible to you (for example most people don't realize a .deb is actually an ar archive).

OTHER TIPS

I had the same problem in a Ruby script I wrote.

I was generating a list of files to pass to tar when building the data.tar.gz archive. When I ungzip and untared the archive manually it would deflate fine, but dpkg would fail.

It turns out that the list of files must also include each directory to create as well.

Note that when I created data.tar.gz I built it with nearly the same options as dpkg-deb/build.c does in the dpkg-1.15.8.11 source.

execlp(TAR, "tar", "-cf", "-", "--format=gnu", "--null", "-T", "-", "--no-recursion", NULL);

Instead I used

IO.popen("gnutar -czf - --format=gnu -T - --no-recursion", "r+")

In addition to what @Arrowmaster said, check the http://www.debian.org/doc/debian-policy/ for some detailed explanation of the files. After you build the package itself, you can check it with lintian tool to see if there is anything obvious you might have missed.

If any one looks for a solution to the problem:
"Build a deb package from an rpm spec file."
Look here http://www.deepnet.cx/debbuild/

I have made my own perl build script much simple then the mentioned one so I can easily maintain it.

Some useful knowledge gained in the process:
0. the deb is an ar archive that contains 3 files, the order of the files is important.
1. the scripts from control.tar.gz must be made executable.
2. it is good to have a preinstall script to make directories if dirs do not exist.
3. sometimes dpkg decides to unzip your zips (this happened if the zip was the only file in the data.tar.gz) so check for that in an postinstall script.
4. when you tar.gz some files be sure to chmod to the dir that contains the directory structure for your tar.

There are lots of reasons for this. You really need to run:

dpkg -i -D1110 mydeb.deb

And post the result to have any hope of someone being able to solve the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top