not a valid DEB package

I was trying to “replace” control.tar.gz and data.tar.gz in a .deb package using ar(1) command. Yes it works, but the new package make apt-get cry “not a valid DEB package.” Although it’s just a warning, it makes me feel bad.

I searched this problem with google and found Creating Debian Packages. It said you have to use dpkg-deb(1) to build .deb to free the warning. Curiously, I checked the two .deb (generated by ar and dpkg-deb) by extracting the package, but they were all the same. Then I took a look at the binary diff of these two, they really had some bytes of different. I don’t know if they were comment or so.

Actually, what I want to do is to replace a few files in a deb package. Do it with ar(1), I only need to:

  1. ar x to extract
  2. gunzip data.tar.gz
  3. tar uf data.tar my_file
  4. gzip data.tar
  5. ar r data.tar.gz

However, with dpkg-deb(1), I have to extract the whole data.tar.gz, putting my file in, and then re-tgz it, which is very bad. I’ll try to figure what the magic bytes is later.

Yellow Dog Linux runs on Playstation 3 – using e17 as WM