Re: Create a binary Debian package

2021-01-25 Thread Colin Watson
On Mon, Jan 25, 2021 at 11:38:47AM -0800, Alex Chen wrote:
> 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.

That doesn't matter for the purposes of my reply.

> > 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 
> 

Source packages don't require the "standard Linux build configuration"
(there isn't really such a thing anyway, but rather a variety of common
build systems).  They don't require configure or make, or indeed any
other build step.  It's perfectly possible and commonplace to have a
source package that simply copies a bunch of prebuilt files into place,
or that runs pretty much whatever script you like.

None of this is a reason to construct the .deb by hand by poking into
DEBIAN/, and you'll just make trouble for yourself by doing so - you can
and should still use the normal packaging toolchain.

Also, another thing I just noticed: for dependencies on shared
libraries, you should normally use ${shlibs:Depends} in debian/control
rather than writing those exact dependencies out by hand.  This makes it
easier to update the package to build correctly on newer versions of the
OS.  You can't do this if you're building DEBIAN/control by hand - it's
a facility provided by the packaging toolchain.

> >> 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
> >>  
> >> 
> > 
> > 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.

In general, the only reason you need Pre-Depends is if you're using the
dependency in question in your package's preinst script, and even that
is often a mistake that can be avoided.  (There are occasional other
cases that really only come up if you're maintaining something that's a
core part of the OS itself.  I'm familiar with what the Debian policy
manual says, and am summarising the essential points here since it's
often misunderstood.)

The Debian policy manual says "You should not specify a Pre-Depends
entry for a package before this has been discussed on the debian-devel
mailing list and a consensus about doing that has been reached", not
because of some kind of gatekeeping, but because Pre-Depends imposes
stronger constraints on the packaging system that can cause upgrade
difficulties down the line, and most of the time Depends turns out to be
sufficient.

We can probably advise if you can give us more details, but it's
unlikely that just putting all your package's dependencies in
Pre-Depends is going to turn out to be correct.  For the usual case
where additional dependencies are 

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 


>> 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
>>  
>> 
> 
> 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 

Re: Create a binary Debian package

2021-01-25 Thread Colin Watson
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.

> 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
>  
> 

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.

> 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

-- 
Colin Watson (he/him)  [cjwat...@ubuntu.com]

-- 
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


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