~niemeyer/golang/stable-packaging

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export GOROOT=$(CURDIR)
export GOROOT_FINAL=/usr/lib/go

ifeq ("$(wildcard .bzr)",".bzr")
TAGS:=$(shell bzr log | awk '/^revno:/ {t=""} /^tags:/ {t=substr($$0,7)} /^author:/ {print t; exit}')
VERSION:=$(shell echo "$(TAGS)" | awk -v RS=', |\n' '/^go[0-9]/ {print substr($$1,3)}')
ifeq ($(VERSION),)
$(error Invalid revision tags: $(TAGS))
endif
endif

PKGNAME=golang-stable
PKGDIR=debian/$(PKGNAME)

%:
	dh $@ 

clean:
	[ ! -d .hg ] || sed -i 's/00000000/$(VERSION)/' debian/changelog
	[ ! -d .hg ] || ( cd src && ./make.bash --dist-tool && ( ../pkg/tool/*/dist version | tee ../VERSION ) )
	test -n "`cat VERSION`"
	[ ! -f bin/go ] || bin/go clean -i std
	[ ! -f pkg/tool/*/dist ] || pkg/tool/*/dist clean
	rm -rf bin/ pkg/
	find src/pkg -maxdepth 1 -type d -name '[a-z]*.*' -exec rm -rf {} \;
	dh_clean

binary-arch: clean
	dh_prep
	dh_installdirs
	mkdir -p $(PKGDIR)/usr/lib/go/src
	
	cp -a src/pkg src/cmd $(PKGDIR)/usr/lib/go/src
	cp -a misc doc include $(PKGDIR)/usr/lib/go
	
	mkdir -p $(PKGDIR)/usr/share/doc/$(PKGNAME)
	for f in LICENSE PATENTS VERSION AUTHORS CONTRIBUTORS; do \
		cp $$f $(PKGDIR)/usr/share/doc/$(PKGNAME); \
	done
	
	/bin/bash -c "cd src && ./all.bash"
	
	test -f bin/gorun
	
	cp -a pkg lib bin VERSION $(PKGDIR)/usr/lib/go
	
	mkdir $(PKGDIR)/usr/bin
	cd $(PKGDIR)/usr/lib/go/bin/ && \
	for f in *; do \
		test ! -f $$f || ln -s ../lib/go/bin/$$f ../../../bin/$$f; \
	done
	
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-arch