LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 654|回复: 2

练习写drcom的ebuild,安装时无法创建文件

[复制链接]
发表于 2008-5-14 15:20:17 | 显示全部楼层 |阅读模式
这是ebuild文件

localhost drcom # cat drcom-1.4.4.ebuild
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

DESCRIPTION="城市热点上网客户端"
HOMEPAGE=""
#SRC_URI=""
SRC_URI="ftp://10.1.3.112/overlay/drcom-1.4.4.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="x86"
IUSE="doc"

DEPEND=""
RDEPEND=""


src_unpack(){
        if [ "${A}" != "" ];then
                echo "unpack ${A}"
                echo ""
                unpack ${A} ||die "unpack failed"
        fi
        cd "${S}"||die "cd ${S} failed"
}

src_compile(){
        if [ -f Makefile ]||[ -f GNUmakefile ]||[ -f makefile ];then
                emake||die "emake failed"
        fi
}
src_install(){
        #emake DESTDIR="${D}" install ||die "einstall failed"
        einstall ||die "einstall failed"
    dodoc README ||die "dodoc failed"      
}

安装提示
///////////////////////////////////////////////////////////////////////
localhost drcom # emerge drcom
Calculating dependencies... done!
>>> Verifying ebuild Manifests...

>>> Emerging (1 of 1) app-portage/drcom-1.4.4 to /
* drcom-1.4.4.tar.gz RMD160 SHA1 SHA256 size ;-) ...                     [ ok ]
* checking ebuild checksums ;-) ...                                      [ ok ]
* checking auxfile checksums ;-) ...                                     [ ok ]
* checking miscfile checksums ;-) ...                                    [ ok ]
* checking drcom-1.4.4.tar.gz ;-) ...                                    [ ok ]
>>> Unpacking source...
unpack drcom-1.4.4.tar.gz

>>> Unpacking drcom-1.4.4.tar.gz to /var/tmp/portage/app-portage/drcom-1.4.4/work
>>> Source unpacked.
>>> Compiling source in /var/tmp/portage/app-portage/drcom-1.4.4/work/drcom-1.4.4 ...
make[1]: Entering directory `/var/tmp/portage/app-portage/drcom-1.4.4/work/drcom-1.4.4/drcomc'
make[1]: warning: jobserver unavailable: using -j1.  Add `+' to parent make rule.
  CC drcomc.c
  CC ../utils/utils.c
  LD drcomc
make[1]: Leaving directory `/var/tmp/portage/app-portage/drcom-1.4.4/work/drcom-1.4.4/drcomc'
make[1]: Entering directory `/var/tmp/portage/app-portage/drcom-1.4.4/work/drcom-1.4.4/drcomd'
make[1]: warning: jobserver unavailable: using -j1.  Add `+' to parent make rule.
  CC drcomd.c
  CC kmodule.c
  CC signal.c
  CC dialog.c
  CC keepalive.c
  CC login.c
  CC logout.c
  CC md5.c
  CC misc.c
  CC passwd.c
  CC readconf.c
  CC watchport.c
  CC log.c
  LD drcomd
make[1]: Leaving directory `/var/tmp/portage/app-portage/drcom-1.4.4/work/drcom-1.4.4/drcomd'
make[1]: Entering directory `/var/tmp/portage/app-portage/drcom-1.4.4/work/drcom-1.4.4/kmod'
make[1]: warning: jobserver unavailable: using -j1.  Add `+' to parent make rule.
make -C /lib/modules/2.6.24-gentoo-r8/build M=/var/tmp/portage/app-portage/drcom-1.4.4/work/drcom-1.4.4/kmod modules
make[2]: Entering directory `/usr/src/linux-2.6.24-gentoo-r8'
  CC [M]  /var/tmp/portage/app-portage/drcom-1.4.4/work/drcom-1.4.4/kmod/drcom.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /var/tmp/portage/app-portage/drcom-1.4.4/work/drcom-1.4.4/kmod/drcom.mod.o
  LD [M]  /var/tmp/portage/app-portage/drcom-1.4.4/work/drcom-1.4.4/kmod/drcom.ko
make[2]: Leaving directory `/usr/src/linux-2.6.24-gentoo-r8'
make[1]: Leaving directory `/var/tmp/portage/app-portage/drcom-1.4.4/work/drcom-1.4.4/kmod'
>>> Source compiled.
>>> Test phase [not enabled]: app-portage/drcom-1.4.4

>>> Install drcom-1.4.4 into /var/tmp/portage/app-portage/drcom-1.4.4/image/ category app-portage
make[1]: Entering directory `/var/tmp/portage/app-portage/drcom-1.4.4/work/drcom-1.4.4/drcomc'
  INSTALL drcomc
ACCESS DENIED  unlink:    /usr/local/bin/drcomc
install: cannot remove `/usr/local/bin/drcomc': Permission denied
make[1]: *** [install] Error 1
make[1]: Leaving directory `/var/tmp/portage/app-portage/drcom-1.4.4/work/drcom-1.4.4/drcomc'
make: *** [install] Error 1
*
* ERROR: app-portage/drcom-1.4.4 failed.
* Call stack:
*               ebuild.sh, line   49:  Called src_install
*             environment, line  108:  Called einstall
*               ebuild.sh, line  555:  Called die
* The specific snippet of code:
*                   ${MAKE:-make} prefix="${D}usr" \
*                           datadir="${D}usr/share" \
*                           infodir="${D}usr/share/info" \
*                           localstatedir="${D}var/lib" \
*                           mandir="${D}usr/share/man" \
*                           sysconfdir="${D}etc" \
*                           ${LOCAL_EXTRA_EINSTALL} \
*                           "$@" install || die "einstall failed"
*  The die message:
*   einstall 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/app-portage/drcom-1.4.4/temp/build.log'.
* The ebuild environment file is located at '/var/tmp/portage/app-portage/drcom-1.4.4/temp/environment'.
*
--------------------------- ACCESS VIOLATION SUMMARY ---------------------------
LOG FILE = "/var/log/sandbox/sandbox-21649.log"

unlink:    /usr/local/bin/drcomc
--------------------------------------------------------------------------------

* Messages for package app-portage/drcom-1.4.4:

*
* ERROR: app-portage/drcom-1.4.4 failed.
* Call stack:
*               ebuild.sh, line   49:  Called src_install
*             environment, line  108:  Called einstall
*               ebuild.sh, line  555:  Called die
* The specific snippet of code:
*                   ${MAKE:-make} prefix="${D}usr" \
*                           datadir="${D}usr/share" \
*                           infodir="${D}usr/share/info" \
*                           localstatedir="${D}var/lib" \
*                           mandir="${D}usr/share/man" \
*                           sysconfdir="${D}etc" \
*                           ${LOCAL_EXTRA_EINSTALL} \
*                           "$@" install || die "einstall failed"
*  The die message:
*   einstall 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/app-portage/drcom-1.4.4/temp/build.log'.
* The ebuild environment file is located at '/var/tmp/portage/app-portage/drcom-1.4.4/temp/environment'.
*


错误提示
/////////////////////////////////////////////////////////////////
ACCESS DENIED  unlink:    /usr/local/bin/drcomc
install: cannot remove `/usr/local/bin/drcomc': Permission denied
make[1]: *** [install] Error 1


############################################
疑问:1.我是在用root安装,怎么会Permission denied呢?
2. 我自己又写了一个gsopcast的ebuild,安装正常
3.我写了一个很简单的ebuild,测试一下:功能就是将一个文件copy到我的根目录
主要这句:cp "${S}/${PN}" /home/pjq/||die "install failed"

安装是和上面类似错误(完整的在下面)
ACCESS DENIED  open_wr:   /home/pjq/tv
cp: cannot create regular file `/home/pjq/tv': Permission denied
*

这里是它的ebuild
localhost tv # cat tv-0.1.ebuild
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

DESCRIPTION="a shell used to play tv,type:mms"
HOMEPAGE="http://percy.blog.ubuntu.org.cn"
SRC_URI="ftp://localhost/overlay/${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="x86"
IUSE="doc"

DEPEND=""
RDEPEND=""

#FILESDIR=/usr/portage/local/myebuilds/app-portage/tv/files
#FILESDIR=/usr/portage/local/myebuilds/app-portage/tv/files
src_unpack()
{
        unpack ${A} ||die "unpack failed"
        cd ${S}
}

src_install()
{
        cp "${S}/${PN}" /home/pjq||die "install failed"
        #dosbin tv||die "dosbin tv failed"
if use doc;then
        dodoc readme||die "dodoc readme failed"
fi
}
安装时和上面类似错误
localhost tv # emerge tv
Calculating dependencies... done!
>>> Verifying ebuild Manifests...

>>> Emerging (1 of 1) app-portage/tv-0.1 to /
* tv-0.1.tar.gz RMD160 SHA1 SHA256 size ;-) ...                          [ ok ]
* checking ebuild checksums ;-) ...                                      [ ok ]
* checking auxfile checksums ;-) ...                                     [ ok ]
* checking miscfile checksums ;-) ...                                    [ ok ]
* checking tv-0.1.tar.gz ;-) ...                                         [ ok ]
>>> Unpacking source...
>>> Unpacking tv-0.1.tar.gz to /var/tmp/portage/app-portage/tv-0.1/work
>>> Source unpacked.
>>> Compiling source in /var/tmp/portage/app-portage/tv-0.1/work/tv-0.1 ...
>>> Source compiled.
>>> Test phase [not enabled]: app-portage/tv-0.1

>>> Install tv-0.1 into /var/tmp/portage/app-portage/tv-0.1/image/ category app-portage
ACCESS DENIED  open_wr:   /home/pjq/tv
cp: cannot create regular file `/home/pjq/tv': Permission denied
*
* ERROR: app-portage/tv-0.1 failed.
* Call stack:
*               ebuild.sh, line   49:  Called src_install
*             environment, line  115:  Called die
* The specific snippet of code:
*       cp "${S}/${PN}" /home/pjq || die "install failed";
*  The die message:
*   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/app-portage/tv-0.1/temp/build.log'.
* The ebuild environment file is located at '/var/tmp/portage/app-portage/tv-0.1/temp/environment'.
*
--------------------------- ACCESS VIOLATION SUMMARY ---------------------------
LOG FILE = "/var/log/sandbox/sandbox-25348.log"

open_wr:   /home/pjq/tv
--------------------------------------------------------------------------------

* Messages for package app-portage/tv-0.1:

*
* ERROR: app-portage/tv-0.1 failed.
* Call stack:
*               ebuild.sh, line   49:  Called src_install
*             environment, line  115:  Called die
* The specific snippet of code:
*       cp "${S}/${PN}" /home/pjq || die "install failed";
*  The die message:
*   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/app-portage/tv-0.1/temp/build.log'.
* The ebuild environment file is located at '/var/tmp/portage/app-portage/tv-0.1/temp/environment'.
*
发表于 2008-5-14 23:03:03 | 显示全部楼层
google "gentoo sandbox violation"
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-5-15 09:57:12 | 显示全部楼层
Post by zhllg;1849736
google "gentoo sandbox violation"

谢谢提示,
找了一下
http://bugday.gentoo.org/sandbox.html
原来sandbox是一种保护机制,防止安装软件时破坏系统

如果实在要安装可以这样
FEATURES="-sandbox" emerge drcom(试了一下,安装成功)
关于sandbox的英文


Gentoo Sandbox Methodology And Troubleshooting
Abstract:
This document is a guide that provides a general framework that novice users/developers can follow in understanding and diagnosing sandbox violation issues. It tries to formalize a troubleshooting methodology so that those uninitiated with the process of debugging sandbox violations will be better equipped to handle such situations when they arise.

Sandbox Violations Explained

The way portage works when you want to emerge some package is as follows:

   1. Portage fetches the needed source tarballs and patches (if necessary).
   2. Portage unpacks the source tarballs to a staging area where all the compilation will take place - portage uses /var/tmp/portage/packagename/work by default
   3. After unpacking and possible patching (this is done in src_unpack() function in the ebuild) portage goes on to do the actual compilation usually just running configure and make in the staging area (ebuilds use ${WORKDIR} to denote this area).
   4. When compilation finishes successfully, portage merges all the files from the staging area to the live filesystem. (usually /, but this can be changed by setting ROOT=''/some path'' when emerging) To avoid bad and/or broken ebuilds from destroying parts or all of the filesystem we need to restrict what areas of the filesystem can portage write to during unpacking and compilation. This is where the sandbox comes into play. By default, the sandbox is set up so that the ebuilds (and everything they run in turn) are restricted to write to the staging area. If an ebuild violates this protected environment known as the sandbox by trying to write outside the staging area - this is denoted as a sandbox violation.

    Sandbox Violation: Definition

    A sandbox violation is any attempt by an ebuild during an emerge to write outside the portage predefined staging area or protected environment known as the sandbox.

    Sandboxurpose

    The sandbox is a control mechanism used by portage originally to aid in debugging of ebuilds. Its main purpose is to provide a safe and protected environment for running programs whose functions are not entirely known. Essentially it provides an environment where building of packages can occur without interfering with the operation of the rest of the system. It basically prevents the build process from getting out of control. By now the reasons should be clear why having ebuilds write outside the sandbox can be problematic.

Sandbox Violation Troubleshooting: Principles and Techniques

Do not re-invent the wheel.

Use bugzilla database at https://bugs.gentoo.org as a valuable debugging research tool. Search for the specific sandbox violation error message you have encountered using keyword search and see if there are any other ebuilds that have had the same problems or issues in the past. If there are such instances examine those further to see if anyone has found a solution to that particular problem. Analyze how those corrections were implemented in the affected ebuilds. If there are alternative corrections use the more simple and elegant solution. Then use common sense and intuition to apply a similar fix to your specific problem.

Note: Consider creating a list/database of frequently encountered sandbox violations and their corresponding optimal corrections that users can look through as an initial resource or checklist.

Further Debugging Required

When the above step fails to provide a solution, more work is required to determine and fix why an ebuild wants access outside the sandbox. To fix or prevent sandbox violation problems from occurring a developer has several tools at his/her disposal.

Ebuild command to step through and isolate

The first of which is the ebuild command. This command gives the developer the control and ability to isolate, test and move through the build process step by step. This allows the developer to determine where exactly in the build process the sandbox violation may be occurring.

Sandbox Shell Functions

The second and probably more important and appropriate tool for sandbox violation debugging is the sandboxshell and its various functions. Sandboxshell provides two tools central to debugging sandbox violations: addpredict and addwrite.

Addpredict is a function that allows the developer to simulate a write outside a sandbox in a particular location to fool portage but in fact it doesn't actually allow any real write. Addwrite on the other hand lets the developer override the default sandbox restrictions by allowing an actual write to occur outside the sandbox environment. We prefer addpredict to addwrite in most instances as we don't really want to poke holes in the sandbox - we only pretend we're poking holes. And it happens to be very useful for testing sandbox violations. For instance, if some imaginary ebuild wants to write to /dev/null we should be able to get away with addpredict...basically and never need to use addwrite to check its effects.

Sandbox and Pkg_* Functions

The functions addpredict and addwrite however have limited scope in situations where packages want to make changes on the live file system. For instance packages like apache and mysql both need to add users to the live filesystem which would both be prevented by the sandbox. Addpredict and addwrite do not cover this situation adequately and so other functions are used. This is where the pkg_* functions come into play.

We have for example a function called pkg_postinst() that is callled after the application is merged with the live filesystem. Similarly we have a pkg_preinst() function that can make necessary changes to the live filesystem before merging the application. There are many more such functions and they are all described briefly in the ebuild(5) manpage. The important point to note for our purposes is that the sandbox is disabled when running the pkg_* functions.

Resources: man sandboxshell

Manually Compile

Possible Resources: info automake, info autoconf, Makefiles, strace
About this document ...
Gentoo Sandbox Methodology And Troubleshooting

This document was generated using the LaTeX2HTML translator Version 2002-2 (1.70)

Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.

The command line arguments were:
latex2html -no_subdir -split 0 -show_section_numbers /tmp/lyx_tmpdir31558pYSoKL/lyx_tmpbuf0/GentooTroubleShootingMethodologyRev3.tex

The translation was initiated by on 2004-09-02
2004-09-02
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表