summaryrefslogtreecommitdiff
blob: 061236e9d5d0b4432aec50a1d2ea29f1403b5cac (plain)
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{10..13} )
inherit cmake flag-o-matic linux-info python-any-r1

if [[ ${PV} == 9999 ]] ; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/cryfs/cryfs"
else
	SRC_URI="
		https://github.com/cryfs/cryfs/archive/refs/tags/${PV}.tar.gz
			-> ${P}.tar.gz
	"
	KEYWORDS="amd64 ~arm64 ~loong ~ppc64 ~riscv x86"
fi

DESCRIPTION="Encrypted FUSE filesystem that conceals metadata"
HOMEPAGE="https://www.cryfs.org/"

LICENSE="LGPL-3 MIT"
SLOT="0"
IUSE="test"
RESTRICT="!test? ( test )"

RDEPEND="
	dev-libs/boost:=
	dev-libs/crypto++:=
	dev-libs/libfmt:=
	dev-libs/spdlog:=
	net-misc/curl
	>=sys-fs/fuse-2.8.6:0
"
DEPEND="
	${RDEPEND}
	dev-cpp/range-v3
	test? (
		dev-cpp/gtest
	)
"
BDEPEND="
	${PYTHON_DEPS}
	virtual/pkgconfig
	$(python_gen_any_dep '
		dev-python/versioneer[${PYTHON_USEDEP}]
	')
"

PATCHES=(
	# TODO: upstream:
	"${FILESDIR}"/cryfs-0.11.4-unbundle-vendored-libs.patch
)

python_check_deps() {
	python_has_version "dev-python/versioneer[${PYTHON_USEDEP}]"
}

pkg_setup() {
	local CONFIG_CHECK="~FUSE_FS"
	local WARNING_FUSE_FS="CONFIG_FUSE_FS is required for cryfs support."

	check_extra_config
	python-any-r1_pkg_setup
}

src_prepare() {
	cmake_src_prepare

	# don't install compressed manpage
	cmake_comment_add_subdirectory doc

	# We use the package instead for >=py3.12 compat, bug #908997
	rm src/gitversion/versioneer.py || die

	# Hook up ctest properly for better maintainer quality of life
	sed -i -e '/option(BUILD_TESTING/aenable_testing()' CMakeLists.txt || die
	sed -i -e '/BUILD_TESTING/a  include(GoogleTest)' test/CMakeLists.txt || die
	sed -i -e 's/add_test/gtest_discover_tests/' test/*/CMakeLists.txt || die
}

src_configure() {
	# ODR violations (bug #880563)
	# ./CMakeLists.txt
	# """
	# We don't use LTO because crypto++ has problems with it,
	# see https://github.com/weidai11/cryptopp/issues/1031 and
	# https://www.cryptopp.com/wiki/Link_Time_Optimization
	# """
	filter-lto

	local mycmakeargs=(
		# Upstream inconsistently specifies their libraries as STATIC
		# Leading to issues when static libraries without PIC are linked
		# with PIC shared libraries.
		-DBUILD_SHARED_LIBS=OFF
		-DBUILD_TESTING=$(usex test)
		-DCRYFS_UPDATE_CHECKS=OFF
		-DUSE_SYSTEM_LIBS=ON
		# Upstream offered method of using system packages for packages installed via conan
		# This only affects those fetched via Conan not those bundled in /vendor.
		# "Note that this is only provided as an example and not officially supported."
		# bug #631196
		-DDEPENDENCY_CONFIG="${S}/cmake-utils/DependenciesFromLocalSystem.cmake"
	)

	append-cppflags -DNDEBUG

	# bug 907096
	use elibc_musl && append-flags -D_LARGEFILE64_SOURCE

	cmake_src_configure
}

src_test() {
	local TMPDIR="${T}"

	local CMAKE_SKIP_TESTS=(
		# Breaks network sanbox
		CurlHttpClientTest
		FakeHttpClientTest
		# Filesystem did not call onMounted callback, probably wasn't successfully mounted.
		# bug #808849
		CliTest.WorksWithCommasInBasedir
		CliTest_IntegrityCheck.givenIncorrectFilesystemId_thenFails
		CliTest_IntegrityCheck.givenIncorrectFilesystemKey_thenFails
		CliTest_Setup.AutocreateBasedir
		CliTest_Setup.AutocreateMountpoint
		CliTest_Setup.ConfigfileGiven
		CliTest_Setup.ExistingLogfileGiven
		CliTest_Setup.NoSpecialOptions
		CliTest_Setup.NotexistingLogfileGiven
		CliTest_Unmount.givenMountedFilesystem_whenUnmounting_thenSucceeds
		RunningInForeground/CliTest_WrongEnvironment.BaseDir_AllPermissions
		RunningInForeground/CliTest_WrongEnvironment.BaseDir_DoesntExist_Create
		RunningInForeground/CliTest_WrongEnvironment.MountDir_AllPermissions
		RunningInForeground/CliTest_WrongEnvironment.MountDir_DoesntExist_Create
		RunningInForeground/CliTest_WrongEnvironment.NoErrorCondition
		RunningInForeground_ExternalConfigfile/CliTest_WrongEnvironment.BaseDir_AllPermissions
		RunningInForeground_ExternalConfigfile/CliTest_WrongEnvironment.BaseDir_DoesntExist_Create
		RunningInForeground_ExternalConfigfile/CliTest_WrongEnvironment.MountDir_AllPermissions
		RunningInForeground_ExternalConfigfile/CliTest_WrongEnvironment.MountDir_DoesntExist_Create
		RunningInForeground_ExternalConfigfile/CliTest_WrongEnvironment.NoErrorCondition
		RunningInForeground_ExternalConfigfile_LogIsNotStderr/CliTest_WrongEnvironment.BaseDir_AllPermissions
		RunningInForeground_ExternalConfigfile_LogIsNotStderr/CliTest_WrongEnvironment.BaseDir_DoesntExist_Create
		RunningInForeground_ExternalConfigfile_LogIsNotStderr/CliTest_WrongEnvironment.MountDir_AllPermissions
		RunningInForeground_ExternalConfigfile_LogIsNotStderr/CliTest_WrongEnvironment.MountDir_DoesntExist_Create
		RunningInForeground_ExternalConfigfile_LogIsNotStderr/CliTest_WrongEnvironment.NoErrorCondition
		RunningInForeground_LogIsNotStderr/CliTest_WrongEnvironment.BaseDir_AllPermissions
		RunningInForeground_LogIsNotStderr/CliTest_WrongEnvironment.BaseDir_DoesntExist_Create
		RunningInForeground_LogIsNotStderr/CliTest_WrongEnvironment.MountDir_AllPermissions
		RunningInForeground_LogIsNotStderr/CliTest_WrongEnvironment.MountDir_DoesntExist_Create
		RunningInForeground_LogIsNotStderr/CliTest_WrongEnvironment.NoErrorCondition
		# Filesystem did not call onMounted callback, probably wasn't successfully mounted.
		# fuse: failed to open /dev/fuse: Permission denied
		CliTest_IntegrityCheck.givenFilesystemWithRolledBackBasedir_whenMounting_thenFails
		CliTest_IntegrityCheck.whenRollingBackBasedirWhileMounted_thenUnmounts
		# Tests that hang due being unable to open fuse
		# bug #699044
		# fuse: failed to open /dev/fuse: Permission denied
		Fuse*
	)

	cmake_src_test
}

src_install() {
	cmake_src_install
	doman doc/man/cryfs.1
}