File: rules

package info (click to toggle)
singularity-container 3.5.2+ds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 10,096 kB
  • sloc: sh: 2,459; ansic: 1,657; awk: 414; python: 99; makefile: 58
file content (107 lines) | stat: -rwxr-xr-x 4,258 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
#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk
include /usr/share/dpkg/pkg-info.mk

#DH_VERBOSE=1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# Causes static variable to become having multiple instances, so we need to strip it away
# See https://github.com/singularityware/singularity/issues/1947
export DEB_LDFLAGS_MAINT_STRIP=-Wl,-Bsymbolic-functions

PKGDIR=debian/singularity-container
export SINGULARITY_CACHEDIR=$(PKGDIR)/var/lib/singularity/cache

export GOPATH=$(CURDIR)/_build
SRCDIR = _build/src/github.com/sylabs/singularity

export DESTDIR:=$(CURDIR)/$(PKGDIR)/
export HOME:=$(CURDIR)/debian/tmp

export DH_GOLANG_GO_GENERATE := 1
export DH_GOLANG_INSTALL_ALL := 1

%:
	dh $@ --with golang --builddirectory=_build --buildsystem=golang

override_dh_auto_configure:
# prepare source directory the way the build system wants it
# https://www.sylabs.io/guides/3.0/user-guide/quick_start.html#compile-the-singularity-binary
	dh_auto_configure --builddirectory=_build
### Dodgy way to prepare "vendor" directory as GOPATH with all dependencies:
	mv -v $(CURDIR)/$(SRCDIR)/vendor $(CURDIR)/$(SRCDIR)/src
	dh_auto_configure --builddirectory=$(CURDIR)/$(SRCDIR)
	$(RM) -rf $(CURDIR)/$(SRCDIR)/src/github.com/sylabs/singularity
	mv -v $(CURDIR)/$(SRCDIR)/src $(CURDIR)/$(SRCDIR)/vendor

## Why, why is this necessary??
##	../vendor/github.com/containerd/cgroups/systemd.go:149:3: cannot use "github.com/sylabs/singularity/vendor/github.com/godbus/dbus".MakeVariant(units) (type "github.com/sylabs/singularity/vendor/github.com/godbus/dbus".Variant) as type "github.com/godbus/dbus".Variant in field value
	$(RM) -v  $(SRCDIR)/vendor/github.com/godbus

# perform the configuration
	cd $(SRCDIR) && \
	./mconfig -v \
	  -b builddir \
	  -V $(DEB_VERSION_UPSTREAM) \
	  --prefix=/usr \
	  --sysconfdir=/etc \
	  --libexecdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
	  --localstatedir=/var/lib \
	  --without-network \
	;

override_dh_auto_build:
	cd $(SRCDIR) && \
	$(MAKE) -C builddir GOFLAGS="-v -mod=readonly" GO111MODULE=off

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	DH_GOLANG_EXCLUDES="cmd/singularity e2e etc/conf internal pkg/image pkg/network pkg/client/shub pkg/ocibundle/sif pkg/util/fs/proc /pkg/util/loop pkg/util/namespaces pkg/util/sysctl" \
        PATH="$(CURDIR)/$(SRCDIR)/builddir:$$PATH" \
        dh_auto_test -v
	## Downloads golangci-lint:
	#-$(MAKE) -C $(SRCDIR)/builddir check
endif

override_dh_auto_install:
	$(MAKE) -C $(SRCDIR)/builddir install
	: # move bash completions into now new standard location
	-mv -v $(PKGDIR)/etc/bash_completion.d $(PKGDIR)/usr/share/bash-completion/completions

override_dh_install:
	dh_install -XLICENSE.md

override_dh_installman:
	: # Very sloppy man pages for now
	debian/generate_manpages $(PKGDIR) $(DEB_VERSION)
	dh_installman

override_dh_fixperms:
	dh_fixperms
	chown -c root.root $(PKGDIR)/usr/lib/*/singularity/bin/*
	chmod -c 4755 $(PKGDIR)/usr/lib/*/singularity/bin/*-suid

override_dh_clean:
	dh_clean
	## Remove Files-Excluded (when built from checkout or non-DFSG tarball):
	$(RM) -rv `perl -0nE 'say $$1 if m{^Files\-Excluded\:\s*(.*?)(?:\n\n|Files:|Comment:)}sm;' debian/copyright`
	-find vendor -mindepth 1 -type d -empty -delete -printf 'removed %p\n'
#	-find . -type f -name '*.generated.go' -delete -printf 'removed %p\n'     ## delete .generated.go files
#	-find . -type f -name '*.pb.go' -delete -printf 'removed %p\n'            ## delete generated .pb.go files

# dh_golang uses `go list` to find the dependencies, then maps them
# to Debian packages. However, it wipes out the GOPATH and forces it
# to look only in <build-directory>/src. It's supposed to have symlinked
# the central libraries from /usr/share/gocode into here, but this doesn't
# appear to be happening (maybe since we aren't using `--buildsystem=golang`).
# I worked around this by using GNU stow to do the symlinking. I also stow
# the vendored libraries in to prevent dh_golang from failing.
#override_dh_golang:
#	stow vendor -t go/src
#	ln -sv /usr/share/gocode/src gocode
#	stow gocode --defer '.*crypto' --defer '.*containernetworking' -t go/src/
#	dh_golang --builddirectory=go
# clean up
#	stow -D vendor -t go/src
#	stow -D gocode -t go/src
#	$(RM) gocode