File: rules

package info (click to toggle)
hugo 0.131.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 45,580 kB
  • sloc: javascript: 31,172; xml: 248; makefile: 73; sh: 42
file content (119 lines) | stat: -rwxr-xr-x 4,372 bytes parent folder | download
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/make -f

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

export DH_GOLANG_EXCLUDES := \
	livereload/gen \
	scripts/fork_go_templates \
	tpl/tplimpl/embedded/generate

export DH_GOLANG_INSTALL_EXTRA := \
	create/skeletons/site \
	create/skeletons/theme \
	livereload/gen/livereload-hugo-plugin.js \
	livereload/livereload.js \
	livereload/livereload.min.js \
	testscripts/commands \
	tpl/tplimpl/embedded/templates

# Prevent TestImageResize8BitPNG from failing due to pkgbinarymangler
# recompressing our test PNG image on Ubuntu
export NO_PNG_PKG_MANGLE := 1

# Prepare -ldflags arguments for Hugo version information

include /etc/os-release

PACKAGE := $(shell sed -n "s/^XS-Go-Import-Path: \(.*\)/\1/p" debian/control)

DATE_FMT = %Y-%m-%dT%H:%M:%SZ
ifdef SOURCE_DATE_EPOCH
  BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u "+$(DATE_FMT)")
else
  BUILD_DATE ?= $(shell date -u "+$(DATE_FMT)")
endif

VENDOR_INFO := $(ID):$(shell dpkg-parsechangelog --show-field Version)

LDFLAGS := -ldflags \
	'-X "$(PACKAGE)/common/hugo.buildDate=$(BUILD_DATE)" \
	 -X "$(PACKAGE)/common/hugo.vendorInfo=$(VENDOR_INFO)"'

HUGO := _build/bin/hugo

# The "dev" tag tells golibsass and gowebp not to build libsass and libwebp
# from source but to link with pre-installed libraries instead.
# See https://github.com/bep/golibsass/blob/master/README.md
# and https://github.com/bep/gowebp/blob/master/README.md
TAGS := -tags 'dev extended'

ifeq ($(DEB_BUILD_ARCH),ppc64)
  # Use golang-go on ppc64 as gccgo has failed to build hugo since March 2018.
  # Better to exceed Debian's minimum ISA than to have no hugo at all.
  go_ver := $(shell sed -E -n 's/\s+golang-([0-9.]+)-go \[ppc64\].*/\1/p' debian/control)
  export PATH := /usr/lib/go-$(go_ver)/bin:$(PATH)
  # Caveat: external linking not supported for linux/ppc64, removing tags.
  # See https://github.com/golang/go/issues/8912
  undefine TAGS
endif

%:
	dh $@ --builddirectory=_build

# github.com/bep/imagemeta v0.7.5
# Need to find copyright information for testdata images before packaging
EXTRA_NON_GOHUGOIO_GO_MODULES += github.com/bep/imagemeta
# github.com/getkin/kin-openapi v0.123.0
# Upstream has received reports from users of Hugo's `openapi3.Unmarshal`
# about breaking behavior `kin-openapi` v0.124.0, so revert to v0.123.0
# for now, pending further investigation. (see commit 29cc37f)
EXTRA_NON_GOHUGOIO_GO_MODULES += github.com/getkin/kin-openapi
execute_before_dh_auto_configure:
	for i in $(EXTRA_NON_GOHUGOIO_GO_MODULES); do \
	    mkdir -p _build/src/$$(dirname $$i) ; \
	    ln -s $(CURDIR)/debian/go/src/$$i _build/src/$$(dirname $$i)/ ; \
	done

# github.com/gohugoio/go-i18n/v2 (Fix multiple unknown language codes)
# See https://github.com/gohugoio/hugo/issues/7838
EXTRA_GOHUGOIO_GO_MODULES += gohugoio/go-i18n
EXTRA_GOHUGOIO_GO_MODULES += gohugoio/hashstructure
EXTRA_GOHUGOIO_GO_MODULES += gohugoio/httpcache
# github.com/gohugoio/hugo-goldmark-extensions/{extras,passthrough}
EXTRA_GOHUGOIO_GO_MODULES += gohugoio/hugo-goldmark-extensions
EXTRA_GOHUGOIO_GO_MODULES += gohugoio/localescompressed
EXTRA_GOHUGOIO_GO_MODULES += gohugoio/testmodBuilder
execute_after_dh_auto_configure:
	for i in $(EXTRA_GOHUGOIO_GO_MODULES); do \
	    ln -s $(CURDIR)/debian/go/src/github.com/$$i \
	        _build/src/github.com/gohugoio/ ; \
	done
	# github.com/gohugoio/locales
	cp -a /usr/share/gocode/src/github.com/go-playground/locales \
	    _build/src/github.com/gohugoio/
	cd _build/src/github.com/gohugoio/locales && \
	    sed -i 's/go-playground/gohugoio/' *.go */*.go

override_dh_auto_build:
	@command -V go
	@go version
	dh_auto_build -- $(LDFLAGS) $(TAGS)
	$(HUGO) version
	mkdir -p debian/completion
	cd debian/completion && mkdir -p bash fish zsh
	$(HUGO) completion bash > debian/completion/bash/hugo
	$(HUGO) completion fish > debian/completion/fish/hugo.fish
	$(HUGO) completion zsh > debian/completion/zsh/_hugo
	$(HUGO) gen man --dir=debian/man
	# TODO: Add "hugo-docs" package in the future?
	#$(HUGO) -s docs -d public/html --uglyURLs

# Disable network access during testing by using -short flag
override_dh_auto_test:
	@command -V go
	@go version
	CI=true dh_auto_test -- -short -timeout 120m

override_dh_auto_install:
	dh_auto_install -- --no-source