Page 1 of 1

Build binary/source package from DEBIAN

PostPosted: 2020-10-16 13:32
by axben
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...

Re: Build binary/source package from DEBIAN

PostPosted: 2020-10-16 13:36
by metreo
Shouldn't this be done in a chroot environment?

Re: Build binary/source package from DEBIAN

PostPosted: 2020-10-16 14:06
by axben
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.

Re: Build binary/source package from DEBIAN

PostPosted: 2020-10-16 14:17
by Head_on_a_Stick
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'?

Re: Build binary/source package from DEBIAN

PostPosted: 2020-10-16 15:19
by axben
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 ;-)

Re: Build binary/source package from DEBIAN

PostPosted: 2020-10-16 15:21
by Head_on_a_Stick
Did you create an install file in the debian directory? Without that file dh_install(1) won't do anything.

Re: Build binary/source package from DEBIAN

PostPosted: 2020-10-17 05:39
by stevepusser
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.

Re: Build binary/source package from DEBIAN

PostPosted: 2020-10-18 13:32
by axben
@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!