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 120 121 122 123 124 125 126 127 128
|
#!/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
# Prune +,ds etc from version
UPSTREAM_VERSION := $(shell echo $(DEB_VERSION_UPSTREAM) | sed 's/+.*//')
# List test tags
GO_TEST_TAGS := sylog singularity_engine fakeroot_engine apparmor selinux seccomp
%:
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
mkdir -p $(CURDIR)/vendor/github.com/storage
$(RM) -rf $(CURDIR)/vendor/github.com/storage/conmon/cmd
### 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
## Similar weirdness for opencontainers as well
$(RM) -v $(SRCDIR)/vendor/github.com/godbus
$(RM) -v $(SRCDIR)/vendor/github.com/opencontainers
# Somehow this is copied twice and ends up with gcc failure due to default -fno-common
$(RM) -v $(SRCDIR)/vendor/github.com/seccomp
# perform the configuration
cd $(SRCDIR) && \
./mconfig -v \
-b builddir \
-V $(UPSTREAM_VERSION) \
--prefix=/usr \
--sysconfdir=/etc \
--libexecdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
--localstatedir=/var/lib \
--without-network \
--without-conmon \
--without-squashfuse \
;
override_dh_auto_build:
ln -s opencontainers $(SRCDIR)/vendor/github.com/openSUSE
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/ocibundle/ocisif pkg/util/fs/proc /pkg/util/loop pkg/util/namespaces pkg/util/sysctl" \
PATH="$(CURDIR)/$(SRCDIR)/builddir:$$PATH" \
dh_auto_test -v -- -tags "$(GO_TEST_TAGS)"
## 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
for f in `find debian/ -name testdata`; do \
$(RM) -rf $$f; \
done
override_dh_installman:
: # Very sloppy man pages for now
debian/generate_manpages $(PKGDIR) $(DEB_VERSION)
dh_installman
override_dh_fixperms:
dh_fixperms
# changing ownership of 'debian/singularity-container/usr/lib/x86_64-linux-gnu/singularity/bin/starter': Operation not permitted
# ... but the final files are owned by root anyway
# chown -c root.root $(PKGDIR)/usr/lib/*/singularity/bin/*
chmod -c 4755 $(PKGDIR)/usr/lib/*/singularity/bin/*-suid
-find debian/ -name verify_ocsp.go | xargs chmod -x
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
|