Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
A little ebuild help: uhub-0.2.8
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
rjmars97
n00b
n00b


Joined: 08 May 2006
Posts: 51
Location: Idaho

PostPosted: Wed Sep 23, 2009 1:49 pm    Post subject: A little ebuild help: uhub-0.2.8 Reply with quote

I'm trying to write an ebuild for my local overlay, but am having a bit of trouble. This is my first ebuild, so I'm not very familiar with them.

This is what I have so far:
Code:
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

DESCRIPTION="A high performance direct connect hub supporting the ADC protocol"
HOMEPAGE="http://www.extatic.org/uhub/intex.html"
SRC_URI="http://www.extatic.org/downloads/uhub/${P}-src.tar.bz2"
LICENSE="GPL-3"
SLOT="0"
KEYWORDS="x86"

DEPEND="sys-devel/make
        >sys-devel/gcc-3.0
        >=dev-libs/libevent-1.3
        dev-lang/perl"

scr_unpack() {
        unpack ${A}
        cd "${S}"
}

scr_compile() {
        make || die "make failed"
}

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


When I emerge the package, I get the following error:
Code:
>>> Install uhub-0.2.8 into /var/tmp/portage/net-p2p/uhub-0.2.8/image/ category net-p2p
Copying uhub to /var/tmp/portage/net-p2p/uhub-0.2.8/image//usr/local/bin/
cp: cannot create regular file `/var/tmp/portage/net-p2p/uhub-0.2.8/image//usr/local/bin/': No such file or directory
make: *** [install] Error 1


I can compile and install the program fine when done manually with a make install, so I am not sure what is causing issues for the ebuild. Maybe something with the makefile? Any help would be appreciated.

edit:
for what its worth, this is the GNUmakefile:
Code:

 ##
## Makefile for uhub (Use GNU make)
## Copyright (C) 2007-2008, Jan Vidar Krey <janvidar@extatic.org>
 #

CC            = gcc
LD            := $(CC)
MV            := mv
RANLIB        := ranlib
CFLAGS        += -pipe -Wall
USE_PCH       ?= YES
USE_SSL       ?= NO
USE_BIGENDIAN ?= AUTO
BITS          ?= AUTO
SILENT        ?= YES
LDLIBS        += -levent
TERSE         ?= NO
STACK_PROTECT ?= NO

ifeq ($(OS), Windows_NT)
WINDOWS       ?= YES
endif

ifeq ($(WINDOWS),YES)
USE_BIGENDIAN := NO
LDLIBS        += -lws2_32
UHUB_CONF_DIR ?= c:/uhub/
UHUB_PREFIX   ?= c:/uhub/
CFLAGS        += -mno-cygwin
LDFLAGS       += -mno-cygwin
BIN_EXT       ?= .exe
else
DESTDIR       ?= /
UHUB_CONF_DIR ?= $(DESTDIR)/etc/uhub
UHUB_PREFIX   ?= $(DESTDIR)/usr/local
CFLAGS        += -I/usr/local/include
LDFLAGS       += -L/usr/local/lib
BIN_EXT       ?=
endif

ifeq ($(SILENT),YES)
        MSG_CC=@echo "  CC:" $(notdir $^) &&
        MSG_PCH=@echo " PCH:" $(notdir $@) &&
        MSG_LD=@echo "  LD:" $(notdir $@) &&
        MSG_AR=@echo "  AR:" $(notdir $@) &&
else
        MSG_CC=
        MSG_PCH=
        MSG_LD=
        MSG_AR=
endif



ifeq ($(TERSE), YES)
        MSG_CC=@
        MSG_PCH=@
        MSG_LD=@
        MSG_AR=@
        MSG_CLEAN=-n ""
else
        MSG_CLEAN="Clean as a whistle"
endif




CFLAGS        += -I/source/libevent
LDFLAGS       += -L/source/libevent

-include release_setup.mk
ifeq ($(RELEASE),YES)
CFLAGS        += -Os -DNDEBUG
else
CFLAGS        += -g -DDEBUG
endif

ifeq ($(STACK_PROTECT),YES)
CFLAGS        += -fstack-protector-all
endif


ifeq ($(PROFILING),YES)
CFLAGS        += -pg
LDFLAGS       += -pg
endif

ifeq ($(FUNCTRACE),YES)
CFLAGS        += -finstrument-functions
CFLAGS        += -DDEBUG_FUNCTION_TRACE
endif

ifeq ($(USE_PCH),YES)
PCHSRC=src/uhub.h
PCH=src/uhub.h.gch
else
PCH=
endif

ifneq ($(BITS), AUTO)
ifeq ($(BITS), 64)
CFLAGS        += -m64
LDFLAGS       += -m64
else
ifeq ($(BITS), 32)
CFLAGS        += -m32
LDFLAGS       += -m32
endif
endif
endif

ifeq ($(USE_BIGENDIAN),AUTO)
ifeq ($(shell perl -e 'print pack("L", 0x554E4958)'),UNIX)
CFLAGS        += -DARCH_BIGENDIAN
endif
else
ifeq ($(USE_BIGENDIAN),YES)
CFLAGS        += -DARCH_BIGENDIAN
endif
endif

ifeq ($(USE_SSL),YES)
CFLAGS        += -DSSL_SUPPORT
LDLIBS        += -lssl
endif

ifneq ($(LIBEVENT_PATH),)
CFLAGS        += -I$(LIBEVENT_PATH)
LDFLAGS       += -L$(LIBEVENT_PATH)
endif

# Sources
libuhub_SOURCES := \
                src/auth.c \
                src/commands.c \
                src/config.c \
                src/eventqueue.c \
                src/hubevent.c \
                src/hub.c \
                src/inf.c \
                src/ipcalc.c \
                src/list.c \
                src/log.c \
                src/memory.c \
                src/message.c \
                src/misc.c \
                src/netevent.c \
                src/network.c \
                src/route.c \
                src/sid.c \
                src/tiger.c \
                src/user.c \
                src/usermanager.c

uhub_SOURCES := src/main.c

adcrush_SOURCES := src/adcrush.c

uhub_HEADERS := \
                src/adcconst.h \
                src/auth.h \
                src/config.h \
                src/eventid.h \
                src/eventqueue.h \
                src/hubevent.h \
                src/hub.h \
                src/inf.h \
                src/ipcalc.h \
                src/list.h \
                src/log.h \
                src/memory.h \
                src/message.h \
                src/misc.h \
                src/netevent.h \
                src/network.h \
                src/route.h \
                src/sid.h \
                src/tiger.h \
                src/uhub.h \
                src/user.h \
                src/usermanager.h

autotest_SOURCES := \
                autotest/test_message.tcc \
                autotest/test_list.tcc \
                autotest/test_memory.tcc \
                autotest/test_ipfilter.tcc \
                autotest/test_inf.tcc \
                autotest/test_hub.tcc \
                autotest/test_misc.tcc \
                autotest/test_tiger.tcc \
                autotest/test_eventqueue.tcc

autotest_OBJECTS = autotest.o

# Source to objects
libuhub_OBJECTS := $(libuhub_SOURCES:.c=.o)
uhub_OBJECTS    := $(uhub_SOURCES:.c=.o)
adcrush_OBJECTS := $(adcrush_SOURCES:.c=.o)

all_OBJECTS     := $(libuhub_OBJECTS) $(uhub_OBJECTS) $(adcrush_OBJECTS) $(autotest_OBJECTS)

LIBUHUB=libuhub.a
uhub_BINARY=uhub$(BIN_EXT)
adcrush_BINARY=adcrush$(BIN_EXT)
autotest_BINARY=autotest/test$(BIN_EXT)

%.o: %.c
        $(MSG_CC) $(CC) -c $(CFLAGS) -o $@.tmp $^ && \
        $(MV) $@.tmp $@

all: $(uhub_BINARY) $(PCH)

$(adcrush_BINARY): $(PCH) $(LIBUHUB) $(adcrush_OBJECTS)
        $(MSG_LD) $(CC) -o $@.tmp $(adcrush_OBJECTS) $(LIBUHUB) $(LDFLAGS) $(LDLIBS) && \
        $(MV) $@.tmp $@

$(uhub_BINARY): $(PCH) $(LIBUHUB) $(uhub_OBJECTS)
        $(MSG_LD) $(CC) -o $@.tmp $(uhub_OBJECTS) $(LIBUHUB) $(LDFLAGS) $(LDLIBS) && \
        $(MV) $@.tmp $@

$(LIBUHUB): $(libuhub_OBJECTS)
        $(MSG_AR) $(AR) rc $@.tmp $^ && \
        $(RANLIB) $@.tmp && \
        $(MV) $@.tmp $@

ifeq ($(USE_PCH),YES)
$(PCH): $(uhub_HEADERS)
        $(MSG_PCH) $(CC) $(CFLAGS) -o $@.tmp $(PCHSRC) && \
        $(MV) $@.tmp $@
endif

autotest.c: $(autotest_SOURCES)
        $(shell exotic --standalone $(autotest_SOURCES) > $@)

$(autotest_OBJECTS): autotest.c
        $(MSG_CC) $(CC) -c $(CFLAGS) -Isrc -o $@.tmp $< && \
        $(MV) $@.tmp $@

$(autotest_BINARY): $(autotest_OBJECTS) $(LIBUHUB)
        $(MSG_LD) $(CC) -o $@.tmp $^ $(LDFLAGS) $(LDLIBS) && \
        $(MV) $@.tmp $@

autotest: $(autotest_BINARY)
        @./$(autotest_BINARY) -s -f

ifeq ($(WINDOWS),YES)
install:
        @echo "Cannot install automatically on windows."
else
install: $(uhub_BINARY)
        @echo Copying $(uhub_BINARY) to $(UHUB_PREFIX)/bin/
        @cp $(uhub_BINARY) $(UHUB_PREFIX)/bin/
        @if [ ! -d $(UHUB_CONF_DIR) ]; then echo Creating $(UHUB_CONF_DIR); mkdir -p $(UHUB_CONF_DIR); fi
        @if [ ! -f $(UHUB_CONF_DIR)/uhub.conf ]; then cp doc/uhub.conf $(UHUB_CONF_DIR); fi
        @if [ ! -f $(UHUB_CONF_DIR)/users.conf ]; then cp doc/users.conf  $(UHUB_CONF_DIR); fi
        @touch $(UHUB_CONF_DIR)/motd.txt
        @echo done.
endif

dist-clean:
        @rm -rf $(all_OBJECTS) $(PCH) *~ core

clean:
        @rm -rf $(libuhub_OBJECTS) $(PCH) *~ core $(uhub_BINARY) $(LIBUHUB) $(all_OBJECTS) && \
        echo $(MSG_CLEAN)

-include release_targets.mk

_________________
I opened Pandora's box, let the cat out of the bag and put the ball in their court.
-- Hon. J. Hacker (The Ministry of Administrative Affairs)
Back to top
View user's profile Send private message
rjmars97
n00b
n00b


Joined: 08 May 2006
Posts: 51
Location: Idaho

PostPosted: Fri Oct 02, 2009 12:40 pm    Post subject: Reply with quote

In playing with this, I figured that the error could just be the lack of a space, in the DESTDIR variable, since it shows it with the source and destination directories together.
Code:
>>> Install uhub-0.2.8 into /var/tmp/portage/net-p2p/uhub-0.2.8/image/ category net-p2p
Copying uhub to /var/tmp/portage/net-p2p/uhub-0.2.8/image//usr/local/bin/
cp: cannot create regular file `/var/tmp/portage/net-p2p/uhub-0.2.8/image//usr/local/bin/': No such file or directory
make: *** [install] Error 1

So I added a space to DESTDIR in the scr_install section, and now get a sandbox error when trying to copy the file.

This is the modified ebuild:
Code:
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

DESCRIPTION="A high performance direct connect hub supporting the ADC protocol"
HOMEPAGE="http://www.extatic.org/uhub/intex.html"
SRC_URI="http://www.extatic.org/downloads/uhub/${P}-src.tar.bz2"
LICENSE="GPL-3"
SLOT="0"
KEYWORDS="x86"

DEPEND="sys-devel/make
        >sys-devel/gcc-3.0
        >=dev-libs/libevent-1.3
        dev-lang/perl"

scr_unpack() {
        unpack ${A}
        cd "${S}"
}

scr_compile() {
        make || die "make failed"
}

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


And this is the error:
Code:
>>> Install uhub-0.2.8 into /var/tmp/portage/net-p2p/uhub-0.2.8/image/ category net-p2p
Copying uhub to /var/tmp/portage/net-p2p/uhub-0.2.8/image/ /usr/local/bin/
ACCESS DENIED  open_wr:      /usr/local/bin/uhub
cp: cannot create regular file `/usr/local/bin/uhub': Permission denied
cp: omitting directory `/var/tmp/portage/net-p2p/uhub-0.2.8/image/'
make: *** [install] Error 1
 *
 * ERROR: net-p2p/uhub-0.2.8 failed.
 * Call stack:
 *               ebuild.sh, line   49:  Called src_install
 *             environment, line   92:  Called die
 * The specific snippet of code:
 *       make DESTDIR="${D} " install || die "make install failed"
 *  The die message:
 *   make install failed
 *
 * If you need support, post the topmost build error, and the call stack if relevant.
 * A complete build log is located at '/var/tmp/portage/net-p2p/uhub-0.2.8/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/net-p2p/uhub-0.2.8/temp/environment'.
 * This ebuild is from an overlay: '/usr/local/portage/'
 *
--------------------------- ACCESS VIOLATION SUMMARY ---------------------------
LOG FILE "/var/log/sandbox/sandbox-19404.log"

VERSION 1.0
FORMAT: F - Function called
FORMAT: S - Access Status
FORMAT: P - Path as passed to function
FORMAT: A - Absolute Path (not canonical)
FORMAT: R - Canonical Path
FORMAT: C - Command Line

F: open_wr
S: deny
P: /usr/local/bin/uhub
A: /usr/local/bin/uhub
R: /usr/local/bin/uhub
C: cp uhub /var/tmp/portage/net-p2p/uhub-0.2.8/image/ /usr/local/bin/
--------------------------------------------------------------------------------


Any ideas? Should I post this in Portage & Programming?
_________________
I opened Pandora's box, let the cat out of the bag and put the ball in their court.
-- Hon. J. Hacker (The Ministry of Administrative Affairs)
Back to top
View user's profile Send private message
SamuliSuominen
Retired Dev
Retired Dev


Joined: 30 Sep 2005
Posts: 2133
Location: Finland

PostPosted: Fri Oct 02, 2009 10:30 pm    Post subject: Reply with quote

Here you go,

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

inherit toolchain-funcs

DESCRIPTION="Fill this entry yourself, thanks."
HOMEPAGE="http://www.extatic.org/uhub/index.html"
SRC_URI="http://www.extatic.org/downloads/${PN}/${P}-src.tar.bz2"

LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""

src_compile() {
emake AR=$(tc-getAR) CC=$(tc-getCC) RANLIB=$(tc-getRANLIB) || die
}

src_install() {
dodir /usr/bin
emake UHUB_CONF_DIR="${D}/etc/uhub" UHUB_PREFIX="${D}/usr" install || die
dodoc AUTHORS BUGS README
}
Back to top
View user's profile Send private message
rjmars97
n00b
n00b


Joined: 08 May 2006
Posts: 51
Location: Idaho

PostPosted: Sun Oct 11, 2009 11:35 pm    Post subject: Reply with quote

Thanks for posting the ebuild, it works great. I do have a few questions, since I'd like to better understand how to write ebuilds. Since installing from the install script works perfectly, I assume that the need to change the ebuild is for sandboxing reasons. Why exactly are the changes you made necessary? I know from the Gentoo Dev Guide what tc-getAR and the other functions do, but I'm not sure why that is needed. Why do I need to know what the archiver indexer is? To be honest, I don't know what the archiver indexer is.

My background is in embedded hardware, but I have done a bit of C programming for micorcontrollers, so this stiff is quite a bit different than what I've done in the past.

Thanks
_________________
I opened Pandora's box, let the cat out of the bag and put the ball in their court.
-- Hon. J. Hacker (The Ministry of Administrative Affairs)
Back to top
View user's profile Send private message
SamuliSuominen
Retired Dev
Retired Dev


Joined: 30 Sep 2005
Posts: 2133
Location: Finland

PostPosted: Mon Oct 12, 2009 7:37 am    Post subject: Reply with quote

rjmars97 wrote:
Thanks for posting the ebuild, it works great. I do have a few questions, since I'd like to better understand how to write ebuilds. Since installing from the install script works perfectly, I assume that the need to change the ebuild is for sandboxing reasons. Why exactly are the changes you made necessary? I know from the Gentoo Dev Guide what tc-getAR and the other functions do, but I'm not sure why that is needed. Why do I need to know what the archiver indexer is? To be honest, I don't know what the archiver indexer is.


$(tc-getAR) function will return the full name of ar, such as, x86_64-pc-linux-gnu-ar in amd64 system. the fullname is required for cross compiling (embedded) targets properly. same applies
to others like tc-getCC, tc-getLD, and so forth.
Back to top
View user's profile Send private message
mizery de aria
Guru
Guru


Joined: 07 Dec 2003
Posts: 309

PostPosted: Wed Mar 31, 2010 6:03 am    Post subject: Reply with quote

Someone should post this at bugs.gentoo.org and create baselayout script. I'm surprised it isn't there yet.
_________________
Do not repIy to or othErwise communicate with me if you use religious, spiritual or similar terminologies or references in your typings.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum