[SOLVED] .deb Built with dpkg .vs .deb Build with ar

If none of the more specific forums is the right place to ask

[SOLVED] .deb Built with dpkg .vs .deb Build with ar

Postby Deluge » 2010-05-12 14:08

I was experimenting a little with .deb packages and wanted to see if I could manually build a package with tar, gzip, and ar. Well.... it didn't install. So I created a package with dpkg to compare it with.

Command using dpkg:
Code: Select all
$ fakeroot dpkg -b blarg blarg_0.1_all.deb


Commands using tar, gzip, and ar:
Code: Select all
$ tar -cf data.tar ./usr
$ gzip data.tar
$ tar -cf control.tar ./control
$ gzip control.tar
$ ar rcs blarg_0.1_all.deb data.tar.gz control.tar.gz debian-binary


So now I have two .deb packages called blarg_0.1_all.deb. They both have identical content, but the one built with ar does not install. I read that a .deb is an ar package. But dpkg must do something more. Does anyone want to let me in on the secret?

Here are the contents of the two packages:

dpkg:
  • control.tar.gz
      ./control
  • data.tar.gz
      ./usr/bin/blarg
  • debian-binary

ar:
  • control.tar.gz
      ./control
  • data.tar.gz
      ./usr/bin/blarg
  • debian-binary

Here is the error that comes up when I try to install the ar package:
Code: Select all
dpkg-deb: file `blarg_0.1_all.deb' is not a debian binary archive (try dpkg-split?)
dpkg: error processing blarg_0.1_all.deb (--install):
 subprocess dpkg-deb --control returned error exit status 2
Errors were encountered while processing:
 blarg_0.1_all.deb


Edit: I just found this article, it looks like it is not possible to create a working deb this way: http://wilmer.gaast.net/blog/archives/3-.deb-files-are-ar-archives,-but-....html
Last edited by Deluge on 2010-05-13 15:25, edited 4 times in total.
Code: Select all
$ uname -vro
4.2.0-1-amd64 #1 SMP Debian 4.2.1-2 (2015-09-27) GNU/Linux
User avatar
Deluge
 
Posts: 82
Joined: 2010-04-30 01:15
Location: U.S.

Re: [SOLVED] .deb Built with dpkg .vs .deb Build with ar

Postby mzilikazi » 2010-05-12 21:58

Deluge wrote:Edit: I just found this article, it looks like it is not possible to create a working deb this way

Or is it?
Debian Sid Laptops:
AMD Athlon(tm) 64 X2 Dual-Core Processor TK-55 / 1.5G
Intel(R) Pentium(R) Dual CPU T2390 @ 1.86GHz / 3G
User avatar
mzilikazi
Forum Ninja
 
Posts: 3321
Joined: 2004-09-16 02:14
Location: Colorado Springs, CO

Re: [SOLVED] .deb Built with dpkg .vs .deb Build with ar

Postby bugsbunny » 2010-05-12 23:54

I suspect the problem traces it's roots into the dawn of (Debian) time and the creation of the deb format. The problem is that the deb format uses the bsd version of ar, which is incompatible with gnu ar for some reason. I do wonder why the bsd version of ar isn't included in bsdutils though.
User avatar
bugsbunny
 
Posts: 5355
Joined: 2008-07-06 17:04

Re: [SOLVED] .deb Built with dpkg .vs .deb Build with ar

Postby Deluge » 2010-05-13 00:55

mzilikazi wrote:Or is it?

I read through that article, but it still didn't work. I didn't realize that, as bugsbunny was saying, there are two different versions of ar. I am going to seek out the BSD version. Thanks bugs.
Code: Select all
$ uname -vro
4.2.0-1-amd64 #1 SMP Debian 4.2.1-2 (2015-09-27) GNU/Linux
User avatar
Deluge
 
Posts: 82
Joined: 2010-04-30 01:15
Location: U.S.

Re: [SOLVED] .deb Built with dpkg .vs .deb Build with ar

Postby mzilikazi » 2010-05-13 01:06

Deluge wrote: I didn't realize that, as bugsbunny was saying, there are two different versions of ar. I am going to seek out the BSD version. Thanks bugs.

That is an interesting point. To what end may I ask are you building .debs this way? Just a learning experience?
Debian Sid Laptops:
AMD Athlon(tm) 64 X2 Dual-Core Processor TK-55 / 1.5G
Intel(R) Pentium(R) Dual CPU T2390 @ 1.86GHz / 3G
User avatar
mzilikazi
Forum Ninja
 
Posts: 3321
Joined: 2004-09-16 02:14
Location: Colorado Springs, CO

Re: .deb Built with dpkg .vs .deb Build with ar

Postby Deluge » 2010-05-13 01:59

It's mostly just learning experience, but I would also like to experiment building debs on a win32 platform.

BTW, does anyone know where I can find the BSD binutils/ar packages?
Code: Select all
$ uname -vro
4.2.0-1-amd64 #1 SMP Debian 4.2.1-2 (2015-09-27) GNU/Linux
User avatar
Deluge
 
Posts: 82
Joined: 2010-04-30 01:15
Location: U.S.

Re: .deb Built with dpkg .vs .deb Build with ar

Postby AdrianTM » 2010-05-13 02:20

Interesting idea, I wonder if it's not a permission issue too.
Ubuntu hate is a mental derangement.
User avatar
AdrianTM
 
Posts: 2520
Joined: 2004-09-19 01:08

Re: .deb Built with dpkg .vs .deb Build with ar

Postby Deluge » 2010-05-13 07:48

I found what I was doing wrong. It turns out that you don't need a BSD version of ar.

Just use these commands to create a valid deb:
Code: Select all
tar -czf control.tar.gz ./control
tar -czf data.tar.gz ./build
ar rcv blarg_0.1_all.deb debian-binary control.tar.gz data.tar.gz

(which is almost identical to what I was doing)

The only way I can reproduce the error is if I change the order of files in the ar command:
Code: Select all
ar rcv blarg_0.1_all.deb data.tar.gz control.tar.gz debian-binary

So it appears that "debian-binary" has to be listed before the gzipped files or else the resulting deb will not be valid.

You can do it the way I originally posted as well, just put debian-binary first in the ar line:
Code: Select all
tar -cf data.tar ./usr
gzip data.tar
tar -cf control.tar ./control
gzip control.tar
ar rcs blarg_0.1_all.deb debian-binary data.tar.gz control.tar.gz
Code: Select all
$ uname -vro
4.2.0-1-amd64 #1 SMP Debian 4.2.1-2 (2015-09-27) GNU/Linux
User avatar
Deluge
 
Posts: 82
Joined: 2010-04-30 01:15
Location: U.S.

Re: [SOLVED] .deb Built with dpkg .vs .deb Build with ar

Postby bugsbunny » 2010-05-13 11:10

See this link, and then see the related bug report (linked to from the post)
Re: [CMake] Producing deb package with 'ar'

Bottom line - the differences are subtle. The debs may sometimes work, but sometimes they may not.
User avatar
bugsbunny
 
Posts: 5355
Joined: 2008-07-06 17:04

Re: [SOLVED] .deb Built with dpkg .vs .deb Build with ar

Postby Deluge » 2010-05-13 12:12

Thanks for letting me know about that, I would have never known anything was wrong with the debs. If I get the bsd variant I should be able to build packages without any problems, correct?

I found a wikipedia article that talks about the differences as well: http://en.wikipedia.org/wiki/Ar_%28Unix%29#BSD_variant

Edit: I still cant find the bsd variant :(.
Code: Select all
$ uname -vro
4.2.0-1-amd64 #1 SMP Debian 4.2.1-2 (2015-09-27) GNU/Linux
User avatar
Deluge
 
Posts: 82
Joined: 2010-04-30 01:15
Location: U.S.

Re: [SOLVED] .deb Built with dpkg .vs .deb Build with ar

Postby bugsbunny » 2010-05-13 12:44

I played with all this a long time back (which is why I knew about the difference). I also looked for the bsd variant, but couldn't find anything practical.
User avatar
bugsbunny
 
Posts: 5355
Joined: 2008-07-06 17:04

Re: .deb Built with dpkg .vs .deb Build with ar

Postby Deluge » 2010-05-13 13:43

I think I found the source here: http://people.freebsd.org/~kaiw/distfiles/. But I don't know how to compile it :? .

Edit: Actually, I think that is the source for bsdar. I don't know if it is the same thing as ar.
Code: Select all
$ uname -vro
4.2.0-1-amd64 #1 SMP Debian 4.2.1-2 (2015-09-27) GNU/Linux
User avatar
Deluge
 
Posts: 82
Joined: 2010-04-30 01:15
Location: U.S.

Re: .deb Built with dpkg .vs .deb Build with ar

Postby Deluge » 2010-05-13 15:24

I think I did it (who knows if it will work right after I messed with the source). I now have what appears to be a bsd variant ar executable:
Code: Select all
$ ./ar --version
BSD ar 1.0.2 - libarchive 2.6.2
Code: Select all
$ uname -vro
4.2.0-1-amd64 #1 SMP Debian 4.2.1-2 (2015-09-27) GNU/Linux
User avatar
Deluge
 
Posts: 82
Joined: 2010-04-30 01:15
Location: U.S.

Re: [SOLVED] .deb Built with dpkg .vs .deb Build with ar

Postby Deluge » 2010-05-14 08:30

It works, but I won't be able to do any experimenting on Win32. I am unable to compile it for that platform :(.
Code: Select all
$ uname -vro
4.2.0-1-amd64 #1 SMP Debian 4.2.1-2 (2015-09-27) GNU/Linux
User avatar
Deluge
 
Posts: 82
Joined: 2010-04-30 01:15
Location: U.S.

Re: .deb Built with dpkg .vs .deb Build with ar

Postby debpat » 2010-07-04 21:34

Deluge wrote:I think I did it (who knows if it will work right after I messed with the source). I now have what appears to be a bsd variant ar executable:
Code: Select all
$ ./ar --version
BSD ar 1.0.2 - libarchive 2.6.2


I'm trying to convert some debs from gzip to lzma... is your BSD AR "debianization" source code available?
thanks
debpat
 
Posts: 2
Joined: 2010-07-04 21:30

Next

Return to General Questions

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable