diff --git a/.gitignore b/.gitignore index 4afcf19..c9b2862 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,11 @@ .idea -build \ No newline at end of file +*.iml +build +obj* +debian/notify-mail +debian/debhelper-build-stamp +debian/.debhelper +debian/files +debian/notify-mail.debhelper.log +debian/notify-mail.substvars +release diff --git a/VERSION b/VERSION deleted file mode 100644 index 23aa839..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.2.2 diff --git a/deb/DEBIAN/control b/deb/DEBIAN/control deleted file mode 100644 index 4f4a322..0000000 --- a/deb/DEBIAN/control +++ /dev/null @@ -1,8 +0,0 @@ -Package: notify-mail -Version: {{version}} -Section: extras -Priority: standard -Architecture: {{architecture}} -Maintainer: Andoni del Olmo -Installed-Size: {{size}} -Description: Send mail notifications diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..f5105ed --- /dev/null +++ b/debian/changelog @@ -0,0 +1,7 @@ +notify-mail (1.2.2) unstable; urgency=medium + + * implement message template. + * validate variables parameter. + * fix message delivery + + -- Andoni del Olmo Sat, 06 Jun 2020 18:22:45 +0200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..56014bf --- /dev/null +++ b/debian/control @@ -0,0 +1,11 @@ +Source: notify-mail +Section: extras +Priority: standard +Maintainer: Andoni del Olmo +Build-Depends: debhelper (>=9), golang-go:native (>= 1.3.3), dh-golang +Standards-Version: 3.9.4 +Homepage: https://github.com/adelolmo/notify-mail + +Package: notify-mail +Architecture: any +Description: Send mail notifications diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..0a79839 --- /dev/null +++ b/debian/rules @@ -0,0 +1,77 @@ +#!/usr/bin/make -f + +export DH_OPTIONS + +## +# From git-lfs/git-lfs repo: +# Looks like dh_golang doesn't set diffrent archs, so you have to do them semi-manually. +## + +## This if-structure is decided on what is passed by the -a flag by dpkg-buildpackage command. +ifeq ($(DEB_HOST_ARCH), i386) + export GOARCH := 386 +else ifeq ($(DEB_HOST_ARCH), amd64) + export GOARCH := amd64 +else ifeq ($(DEB_HOST_ARCH), armhf) + export GOARCH := arm + # May need to set GOARM as well if your going to target ARM. But for now this works. +else ifeq ($(DEB_HOST_ARCH), arm64) + export GOARCH := arm64 +endif + +# Or add your arch that your targeting, these are just examples. + +# Directory where compiled binary is placed + debian setup files. +# Note: If your doing building thru git, you may want to add obj-* to .gitignore +BUILD_DIR := obj-$(DEB_HOST_GNU_TYPE) + +# Required: Put the url (without http://) of your git repo. +export DH_GOPKG := github.com/adelolmo/notify-mail + +# Required: Put the name of your git repo below. +GIT_REPO_NAME := notify-mail + +export PATH := $(CURDIR)/$(BUILD_DIR)/bin:$(PATH) + +## +# From git-lfs/git-lfs repo: +# by-default, dh_golang only copies *.go and other source - this upsets a bunch of vendor test routines +## +export DH_GOLANG_INSTALL_ALL := 1 + +%: + mkdir -p /tmp/gocache + GO111MODULE=on GOFLAGS=-mod=vendor GOCACHE=/tmp/gocache dh $@ --buildsystem=golang --with=golang + +override_dh_clean: + rm -f debian/debhelper.log + dh_clean + +override_dh_auto_build: + dh_auto_build + ## + # From git-lfs/git-lfs repo: + # dh_golang doesn't do anything here in deb 8, and it's needed in both + ## + if [ "$(DEB_HOST_GNU_TYPE)" != "$(DEB_BUILD_GNU_TYPE)" ]; then\ + cp -rf $(BUILD_DIR)/bin/*/* $(BUILD_DIR)/bin/; \ + fi + +override_dh_strip: + ## + # From git-lfs/git-lfs repo: + # strip disabled as golang upstream doesn't support it and it makes go crash. + # See https://launchpad.net/bugs/1200255. + ## + +override_dh_golang: + ## + # From git-lfs/git-lfs repo: + # The dh_golang is used to add the Built-using field to the deb. This is only for reference. + # As of https://anonscm.debian.org/cgit/collab-maint/dh-golang.git/commit/script/dh_golang?id=7c3fbec6ea92294477fa8910264fe9bd823f21c3 + # dh_golang errors out because the go compiler used was not installed via a package. Therefore the step is skipped + ## + +override_dh_auto_install: + install -g 0 -o 0 -d debian/$(GIT_REPO_NAME)/usr/bin + cp $(BUILD_DIR)/bin/notify-mail debian/$(GIT_REPO_NAME)/usr/bin diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..f513aa5 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/adelolmo/notify-mail + +go 1.14 diff --git a/package b/package deleted file mode 100755 index c2e8f64..0000000 --- a/package +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -set -e - -BUILD=build -version=$(cat VERSION) -rm -Rf ${BUILD} -mkdir -p ${BUILD}/release ${BUILD}/tmp - -echo "Building version $version..." - -ar="amd64 arm" -for arch in ${ar}; do - echo ${arch} - - rm -rf ${BUILD}/tmp/* - cp -R deb/* ${BUILD}/tmp - - GOOS=linux GOARCH=${arch} GOARM=7 go build -o ${BUILD}/tmp/usr/bin/notify-mail main.go - if [ "${arch}" = "amd64" ]; then - cp ${BUILD}/tmp/usr/bin/notify-mail ${BUILD}/release/notify-mail-x86_64.AppImage - fi - - architecture=$( echo ${arch} | sed 's/arm/armhf/g' ) - size=$(du -cs ${BUILD}/tmp | sed '1!d' | grep -oe "^[0-9]*") - sed -i 's/{{version}}/'${version}'/g;s/{{size}}/'${size}'/g;s/{{architecture}}/'${architecture}'/g' ${BUILD}/tmp/DEBIAN/control - - fakeroot dpkg-deb -b -z9 ${BUILD}/tmp ${BUILD}/release -done - -echo done