Add an upload target for uploading to Debian.
[mythtv-status.git] / Makefile
1 #!/usr/bin/make -f
2
3 package=mythtv-status
4 releases=sid
5 release=sid
6 sponsor_keyid=19D03486
7
8 build=dpkg-buildpackage -rfakeroot -i'(.git|build|.gitignore|testing)*' -I.git -Ibuild -I.gitignore -Itesting -tc -k0C62B791
9 version=$(shell git tag -l | grep '^[0-9]' | sort -t"." -k 1,1 -k 2,2 -k 3,3 -n | tail -1)
10 deb_version=$(shell git tag -l | grep ^debian-$(release)-[[:digit:]] | sort -t"." -k 1,1 -k 2,2 -k 3,3 -n | tail -1 | sed 's/debian-$(release)-//' | sed 's/@/~/')
11
12 deb=$(package)_$(deb_version)_all.deb
13 orig_tarball=../$(package)_$(version).orig.tar.gz
14 tarball=build/tarball/$(package)-$(version).tar.gz
15 tarball_dir=../$(package)_tarballs
16
17 DEBS=$(foreach release, $(releases), build/$(release)/$(deb))
18
19 RELEASE_FILES=$(orig_tarball) build/tarball/mythtv-status-${version}.tar.gz $(DEBS)
20
21 TEST_VERBOSE=0
22 TEST_FILES=t/*.t
23
24 all: test release
25
26 release: $(RELEASE_FILES)
27
28 $(orig_tarball): $(tarball)
29         @rm -f $@
30         @ln -s `basename \`pwd\``/$< $@
31
32 sponsor: $(orig_tarball)
33         dpkg-buildpackage -rfakeroot -k$(sponsor_keyid) -i'(.git|build|Makefile|testing)' -I.git -IMakefile -I.gitignore -Ibuild -Itesting -tc
34
35 $(tarball):
36         @mkdir -p $(@D)
37         @git archive --format=tar --prefix=$(package)-$(version)/ $(version) `git ls-tree --name-only $(version) | egrep -v "(.gitignore|debian|Makefile|testing)"` | gzip > $(tarball)
38
39 build/$(release)/$(deb): 
40         @echo Building $(release)
41         @ssh -t build-$(release)-i386 "cd `pwd`; $(build)"
42         @ssh build-$(release)-i386 "cd `pwd`/..; /usr/bin/lintian -i -I $(package)_$(version)*.changes" || true
43         #@ssh build-$(release)-i386 "cd `pwd`/..; /usr/bin/linda -i $(package)_$(version)*.changes" || true
44         @mkdir -p build/$(release)
45         @cp ../$(deb)  \
46                 ../$(package)_$(deb_version)_i386.changes \
47                 ../$(package)_$(deb_version).dsc \
48                 ../$(package)_$(version).orig.tar.gz \
49                 ../$(package)_$(deb_version).debian.tar.gz \
50                 build/$(release)
51
52 publish: $(RELEASE_FILES)
53         for release in $(releases); do reprepro includedsc $$release build/$$release/$(package)_$(deb_version).dsc; done
54         @cp $(tarball) $(tarball_dir)
55         @chmod o+r $(tarball_dir)/*-$(version).*
56         @ln -sf `basename $(tarball)` $(tarball_dir)/$(package)-latest.tar.gz
57
58 upload: $(RELEASE_FILES)
59         for release in $(releases); do cd build/$$release; dput $(package)_$(deb_version)*.changes; done
60
61 test:
62         PERL_DL_NONLAZY=1 perl "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE))" $(TEST_FILES)
63
64
65 clean:
66         @rm -rf build
67         @rm -f ../$(package)*.changes ../$(package)*.dsc ../$(package)*.tar.gz ../$(package)*.deb
68
69 .PHONY: release clean sponsor