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
时间: 2024-10-07 13:26:42