Skip to content
Permalink
Browse files

Debianization

  • Loading branch information...
subuk committed Sep 7, 2019
1 parent 1fb3048 commit 9c9863afc71b924e7d72d85b68aca733cc975f7d
@@ -1,11 +1,13 @@
export GOFLAGS=-mod=vendor
export GOBIN=$(PWD)/bin/
# Fix for debian sbuild
export GOCACHE=/tmp/.vmango-go-build-cache
GO = go
INSTALL = install
GO_SOURCES = $(shell find . -name '*.go')
ASSETS_SOURCES = $(shell find templates static)
UNAME_S := $(shell uname -s)
TARBALL_SOURCES = $(GO_SOURCES) Makefile Makefile.RPM.mk README.md vmango.dist.conf vmango.service static/ templates/ vendor/ go.mod go.sum
TARBALL_SOURCES = $(GO_SOURCES) Makefile README.md vmango.dist.conf vmango.service static/ templates/ vendor/ go.mod go.sum

VERSION = 0.9.0

@@ -28,7 +30,7 @@ bin/vmango: $(GO_SOURCES) web/assets_generated.go Makefile
$(GO) build -ldflags='$(BUILD_LDFLAGS)' -o bin/vmango

bin/go-bindata:
$(GO) install github.com/go-bindata/go-bindata/go-bindata
$(GO) build -o bin/go-bindata github.com/go-bindata/go-bindata/go-bindata

web/assets_generated.go: bin/go-bindata $(ASSETS_SOURCES)
bin/go-bindata $(ASSETS_FLAGS) -o web/assets_generated.go -pkg web static/... templates/...
@@ -50,10 +52,11 @@ vendor:

.PHONY: test
test:
go test vmango/...
go test

.PHONY: clean
clean:
rm -rf web/assets_generated.go bin/ $(RPM_NAME)*.spec $(RPM_NAME)-*.tar.gz *.rpm
rm -rf web/assets_generated.go bin/ *.tar.gz *.tar.hz *.rpm *.deb *_source.buildinfo *_source.changes *_source.ppa.upload *.debian.tar.xz *.dsc

include Makefile.RPM.mk
-include Makefile.RPM.mk
-include Makefile.DEB.mk
@@ -0,0 +1,55 @@
DEB_NAME = vmango
DEB_VERSION = $(VERSION)
DEB_TOPDIR = /tmp/debian-build-root
DEB_OUTDIR = .
DEB_ARCH = $(shell dpkg --print-architecture)
DEB_RELEASE = $(shell git describe --tags 2>/dev/null | awk -F- '{print $$2"."$$3}')
DEB_DISTRIBUTION = unstable

ifeq ($(DEB_RELEASE),.)
DEB_RELEASE = 1
endif
ifeq ($(DEB_RELEASE),)
DEB_RELEASE = 1
endif

# Signing:
# gpg --list-keys --keyid-format=short
# debsign -k $ID vmango_$version_source.changes
#
sdeb: $(DEB_OUTDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE)_source.changes $(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE)_source.buildinfo $(DEB_OUTDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE).dsc $(DEB_OUTDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE).debian.tar.xz $(DEB_OUTDIR)/vmango_$(VERSION).orig.tar.gz
$(DEB_OUTDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE)_source.changes $(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE)_source.buildinfo $(DEB_OUTDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE).dsc $(DEB_OUTDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE).debian.tar.xz $(DEB_OUTDIR)/vmango_$(VERSION).orig.tar.gz: vmango-$(VERSION).tar.gz debian/* Makefile.DEB.mk
mk-build-deps -t 'apt-get -y' --remove --install debian/control
mkdir -p $(DEB_TOPDIR)
cp vmango-$(VERSION).tar.gz $(DEB_TOPDIR)/vmango_$(DEB_VERSION).orig.tar.gz

rm -rf $(DEB_TOPDIR)/vmango-$(VERSION)/
tar -C $(DEB_TOPDIR)/ -xf $(DEB_TOPDIR)/vmango_$(DEB_VERSION).orig.tar.gz
cp -r debian $(DEB_TOPDIR)/vmango-$(VERSION)/

cd $(DEB_TOPDIR)/vmango-$(VERSION)/ \
&& dch -D '$(DEB_DISTRIBUTION)' -m -v $(DEB_VERSION)-$(DEB_RELEASE) 'Local docker source build' \
&& debuild -S -sa -us -uc

mkdir -p $(DEB_OUTDIR)
cp $(DEB_TOPDIR)/$(DEB_NAME)_$(DEB_VERSION).orig.tar.gz $(DEB_OUTDIR)/
cp $(DEB_TOPDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE)_source.changes $(DEB_OUTDIR)/
cp $(DEB_TOPDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE)_source.buildinfo $(DEB_OUTDIR)/
cp $(DEB_TOPDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE).dsc $(DEB_OUTDIR)/
cp $(DEB_TOPDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE).debian.tar.xz $(DEB_OUTDIR)/
rm -rf $(DEB_TOPDIR)/vmango-$(VERSION)

deb: $(DEB_OUTDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE)_$(DEB_ARCH).deb
$(DEB_OUTDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE)_$(DEB_ARCH).deb: $(DEB_OUTDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE)_source.changes $(DEB_OUTDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE).dsc $(DEB_OUTDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE).debian.tar.xz $(DEB_OUTDIR)/vmango_$(VERSION).orig.tar.gz Makefile.DEB.mk
mkdir -p $(DEB_TOPDIR)/
cp $(DEB_OUTDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE)_source.changes $(DEB_TOPDIR)/
cp $(DEB_OUTDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE).dsc $(DEB_TOPDIR)/
cp $(DEB_OUTDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE).debian.tar.xz $(DEB_TOPDIR)/
cp $(DEB_OUTDIR)/vmango_$(VERSION).orig.tar.gz $(DEB_TOPDIR)/

rm -rf $(DEB_TOPDIR)/vmango-$(VERSION)
cd $(DEB_TOPDIR)/ && dpkg-source -x $(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE).dsc
cd $(DEB_TOPDIR)/vmango-$(DEB_VERSION)/ && mk-build-deps -t 'apt-get -y' --remove --install debian/control
cd $(DEB_TOPDIR)/vmango-$(DEB_VERSION)/ && DEB_BUILD_OPTIONS=noddebs debuild -us -uc

cp $(DEB_TOPDIR)/$(DEB_OUTDIR)/$(DEB_NAME)_$(DEB_VERSION)-$(DEB_RELEASE)_$(DEB_ARCH).deb $(DEB_OUTDIR)/
@@ -17,7 +17,7 @@ endif


spec: $(RPM_SPEC)
$(RPM_SPEC): $(RPM_NAME)-$(RPM_VERSION)-$(RPM_RELEASE).spec
$(RPM_SPEC): $(RPM_NAME)-$(RPM_VERSION)-$(RPM_RELEASE).spec Makefile.RPM.mk
cp $(RPM_NAME)-$(RPM_VERSION)-$(RPM_RELEASE).spec $(RPM_SPEC)
$(RPM_NAME)-$(RPM_VERSION)-$(RPM_RELEASE).spec: $(RPM_NAME).spec.in
sed -e "s/@@_VERSION_@@/$(RPM_VERSION)/g" -e "s/@@_RELEASE_@@/$(RPM_RELEASE)/g" $(RPM_NAME).spec.in > $(RPM_NAME)-$(RPM_VERSION)-$(RPM_RELEASE).spec
@@ -35,7 +35,3 @@ $(RPM_OUTDIR)/$(RPM_NAME)-$(RPM_VERSION)-$(RPM_RELEASE)$(RPM_DIST).$(RPM_ARCH).r
yum-builddep -y $(RPM_OUTDIR)/$(RPM_NAME)-$(RPM_VERSION)-$(RPM_RELEASE)$(RPM_DIST).src.rpm
rpmbuild --rebuild $(RPM_OUTDIR)/$(RPM_NAME)-$(RPM_VERSION)-$(RPM_RELEASE)$(RPM_DIST).src.rpm
mv $(RPM_TOPDIR)/RPMS/$(RPM_ARCH)/$(RPM_NAME)-$(RPM_VERSION)-$(RPM_RELEASE)$(RPM_DIST).$(RPM_ARCH).rpm $(RPM_OUTDIR)/

.PHONY: docker-rpm
docker-rpm:
./dockerbuild.sh centos-7 rpm
@@ -105,8 +105,18 @@ Make sure to add ?socket option to remote libvirt urls.

With docker for Centos 7:

make clean docker-rpm
./dockerbuild.sh centos-7 make rpm

Locally:

make clean rpm
make rpm

## Build DEB

With docker for Ubuntu 18.04:

./dockerbuild.sh ubuntu-1804 make deb

Locally:

make deb
@@ -0,0 +1,5 @@
vmango (0.9.0-1) unstable; urgency=medium

* Initial release

-- Matvey Kruglov <kubuzzzz@gmail.com> Sat, 06 Sep 2019 20:09:31 +0000
@@ -0,0 +1 @@
10
@@ -0,0 +1,12 @@
Source: vmango
Maintainer: Matvey Kruglov <kubuzzzz@gmail.com>
Section: admin
Priority: optional
Build-Depends: libvirt-dev (>=1.2.0), debhelper (>=10), golang, pkg-config
Standards-Version: 4.1.2
Homepage: https://github.com/subuk/vmango

Package: vmango
Architecture: any
Depends: genisoimage, ${shlibs:Depends}, ${misc:Depends}
Description: Your own personal IaaS cloud
@@ -0,0 +1,34 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: vmango
Source: <url://example.com>

Files: *
Copyright: <years> <put author's name and email here>
<years> <likewise for another author>
License: GPL-3.0+

Files: debian/*
Copyright: 2019 unknown <kubuzzzz@gmail.com>
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 package 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 <https://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".

# Please also look if there are files or directories which have a
# different copyright/license attached and list them here.
# Please avoid picking licenses with terms that are more restrictive than the
# packaged work, as it may make Debian's contributions unacceptable upstream.
@@ -0,0 +1,2 @@
# git-build-recipe format 0.4 deb-version {debupstream}-{time}~{git-commit}
lp:~subuk/+git/vmango feature/debian_packaging
@@ -0,0 +1,22 @@
#!/usr/bin/make -f

# output every command that modifies files on the build system.
export DH_VERBOSE = 1


# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


%:
dh $@

# This is example for Cmake (See https://bugs.debian.org/641051 )
#override_dh_auto_configure:
# dh_auto_configure -- # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)
@@ -0,0 +1 @@
3.0 (quilt)
@@ -0,0 +1,8 @@
vmango source: source-is-missing static/coreui/js/Chart.min.js
vmango source: source-is-missing static/coreui/js/Chart.min.js
vmango source: source-is-missing static/coreui/js/bootstrap.min.js
vmango source: source-is-missing static/coreui/js/jquery.min.js
vmango source: source-is-missing static/coreui/js/pace.min.js
vmango source: source-is-missing static/coreui/js/tether.min.js
vmango source: source-is-missing static/xterm/xterm.js line length is 865 characters (>512)
vmango source: source-is-missing static/xterm/addons/fit/fit.js line length is 860 characters (>512)
@@ -0,0 +1,3 @@
README
README.Debian
README.source
@@ -0,0 +1,9 @@
#!/bin/sh

case "$1" in
configure)
adduser --system --group --home /var/lib/vmango vmango
;;
esac

#DEBHELPER#
@@ -0,0 +1,13 @@
[Unit]
Description=Vmango web service
After=network-online.target

[Service]
Type=simple
User=vmango
Group=vmango
EnvironmentFile=-/etc/default/vmango
ExecStart=/usr/bin/vmango --config /etc/vmango.conf

[Install]
WantedBy=multi-user.target
@@ -1,28 +1,55 @@
#!/bin/bash
set -e

USAGE="Usage: $0 [centos-7] <make args...>"
CACHE_DIR=/tmp/rpmbuild-cache
USAGE="Usage: $0 [centos-7|ubuntu-1804] <make args...>"
CACHE_DIR=/tmp/vmango-package-build-cache
mkdir -p $CACHE_DIR

case "$1" in
"centos-7")
DOCKER_IMAGE=vmango:build_centos7
YUM_CONFIG=`pwd`/dockerbuild/centos7.yum.conf
if [[ "Y$(docker images -q $DOCKER_IMAGE)" == "Y" ]]; then
if [[ "Y$(docker images -q $DOCKER_IMAGE)" == "Y" || "Y${FORCE_REBUILD}" != "Y" ]]; then
docker build -t $DOCKER_IMAGE -f dockerbuild/centos7.dockerfile .
fi
shift
exec docker run --rm -it \
-v `pwd`:/source \
-v $CACHE_DIR:/cache \
-v $YUM_CONFIG:/etc/yum.conf \
-w /source \
$DOCKER_IMAGE $@
;;
"ubuntu-1804")
DOCKER_IMAGE=vmango:build_ubuntu1804
YUM_CONFIG=`pwd`/dockerbuild/centos7.yum.conf
if [[ "Y$(docker images -q $DOCKER_IMAGE)" == "Y" || "Y${FORCE_REBUILD}" != "Y" ]]; then
docker build -t $DOCKER_IMAGE -f dockerbuild/ubuntu1804.dockerfile .
fi
mkdir -p $CACHE_DIR/apt
shift
exec docker run --rm -it \
-v `pwd`:/source \
-v $HOME/.gnupg/:/root/.gnupg \
-v $CACHE_DIR/apt_ubuntu1804:/var/cache/apt \
-w /source \
$DOCKER_IMAGE $@
;;
"debian-10")
DOCKER_IMAGE=vmango:build_debian10
YUM_CONFIG=`pwd`/dockerbuild/centos7.yum.conf
if [[ "Y$(docker images -q $DOCKER_IMAGE)" == "Y" || "Y${FORCE_REBUILD}" != "Y" ]]; then
docker build -t $DOCKER_IMAGE -f dockerbuild/debian10.dockerfile .
fi
mkdir -p $CACHE_DIR/apt
shift
exec docker run --rm -it \
-v `pwd`:/source \
-v $CACHE_DIR/apt_debian_10:/var/cache/apt \
-w /source \
$DOCKER_IMAGE $@
;;
*)
echo $USAGE
exit 1
esac
shift

mkdir -p $CACHE_DIR

exec docker run --rm -it \
-v `pwd`:/source \
-v $CACHE_DIR:/cache \
-v $YUM_CONFIG:/etc/yum.conf \
-w /source \
$DOCKER_IMAGE $@
@@ -0,0 +1,5 @@
FROM debian:10
ENV TZ=UTC
ENV DEBIAN_FRONTEND noninteractive
RUN rm -f /etc/apt/apt.conf.d/docker-clean
RUN apt-get update && apt-get install -y wget dpkg-dev devscripts equivs fakeroot debhelper software-properties-common vim git-build-recipe
@@ -0,0 +1,6 @@
FROM ubuntu:18.04
ENV TZ=UTC
ENV DEBIAN_FRONTEND noninteractive
RUN rm -f /etc/apt/apt.conf.d/docker-clean
RUN apt-get update && apt-get install -y wget dpkg-dev devscripts equivs fakeroot debhelper software-properties-common vim git-build-recipe
RUN add-apt-repository ppa:longsleep/golang-backports
@@ -0,0 +1,2 @@
# git-build-recipe format 0.4 deb-version {debupstream}-{time}~{git-commit}
lp:~subuk/+git/vmango feature/debian_packaging

0 comments on commit 9c9863a

Please sign in to comment.
You can’t perform that action at this time.