Name libcap2
Description POSIX 1003.1e capabilities (library)
Version 1:2.66-5ubuntu2.2
Package Base
Homepage https://sites.google.com/site/fullycapable/
Maintainers ['Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>']
Contributors []
Distro-repo https://git.launchpad.net/ubuntu/+source/libcap2/tree/?h=ubuntu/noble
Sources ['https://git.launchpad.net/ubuntu/+source/libcap2/plain/debian/patches/../?h=ubuntu/noble', 'https://git.launchpad.net/ubuntu/+source/libcap2/plain/debian/patches/Correct-the-check-of-pthread_create-s-return-value.patch?h=ubuntu/noble', 'https://git.launchpad.net/ubuntu/+source/libcap2/plain/debian/patches/Filter-out-PIE-flags-when-building-shared-objects.patch?h=ubuntu/noble', 'https://git.launchpad.net/ubuntu/+source/libcap2/plain/debian/patches/Hide-private-symbols.patch?h=ubuntu/noble', 'https://git.launchpad.net/ubuntu/+source/libcap2/plain/debian/patches/Large-strings-can-confuse-libcap-s-internal-strdup-code.patch?h=ubuntu/noble', 'https://git.launchpad.net/ubuntu/+source/libcap2/plain/debian/patches/Skip-git-if-not-installed.patch?h=ubuntu/noble', 'https://git.launchpad.net/ubuntu/+source/libcap2/plain/debian/patches/series?h=ubuntu/noble', 'https://git.launchpad.net/ubuntu/+source/libcap2/plain/debian/watch?h=ubuntu/noble']
Dependencies ['libc6']
Optional-Dependencies []
Build-Dependencies ['chrpath', 'debhelper-compat', 'gperf', 'indent', 'libpam0g-dev']
Provides []
Builddate
Architecture amd64
Distro-Version noble
Licenses []
Hash 9241539476d657d102b5a51ea3cd80ac3576e8e15f23c59f22b757d8eb4c5301
#!/usr/bin/make -f

# Exports DEB_{BUILD,HOST}_* flags
include /usr/share/dpkg/architecture.mk

# Pass this as version-info to dh_makeshlibs
SHLIBS_MINVER = 1:2.63

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# Removing the linker flag. It causes problems with libcap2, see LP#2003892
export DEB_LDFLAGS_MAINT_STRIP = -Wl,-Bsymbolic-functions

# Support cross-compiling
ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
CC := $(DEB_HOST_GNU_TYPE)-gcc
endif

# One upstream target, "_makenames", requires the BUILD compiler instead of HOST
BUILD_CC ?= cc
export BUILD_LDFLAGS = $(shell dpkg-architecture -a$(DEB_BUILD_ARCH) -c dpkg-buildflags --get LDFLAGS)
export BUILD_CPPFLAGS = $(shell dpkg-architecture -a$(DEB_BUILD_ARCH) -c dpkg-buildflags --get CPPFLAGS)

# Upstream's way of setting optimization
ifneq (,$(filter noopt, $(DEB_BUILD_OPTIONS)))
COPTS = COPTS=-O0
endif

# See pam_cap/Makefile for FORCELINKPAM
MAKE_ASSIGNMENTS = \
	prefix=/usr \
	FORCELINKPAM=yes \
	GOLANG=no

%:
	dh ${@}


override_dh_auto_clean:
	dh_auto_clean -- $(MAKE_ASSIGNMENTS)


override_dh_auto_build:
	# See pam_cap/Makefile for FORCELINKPAM
	dh_auto_build -- \
		$(MAKE_ASSIGNMENTS) \
		BUILD_CC=$(BUILD_CC) \
		CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)- \
		$(COPTS) \
		DYNAMIC=yes \
		SUDO=$(DEB_GAIN_ROOT_CMD)
	# Some of test suite is only invoked when run as real root. Explicitly
	# build all binaries so we can include them in the autopkgtest.	
	dh_auto_build -D libcap -- $(MAKE_ASSIGNMENTS) cap_test
	dh_auto_build -D pam_cap -- $(MAKE_ASSIGNMENTS) test_pam_cap
	# Change lookup from sibling dir to current dir
	sed -i -e 's,\.\./progs/tcapsh-static,./tcapsh-static,g' tests/libcap_launch_test.c
	dh_auto_build -D tests -- $(MAKE_ASSIGNMENTS) \
		psx_test \
		libcap_psx_test \
		uns_test \
		libcap_launch_test \
		libcap_psx_launch_test \
		noop \
		exploit \
		noexploit
	dh_auto_build -D progs -- $(MAKE_ASSIGNMENTS) tcapsh-static


override_dh_installdirs:
	dh_installdirs
	# While the PAM module and the library are in /lib, according to the
	# FHS, development files must go into usr/lib/<triplet>.
	mkdir -p debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)


override_dh_auto_install:
	# Unfortunately, RPATH seems to be needed for the build-time tests
	# (avoiding it and going through LD_LIBRARY_PATH didn't work in all
	# cases)
	# List is identical to build above, minus noop (no RPATH)
	cd tests && chrpath -d \
		psx_test \
		libcap_psx_test \
		uns_test \
		libcap_launch_test \
		libcap_psx_launch_test \
		exploit \
		noexploit
	dh_auto_install -- \
		$(MAKE_ASSIGNMENTS) \
		lib=lib/$(DEB_HOST_MULTIARCH) \
		PKGCONFIGDIR=/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig \
		RAISE_SETFCAP=no


override_dh_auto_test:
	dh_auto_test -- $(MAKE_ASSIGNMENTS)


override_dh_makeshlibs:
	dh_makeshlibs -V'libcap2 (>= $(SHLIBS_MINVER))' -plibcap2 \
		--add-udeb=libcap2-udeb -- -c4
	dh_makeshlibs --remaining-packages -- -c4