Ebuild and emerge

折腾了半天的ebuild,将记录张贴如下:

  • ebuild 包含下载,解压,编译安装包的全部信息,还有卸载和配置内容。大多数ebuild用bash脚本编写。简单来说就是一个Portage系统的底层z直接接 口,它可以通过命令执行ebuild文件中提供的子功能。包括下载源码包(fetch),解压(unpack),配置(configure),编译 (make),安装目标文件(install)甚至包括重新打包为二进制压缩包(package)
  • 例如,以我现在正在安装的cross-mips64el-unknown-linux-gnu/gcc为例,需要使用gcc-4.4.2.ebuild。运行 ebuild gcc-4.4.2.ebuild help 会得到能执行的命令,如下
  • ebuild /usr/local/portage/loongson/cross-mips64el-unknown-linux-gnu/gcc/gcc-4.4.2.ebuild help
    你就可以看到ebuild能执行的命令了,这里列举几个和安装有关的。
    help : show this help screen,帮助信息
    setup : execute package specific setup actions,执行设置命令,检测系统环境和系统变量设置以及设置必要的环境变量
    fetch : download source archive(s) and patches,在指定的URL下载源码包
    unpack : unpack sources (auto-dependencies if needed) 解压源码包
    prepare : prepare sources (auto-dependencies if needed)
    configure : configure sources (auto-fetch/unpack if needed) 执行configure脚本得到makefile,在gcc的ebuild里,configure和make一起完成了。
    compile : compile sources (auto-fetch/unpack/configure if needed) 执行make命令
    test : test package (auto-fetch/unpack/configure/compile if needed) 执行make test
    install : install the package to the temporary install directory 执行make install,安装到/var下的指定目录
    qmerge : merge image into live filesystem, recording files in db 将make install得到的镜像安装到系统中,并升级db
    merge : do fetch, unpack, compile, install and qmerge 将上面几步一起完成
    unmerge : remove package from live filesystem
    相当于emerge -C
    config : execute package specific configuration actions
    package : create a tarball package in /usr/portage/packages/All 将编译出的二进制文件打包
    rpm : build a RedHat RPM package
    生成rpm包
    clean : clean up all source and temporary files 删除/var/tmp/portage/下编译使用的所有临时文件。
    可 见基本上emerge是ebuild分解动作的连续执行,但是有个疑问,ebuild是在何时根据use的配置configure。根据上面的这些命令, 应该是在setup时。在setup的过程中,ebuild会根据当前的系统设置和USE设置,检测系统,并export很多的系统变量。并保存到文件 environment中

  • ebuild的命名:pkg-ver{_suf{#}}}{-r#}.ebuild
  • ebuild 的内容,头部,变量,函数和帮助函数四部分。其中,变量包括:包和版本相关变量(P,PN,PV,PR,PVR,PF,CATEGORY,A),目录 (WORKDIR,FILESDIR,S,T,D)。几个关键函数:pkg_setup(),pkg_nofetch,src_unpack(解压到 WORKDIR),src_prepare(准备源码,包括打补丁),src_configure(configure在这部分完 成),src_compile(编译过程),src_test(运行包里面的测试集测试),src_install(包含所有安装目标文件夹信 息),pkg_config(安装之后的配置)
  • portage相关
  • portage使用python和bash编写,基于ebuild。
  • emerge –sync emerge-webrsync同步portage树
  • emerge search pdf ,emerge searchdesc pdf 前者搜索包名称中有pdf的,后者搜索包介绍中有pdf的。
  • emerge 命令是比较基本的软件包管理工具,它会自动的完成下载源码包,解压,configure,make,make install的功能,其中下载源码包默认就在/usr/portage/distfiles/文件夹下。解压,configure,make 都在/var/tmp/portage/下。
  • 相关文章:

    This entry was posted in Linux系统 and tagged , , , , , , , , , , . Bookmark the permalink.

    One Response to Ebuild and emerge

    1. Pingback: 《编译点滴》半年记 « 编译点滴

    发表评论

    电子邮件地址不会被公开。 必填项已用 * 标注

    *

    您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>