Deploying custom built DEB package

Hi, I’ve got a custom built grafana docker image that I build using

‘go run build.go build package’

This all works fine, and I get a deb image from the process (grafana_4.3.0-1490275845pre1_amd64.deb) as well as a .tar.gz file and an rpm package as well.

When using the dockerfile (essentially copied from grafana/grafana-docker):

FROM debian:jessie

COPY ./grafana.deb /tmp/grafana.deb

RUN apt-get update &&
apt-get -y --no-install-recommends install libfontconfig curl ca-certificates &&
apt-get clean &&
dpkg -i --debug=3773 /tmp/grafana.deb &&
rm /tmp/grafana.deb && \

I get the following error:

dpkg (subprocess): unable to execute installed post-installation script (/var/lib/dpkg/info/grafana.postinst): No such file or directory
dpkg: error processing package grafana (–install):
subprocess installed post-installation script returned error exit status 2
D000001: ensure_diversions: same, skipping
D000002: fork/exec /var/lib/dpkg/info/systemd.postinst ( triggered /etc/init.d )
D000001: ensure_diversions: same, skipping
Errors were encountered while processing:
grafana
Setting up grafana (4.3.0-1490275845pre1) …
Processing triggers for systemd (215-17+deb8u6) …
The command ‘/bin/sh -c apt-get update && apt-get -y --no-install-recommends install libfontconfig curl ca-certificates && apt-get clean && dpkg -i --debug=3773 --force-all /tmp/grafana.deb && rm /tmp/grafana.deb && curl -L https://github.com/tianon/gosu/releases/download/1.7/gosu-amd64 > /usr/sbin/gosu && chmod +x /usr/sbin/gosu && apt-get remove -y curl && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*’ returned a non-zero code: 1

Not knowing anything about dpkg I don’t really know where to start trying to debug it. Thanks.

You can find the files that are packaged in the Debian package here: https://github.com/grafana/grafana/tree/master/packaging/deb

The post-install script is here: https://github.com/grafana/grafana/blob/master/packaging/deb/control/postinst

Here is the code that builds the Debian package:

And here is where fpm is used to build a Linux package:

I’m using Windows boot2docker with a shared folder, so the Grafana source is on the Windows drive. In the end, it turned out to be Windows newlines getting in to the deployment scripts. A liberal application of dos2unix on deployment did the trick. Debugging the postinst script on deployment also helped me find the problem. Thanks for the reply.

1 Like