]> git.proxmox.com Git - pve-qemu.git/blobdiff - Makefile
buildsys: create build directory atomically
[pve-qemu.git] / Makefile
index 385a64de600264ff821672b6333d2e2b8da4885a..da63ce27bd7da5b60569b52ff2f31ce82ccc6f86 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,65 +1,76 @@
-# also update debian/changelog
-KVMVER=2.11.2
-KVMPKGREL=1
+include /usr/share/dpkg/default.mk
 
-KVMPACKAGE = pve-qemu-kvm
-KVMSRC = qemu
-BUILDSRC = $(KVMSRC).tmp
+PACKAGE = pve-qemu-kvm
 
 SRCDIR := qemu
+BUILDDIR ?= ${PACKAGE}-${DEB_VERSION_UPSTREAM}
+ORIG_SRC_TAR=$(PACKAGE)_$(DEB_VERSION_UPSTREAM).orig.tar.gz
 
-ARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH)
 GITVERSION := $(shell git rev-parse HEAD)
 
-DEB = ${KVMPACKAGE}_${KVMVER}-${KVMPKGREL}_${ARCH}.deb
-DEB_DBG = ${KVMPACKAGE}-dbg_${KVMVER}-${KVMPKGREL}_${ARCH}.deb
+DSC=$(PACKAGE)_$(DEB_VERSION_UPSTREAM_REVISION).dsc
+DEB = ${PACKAGE}_${DEB_VERSION_UPSTREAM_REVISION}_${DEB_BUILD_ARCH}.deb
+DEB_DBG = ${PACKAGE}-dbg_${DEB_VERSION_UPSTREAM_REVISION}_${DEB_BUILD_ARCH}.deb
 DEBS = $(DEB) $(DEB_DBG)
 
-
 all: $(DEBS)
 
 .PHONY: submodule
 submodule:
-       test -f "${SRCDIR}/debian/changelog" || git submodule update --init
+       test -f "${SRCDIR}/configure" || git submodule update --init --recursive
+
+$(BUILDDIR): keycodemapdb | submodule
+       # check if qemu/ was used for a build
+       # if so, please run 'make distclean' in the submodule and try again
+       test ! -f $(SRCDIR)/build/config.status
+       rm -rf $(BUILDDIR).tmp $(BUILDDIR)
+       cp -a $(SRCDIR) $(BUILDDIR).tmp
+       cp -a debian $(BUILDDIR).tmp/debian
+       rm -rf $(BUILDDIR).tmp/ui/keycodemapdb
+       cp -a keycodemapdb $(BUILDDIR).tmp/ui/
+       echo "git clone git://git.proxmox.com/git/pve-qemu.git\\ngit checkout $(GITVERSION)" > $(BUILDDIR).tmp/debian/SOURCE
+       mv $(BUILDDIR).tmp $(BUILDDIR)
 
 .PHONY: deb kvm
 deb kvm: $(DEBS)
 $(DEB_DBG): $(DEB)
-$(DEB): keycodemapdb | submodule
-       rm -f *.deb
-       rm -rf $(BUILDSRC)
-       mkdir $(BUILDSRC)
-       cp -a $(KVMSRC)/* $(BUILDSRC)/
-       cp -a debian $(BUILDSRC)/debian
-       rm -rf $(BUILDSRC)/ui/keycodemapdb
-       cp -a keycodemapdb $(BUILDSRC)/ui/
-       echo "git clone git://git.proxmox.com/git/pve-qemu.git\\ngit checkout $(GITVERSION)" > $(BUILDSRC)/debian/SOURCE
-       # set package version
-       sed -i 's/^pkgversion="".*/pkgversion="${KVMPACKAGE}_${KVMVER}-${KVMPKGREL}"/' $(BUILDSRC)/configure
-       cd $(BUILDSRC); dpkg-buildpackage -b -rfakeroot -us -uc
-       lintian $(DEBS) || true
+$(DEB): $(BUILDDIR)
+       cd $(BUILDDIR); dpkg-buildpackage -b -us -uc -j
+       lintian $(DEBS)
+
+sbuild: $(DSC)
+       sbuild $(DSC)
+
+$(ORIG_SRC_TAR): $(BUILDDIR)
+       tar czf $(ORIG_SRC_TAR) --exclude="$(BUILDDIR)/debian" $(BUILDDIR)
+
+.PHONY: dsc
+dsc: $(DSC)
+$(DSC): $(ORIG_SRC_TAR) $(BUILDDIR)
+       rm -f *.dsc
+       cd $(BUILDDIR); dpkg-buildpackage -S -us -uc -d
+       lintian $(DSC)
 
 .PHONY: update
 update:
-       cd $(KVMSRC) && git submodule deinit ui/keycodemapdb || true
-       rm -rf $(KVMSRC)/ui/keycodemapdb
-       mkdir $(KVMSRC)/ui/keycodemapdb
-       cd $(KVMSRC) && git submodule update --init ui/keycodemapdb
+       cd $(SRCDIR) && git submodule deinit ui/keycodemapdb || true
+       rm -rf $(SRCDIR)/ui/keycodemapdb
+       mkdir $(SRCDIR)/ui/keycodemapdb
+       cd $(SRCDIR) && git submodule update --init ui/keycodemapdb
        rm -rf keycodemapdb
        mkdir keycodemapdb
-       cp -R $(KVMSRC)/ui/keycodemapdb/* keycodemapdb/
+       cp -R $(SRCDIR)/ui/keycodemapdb/* keycodemapdb/
        git add keycodemapdb
 
 .PHONY: upload
+upload: UPLOAD_DIST ?= $(DEB_DISTRIBUTION)
 upload: $(DEBS)
-       tar cf - ${DEBS} | ssh repoman@repo.proxmox.com upload --product pve --dist stretch
+       tar cf - ${DEBS} | ssh repoman@repo.proxmox.com upload --product pve --dist $(UPLOAD_DIST)
 
-.PHONY: distclean
+.PHONY: distclean clean
 distclean: clean
-
-.PHONY: clean
 clean:
-       rm -rf $(BUILDSRC) $(KVMPACKAGE)_* $(DEBS) *.buildinfo
+       rm -rf $(BUILDDIR) $(PACKAGE)*.deb *.buildinfo *.changes
 
 .PHONY: dinstall
 dinstall: $(DEBS)