#!/usr/bin/make -f include /usr/share/dpkg/architecture.mk include /usr/share/dpkg/pkg-info.mk include /usr/share/dpkg/default.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/apptainer export SINGULARITY_CACHEDIR=$(PKGDIR)/var/lib/apptainer/cache export GOPATH=$(CURDIR)/_build SRCDIR = _build/src/github.com/apptainer/apptainer 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: if [ ! -e VERSION ] ; then echo "$(DEB_VERSION_UPSTREAM)" > VERSION ; fi # 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 dh_auto_configure --builddirectory=$(CURDIR)/$(SRCDIR) $(RM) -rf $(CURDIR)/$(SRCDIR)/src/github.com/apptainer/apptainer # 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 \ --without-suid \ ; 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/apptainer 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 -mv -v $(PKGDIR)/usr/bin/singularity $(PKGDIR)/usr/bin/singularity.$$(awk '/^Package:/ { print $$2 }' debian/control | head -1) -mv -v $(PKGDIR)/usr/bin/run-singularity $(PKGDIR)/usr/bin/run-singularity.$$(awk '/^Package:/ { print $$2 }' debian/control | head -1) : # 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 execute_before_dh_installman: : # Very sloppy man pages for now debian/generate_manpages $(PKGDIR) $(DEB_VERSION) execute_after_dh_installman: rm $(PKGDIR)/usr/share/man/man1/singularity.1 #execute_after_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' # 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 /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