Skip to content

Commit 4c497a0

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 <matoro_gentoo@matoro.tk>
1 parent f2fa3cf commit 4c497a0

File tree

3 files changed

+217
-0
lines changed

3 files changed

+217
-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: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
commit 1c57ce9c688d26d95fe8f9d7b7590f4670956749
6+
Author: matoro <matoro@users.noreply.github.com>
7+
Date: Thu Dec 14 00:28:50 2023 -0500
8+
9+
SafeFile: do endian-swap on float tag values
10+
11+
There are comments noting that writing raw float values may not be
12+
endian-correct and indeed it is not. WX does not provide functions for
13+
endian-swapping floats, but since amule explicitly uses exclusively
14+
single-precision (32-bit) floats, just cast it into a uint32_t for the
15+
swapping.
16+
17+
This is a no-op on little-endian.
18+
19+
diff --git a/src/SafeFile.cpp b/src/SafeFile.cpp
20+
index 30f9a7f23..0d9c4f8e7 100644
21+
--- a/src/SafeFile.cpp
22+
+++ b/src/SafeFile.cpp
23+
@@ -31,6 +31,7 @@
24+
#include <common/Format.h> // Needed for CFormat
25+
#include "CompilerSpecific.h" // Needed for __FUNCTION__
26+
27+
+#include <cstring> // For std::memcpy
28+
29+
#define CHECK_BOM(size, x) ((size >= 3) && (x[0] == (char)0xEF) && (x[1] == (char)0xBB) && (x[2] == (char)0xBF))
30+
31+
@@ -189,6 +190,10 @@ float CFileDataIO::ReadFloat() const
32+
{
33+
float retVal;
34+
Read(&retVal, sizeof(float));
35+
+ uint32_t toswap{};
36+
+ std::memcpy(&toswap, &retVal, sizeof(toswap));
37+
+ toswap = ENDIAN_SWAP_32(toswap);
38+
+ std::memcpy(&retVal, &toswap, sizeof(retVal));
39+
return retVal;
40+
}
41+
42+
@@ -306,6 +311,10 @@ void CFileDataIO::WriteHash(const CMD4Hash& value)
43+
44+
void CFileDataIO::WriteFloat(float value)
45+
{
46+
+ uint32_t toswap{};
47+
+ std::memcpy(&toswap, &value, sizeof(toswap));
48+
+ toswap = ENDIAN_SWAP_32(toswap);
49+
+ std::memcpy(&value, &toswap, sizeof(value));
50+
Write(&value, sizeof(float));
51+
}
52+

0 commit comments

Comments
 (0)