# [ebuild] Schreibrechte für /etc ?

## 3PO

Hallo Zusammen, 

ich versuche ein ebuild für die git Version von serdiplib zu erstellen, was soweit auch ganz gut funktioniert, nur beim scr_install bekomme ich folgenden Fehler:

```
[....]

list='serdisplearn'; \

        for prog in $list; do \

          /usr/bin/install -c $prog /tmp/portage/dev-libs/serdisplib-1.98.9999/image//usr/bin/ ; \

        done

/usr/bin/install -c -m 644 examples/serdispd.cfg /etc/

ACCESS DENIED  open_wr:      /etc/serdispd.cfg

/usr/bin/install: reguläre Datei „/etc/serdispd.cfg“ kann nicht angelegt werden: Keine Berechtigung

gmake[1]: *** [install] Fehler 1

gmake[1]: Leaving directory `/tmp/portage/dev-libs/serdisplib-1.98.9999/work/serdisplib-1.98.9999/server'

make: *** [install] Fehler 1

emake failed
```

Der entsprechende Teil im ebuild sieht so aus:

```
src_install() {

      emake DESTDIR="${D}" install || die "make install failed"

      dodoc AUTHORS HISTORY README BUGS PINOUTS

}
```

Was mache ich falsch, bzw. was muss ich tun, damit die "serdispd.cfg" nach "/etc" kopiert wird?

----------

## mv

Offensichtlich ist das Makefile des Projekts fehlerhaft: Es ignoriert DESTDIR. Der erzeugte Befehl hätte

/usr/bin/install -c -m 644 examples/serdispd.cfg $DESTDIR/etc/ 

lauten müssen (mit DESTDIR=/tmp/portage/dev-libs/serdisplib-1.98.9999/image/)

----------

## 3PO

Und was kann man dagegen tun?

----------

## franzf

 *3PO wrote:*   

> Und was kann man dagegen tun?

 

Makefile patchen...

----------

## 3PO

 *franzf wrote:*   

>  *3PO wrote:*   Und was kann man dagegen tun? 
> 
> Makefile patchen...

 

Gute Idee...  :Smile: 

Leider ist aber nur so, dass ich kein "C" kann.  :Sad: 

Wenn Du mir sagen kannst, an welcher Stelle, was geändert werden muss, dann baue das mit "sed" ins ebuild ein.

Hier mal das Makefile:

```
# Makefile for project 'serdisplib', root-directory

# (C) 2003-2010 by Wolfgang Astleitner

SHELL = /bin/sh

top_srcdir = .

srcdir = .

prefix = /tmp/portage/dev-libs/serdisplib-1.98.9999/image//usr

exec_prefix = ${prefix}

bindir = ${exec_prefix}/bin

libdir = ${exec_prefix}/lib

mandir = /usr/share/man

abs_top_srcdir=/tmp/portage/dev-libs/serdisplib-1.98.9999/work/serdisplib-1.98.9999

base_abs_top_srcdir=$(shell /bin/basename $(abs_top_srcdir))

current_timestamp=$(shell /bin/date '+%Y%m%d-%H%M')

CC = i686-pc-linux-gnu-gcc

MAKE=gmake

INSTALL=/usr/bin/install -c

INSTALL_PROGRAM = ${INSTALL}

INSTALL_SCRIPT = ${INSTALL}

INSTALL_DATA = ${INSTALL} -m 644

subdirs = src tools

ifeq "true" "true"

  subdirs += server

endif

all:

   @for dir in ${subdirs}; do \

     (cd $(srcdir) && cd $$dir && $(MAKE) all) \

     || case "$(MFLAGS)" in *k*) fail=yes;; *) exit 1;; esac; \

   done && test -z "$$fail"

install:

   $(top_srcdir)/mkinstalldirs $(libdir)/pkgconfig

   $(INSTALL_DATA) serdisplib.pc $(libdir)/pkgconfig/

   @for dir in ${subdirs}; do \

     (cd $(srcdir) && cd $$dir && $(MAKE) install) \

     || case "$(MFLAGS)" in *k*) fail=yes;; *) exit 1;; esac; \

   done && test -z "$$fail"

uninstall:

   -/bin/rm -f $(libdir)/pkgconfig/serdisplib.pc

   @for dir in ${subdirs}; do \

     (cd $(srcdir) && cd $$dir && $(MAKE) uninstall) \

     || case "$(MFLAGS)" in *k*) fail=yes;; *) exit 1;; esac; \

   done && test -z "$$fail"

clean:

   /bin/rm -f core* *~

   @for dir in ${subdirs}; do \

     (cd $(srcdir) && cd $$dir && $(MAKE) clean) \

     || case "$(MFLAGS)" in *k*) fail=yes;; *) exit 1;; esac; \

   done && test -z "$$fail"

distclean: clean

   -/bin/rm -f autom4te.cache/* && /bin/rmdir autom4te.cache

   /bin/rm -f Makefile config.h config.status config.cache config.log tags

   @for dir in ${subdirs}; do \

     (cd $(srcdir) && cd $$dir && $(MAKE) distclean) \

     || case "$(MFLAGS)" in *k*) fail=yes;; *) exit 1;; esac; \

   done && test -z "$$fail"

# make snapshot is meant for internal use only

snapshot: distclean

   cd $(top_srcdir)/.. && \

   /bin/gtar c --exclude "*~" --exclude ".svn" --exclude "temp" --exclude "*_bkp*" --exclude "*.o" --exclude serdisplib.pc $(base_abs_top_srcdir) | /bin/gzip -c > $(base_abs_top_srcdir)_$(current_timestamp).tar.gz

# automatic re-running of configure if the configure.in file has changed

# disabled because of possible infinive-loop when invalid system time

###${srcdir}/configure: configure.in

###   cd ${srcdir} && autoconf

# autoheader might not change config.h.in, so touch a stamp file

${srcdir}/config.h.in: stamp-h.in

${srcdir}/stamp-h.in: configure.in aclocal.m4

      cd ${srcdir} && autoheader

      echo timestamp > ${srcdir}/stamp-h.in

config.h: stamp-h

stamp-h: config.h.in config.status

   ./config.status

Makefile: Makefile.in config.status

   ./config.status

config.status: configure

   ./config.status --recheck

```

----------

## sirro

Das Makefile ist rekursiv. Auf den ersten Blick finde ich zum install nur das:

```
install: 

    $(top_srcdir)/mkinstalldirs $(libdir)/pkgconfig 

    $(INSTALL_DATA) serdisplib.pc $(libdir)/pkgconfig/ 

    @for dir in ${subdirs}; do \ 

      (cd $(srcdir) && cd $$dir && $(MAKE) install) \ 

      || case "$(MFLAGS)" in *k*) fail=yes;; *) exit 1;; esac; \ 

    done && test -z "$$fail"
```

Und das installiert nur eine Datei anscheinend ins richtige Verzeichnis. Ausserdem ruft es make in den Verzeichnissen "src", "tools" und "server" auf. Dein Übeltäter ist wohl im Makefile von server zu finden. Zu erkennen an der Ausgabe aus dem OP.

```
gmake[1]: Leaving directory `/tmp/portage/dev-libs/serdisplib-1.98.9999/work/serdisplib-1.98.9999/server'
```

----------

## 3PO

 *sirro wrote:*   

> [...] Dein Übeltäter ist wohl im Makefile von server zu finden. Zu erkennen an der Ausgabe aus dem OP.
> 
> ```
> gmake[1]: Leaving directory `/tmp/portage/dev-libs/serdisplib-1.98.9999/work/serdisplib-1.98.9999/server'
> ```
> ...

 

Hier noch das: "/tmp/portage/dev-libs/serdisplib-1.98.9999/work/serdisplib-1.98.9999/server/Makefile"

```
# Makefile for serdisplib server

# (C) 2006-2010 by Wolfgang Astleitner

VERSION=1.98.0

VERSION_MAJOR=1

VERSION_MINOR=98

VERSION_SUBMINOR=0

SHELL = /bin/sh

top_srcdir = ..

srcdir = .

prefix = /tmp/portage/dev-libs/serdisplib-1.98.9999/image//usr

exec_prefix = ${prefix}

bindir = ${exec_prefix}/bin

sbindir = ${exec_prefix}/sbin

libdir = ${exec_prefix}/lib

mandir = /usr/share/man

includedir = ${prefix}/include

sysconfdir = /etc

CC=i686-pc-linux-gnu-gcc

AR=i686-pc-linux-gnu-ar -r

LN_S=ln -s

INSTALL=/usr/bin/install -c

INSTALL_PROGRAM = ${INSTALL}

INSTALL_SCRIPT = ${INSTALL}

INSTALL_DATA = ${INSTALL} -m 644

#CFLAGS=-march=core2 -O2 -mtune=generic -pipe  -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -Wall -Wimplicit -Wmissing-prototypes -Wstrict-prototypes -fPIC -I../include -I..

CFLAGS=-I../include -I.. -march=core2 -O2 -mtune=generic -pipe  -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -Wall -fPIC

LDFLAGS=-Wl,-O1 -Wl,--as-needed

#LIBS=-lusb -lgd 

# start w/ empty libs-list

LIBS=

#CFLAGS=-march=core2 -O2 -mtune=generic -pipe  -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -ansi -Wall -Wno-implicit -fPIC -I../include -I..

#CFLAGS=-ansi -Wall -Wno-implicit -O2

#CFLAGS=-g -ansi -Wall -Wno-implicit -fPIC -O2 -I../serdisplib -I..

SDISPDOBJECTS= serdispd.o args.o conf.o lcds.o connections.o commands.o lirc.o rc5trans.o

SLEARNOBJECTS= serdisplearn.o args.o rc5trans.o

SPROXYOBJECTS= serdispproxy.o lcds.o args.o connections.o commands.o lirc.o rc5trans.o

OBJECTS= $(SDISPDOBJECTS) $(SLEARNOBJECTS) $(SPROXYOBJECTS)

PROGRAMS_BIN= serdisplearn

#PROGRAMS_SBIN= serdispd

PROGRAMS_SBIN= serdispd serdispproxy

PROGRAMS= $(PROGRAMS_BIN) $(PROGRAMS_SBIN)

LIB_NAME=serdisp

LIB_STATIC=lib$(LIB_NAME).a

LIB_SHARED=lib$(LIB_NAME).so.$(VERSION)

LIB_DIR=../lib

# link shared or static lib to executables

ifeq "false" "true"

 LIB_SERDISP=-L$(LIB_DIR) -l$(LIB_NAME)

else

 LIB_SERDISP=$(LIB_DIR)/$(LIB_STATIC)

endif

# link programs to libdl if required by OS and libserdisp is linked statically

ifeq "true" "true"

  ifeq "false" "false"

    EXTRA_LIBS_STATIC=-ldl

  endif

endif

# link programs to libusb only if libserdisp is linked statically

#ifeq "true" "true"

#  ifneq "false" "true"

#    LIBS+=@LIBUSB_LIBS@

#   endif

#endif

.SUFFIXES : .c .o

all: programs

programs: $(PROGRAMS)

.c.o:

   $(CC) $(CFLAGS) $(DEFINES)  -c $(INCLUDES) $<

serdispd: $(LIB_DIR)/$(LIB_STATIC) $(SDISPDOBJECTS)

   $(CC) -o $@ $(SDISPDOBJECTS) $(LIB_SERDISP) $(LDFLAGS) $(EXTRA_LIBS_STATIC)

serdisplearn: $(LIB_DIR)/$(LIB_STATIC) $(SLEARNOBJECTS)

   $(CC) -o $@ $(SLEARNOBJECTS) $(LIB_SERDISP) $(LDFLAGS) $(EXTRA_LIBS_STATIC)

serdispproxy: $(LIB_DIR)/$(LIB_STATIC) $(SPROXYOBJECTS)

   $(CC) -o $@ $(SPROXYOBJECTS) $(LIB_SERDISP) $(LDFLAGS) $(EXTRA_LIBS_STATIC)

clean:

   /bin/rm -f $(OBJECTS)

   /bin/rm -f *core* $(PROGRAMS) *~

distclean: clean

   /bin/rm -f Makefile

install: $(PROGRAMS)

   $(top_srcdir)/mkinstalldirs $(bindir)

   $(top_srcdir)/mkinstalldirs $(sbindir)

   $(top_srcdir)/mkinstalldirs $(sysconfdir)

   list='$(PROGRAMS_SBIN)'; \

   for prog in $$list; do \

     $(INSTALL_PROGRAM) $$prog $(sbindir)/ ; \

   done

   list='$(PROGRAMS_BIN)'; \

   for prog in $$list; do \

     $(INSTALL_PROGRAM) $$prog $(bindir)/ ; \

   done

   $(INSTALL_DATA) examples/serdispd.cfg $(sysconfdir)/

uninstall:

   list='$(PROGRAMS)'; \

   for prog in $$list; do \

     /bin/rm -f $(sbindir)/$$prog ; \

   done

```

----------

## sirro

```
sysconfdir = /etc
```

Da fehlt das prefix (siehe Zeilen darüber)

----------

## 3PO

 *sirro wrote:*   

> 
> 
> ```
> sysconfdir = /etc
> ```
> ...

 

Wie müsste denn das dann aussehen?? 

So?

```
sysconfdir = ${prefix}/etc
```

----------

## sirro

 *3PO wrote:*   

> 
> 
> ```
> sysconfdir = ${prefix}/etc
> ```
> ...

 

So wuerde ich es probieren.

----------

## 3PO

So gehts:  :Wink: 

```
sysconfdir = ${DESTDIR}/etc
```

Thx @ all.

----------

