Build binary/source package from DEBIAN

News and discussion about development of the Debian OS itself

Build binary/source package from DEBIAN

Postby axben » 2020-10-16 13:32

Having only a binary package at hand, how would I construct a new (updated) package from the base one?

What I did:

md pac-2.0
cd pac-2.0

ar x ../<package>.deb (-> control.tar.gz, data.tar.gz, and debian-binary)
tar -xf data.tar.gz (-> files in ./bin, ./share)

md debian
cd debian
tar -xf ../control.tar.gz (some control files)

cd ..
dh_make --addmissing

rm <no_longer_used_extracted_files_from_deb_package>
ls (->seeing ./debian, ./bin, and ./share)

dpkg-buildpackage --build=binary

The usual files are created but pac_2.0-*.deb does not contain the files from data.tar.gz.

As I'm pretty new to this, this might be the complete wrong way of doing this; however, I don't want to ressort to using dpkg-deb --raw-extract/--build...
axben
 
Posts: 4
Joined: 2020-10-16 13:06

Re: Build binary/source package from DEBIAN

Postby metreo » 2020-10-16 13:36

Shouldn't this be done in a chroot environment?
User avatar
metreo
 
Posts: 20
Joined: 2020-10-08 19:15

Re: Build binary/source package from DEBIAN

Postby axben » 2020-10-16 14:06

Tried that. Makes no difference with fakeroot dpkg-buildpackage --build=binary.

I also tried to move said directories (namely ./bin and ./share) to ./debian/pac2.0/usr but the files get deleted from there.

I'm completely lost.
axben
 
Posts: 4
Joined: 2020-10-16 13:06

Re: Build binary/source package from DEBIAN

Postby Head_on_a_Stick » 2020-10-16 14:17

I think you'll need to add either debian/rules or debian/pac.install — see https://www.debian.org/doc/manuals/debm ... html#rules & dh_install(1) for more on this.

But why not just use 'apt source'?
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12612
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Build binary/source package from DEBIAN

Postby axben » 2020-10-16 15:19

I tried dh_install and it correctly copied ./bin and ./share to the corresponding directories below ./debian/<package>. From what I've read this is WAD.

However, on running dpkg-packagebuild --binary the copied files get deleted and the resulting <package>.deb does not contain them.

I'm even loster ;-)
axben
 
Posts: 4
Joined: 2020-10-16 13:06

Re: Build binary/source package from DEBIAN

Postby Head_on_a_Stick » 2020-10-16 15:21

Did you create an install file in the debian directory? Without that file dh_install(1) won't do anything.
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12612
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Build binary/source package from DEBIAN

Postby stevepusser » 2020-10-17 05:39

dpkg-buildpackage builds packages from source. You don't have the source at all when you unpack a deb archive, or even the files that tell that command what to do.

Dpkg already has the tools for unpacking a deb, changing a text file, and repacking them into a deb. If that's all you need, why not use them?

If you want to make more changes than that, such as add files to the deb that were not there to begin with, then you'd have to go back to building the package from the original source. But Debian likes you to either make those changes to the source with a patch, or install them from the /debian folder during the build.
Last edited by stevepusser on 2020-10-19 04:42, edited 1 time in total.
MX Linux packager and developer
User avatar
stevepusser
 
Posts: 12061
Joined: 2009-10-06 05:53

Re: Build binary/source package from DEBIAN

Postby axben » 2020-10-18 13:32

@stevepusser
I've had to learn this by now ;-)
However, as I said before, we only have what we got...

@Head_on_a_Stick
Your hint regarding the install file saved me the day (as I said, I'm new to this...)
I finally got it to work with the following setup:

Code: Select all
pac-2.0
 - debian
   - pac.install
     | ../usr/...   ./tmp/usr/... |
 - usr (additions)
   - bin
   - share


@all: THANKS!
axben
 
Posts: 4
Joined: 2020-10-16 13:06


Return to Debian Development

Who is online

Users browsing this forum: No registered users and 1 guest

fashionable