Skip to content

Commit

Permalink
makefile: debian packaging based on dh-golang
Browse files Browse the repository at this point in the history
Signed-off-by: Máximo Cuadros <[email protected]>
  • Loading branch information
mcuadros committed Dec 29, 2017
1 parent 57bdaa4 commit 2c41599
Show file tree
Hide file tree
Showing 13 changed files with 189 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
build

debian/changelog
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ ARG GO_TAGS
ENV GO_TAGS=${GO_TAGS}

RUN apt-get update && apt-get install -y --no-install-recommends \
git build-essential gettext-base \
git build-essential \
debhelper devscripts fakeroot git-buildpackage dh-make dh-systemd dh-golang \
libcairo2-dev \
libgtk-3-dev

# We cache go get gtk, to speed up builds.
RUN go get -tags ${GO_TAGS} -v github.com/gotk3/gotk3/gtk/...
#RUN go get -tags ${GO_TAGS} -v github.com/gotk3/gotk3/gtk/...

ADD . ${GOPATH}/src/github.com/mcuadros/OctoPrint-TFT/
RUN go get -tags ${GO_TAGS} -v ./...
#RUN go get -tags ${GO_TAGS} -v ./...

WORKDIR ${GOPATH}/src/github.com/mcuadros/OctoPrint-TFT/
32 changes: 15 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ GOGET = $(GOCMD) get -v -t
GOTEST = $(GOCMD) test -v

# Environment
BUILD_PATH := $(shell pwd)/build
WORKDIR := $(shell pwd)
BUILD_PATH := $(WORKDIR)/build
DOCKER_IMAGE_BUILD = mcuadros/octoprint-tft-build

DEBIAN_PACKAGES = JESSIE
Expand All @@ -26,18 +27,15 @@ JESSIE_GO_TAGS := gtk_3_14

# Build information
GIT_COMMIT = $(shell git rev-parse HEAD | cut -c1-7)
GIT_DIRTY = $(shell test -n "`git status --porcelain`" && echo "-dirty" || true)
DEV_PREFIX := 0.dev
VERSION ?= $(DEV_PREFIX)-$(GIT_COMMIT)$(GIT_DIRTY)
DEV_PREFIX := 0.0
VERSION ?= $(DEV_PREFIX)~git$(GIT_COMMIT)

ifneq ($(origin TRAVIS_TAG), undefined)
VERSION := $(TRAVIS_TAG)
endif

# Package information
BINARY_NAME = octoprint-tft
INSTALL_FOLDER = /opt/octoprint-tft
PACKAGE_NAME = ${BINARY_NAME}_${VERSION}_$(shell uname -m).deb
PACKAGE_NAME = octoprint-tft

# we export the variable to allow envsubst, substitute the vars in the
# Dockerfiles
Expand All @@ -57,18 +55,18 @@ $(DEBIAN_PACKAGES):
docker run -it --rm \
-v ${BUILD_PATH}/${${@}_NAME}:/build \
${DOCKER_IMAGE_BUILD}:${${@}_NAME} \
make package-internal
make build-internal

build-internal:
go build --tags ${GO_TAGS} -v -o /build/bin/${BINARY_NAME} main.go
build-internal: prepare-internal
#go build --tags ${GO_TAGS} -v -o /build/bin/${BINARY_NAME} main.go
cd $(WORKDIR); \
debuild --prepend-path=/usr/local/go/bin/ --preserve-env -us -uc; \
cp ../*.deb /build/;

package-internal: build-internal
mkdir -p /build/deb/${INSTALL_FOLDER}/bin/; \
cp -rf styles /build/deb/${INSTALL_FOLDER}; \
cp -rf /build/bin/${BINARY_NAME} /build/deb/${INSTALL_FOLDER}/bin/; \
cp -rf etc/DEBIAN /build/deb/; \
envsubst < etc/DEBIAN/control > /build/deb/DEBIAN/control; \
dpkg-deb --build /build/deb/ /build/${PACKAGE_NAME}
prepare-internal:
dch --create -v $(VERSION)-1 --package $(PACKAGE_NAME) empty; \
cd $(WORKDIR)/..; \
tar -czf octoprint-tft_$(VERSION).orig.tar.gz --exclude-vcs OctoPrint-TFT

clean:
rm -rf ${BUILD_PATH}
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
36 changes: 36 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Source: octoprint-tft
Section: devel
Priority: optional
Maintainer: Debian Go Packaging Team <[email protected]>
Uploaders: Máximo Cuadros <[email protected]>
Build-Depends: debhelper (>= 9),
dh-golang,
dh-systemd,
libcairo2-dev (>= 1.14.0),
libgtk-3-dev (>= 3.14)
Standards-Version: 4.1.1
Homepage: https://github.com/mcuadros/OctoPrint-TFT
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-go/packages/octoprint-tft.git
Vcs-Git: https://anonscm.debian.org/git/pkg-go/packages/octoprint-tft.git
XS-Go-Import-Path: github.com/mcuadros/OctoPrint-TFT
Testsuite: autopkgtest-pkg-go

Package: octoprint-tft
Architecture: any
Built-Using: ${misc:Built-Using}
Depends: ${shlibs:Depends},
${misc:Depends},
libcairo2 (>= 1.14.0),
libgtk-3-0 (>= 3.14)
Description: A OctoPrint touch interface for TFT touch modules based on GTK+3
OctoPrint-TFT OctoPrint-TFT, a touch interface for TFT touch modules
based on GTK+3.
.
Is a X application to be executed directly in the X Server without any
windows manager, as frontend of a OctoPrint (http://octoprint.org)
server in a Raspberry Pi equipped with any TFT Touch module
(https://www.waveshare.com/wiki/3.5inch_RPi_LCD_(A)).
.
Allows you to control your 3D Printer, like you can do with any TFT/LCD
panel (http://reprap.org/wiki/RepRapTouch), but using OctoPrint and a
Raspberry Pi.
35 changes: 35 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: OctoPrint-TFT
Source: https://github.com/mcuadros/OctoPrint-TFT

Files: *
Copyright: 2017 Máximo Cuadros
License: MIT License

Files: debian/*
Copyright: 2017 Máximo Cuadros <[email protected]>
License: MIT License
Comment: Debian packaging is licensed under the same terms as upstream

License: MIT License
MIT License
.
Copyright (c) 2017 Máximo Cuadros
.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions debian/gbp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[DEFAULT]
pristine-tar = True
52 changes: 52 additions & 0 deletions debian/octoprint-tft.postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/sh

set -e

. /usr/share/debconf/confmodule

THIS_PACKAGE=octoprint-tft
DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager


# debconf is not a registry, so we only fiddle with the default file if it
# does not exist
if [ ! -e $DEFAULT_DISPLAY_MANAGER_FILE ]; then
if db_get shared/default-x-display-manager; then
# workaround debconf passthru bug (#379198)
if [ -z "$RET" ]; then
$RET="$THIS_PACKAGE"
fi
if [ "$THIS_PACKAGE" != "$RET" ]; then
echo "Please be sure to run \"dpkg --configure $RET\"."
fi
if db_get "$RET"/daemon_name; then
echo "$RET" > $DEFAULT_DISPLAY_MANAGER_FILE
fi
fi
fi

# Registering the init scripts or starting the daemon may cause output to
# stdout, which can confuse debconf.
db_stop

DEFAULT_SERVICE=/etc/systemd/system/display-manager.service
# set default-display-manager systemd service link according to our config
if [ "$1" = configure ] && [ -d /etc/systemd/system/ ]; then
if [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" ]; then
SERVICE=/lib/systemd/system/$(basename $(cat "$DEFAULT_DISPLAY_MANAGER_FILE")).service
if [ -h "$DEFAULT_SERVICE" ] && [ $(readlink "$DEFAULT_SERVICE") = /dev/null ]; then
echo "Display manager service is masked" >&2
elif [ -e "$SERVICE" ]; then
ln -sf "$SERVICE" "$DEFAULT_SERVICE"
else
echo "WARNING: $SERVICE is the selected default display manager but does not exist" >&2
rm -f "$DEFAULT_SERVICE"
fi
else
rm -f "$DEFAULT_SERVICE"
fi
fi

#DEBHELPER#

exit 0
16 changes: 16 additions & 0 deletions debian/octoprint-tft.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=OctoPrint-TFT
Conflicts[email protected]
After=systemd-user-sessions.service [email protected] plymouth-quit.service

[Service]
ExecStart=/usr/bin/OctoPrint-TFT
StandardOutput=journal
Restart=always
RestartSec=1s
TimeoutStopSec=5s
IgnoreSIGPIPE=no

[Install]
WantedBy=graphical.target
Alias=display-manager.service
22 changes: 22 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/make -f

export DH_VERBOSE := 1
export DH_GOPKG := github.com/mcuadros/OctoPrint-TFT
export DH_GOLANG_INSTALL_ALL := 1
export DH_GOLANG_EXCLUDES := vendor

%:
dh $@ --buildsystem=golang --with=golang,systemd

override_dh_auto_build:
env; \
dh_auto_build -O--buildsystem=golang -O--no-parallel -- --tags $(GO_TAGS)

override_dh_install:
mkdir -p $(CURDIR)/debian/octoprint-tft/opt/octoprint-tft/
cp -r styles $(CURDIR)/debian/octoprint-tft/opt/octoprint-tft/
rm -rf $(CURDIR)/debian/octoprint-tft/usr/share/gocode
dh_install -XLICENSE

override_dh_auto_test:
echo "skip no tests"
1 change: 1 addition & 0 deletions debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (quilt)
4 changes: 4 additions & 0 deletions debian/watch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version=3
opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/octoprint-tft-\$1\.tar\.gz/,\
uversionmangle=s/(\d)[_\.\-\+]?(RC|rc|pre|dev|beta|alpha)[.]?(\d*)$/\$1~\$2\$3/ \
https://github.com/mcuadros/OctoPrint-TFT/tags .*/v?(\d\S*)\.tar\.gz
8 changes: 0 additions & 8 deletions etc/DEBIAN/control

This file was deleted.

0 comments on commit 2c41599

Please sign in to comment.