Search code examples
grafanadebdpkg

Installation of debian file failing in Grafana


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

The obvious issue is (/var/lib/dpkg/info/grafana.postinst): No such file or directory but not knowing anything about dpkg I don't really know where to start trying to debug it. As far as I'm aware, I've not altered the deployment scripts so I'm at a loss to know where the issue has arisen.


Solution

  • As I was developing Grafana on a shared Windows folder, with Grafana running in a Docker container on VirtualBox, it seems that (despite not editing the files) SourceTree or something else edited the source to add Windows new lines which messed up the packaging step. I just used dos2unix to remove newlines and everything started working as expected.

    The particular error message was related to newlines in the postinst file, which I debugged manually with bash on the VM.