HowTo Compile In Gentoo

From AMule Project FAQ
Revision as of 19:59, 1 August 2009 by Libre (Talk | contribs | merge | delete)

Jump to: navigation, search

English | Deutsch | Español

I am currently editing this very outdated article! English version updated: 23.12.2007 - Newest Gentoo Version are now 2.2.5.

Introduction

Gentoo is known for choices. Unfortunately, some choices require more labor than others. As such, aMule comes in a variety of versions and installation methods based on what version of wxGTK you decide to use...

Methods of Installation

amule-2.2.5.ebuild

This ebuild matches the 2.2.5 stable aMule release, it is available 28.08.2009 in portage.

Dependencies: >=x11-libs/wxGTK-2.8*; >=dev-libs/crypto++-5.5.2; >=sys-libs/zlib-1.2.1

Conditional dependencies: >=dev-libs/geoip for geoip support; >=net-libs/libupnp for Intel UPnP stack support; >=media-libs/libpng-1.2.0 for remote support; >=media-libs/gd-2.0.26 for unicode support and or statistic reporting.

Installation instructions

They must be updated to reflect the actual portage state. Some volunteer?

amule-2.1.3.ebuild

1. Emerge package:

 emerge --sync
 emerge amule -pv
 emerge amule

amule SVN (latest one)

It is no ebuild for the current aMule SVN so we need to add one in portage. For that, we will make use of a personal portage overlay. If you don't already have one, just follow this HOWTO article: HOWTO Installing 3rd Party Ebuilds

We will also follow the naming scheme of portage. SVN ebuild from a SVN tarball are not named as package_name-SVN but as package_name-version_date_of_the_tarball. That is to distinguish them from real SVN ebuilds (the so called live ebuilds) named as package_name-9999 and using keywords="".

1. Define PORTDIR_OVERLAY. Open up /etc/make.conf with your favourite text editor and define the PORTDIR_OVERLAY variable. We will use:

 PORTDIR_OVERLAY="/usr/local/portage"

2. Create overlay for amule-svn:

 mkdir -p /usr/local/net-p2p/amule

3. Add to package.keywords:

 echo "net-p2p/amule ~x86" >> /etc/portage/package.keywords

4. Copy the following ebuild into {PORTDIR_OVERLAY}/net-p2p/amule/amule-2.2.0_p20071217.ebuild

I use here the tarball from 17 December 2007 that was working fine for me, but you can change the date like you want. I use p in order to distinguish this ebuild from the ones in portage (using pre).

# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit eutils flag-o-matic wxwidgets

MY_PN=${PN/m/M}
MY_PV="${PV/2.2.0_p/}"
S="${WORKDIR}/amule-svn"

DESCRIPTION="aMule, the all-platform eMule p2p client"
HOMEPAGE="http://www.amule.org/"
SRC_URI="http://www.hirnriss.net/files/svn/${MY_PN}-SVN-${MY_PV}.tar.bz2"

RESTRICT="nomirror"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~hppa ~ppc ~ppc64 ~sparc ~x86"
IUSE="amuled debug geoip gtk nls remote stats unicode"

DEPEND="=x11-libs/wxGTK-2.8*
		>=sys-libs/zlib-1.2.1
		stats? ( >=media-libs/gd-2.0.26 )
		geoip? ( dev-libs/geoip )
		remote? ( >=media-libs/libpng-1.2.0
		unicode? ( >=media-libs/gd-2.0.26 ) )"

pkg_setup() {
		if ! use gtk && ! use remote && ! use amuled; then
				eerror ""
				eerror "You have to specify at least one of gtk, remote or amuled"
				eerror "USE flag to build amule."
				eerror ""
				die "Invalid USE flag set"
		fi

		if use stats && ! use gtk; then
				einfo "Note: You would need both the gtk and stats USE flags"
				einfo "to compile aMule Statistics GUI."
				einfo "I will now compile console versions only."
		fi

		if use stats && ! built_with_use media-libs/gd jpeg; then
				die "media-libs/gd should be compiled with the jpeg use flag when you have the stats use   flag set"
		fi
}

pkg_preinst() {
	if use amuled || use remote; then
		enewgroup p2p
		enewuser p2p -1 -1 /home/p2p p2p
	fi
}

src_compile() {
		local myconf

		WX_GTK_VER="2.8"

		if use gtk; then
				einfo "wxGTK with gtk support will be used"
				need-wxwidgets unicode
		else
				einfo "wxGTK without X support will be used"
				need-wxwidgets base
		fi

		if use gtk ; then
				use stats && myconf="${myconf}
					--enable-wxcas
					--enable-alc"
				use remote && myconf="${myconf}
					--enable-amule-gui"
		else
				myconf="
					--disable-monolithic
					--disable-amule-gui
					--disable-wxcas
					--disable-alc"
		fi

		econf \
				--with-wx-config=${WX_CONFIG} \
				--with-wxbase-config=${WX_CONFIG} \
				--enable-amulecmd \
				$(use_enable debug) \
				$(use_enable !debug optimize) \
				$(use_enable amuled amule-daemon) \
				$(use_enable geoip) \
				$(use_enable nls) \
				$(use_enable remote webserver) \
				$(use_enable stats cas) \
				$(use_enable stats alcc) \
				${myconf} || die

		# we filter ssp until bug #74457 is closed to build on hardened
		filter-flags -fstack-protector -fstack-protector-all

		emake -j1 || die
}

src_install() {
		emake DESTDIR="${D}" install || die

		if use amuled; then
				newconfd "${FILESDIR}"/amuled.confd amuled
				newinitd "${FILESDIR}"/amuled.initd amuled
		fi

		if use remote; then
				newconfd "${FILESDIR}"/amuleweb.confd amuleweb
				newinitd "${FILESDIR}"/amuleweb.initd amuleweb
		fi
}

5. Change directory:

 cd /usr/local/portage/net-p2p/amule/

6. Digest the ebuild:

 ebuild amule-2.2.0_p10071217.ebuild digest

7. Review installation flags:

 emerge amule -pv

8. Modify /etc/portage/package.use to suit your needs (please note that debug is enabled regardless of USE flag):

 net-p2p/amule -amuled -debug geoip gtk nls -remote -stats unicode

This would install amule without deamon and remote support. To activate deamons and remote options, leave out the '-' like this:

 net-p2p/amule amuled -debug geoip gtk nls remote -stats unicode

As aMule needs unicode support or it won't compile, you might also want to add a line to enable unicode in x11-libs/wxGTK

 x11-libs/wxGTK unicode

9. Install aMule SVN:

 emerge amule

PLEASE do emerge amule -pv before installing to determine how you want to compile aMule.

aMule 2.1.1 Compilation FAQ

When compiling aMule-2.1.1 on a hardened system with gcc-3.4.5(at least), it will fail with something like:

WebServer.h: In member function `T* UpdatableItemsContainer<T, G, I>::GetByID(I) [with T = SharedFile, G = CEC_SharedFile_Tag, I = CMD4Hash]':
WebServer.h:270: internal compiler error: in sweep_string_variable, at protector.c:1158

The possible problem is the -fPIE CFLAG because using `gcc-config` to select i386-pc-linux-gnu-3.4.5-hardenednopiessp fixed the problem, and you can even remove from the ebuild:

if has_hardened; then
    filter-flags -fstack-protector -fstack-protector-all
fi

You can read more on the subject following the link http://bugs.gentoo.org/show_bug.cgi?id=74457