ABSTRACT:

  Daniel Robbins is best known as the creator of Gentoo Linux and author of many IBM developerWorks articles about Linux. Daniel currently serves as Benevolent Dictator for Life (BDFL) of Funtoo Linux. Funtoo Linux is a Gentoo-based distribution and continuation of Daniel's original Gentoo vision.


Section 3

Operation logic of the original version of Portage(a package manager used by Gentoo,Funtoo,etc.)


ebuild.conf: 

1 # /etc/ebuild.conf:set system-wide ebuild options in this file
2 # MAKEOPTS are options passed to make
3 MAKEOPTS="-j2"

package.ebuild:

1 #this ebuild file overrides the default user_compile()
2 P=e2fsprogs-1.18
3 A=${P}.tar.gz
4 user_compile() {
5   ./configure --enable-elf-shlibs
6 make
7 }  #e2fsprogs.ebuild

ebuild:

 1 #!/usr/bin/env bash
2 if [ $# -ne 2 ]
3 then
4   echo "Please specify ebuild file and unpack, compile or all"
5 exit 1
6 fi
7 source /etc/ebuild.conf
8 if [ -z "$DISTDIR" ]
9 then
10 # set DISTDIR to /usr/src/distfiles if not already set
11   DISTDIR=/usr/src/distfiles
12 fi
13 export DISTDIR
14 ebuild_unpack() {
15   #make sure we're in the right directory
16   cd ${ORIGDIR}
17 if [ -d ${WORKDIR} ]
18 then
19   rm -rf ${WORKDIR}
20 fi
21 mkdir ${WORKDIR}
22 cd ${WORKDIR}
23 if [ ! -e ${DISTDIR}/${A} ]
24 then
25   echo "${DISTDIR}/${A} does not exist. Please download first."
26 exit 1
27 fi
28 tar xzf ${DISTDIR}/${A}
29 echo "Unpacked ${DISTDIR}/${A}."
30 #source is now correctly unpacked
31 }
32 user_compile()
33 {
34 #we're already in ${SRCDIR}
35 if [ -e configure ]
36 then
37 #run configure script if it exists
38   ./configure --prefix=/usr
39 fi
40   #run make
41   make $MAKEOPTS MAKE="make $MAKEOPTS"
42 }
43 ebuild_compile() {
44 if [ ! -d "${SRCDIR}" ]
45 then
46   echo "${SRCDIR} does not exist -- please unpack first."
47 exit 1
48 fi
49 #make sure we're in the right directory
50 cd ${SRCDIR}
51 user_compile
52 }
53 export ORIGDIR=`pwd`
54 export WORKDIR=${ORIGDIR}/work
55 if [ -e "$1" ]
56 then
57   source $1
58 else
59   echo "Ebuild file $1 not found."
60 exit 1
61 fi
62 export SRCDIR=${WORKDIR}/${P}
63 case "${2}" in
64   unpack)
65     ebuild_unpack ;;
66   compile)
67     ebuild_compile ;;
68   all)
69     ebuild_unpack ebuild_compile ;;
70   *)
71     echo "Please specify unpack, compile or all as the second arg"
72     exit 1 ;;
73 esac

REFERENCES:

  • http://www.funtoo.org/Bash_by_Example,_Part_1
  • http://www.funtoo.org/Bash_by_Example,_Part_2
  • http://www.funtoo.org/Bash_by_Example,_Part_3
  • http://www.jb51.net/article/51342.htm

『BASH』——Learn BashScript from Daniel Robbins——[003]的更多相关文章

  1. 『BASH』——Learn BashScript from Daniel Robbins——[001-002]

    ABSTRACT: Daniel Robbins is best known as the creator of Gentoo Linux and author of many IBM develop ...

  2. 『BASH』——文件权限批量恢复脚本——「Permission Revovery」

    一.恢复指定程序包所有文件的权限: #!/bin/bash #Assume that you have mounted a correct orignal-system on /mnt read -p ...

  3. 『BASH』——Hadex's brief analysis of "Lookahead and Lookbehind Zero-Length Assertions"

    /*为节省时间,本文以汉文撰写*/ -前言- 深入学习正则表达式,可以很好的提高思维逻辑的缜密性:又因正则应用于几乎所有高级编程语言,其重要性不言而喻,是江湖人士必备的内功心法. 正则表达式概要(ob ...

  4. 『AngularJS』$location 服务

    项目中关于 $location的用法 简介 $location服务解析在浏览器地址栏中的URL(基于window.location)并且让URL在你的应用中可用.改变在地址栏中的URL会作用到$loc ...

  5. [原创] 【2014.12.02更新网盘链接】基于EasySysprep4.1的 Windows 7 x86/x64 『视频』封装

    [原创] [2014.12.02更新网盘链接]基于EasySysprep4.1的 Windows 7 x86/x64 『视频』封装 joinlidong 发表于 2014-11-29 14:25:50 ...

  6. JS 中通过对象关联实现『继承』

    JS 中继承其实是种委托,而不是传统面向对象中的复制父类到子类,只是通过原型链将要做的事委托给父类. 下面介绍通过对象关联来实现『继承』的方法: Foo = { // 需要提供一个 init 方法来初 ...

  7. 『摄影欣赏』16幅 Romantic 风格照片欣赏【组图】

    今天,我们将继续分享人类情感的系列文章.爱是人类最重要的感觉,也可能是各种形式的艺术(电影,音乐,书,画等)最常表达的主题 .这里有40个最美丽的爱的照片,将激励和给你一个全新的视觉角度为这种情绪.我 ...

  8. 『开源』Slithice 2013 服务器集群 设计和源码

    相关介绍文章: <『设计』Slithice 分布式架构设计-支持一体式开发,分布式发布> <『集群』001 Slithice 服务器集群 概述> <『集群』002 Sli ...

  9. 『片段』OracleHelper (支持 多条SQL语句)

    C# 调用 Oracle 是如此尴尬 >System.Data.OracleClient.dll —— .Net 自带的 已经 过时作废. >要链接 Oracle 服务器,必须在 本机安装 ...

随机推荐

  1. EL表达式的简单介绍

    EL表达式的简单介绍 一.JSP EL语言定义 E L(ExpressionLanguage)  目的:为了使JSP写起来更加简单. 表达式语言的灵感来自于ECMAScript 和 XPath 表达式 ...

  2. bzoj1047题解

    [解题思路] (p.s.:刚看的时候一脸懵逼..没看见N已经给定了,还以为要用某些高明的方法..果然还是太naive了..) 两遍预处理,第一遍处理出f[i][j][0/1]表示第i行从j-n+1~j ...

  3. Vlan的相关知识点收纳

    Q.思科Vlan的上限个数是多少? VLAN的范围:根据平台和软件版本不同,Cisco交换机最多支持4096个VLAN.VLAN号共有4096个,0-4095    0,4095:这两个号保留,仅限系 ...

  4. delphi dll创建及调用

    第一章 DLL简单介绍由于在目前的学习工作中,需要用到DLL文件,就学习了下,在这里作个总结.首先装简单介绍下DLL:1,减小可执行文件的大小DLL技术的产生有很大一部分原因是为了减小可执行文件的大小 ...

  5. flutter 使用keyboard_actions 关闭ios键盘

    项目中登录 输入账号密码 弹出的键盘 关闭不了,从而 引来一些问题, 1,第一次关闭 项目是在 最外层包裹一层,点击的时候进行关闭, return Scaffold( resizeToAvoidBot ...

  6. linux进阶之路(二):linux文件目录

    Linux的目录结构: Linux文件系统采用级层式的目录结构,最上层是根目录"/",在此目录下再创建其他目录. 树状的文件目录.再Linux世界,一切皆文件. /etc 所有系统 ...

  7. Codeforces 1191B Tokitsukaze and Mahjong

    题目链接:http://codeforces.com/problemset/problem/1191/B 题意:类似于麻将,三个一样花色一样数字的,或者三个同花顺就赢了,新抽的能当任何类型,问至少几个 ...

  8. mkdir和_mkdir的区别

    没有下划线的位不符合ISO c++ 标准的写法,标准要求带下划线的标准,没有下划线的是为了兼容以前的版本.

  9. troff - groff 文档排版系统的 troff 处理器

    总览 SYNOPSIS troff [ -abcivzCERU ] [ -d cs ] [ -f fam ] [ -F dir ] [ -m name ] [ -M dir ] [ -n num ] ...

  10. hadoop–JobTracker 相关

    JobTracker 内部使用三层表示: JobInProgress: 跟踪和监控作业运行状态的对象.每个Job分成了多个Task.并为每个Task创建一个TaskInProgress跟踪和监控其运行 ...