diff --git a/.gitignore b/.gitignore index 4c68c7fd..cf7882da 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ mgmt.static mgmt-* mgmt.iml rpmbuild/ +*.deb diff --git a/Makefile b/Makefile index 6fb86a37..693c4ba5 100644 --- a/Makefile +++ b/Makefile @@ -290,4 +290,16 @@ upload-rpms: rpmbuild/RPMS/ rpmbuild/RPMS/SHA256SUMS rpmbuild/RPMS/SHA256SUMS.as copr: upload-srpms ./misc/copr-build.py https://$(SERVER)/$(REMOTE_PATH)/SRPMS/$(SRPM_BASE) +# +# deb build +# + +deb: + ./misc/gen-deb-changelog-from-git.sh + dpkg-buildpackage + # especially when building in Docker container, pull build artifact in project directory. + cp ../mgmt_*_amd64.deb ./ + # cleanup + rm -rf debian/mgmt/ + # vim: ts=8 diff --git a/debian/.gitignore b/debian/.gitignore new file mode 100644 index 00000000..018666a7 --- /dev/null +++ b/debian/.gitignore @@ -0,0 +1,7 @@ +*.debhelper.log +*debhelper +changelog +debhelper-build-stamp +files +mgmt.substvars +mgmt/* diff --git a/debian/compat b/debian/compat new file mode 100644 index 00000000..ec635144 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..2fa5da14 --- /dev/null +++ b/debian/control @@ -0,0 +1,16 @@ +Source: mgmt +Maintainer: Johan Bloemberg (aequitas) +Build-Depends: + debhelper, + devscripts, + dh-golang, + dh-systemd, + golang-go, + +Package: mgmt +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: mgmt: next generation config management! + The mgmt tool is a next generation config management prototype. It's + not yet ready for production, but we hope to get there soon. Get + involved today! diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 00000000..cf598358 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,21 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: mgmt +Source: + +Files: * +Copyright: Copyright (C) 2013-2018+ James Shubin and the project contributors +License: GPL-3.0 + +License: GPL-3.0 + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . diff --git a/debian/mgmt.docs b/debian/mgmt.docs new file mode 100644 index 00000000..6c793559 --- /dev/null +++ b/debian/mgmt.docs @@ -0,0 +1,11 @@ +AUTHORS +COPYING +COPYRIGHT +README.md +THANKS +TODO.md +docs +examples +misc/bashrc.sh +misc/delta-cpu.sh +misc/mgmt.service diff --git a/debian/mgmt.install b/debian/mgmt.install new file mode 100644 index 00000000..13346b60 --- /dev/null +++ b/debian/mgmt.install @@ -0,0 +1,2 @@ +mgmt usr/bin +misc/mgmt.service /lib/systemd/system diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..c7675ddf --- /dev/null +++ b/debian/rules @@ -0,0 +1,15 @@ +#!/usr/bin/make -f + +export DH_OPTIONS +export DH_GOPKG := mgmt +export DH_GOLANG_INSTALL_ALL := 1 +unexport GOROOT + +override_dh_auto_build: + make build + +override_dh_auto_test: + @echo "Tests are disabled for now" + +%: + dh $@ --with=systemd diff --git a/misc/gen-deb-changelog-from-git.sh b/misc/gen-deb-changelog-from-git.sh new file mode 100755 index 00000000..6d25b728 --- /dev/null +++ b/misc/gen-deb-changelog-from-git.sh @@ -0,0 +1,76 @@ +#!/bin/bash +set -euo pipefail +IFS=$'\n\t' + +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin + +cleanup() { + if [ -f "${tmpfile}" ]; then + rm -f "${tmpfile}" + fi +} + +trap "{ cleanup; }" EXIT SIGTERM + +getCommits() { + prevtag="${1}" + tag="${2}" + local -a authors + local ver="${tag}-1" + local h + + echo "»»» Processing ${prevtag}..${tag}" + numCommits=$(git --no-pager rev-list --count "${prevtag}".."${tag}") + if ((numCommits>0)); then + echo " ${numCommits} commits found" + + if [ "${tag}" == "HEAD" ]; then + h=$(git rev-list --max-count=1 --abbrev-commit HEAD) + ver="${prevtag}~1.${h}" + fi + + echo "${pkgname} (${ver}) UNRELEASED; urgency=low" >> "${tmpfile}" + + authors=($(git log --format='%aN' "${prevtag}".."${tag}" | sort | uniq)) + for author in "${authors[@]}"; do + echo " Gathering commits from ${author}" + { + echo " [ ${author} ]" + git --no-pager log --author="${author}" --pretty=format:' * %s' "${prevtag}".."${tag}" + echo "" + } >> "${tmpfile}" + done + + git --no-pager log -n 1 --pretty='format:%n -- %aN <%aE> %aD%n%n' "${tag}" >> "${tmpfile}" + else + echo " 0 commits found, skipping" + fi +} + +if [ ! -d "debian" ]; then + echo "Directory ./debian not found" + exit 1 +fi + +tmpfile=$(mktemp) +firstHash=$(git rev-list --max-parents=0 HEAD) # This should yield the very first commit hash +pkgname=$(grep '^Package: ' debian/control | sed 's/^Package: //') +tags=($(git tag | sort -r -V)) + +echo "»»» Gathering untagged commits" +tag=${tags[0]} +untagged=$(git rev-list --count "${tag}"..HEAD) +if ((untagged>0)); then + getCommits "${tag}" HEAD +fi + + +for ((i=1; i<${#tags[@]}; i++)); do + tag="${tags[${i}]}" + nexttag="${tags[$((i-1))]}" + getCommits "${tag}" "${nexttag}" +done + +getCommits "${firstHash}" "${tags[-1]}" + +mv "${tmpfile}" debian/changelog diff --git a/misc/make-deps.sh b/misc/make-deps.sh index 934d572a..293cfcee 100755 --- a/misc/make-deps.sh +++ b/misc/make-deps.sh @@ -36,6 +36,8 @@ if [ ! -z "$APT" ]; then $sudo_command $APT install -y libvirt-dev || true $sudo_command $APT install -y libaugeas-dev || true $sudo_command $APT install -y libpcap0.8-dev || true + # dependencies for building debian packages with `make deb` + $sudo_command $APT install -y dpkg-dev devscripts debhelper dh-golang dh-systemd fi if [ ! -z "$BREW" ]; then