# MANIFEST: pkg dependency on another binary pkg



## Xylene (Apr 9, 2018)

Is there a way to create a dependency on a binary pkg?

I want to create a binary package that depends on another binary package to be installed (Or even just exist in the current directory, so that it gets installed too)

In the Manifest file I can put something like:

deps: {
  hello-world: { origin: "hello-world", version: "1.0.0.0"}
}

But I never get a notice that the deps is not met when running an install.  When I remove hello-world it asks if I want to remove this package as well, which is great, but how do I make it ask to install the missing dep?  Works great for ports, but this isn't a port.


----------



## Bobi B. (Apr 10, 2018)

Xylene said:


> Is there a way to create a dependency on a binary pkg?


No point to do that. AFAIK pkg(8) does not care if you built it yourself (from ports) or installed a binary package. You just declare a dependency.



Xylene said:


> Works great for ports, but this isn't a port.


Well, make it a port, then. There is no need to push this port to the ports tree, you can keep it private. Here is what I did for company's code: generally I used two kinds of ports Makefiles. One depends on an archive with real utility source code and another uses an archive with a dummy file. Then used a simple Makefile:

```
PORTNAME=       acmefoo
DISTVERSION=    0.1
CATEGORIES=     sysutils
MASTER_SITES=   ../
DISTDIR=        $(.CURDIR)
WRKSRC=         work

MAINTAINER=     someone@acme.com
COMMENT=        Acme's foomatic 2000

ALL_TARGET=     BUILD=release
LIB_DEPENDS=    libfcgi.so:www/fcgi

PLIST_FILES=    libexec/foo

post-patch:
        ln -sf BSDmakefile ${WRKSRC}/Makefile

do-install:
        ${INSTALL_PROGRAM} ${WRKSRC}/.build/release/foo ${STAGEDIR}${PREFIX}/libexec

.include <bsd.port.mk>
```
Basically this will search for acmefoo-0.1.tar.gz (based on `PORTNAME` and `DISTVERSION`) in ../ (`MASTER_SITES`, relative to where Makefile is). It will extract archive in work (`WRKSRC`), will execute `post-patch` step, if such, will navigate to work/acmefoo-0.1, and will run `make $(ALL_TARGET)`. You can include a dummy Makefile in acmefoo-0.1.tar.gz with a bare target name `all`. Or you can override build directory with `ALL_TARGET=     -C ../../acmefoo`. Upon successful build (or "build") next is `do-install` target.

`LIB_DEPENDS` is a library dependency (hence build-time and run-time). Put alike of `RUN_DEPENDS=    p5-IO-Interface>=1.09:net/p5-IO-Interface` for run-time dependency.

If you need an installable package run with `make package`. More information in FreeBSD Porter's Handbook.


----------



## Xylene (Apr 11, 2018)

Do you ship this to customers?


----------



## Bobi B. (Apr 11, 2018)

We chose to use nanobsd for our backends. Images we provide to our customers include our binary packages.

Previous attempts included custom package repository, which also worked fine; but nanobsd greatly simplifies transitions between FreeBSD releases (i.e. 10.3 -> 10.4 -> 11.1), testing, atomic upgrades and rollbacks.


----------



## Xylene (Apr 11, 2018)

Have you been able to get dependencies to work against other pkg binaries that are not ports?  I have also noticed that pkg doesn't even complain if the shlibs_required libs are not installed.


----------



## Bobi B. (Apr 12, 2018)

I believe they do:

```
root@bsd11test:~ # pkg install ./mstrtools-1.2.3.txz
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/FreeBSD:11:amd64/quarterly, please wait...
Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
Installing pkg-1.10.5...
Extracting pkg-1.10.5: 100%
Updating FreeBSD repository catalogue...
pkg: Repository FreeBSD load error: access repo file(/var/db/pkg/repo-FreeBSD.sqlite) failed: No such file or directory
Fetching meta.txz: 100%    944 B   0.9kB/s    00:01   
Fetching packagesite.txz: 100%    6 MiB   3.2MB/s    00:02   
Processing entries: 100%
FreeBSD repository update completed. 31144 packages processed.
All repositories are up to date.
Updating database digests format: 100%
The following 4 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    mstrtools: 1.2.3
    db5: 5.3.28_6
    p5-BerkeleyDB: 0.55_1
    perl5: 5.26.1

Number of packages to be installed: 4

The process will require 102 MiB more space.
26 MiB to be downloaded.

Proceed with this action? [y/N]:
```
IIRC dependencies fail silently when using a custom repo and dependent package is not in the repo, hence cannot be offered.


----------



## Xylene (Apr 12, 2018)

So it looks like all dependencies have to belong to a repo? So if I ship two binary packages, and package 1 depends on package 2, there isn't a way to force a dependency on package 2 without it being in a repo?


----------



## Bobi B. (Apr 12, 2018)

It seems like it is possible to configure more than one repository (see /etc/pkg/FreeBSD.conf and pkg(8)). You can publish and provide a custom repo, with your packages, to your customers. Just remember that FreeBSD repositories are refreshed every now and then, independently from security updates, and you'll have to keep an eye on that, or a shared library upgrade could break your Apps.


----------

