Skip to content

Commit 06355c4

Browse files
committed
net-p2p/amule: wire up tests
See: amule-project/amule#342 See: amule-project/amule#368 Bug: https://bugs.gentoo.org/841296 Signed-off-by: Matoro Mahri <[email protected]>
1 parent f2fa3cf commit 06355c4

File tree

3 files changed

+209
-0
lines changed

3 files changed

+209
-0
lines changed
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# Copyright 1999-2023 Gentoo Authors
2+
# Distributed under the terms of the GNU General Public License v2
3+
4+
EAPI=8
5+
WX_GTK_VER="3.0-gtk3"
6+
7+
inherit autotools flag-o-matic wxwidgets xdg-utils
8+
9+
if [[ ${PV} == 9999 ]] ; then
10+
EGIT_REPO_URI="https://github.com/amule-project/amule"
11+
inherit git-r3
12+
else
13+
MY_P="${PN/m/M}-${PV}"
14+
SRC_URI="https://download.sourceforge.net/${PN}/${MY_P}.tar.xz"
15+
S="${WORKDIR}/${MY_P}"
16+
KEYWORDS="~alpha ~amd64 ~arm ~ppc ~ppc64 ~riscv ~sparc ~x86"
17+
fi
18+
19+
DESCRIPTION="aMule, the all-platform eMule p2p client"
20+
HOMEPAGE="http://www.amule.org/"
21+
22+
LICENSE="GPL-2+"
23+
SLOT="0"
24+
IUSE="daemon debug geoip nls remote stats upnp +X"
25+
26+
RDEPEND="
27+
dev-libs/boost:=
28+
dev-libs/crypto++:=
29+
sys-libs/binutils-libs:0=
30+
sys-libs/readline:0=
31+
sys-libs/zlib
32+
>=x11-libs/wxGTK-3.0.4:${WX_GTK_VER}[X?]
33+
daemon? ( acct-user/amule )
34+
geoip? ( dev-libs/geoip )
35+
nls? ( virtual/libintl )
36+
remote? (
37+
acct-user/amule
38+
media-libs/libpng:0=
39+
)
40+
stats? ( media-libs/gd:=[jpeg,png] )
41+
upnp? ( net-libs/libupnp:0 )
42+
"
43+
DEPEND="${RDEPEND}
44+
X? ( dev-util/desktop-file-utils )
45+
"
46+
BDEPEND="
47+
virtual/pkgconfig
48+
>=sys-devel/boost-m4-0.4_p20221019
49+
nls? ( sys-devel/gettext )
50+
"
51+
52+
PATCHES=(
53+
"${FILESDIR}/${PN}-2.3.2-disable-version-check.patch"
54+
"${FILESDIR}/${PN}-2.3.3-fix-exception.patch"
55+
"${FILESDIR}/${P}-autoconf-2.70.patch"
56+
"${FILESDIR}/${PN}-2.3.3-backport-pr368.patch"
57+
)
58+
59+
pkg_setup() {
60+
setup-wxwidgets
61+
}
62+
63+
src_prepare() {
64+
default
65+
rm m4/boost.m4 || die
66+
67+
if [[ ${PV} == 9999 ]]; then
68+
./autogen.sh || die
69+
else
70+
eautoreconf
71+
fi
72+
}
73+
74+
src_configure() {
75+
use debug || append-cppflags -DwxDEBUG_LEVEL=0
76+
append-cxxflags -std=gnu++14
77+
78+
local myconf=(
79+
--with-denoise-level=0
80+
--with-wx-config="${WX_CONFIG}"
81+
--enable-amulecmd
82+
--with-boost
83+
$(use_enable debug)
84+
$(use_enable daemon amule-daemon)
85+
$(use_enable geoip)
86+
$(use_enable nls)
87+
$(use_enable remote webserver)
88+
$(use_enable stats cas)
89+
$(use_enable stats alcc)
90+
$(use_enable upnp)
91+
)
92+
93+
if use X; then
94+
myconf+=(
95+
$(use_enable remote amule-gui)
96+
$(use_enable stats alc)
97+
$(use_enable stats wxcas)
98+
)
99+
else
100+
myconf+=(
101+
--disable-monolithic
102+
--disable-amule-gui
103+
--disable-alc
104+
--disable-wxcas
105+
)
106+
fi
107+
108+
econf "${myconf[@]}"
109+
}
110+
111+
src_test() {
112+
emake check
113+
}
114+
115+
src_install() {
116+
default
117+
118+
if use daemon; then
119+
newconfd "${FILESDIR}"/amuled.confd-r1 amuled
120+
newinitd "${FILESDIR}"/amuled.initd amuled
121+
fi
122+
if use remote; then
123+
newconfd "${FILESDIR}"/amuleweb.confd-r1 amuleweb
124+
newinitd "${FILESDIR}"/amuleweb.initd amuleweb
125+
fi
126+
127+
if use daemon || use remote; then
128+
keepdir /var/lib/${PN}
129+
fowners amule:amule /var/lib/${PN}
130+
fperms 0750 /var/lib/${PN}
131+
fi
132+
}
133+
134+
pkg_postinst() {
135+
local ver
136+
137+
if use daemon || use remote; then
138+
for ver in ${REPLACING_VERSIONS}; do
139+
if ver_test ${ver} -lt "2.3.2-r4"; then
140+
elog "Default user under which amuled and amuleweb daemons are started"
141+
elog "have been changed from p2p to amule. Default home directory have been"
142+
elog "changed as well."
143+
echo
144+
elog "If you want to preserve old download/share location, you can create"
145+
elog "symlink /var/lib/amule/.aMule pointing to the old location and adjust"
146+
elog "files ownership *or* restore AMULEUSER and AMULEHOME variables in"
147+
elog "/etc/conf.d/{amuled,amuleweb} to the old values."
148+
149+
break
150+
fi
151+
done
152+
fi
153+
154+
use X && xdg_desktop_database_update
155+
}
156+
157+
pkg_postrm() {
158+
use X && xdg_desktop_database_update
159+
}

net-p2p/amule/amule-9999.ebuild

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ BDEPEND="
5252
PATCHES=(
5353
"${FILESDIR}/${PN}-2.3.2-disable-version-check.patch"
5454
"${FILESDIR}/${PN}-2.3.3-fix-exception.patch"
55+
"${FILESDIR}/${PN}-2.3.3-backport-pr368.patch"
5556
)
5657

5758
pkg_setup() {
@@ -70,6 +71,7 @@ src_prepare() {
7071
}
7172

7273
src_configure() {
74+
use debug || append-cppflags -DwxDEBUG_LEVEL=0
7375
append-cxxflags -std=gnu++14
7476

7577
local myconf=(
@@ -105,6 +107,10 @@ src_configure() {
105107
econf "${myconf[@]}"
106108
}
107109

110+
src_test() {
111+
emake check
112+
}
113+
108114
src_install() {
109115
default
110116

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
https://bugs.gentoo.org/841296
2+
https://github.com/amule-project/amule/issues/342
3+
https://github.com/amule-project/amule/pull/368
4+
5+
From dcb419305abbe3defbfa4b18ec0d8a2e76041b04 Mon Sep 17 00:00:00 2001
6+
From: matoro <[email protected]>
7+
Date: Thu, 14 Dec 2023 00:28:50 -0500
8+
Subject: [PATCH] SafeFile: do endian-swap on float tag values
9+
10+
There are comments noting that writing raw float values may not be
11+
endian-correct and indeed it is not. WX does not provide functions for
12+
endian-swapping floats, but since amule explicitly uses exclusively
13+
single-precision (32-bit) floats, just cast it into a uint32_t for the
14+
swapping.
15+
16+
This is a no-op on little-endian.
17+
---
18+
src/SafeFile.cpp | 6 +++++-
19+
1 file changed, 5 insertions(+), 1 deletion(-)
20+
21+
diff --git a/src/SafeFile.cpp b/src/SafeFile.cpp
22+
index 30f9a7f23..6e9b07df5 100644
23+
--- a/src/SafeFile.cpp
24+
+++ b/src/SafeFile.cpp
25+
@@ -189,7 +189,8 @@ float CFileDataIO::ReadFloat() const
26+
{
27+
float retVal;
28+
Read(&retVal, sizeof(float));
29+
- return retVal;
30+
+ const auto toswap = ENDIAN_SWAP_32(reinterpret_cast<const uint32_t&>(retVal));
31+
+ return reinterpret_cast<const float&>(toswap);
32+
}
33+
34+
35+
@@ -306,6 +307,9 @@ void CFileDataIO::WriteHash(const CMD4Hash& value)
36+
37+
void CFileDataIO::WriteFloat(float value)
38+
{
39+
+ const auto toswap = ENDIAN_SWAP_32(reinterpret_cast<const uint32_t&>(value));
40+
+ value = reinterpret_cast<const float&>(toswap);
41+
+
42+
Write(&value, sizeof(float));
43+
}
44+

0 commit comments

Comments
 (0)