Create a binary Debian package

Alex Chen alex_chen at claris.com
Mon Jan 25 19:38:47 UTC 2021


Thanks for the information Colin.  However, this is a binary package built from proprietary cross-platform source code.  
It is not open-source nor free software.  There is no up-stream source package.

Please see my in-line comments below

Alex


> On Jan 25, 2021, at 6:51 AM, Colin Watson <cjwatson at ubuntu.com> wrote:
> 
> On Sun, Jan 24, 2021 at 11:21:01PM -0800, Alex Chen wrote:
>>   I am trying to create a Debian package, i.e. a .deb file, that can install  software in Ubuntu. I put a the following files under the build directory:
>> 
>> build_dir/DEBIAN/control - Package configuration
>> build_dir/DEBIAN/md5sums - MD5 checksums of every files to be installed.
>> build_dir/DEBIAN/preinst postinst  prerm postrm - Pre/Post installation and pre/post uninstallation scripts.
> 
> You should never create files under DEBIAN/ directly.  Build a proper
> source package instead with the appropriate files under debian/, and
> build binary packages from it using debuild.  See for instance
> https://wiki.debian.org/Packaging/Intro.
> 

It is not built from with 'configure' and 'make' from the source. The standard Linux build configuration does not apply.
It is packaged with a script following the descriptions in https://www.debian.org/doc/debian-policy/ch-binary.html#binary-packages <https://www.debian.org/doc/debian-policy/ch-binary.html#binary-packages>

>> This what I have in the 'control' file
>> =====
>> Package: test-package
>> Version: 1.0.0
>> Architecture: amd64
>> Pre-Depends: coreutils, libicu60, libfontconfig1, firewalld, unzip, zip, curl, lapache2, apache2-bin
>> ======
>> 
>> I thought packages listed in Pre-Depends field of a control file are supposed to be installed by the system before it process the package itself, according to this document: https://www.debian.org/doc/debian-policy/ch-relationships.html#binary-dependencies-depends-recommends-suggests-enhances-pre-depends <https://www.debian.org/doc/debian-policy/ch-relationships.html#binary-dependencies-depends-recommends-suggests-enhances-pre-depends>
> 
> Pre-Depends should only be used in rare circumstances.  You should
> normally use Depends instead.  You also don't need to (and shouldn't)
> explicitly depend on coreutils, since it's an essential package.

In order for our software to function, several packages not usually present in a base system need to be installed first and according to the definition of 'Depends' and 'Pre-Depends', 'Pre-Depends' seems to be what is needed.

Depends -  Requires other packages it depends on to be 'unpackaged' or 'configured',
'Pre-Depends' - Requires 'dpkg' to complete 'installation' of these packages before event installing the package itself.


Depends
This declares an absolute dependency. A package will not be configured unless all of the packages listed in its Depends field have been correctly configured (unless there is a circular dependency as described above).

The Depends field should be used if the depended-on package is required for the depending package to provide a significant amount of functionality.

The Depends field should also be used if the postinst or prerm scripts require the depended-on package to be unpacked or configured in order to run. In the case of postinst configure, the depended-on packages will be unpacked and configured first. (If both packages are involved in a dependency loop, this might not work as expected; see the explanation a few paragraphs back.) In the case of prerm or other postinst actions, the package dependencies will normally be at least unpacked, but they may be only “Half-Installed” if a previous upgrade of the dependency failed.

Finally, the Depends field should be used if the depended-on package is needed by the postrm script to fully clean up after the package removal. There is no guarantee that package dependencies will be available when postrm is run, but the depended-on package is more likely to be available if the package declares a dependency (particularly in the case of postrmremove). The postrm script must gracefully skip actions that require a dependency if that dependency isn’t available.

Pre-Depends
This field is like Depends, except that it also forces dpkg to complete installation of the packages named before even starting the installation of the package which declares the pre-dependency, as follows:

When a package declaring a pre-dependency is about to be unpacked the pre-dependency can be satisfied if the depended-on package is either fully configured, or even if the depended-on package(s) are only in the “Unpacked” or the “Half-Configured” state, provided that they have been configured correctly at some point in the past (and not removed or partially removed since). In this case, both the previously-configured and currently “Unpacked” or “Half-Configured” versions must satisfy any version clause in the Pre-Depends field.

When the package declaring a pre-dependency is about to be configured, the pre-dependency will be treated as a normalDepends. It will be considered satisfied only if the depended-on package has been correctly configured. However, unlike with Depends, Pre-Depends does not permit circular dependencies to be broken. If a circular dependency is encountered while attempting to honor Pre-Depends, the installation will be aborted.

> 
>> I was able create the package with 'dpkg-deb --build build_dir' command successfully, however I got the following dependency errors when I tried to install the package in an Ubuntu server
>> 
>> ===========
>> $ sudo dpkg -i test-package_1.0.0_amd64.deb 
>> [sudo] password for tester
>> dpkg: regarding test-package_1.0.0_amd64.deb containing test-package, pre-dependency problem:
>> test-package pre-depends on libfontconfig1
>>  libfontconfig1 is not installed.
> 
> dpkg -i won't acquire or install dependencies that aren't yet installed;
> it only processes the files you give it.  You can use this instead,
> which knows how to acquire and install dependencies as well as the
> specific file you give it (note that the "./" is important so that apt
> knows that you're talking about a file name rather than a package name):
> 
>  sudo apt install ./test-package_1.0.0_amd64.deb
> 

I will try 'apt' command instead of 'dpkg'.

Thanks

> -- 
> Colin Watson (he/him)                              [cjwatson at ubuntu.com]
> 
> -- 
> Ubuntu-devel-discuss mailing list
> Ubuntu-devel-discuss at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-devel-discuss/attachments/20210125/22c770ff/attachment-0001.html>


More information about the Ubuntu-devel-discuss mailing list