Re: Create a binary Debian package

2021-01-25 Thread Alex Chen
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  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 

Create a binary Debian package

2021-01-24 Thread Alex Chen
Hi,
   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.

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
 


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: error processing archive test-package_1.0.0_amd64.deb (--install):
 pre-dependency problem - not installing test-package
Errors were encountered while processing:
 test-package_1.0.0_amd64.deb
=


I got the following errors if I changed Pre-Depends to Depends in 'control'
===
$ sudo dpkg -i test-package_1.0.0_amd64.deb 
Selecting previously unselected package test-package.
(Reading database ... 102747 files and directories currently installed.)
Preparing to unpack test-package_1.0.0_amd64.deb ...
Unpacking test-package (1.0.0) ...
dpkg: dependency problems prevent configuration of test-package
 test-package depends on libfontconfig1; however:
  Package libfontconfig1 is not installed.
 test-package depends on firewalld; however:
  Package firewalld is not installed.
 test-package depends on apache2; however:
  Package apache2 is not installed.
 test-package depends on apache2-bin; however:
  Package apache2-bin is not installed.
 
dpkg: error processing package test-package (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 test-package
==

Isn't the 'Pre-Depends' field in the 'control' file equivalent to the 
'Requires' directive in a RPM specification file?

How can I get the 'dpkg' command to install the prerequisites before it unpack 
and install my package?

Any help is appreciated.

Alex






-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss