+include /usr/share/dpkg/default.mk
+
PACKAGE=libpve-apiclient-perl
-PKGVER=1.0
-PKGREL=2
-DEB=${PACKAGE}_${PKGVER}-${PKGREL}_all.deb
+BUILDSRC := $(PACKAGE)-$(DEB_VERSION)
+DEB=$(PACKAGE)_$(DEB_VERSION)_all.deb
+DSC=$(PACKAGE)_$(DEB_VERSION).dsc
DESTDIR=
+PERL5DIR=$(DESTDIR)/usr/share/perl5
+DOCDIR=$(DESTDIR)/usr/share/doc/$(PACKAGE)
+
+GITVERSION:=$(shell git rev-parse HEAD)
-PERL5DIR=${DESTDIR}/usr/share/perl5
-DOCDIR=${DESTDIR}/usr/share/doc/${PACKAGE}
+all: $(DEB)
-all: ${DEB}
+$(BUILDSRC):
+ rm -rf $@ $@.tmp
+ cp -a src $@.tmp
+ cp -a debian $@.tmp/
+ echo "git clone git://git.proxmox.com/git/pve-apiclient.git\\ngit checkout $(GITVERSION)" >$@.tmp/debian/SOURCE
+ mv $@.tmp $@
.PHONY: deb
-deb ${DEB}:
- rm -rf build
- rsync -a debian build
- make DESTDIR=./build install
- cd build; dpkg-buildpackage -rfakeroot -b -us -uc
- lintian ${DEB}
-
-install:
- install -D -m 0644 PVE/APIClient/LWP.pm ${PERL5DIR}/PVE/APIClient/LWP.pm
- install -d -m 755 ${DOCDIR}/examples
- install -m 0755 examples/example1.pl ${DOCDIR}/examples
- install -m 0755 examples/example2.pl ${DOCDIR}/examples
+deb $(DEB): $(BUILDSRC)
+ cd $(BUILDSRC); dpkg-buildpackage -b -us -uc
+ lintian $(DEB)
+
+.PHONY: dsc
+dsc: $(DSC)
+$(DSC): $(BUILDSRC)
+ cd $(BUILDSRC); dpkg-buildpackage -S -us -uc -d
+ lintian $(DSC)
+
+sbuild: $(DSC)
+ sbuild $(DSC)
.PHONY: upload
-upload: ${DEB}
- tar cf - ${DEB} | ssh repoman@repo.proxmox.com upload
+upload: UPLOAD_DIST ?= $(DEB_DISTRIBUTION)
+upload: $(DEB)
+ tar cf - $(DEB) | ssh -X repoman@repo.proxmox.com upload --product pmg,pve --dist $(UPLOAD_DIST)
distclean: clean
-
clean:
- rm -rf ./build *.deb *.changes
- find . -name '*~' -exec rm {} ';'
+ rm -rf $(PACKAGE)-[0-9]*/ *.deb *.changes *.buildinfo *.build *.dsc *.tar.*
.PHONY: dinstall
-dinstall: ${DEB}
- dpkg -i ${DEB}
+dinstall: $(DEB)
+ dpkg -i $(DEB)