| 1 |
#!/usr/bin/make -f |
| 2 |
|
| 3 |
# Uncomment this to turn on verbose mode. |
| 4 |
#export DH_VERBOSE=1 |
| 5 |
|
| 6 |
export DH_GOLANG_EXCLUDES := \ |
| 7 |
internal/warpc/gen \ |
| 8 |
livereload/gen \ |
| 9 |
scripts/fork_go_templates \ |
| 10 |
tpl/tplimpl/embedded/generate |
| 11 |
|
| 12 |
export DH_GOLANG_INSTALL_EXTRA := \ |
| 13 |
common/hexec/esmloader.mjs \ |
| 14 |
create/skeletons/project \ |
| 15 |
create/skeletons/theme \ |
| 16 |
internal/js/esbuild \ |
| 17 |
internal/warpc/wasm \ |
| 18 |
livereload/gen/livereload-hugo-plugin.js \ |
| 19 |
livereload/livereload.js \ |
| 20 |
livereload/livereload.min.js \ |
| 21 |
testscripts/ \ |
| 22 |
tpl/tplimpl/embedded/templates |
| 23 |
|
| 24 |
# Prevent TestImageResize8BitPNG from failing due to pkgbinarymangler |
| 25 |
# recompressing our test PNG image on Ubuntu |
| 26 |
export NO_PNG_PKG_MANGLE := 1 |
| 27 |
|
| 28 |
# Prepare -ldflags arguments for Hugo version information |
| 29 |
|
| 30 |
include /etc/os-release |
| 31 |
|
| 32 |
PACKAGE := $(shell sed -n "s/^XS-Go-Import-Path: \(.*\)/\1/p" debian/control) |
| 33 |
|
| 34 |
DATE_FMT = %Y-%m-%dT%H:%M:%SZ |
| 35 |
ifdef SOURCE_DATE_EPOCH |
| 36 |
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)") |
| 37 |
else |
| 38 |
BUILD_DATE ?= $(shell date -u "+$(DATE_FMT)") |
| 39 |
endif |
| 40 |
|
| 41 |
VENDOR_INFO := $(ID):$(shell dpkg-parsechangelog --show-field Version) |
| 42 |
|
| 43 |
LDFLAGS := -ldflags \ |
| 44 |
'-X "$(PACKAGE)/common/hugo.buildDate=$(BUILD_DATE)" \ |
| 45 |
-X "$(PACKAGE)/common/hugo.vendorInfo=$(VENDOR_INFO)"' |
| 46 |
|
| 47 |
HUGO := _build/bin/hugo |
| 48 |
|
| 49 |
# The "dev" tag tells golibsass and gowebp not to build libsass and libwebp |
| 50 |
# from source but to link with pre-installed libraries instead. |
| 51 |
# See https://github.com/bep/golibsass/blob/master/README.md |
| 52 |
# and https://github.com/bep/gowebp/blob/master/README.md |
| 53 |
TAGS := -tags 'dev extended' |
| 54 |
|
| 55 |
ifeq ($(DEB_BUILD_ARCH),ppc64) |
| 56 |
# Use golang-go on ppc64 as gccgo has failed to build hugo since March 2018. |
| 57 |
# Better to exceed Debian's minimum ISA than to have no hugo at all. |
| 58 |
go_ver := $(shell sed -E -n 's/\s+golang-([0-9.]+)-go \[ppc64\].*/\1/p' debian/control) |
| 59 |
export PATH := /usr/lib/go-$(go_ver)/bin:$(PATH) |
| 60 |
# Caveat: external linking not supported for linux/ppc64, removing tags. |
| 61 |
# See https://github.com/golang/go/issues/8912 |
| 62 |
undefine TAGS |
| 63 |
endif |
| 64 |
|
| 65 |
%: |
| 66 |
dh $@ --builddirectory=_build |
| 67 |
|
| 68 |
EXTRA_NON_GOHUGOIO_GO_MODULES += github.com/bep/golocales |
| 69 |
execute_before_dh_auto_configure: |
| 70 |
for i in $(EXTRA_NON_GOHUGOIO_GO_MODULES); do \ |
| 71 |
mkdir -p _build/src/$$(dirname $$i) ; \ |
| 72 |
ln -s $(CURDIR)/debian/go/src/$$i _build/src/$$(dirname $$i)/ ; \ |
| 73 |
done |
| 74 |
|
| 75 |
# github.com/gohugoio/go-i18n/v2 (Fix multiple unknown language codes) |
| 76 |
# See https://github.com/gohugoio/hugo/issues/7838 |
| 77 |
EXTRA_GOHUGOIO_GO_MODULES += gohugoio/go-i18n |
| 78 |
EXTRA_GOHUGOIO_GO_MODULES += gohugoio/go-radix |
| 79 |
execute_after_dh_auto_configure: |
| 80 |
for i in $(EXTRA_GOHUGOIO_GO_MODULES); do \ |
| 81 |
ln -s $(CURDIR)/debian/go/src/github.com/$$i \ |
| 82 |
_build/src/github.com/gohugoio/ ; \ |
| 83 |
done |
| 84 |
# github.com/gohugoio/locales |
| 85 |
cp -a /usr/share/gocode/src/github.com/go-playground/locales \ |
| 86 |
_build/src/github.com/gohugoio/ |
| 87 |
cd _build/src/github.com/gohugoio/locales && \ |
| 88 |
sed -i 's/go-playground/gohugoio/' *.go */*.go |
| 89 |
|
| 90 |
override_dh_auto_build: |
| 91 |
@command -V go |
| 92 |
@go version |
| 93 |
dh_auto_build -- $(LDFLAGS) $(TAGS) |
| 94 |
$(HUGO) version |
| 95 |
mkdir -p debian/completion |
| 96 |
cd debian/completion && mkdir -p bash fish zsh |
| 97 |
$(HUGO) completion bash > debian/completion/bash/hugo |
| 98 |
$(HUGO) completion fish > debian/completion/fish/hugo.fish |
| 99 |
$(HUGO) completion zsh > debian/completion/zsh/_hugo |
| 100 |
$(HUGO) gen man --dir=debian/man |
| 101 |
# TODO: Add "hugo-docs" package in the future? |
| 102 |
#$(HUGO) -s docs -d public/html --uglyURLs |
| 103 |
|
| 104 |
# Disable network access during testing by using -short flag |
| 105 |
override_dh_auto_test: |
| 106 |
@command -V go |
| 107 |
@go version |
| 108 |
CI=true dh_auto_test -- -short -timeout 120m |
| 109 |
|
| 110 |
override_dh_auto_install: |
| 111 |
dh_auto_install -- --no-source |