+include /usr/share/dpkg/default.mk
+
PACKAGE=lxcfs
-PKGVER=2.0.7
-DEBREL=pve1
-SRCDIR=${PACKAGE}
-SRCTAR=${SRCDIR}.tgz
+SRCDIR=$(PACKAGE)
+BUILDDIR ?= $(PACKAGE)-$(DEB_VERSION_UPSTREAM)
+ORIG_SRC_TAR=$(PACKAGE)_$(DEB_VERSION_UPSTREAM).orig.tar.gz
+
+GITVERSION:=$(shell git rev-parse HEAD)
+
+DSC=$(PACKAGE)_$(DEB_VERSION_UPSTREAM_REVISION).dsc
+DEB=$(PACKAGE)_$(DEB_VERSION_UPSTREAM_REVISION)_$(DEB_HOST_ARCH).deb
+DBGDEB=$(PACKAGE)-dbgsym_$(DEB_VERSION_UPSTREAM_REVISION)_$(DEB_HOST_ARCH).deb
+DEBS=$(DEB) $(DBGDEB)
-ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
-GITVERSION:=$(shell cat .git/refs/heads/master)
+all: $(DEB)
-DEB1=${PACKAGE}_${PKGVER}-${DEBREL}_${ARCH}.deb
-DEB2=${PACKAGE}-dbg_${PKGVER}-${DEBREL}_${ARCH}.deb
-DEBS=$(DEB1) $(DEB2)
+.PHONY: submodule
+submodule:
+ test -f "$(SRCDIR)/README" || git submodule update --init
+$(SRCDIR)/README: submodule
-all: ${DEB}
+$(BUILDDIR): $(SRCDIR)/README debian
+ rm -rf $(BUILDDIR)
+ rsync -a $(SRCDIR)/ debian $(BUILDDIR)
+ echo "git clone git://git.proxmox.com/git/lxcfs.git\\ngit checkout $(GITVERSION)" > $(BUILDDIR)/debian/SOURCE
.PHONY: deb
deb: $(DEBS)
-$(DEB2): $(DEB1)
-$(DEB1): $(SRCTAR)
- rm -rf ${SRCDIR}
- tar xf ${SRCTAR}
- cp -a debian ${SRCDIR}/debian
- echo "git clone git://git.proxmox.com/git/lxcfs.git\\ngit checkout ${GITVERSION}" > ${SRCDIR}/debian/SOURCE
- echo "debian/SOURCE" >> ${SRCDIR}/debian/docs
- cd ${SRCDIR}; dpkg-buildpackage -rfakeroot -b -us -uc
- #lintian $(DEB)
-
-
-.PHONY: download
-download ${SRCTAR}:
- rm -rf ${SRCDIR} ${SRCTAR}
- git clone --depth=1 -b lxcfs-${PKGVER} git://github.com/lxc/lxcfs
- tar czf ${SRCTAR}.tmp ${SRCDIR}
- mv ${SRCTAR}.tmp ${SRCTAR}
+$(DBGDEB): $(DEB)
+$(DEB): $(BUILDDIR)
+ cd $(BUILDDIR); dpkg-buildpackage -rfakeroot -b -us -uc
+ lintian $(DEBS)
+
+sbuild: $(DSC)
+ sbuild $(DSC)
+
+$(ORIG_SRC_TAR): $(BUILDDIR)
+ tar czf $(ORIG_SRC_TAR) --exclude="$(BUILDDIR)/debian" $(BUILDDIR)
+
+.PHONY: dsc
+dsc:
+ $(MAKE) clean
+ $(MAKE) $(DSC)
+ lintian $(DSC)
+
+$(DSC): $(ORIG_SRC_TAR) $(BUILDDIR)
+ cd $(BUILDDIR); dpkg-buildpackage -S -us -uc -d
.PHONY: upload
+upload: UPLOAD_DIST ?= $(DEB_DISTRIBUTION)
upload: $(DEBS)
- tar cf - ${DEBS} | ssh repoman@repo.proxmox.com upload --product pve --dist stretch
-
-distclean: clean
+ tar cf - $(DEBS) | ssh repoman@repo.proxmox.com upload --product pve --dist $(UPLOAD_DIST)
-.PHONY: clean
+.PHONY: clean distclean
clean:
- rm -rf ${SRCDIR} ${SRCDIR}.tmp *_${ARCH}.deb *.changes *.dsc *.buildinfo
- find . -name '*~' -exec rm {} ';'
+ rm -rf $(PACKAGE)-[0-9]*/
+ rm -rf $(PACKAGE)*.tar* *.deb *.dsc *.changes *.dsc *.buildinfo *.build
+
+distclean: clean
+ git submodule deinit --all
.PHONY: dinstall
dinstall: $(DEBS)