Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

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

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
User avatar
Deluge
Posts: 82
Joined: 2010-04-30 01:15
Location: U.S.

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

#1 Post by Deluge »

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 ... t-....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
mzilikazi
Forum Account
Forum Account
Posts: 3282
Joined: 2004-09-16 02:14
Location: Colorado Springs, CO

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

#2 Post by mzilikazi »

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
bugsbunny
Posts: 5354
Joined: 2008-07-06 17:04
Been thanked: 1 time

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

#3 Post by bugsbunny »

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
Deluge
Posts: 82
Joined: 2010-04-30 01:15
Location: U.S.

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

#4 Post by Deluge »

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
mzilikazi
Forum Account
Forum Account
Posts: 3282
Joined: 2004-09-16 02:14
Location: Colorado Springs, CO

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

#5 Post by mzilikazi »

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
Deluge
Posts: 82
Joined: 2010-04-30 01:15
Location: U.S.

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

#6 Post by Deluge »

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
AdrianTM
Posts: 2499
Joined: 2004-09-19 01:08

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

#7 Post by AdrianTM »

Interesting idea, I wonder if it's not a permission issue too.
Ubuntu hate is a mental derangement.

User avatar
Deluge
Posts: 82
Joined: 2010-04-30 01:15
Location: U.S.

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

#8 Post by Deluge »

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
bugsbunny
Posts: 5354
Joined: 2008-07-06 17:04
Been thanked: 1 time

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

#9 Post by bugsbunny »

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
Deluge
Posts: 82
Joined: 2010-04-30 01:15
Location: U.S.

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

#10 Post by Deluge »

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
bugsbunny
Posts: 5354
Joined: 2008-07-06 17:04
Been thanked: 1 time

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

#11 Post by bugsbunny »

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
Deluge
Posts: 82
Joined: 2010-04-30 01:15
Location: U.S.

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

#12 Post by Deluge »

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

#13 Post by Deluge »

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

#14 Post by Deluge »

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

debpat
Posts: 2
Joined: 2010-07-04 21:30

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

#15 Post by debpat »

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

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

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

#16 Post by stevepusser »

debpat wrote:
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
Interesting...I know how to compile and create lzma debs the standard way, by adding the option to do so to dh_builddeb in the debian/rules file, but not how to do it manually.
MX Linux packager and developer

debpat
Posts: 2
Joined: 2010-07-04 21:30

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

#17 Post by debpat »

never mind,
the BSD ar is not the way to go...

instead I took a look at "dpkg-deb"; everything is there... I used ubuntu sources..
/dpkg-1.14.16.6ubuntu4.1/dpkg-deb/extract.c & build.c show how the debian files are created

dpkg-deb allows to unassemble a deb/udeb file (a 2 step process) and reassemble it choosing the compression I need...

tested; everything works great

thanks
Patrick

User avatar
Deluge
Posts: 82
Joined: 2010-04-30 01:15
Location: U.S.

Update to ar BSD Variant for Linux

#18 Post by Deluge »

I did a better job of porting the source over to Linux this time. It was mostly just adding some defines:

Linux x86 binaries: https://sourceforge.net/projects/deluge ... ties/bsdar
Source code: https://sourceforge.net/projects/deluge ... inux/bsdar

If someone compiles it for 64 bit please send me a copy of the binary.

Code: Select all

$ uname -vro
4.2.0-1-amd64 #1 SMP Debian 4.2.1-2 (2015-09-27) GNU/Linux

Post Reply