| 1 |
#!/usr/bin/make -f |
| 2 |
|
| 3 |
include /usr/share/dpkg/pkg-info.mk |
| 4 |
|
| 5 |
# https://wiki.debian.org/HardeningWalkthrough |
| 6 |
export DEB_BUILD_MAINT_OPTIONS = hardening=+all |
| 7 |
|
| 8 |
DH_GOPKG := github.com/google/fscrypt |
| 9 |
|
| 10 |
### Set some build flags. |
| 11 |
### Partially borrowed from upstream Makefile |
| 12 |
|
| 13 |
GO_LINK_FLAGS := -s -w |
| 14 |
VERSION_FLAG := -X "main.version=v$(DEB_VERSION_UPSTREAM)" |
| 15 |
GO_LINK_FLAGS += $(VERSION_FLAG) -extldflags "$(LDFLAGS)" |
| 16 |
GO_FLAGS += --ldflags '$(GO_LINK_FLAGS)' |
| 17 |
|
| 18 |
%: |
| 19 |
dh $@ --buildsystem=golang --with=golang |
| 20 |
|
| 21 |
override_dh_auto_build: |
| 22 |
# Build the command line tool |
| 23 |
DH_GOLANG_BUILDPKG=$(DH_GOPKG)/cmd/... dh_auto_build -O--buildsystem=golang -- $(GO_FLAGS) |
| 24 |
|
| 25 |
# Build the PAM module (C shared library) |
| 26 |
DH_GOLANG_BUILDPKG=$(DH_GOPKG)/pam_fscrypt/... dh_auto_build -O--buildsystem=golang -- $(GO_FLAGS) -buildmode=c-shared |
| 27 |
|
| 28 |
# Workaround for https://github.com/golang/go/issues/24253 |
| 29 |
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=903385 |
| 30 |
# |
| 31 |
# golang-go calls the library pam_fscrypt.a, while gccgo-go calls it libpam_fscrypt.a. |
| 32 |
# One thing we (hopefully) know: there is only one .a file. Its path is also difficult |
| 33 |
# to predict. Let's try to write a command that will always rename it to pam_fscrypt.so. |
| 34 |
ls -l obj-*/pkg/*/$(DH_GOPKG)/*.a |
| 35 |
SOPATH=$$(dirname obj-*/pkg/*/$(DH_GOPKG)/*.a) && mv -v $$SOPATH/*.a $$SOPATH/pam_fscrypt.so |
| 36 |
|
| 37 |
override_dh_auto_test: |
| 38 |
# Excluded tests: |
| 39 |
# |
| 40 |
# keyring: needs a user keyring linked into the session keyring |
| 41 |
# https://github.com/google/fscrypt/issues/99 |
| 42 |
# filesystem: requires a filesystem to test upon and root privileges |
| 43 |
|
| 44 |
DH_GOLANG_EXCLUDES="keyring filesystem" dh_auto_test |
| 45 |
|
| 46 |
override_dh_auto_install: |
| 47 |
# See dh-golang(3) |
| 48 |
dh_auto_install -- --no-source |
| 49 |
|
| 50 |
override_dh_install: |
| 51 |
dh_install |
| 52 |
|
| 53 |
# Adapted from the upstream Makefile |
| 54 |
m4 --define=PAM_INSTALL_PATH=pam_fscrypt.so \ |
| 55 |
< pam_fscrypt/config \ |
| 56 |
> $(CURDIR)/debian/libpam-fscrypt/usr/share/pam-configs/fscrypt |