LinuxSir.cn,穿越时空的Linuxsir!

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

Installing portage on other distros, easier than ever

[复制链接]
发表于 2006-5-7 18:23:57 | 显示全部楼层 |阅读模式
原贴地址:http://forums.gentoo.org/viewtopic.php?t=125553

=================================================
OK guys, after I figured that lot of people had problems regarding this, I thought a script is in order and hence a separate thread.

WARNING: I have verified each and every step in this script. I have everything in there from my own experience. Before you attempt to use it, make sure that you have a backup of the system(for weak hearted guys...). Have a look at the script and know what it does. Although, its not destructive in the sense that unless and until you emerge glibc straightaway, you are safe. Don't emerge glibc,gcc,binutils,baselayout. Alias emerge to something which asks for confirmation if its not "emerge -p <>". And if e.g. "emerge -p tar" tells you that its going to emerge binutils, make sure to inject binutils first. Make sure you have enough space in /(roughly at least 1GB). Just a friendly warning...  

Here it goes:
---------------------------------------------------------------
Code:

#!/bin/bash
#
                                                                                
if [ "`id -u`" != "0" ]; then
   echo ""
   echo "Su as root and try again."
   echo ""
   exit 1
fi
                                                                                
pythonV=`python -V 2>&1`
if [ "$pythonV" \< "ython 2.2.0" ];then
   echo ""
   echo "Install python 2.2 and then try again"
   echo ""
   exit 1
fi
                                                                                
   mkdir -p /usr/lib/portage/bin
   mkdir -p /usr/lib/portage/pym
   mkdir -p /usr/portage/profiles
   mkdir -p /etc/env.d
   mkdir -p /etc/portage/profile
   mkdir -p /var/log/portage
   mkdir -p /var/tmp/portage
   mkdir -p /etc/config-archive
   mkdir -p /var/lib/init.d
   mkdir -p /var/lib/portage
      
   cd /tmp
   rm -rf portage-2.*                                                                     
   wget ftp://gentoo.mirrors.pair.com/distfiles/portage-2.0.*
   portar=`/bin/ls portage-2.0.* 2>/dev/null |sort|tail -n 1`
   if [ ! -f "${portar}" ];then
      echo ""
      echo "Mirror error. Try this script again after a while without any args".
      echo ""
      exit 1
   fi
   tar jxf ${portar}
                                                                                
   cd portage-2.*/bin
   cp * /usr/lib/portage/bin
   export PATH=/usr/lib/portage/binPATH
   cd ../pym ; cp * /usr/lib/portage/pym/
   cd ../man ;cp *.1 /usr/share/man/man1 ;cp *.5 /usr/share/man/man5
   cd ../src/python-missingos
   ./setup.py install
   cd ../sandbox-1.1
   make && make install
   cd ../../cnf; cp * /etc
                                                                                
   if [ "`id portage`" == "" ]; then
      /usr/sbin/groupadd -g 250 portage
      /usr/sbin/useradd -d /var/tmp/portage -g portage -u 250 portage
   fi
                                                                                
   cd /usr/sbin
   ln -sf ../lib/portage/bin/regenworld .
   ln -sf ../lib/portage/bin/pkgmerge .
   ln -sf ../lib/portage/bin/fixpackages .
   ln -sf ../lib/portage/bin/etc-update .
   ln -sf ../lib/portage/bin/env-update .
   ln -sf ../lib/portage/bin/emerge-webrsync .
   ln -sf ../lib/portage/bin/ebuild.sh .
   ln -sf ../lib/portage/bin/ebuild .
   ln -sf ../lib/portage/bin/dispatch-conf .
   ln -sf ../lib/portage/bin/archive-conf .
                                                                                
   cd /usr/bin
   ln -sf ../lib/portage/bin/xpak .
   ln -sf ../lib/portage/bin/repoman .
   ln -sf ../lib/portage/bin/quickpkg .
   ln -sf ../lib/portage/bin/portageq .
   ln -sf ../lib/portage/bin/g-cpan.pl .
   ln -sf ../lib/portage/bin/emerge .
                    
export PATH=/usr/lib/portage/binPATH                                                         
echo "CC=gcc;CXX=g++" > /etc/env.d/compilers.sh
myldpath="/lib:/usr/lib"
# before we call portage the first time, we should save our ld.so.conf
for i in $(cat /etc/ld.so.conf);do myldpath=$myldpathi;done
echo "LDPATH=\"${myldpath}\"" > /etc/env.d/10ldpath
. /etc/env.d/compilers.sh
emerge sync
#
# emerge sync should get /usr/portage/profiles
#
if [ -d /usr/portage/profiles/default-linux ];then
   rm -f /etc/make.profile
   ln -s /usr/portage/profiles/default-linux/x86/2004.2/gcc34 /etc/make.profile
else
   echo ""
   echo "Something wrong. Get /usr/portage/profiles dir from a working"
   echo "Gentoo system and try again."
   echo ""
   exit 1
fi
                                                                                
# inject the "dangerous" packages first.
glibcP=`emerge -p -O glibc|grep ebuild|cut -d" " -f8`
emerge inject $glibcP
gccP=`emerge -p -O gcc|grep ebuild|cut -d" " -f8`
emerge inject $gccP
binP=`emerge -p -O binutils|grep ebuild|cut -d" " -f8`
emerge inject $binP
                                                                                
# fetch the baselayout.
emerge -f -O baselayout
                                                                                
# now inject it too.
baseP=`emerge -p -O baselayout|grep ebuild|cut -d" " -f8`
emerge inject $baseP

#was inject success
ret=`emerge -p baselayout|grep "ebuild   R"`

if [ "$ret" == "" ] ;then
  echo "Inject has failed. Please verify and continue with cut & paste of rest of the steps"
  echo "ERROR."
  exit 1
fi
                                                                                
# if it fails with some errors, its fine.
emerge -O portage
                                                                                
cd /tmp
fileN=`ls /usr/portage/distfiles/rc-scripts-*|sort|tail -n1`
tar xjpf $fileN
cd rc-scripts*/sbin
cp depscan.sh /sbin; cp functions.sh /sbin
mkdir -p /lib/rcscripts/awk
cd ../src/awk
cp *.awk /lib/rcscripts/awk/
cd /etc/init.d
ln -s /sbin/depscan.sh .
ln -s /sbin/functions.sh .
                                                                                
emerge -O bison gawk

# FOLLOWING SHOULD NOT GIVE ANY ERRORS HERE. You screwed up if it did.
emerge -O portage
                                                                                
if ! fgrep -q "/etc/profile.env" /etc/profile ; then
  echo ". /etc/profile.env" >> /etc/profile
fi
                                                                                
echo ""
echo "#############################################################"
echo "You are now free to enjoy portage. Make sure you tune"
echo "/etc/make.conf and other portage configuration files to take"
echo "advantage of portage. If you screwed up, its OK. Pick yourself"
echo "up and give it another go."
echo "#############################################################"
echo ""


-----------------------------------------------------------------------------

This script is now officially tested by me and others.

Thanks.

PS:
I use the following script to prune out all packages I have marked unsafe for portage on Fedora.
-------------------------------------------------
Code:

#!/bin/bash
emerge sync
emerge -p -uD world > /tmp/world.update
for i in `cat /etc/portage/package.mask.ORG` ;
do
matching=`grep "$i" /tmp/world.update`
if [ -n "$matching" ]; then
toInject=`echo $matching|cut -d " " -f 4`;
echo "Injecting $toInject"
echo "$toInject" >> /etc/portage/profile/package.provided
fi
done
echo "# #"
echo "################# UPDATES #######################"
echo "# #"
cat /tmp/world.update


-------------------------------------------

Currently, my /etc/portage/package.mask.ORG looks like this:
--------------
Code:

sys-apps/baselayout
sys-apps/sysvinit
sys-fs/devfsd
sys-kernel/linux-headers
sys-libs/pwdb
sys-libs/pam
sys-libs/pam-login
sys-apps/kbd
sys-devel/bin86
net-misc/iputils
sys-apps/shadow
net-misc/dhcpcd
sys-apps/modutils
sys-libs/glibc
sys-apps/cronbase
x11-base/opengl-update
net-mail/mailbase
net-nds/portmap
sys-fs/e2fsprogs


-------------------

No specific reason for anything other than baselayout, glibc, gcc, binutils, I usually update these fabfour with up2date once in a while. These four you should never emerge on redhat/fedora. Remember, services are handled by different mechanisms in gentoo and other distros, so anything which has to do with services you can't really emerge because you didn't emerge baselayout and hence don't have rc-update script. you could hack around them though.

perfect for keeping xfree, gnome, multimedia kind of stuff up2date.

Good luck.

EDIT: How can I forget to thanks Crichards for floating this idea here? Thanks crichards!! please refer this thread as well:

http://forums.gentoo.org/viewtopic.php?t=28559

EDIT: mar 10, 05
existing ld.so.conf is killed by portage because it doesn't know about redhat installed stuff. Fixed this in the script.
/EDIT

EDIT: feb 21 '05
update the script for latest portage. I link /etc/make.profile with gcc34 profile, feel free to change to your taste after installing. also, I do emerge gcc,binutils now on my FC2 install, works out better. so apart from some very specific stuff like sysvinit, baselayout, glibc you can pretty emerge whole system. I did a custom nitro2 install sometime back using portage on FC2, works out fine.
/EDIT

EDIT: 03-03-2004

Somebody posted the link for rescue tars in responses, just updating it here at the top:

http://dev.gentoo.org/~carpaski/portage_rescue/

/EDIT

EDIT: Jan 22
found a much easier way to install portage on a non-gentoo system.

get the rescue tarball for your arch from here:

ftp://ftp.ucsb.edu/pub/mirrors/l ... apps/portage/files/

read the README.RESCUE. Untar, emerge sync and emerge portage should get you on your way!!

/EDIT

Last edited by devsk on Sat Sep 17, 2005 8:10 pm; edited 24 times in total
 楼主| 发表于 2006-5-7 18:25:02 | 显示全部楼层
时间允许,一定把它翻译一下的。算是做点贡献把!!

其实一直都想把gentoo的portage移植到lfs上面去!这个好象很不错!晚上再来看看!
回复 支持 反对

使用道具 举报

发表于 2006-5-7 20:27:23 | 显示全部楼层
让VirusCamp看看,他正好需要。
回复 支持 反对

使用道具 举报

发表于 2006-5-7 21:50:45 | 显示全部楼层
谢谢,我已经不需要了,基本都解决了.

这个脚本也并不太适合,因为我的 clfs 并没有完成, 只是完成了 tool chain , 而 gentoo 的 portage 需要 /bin /usr 里的软件.

我安装 emerge glibc 后,还必须 adjust tool-chain 。

不完成 clfs /bin 和 /usr 里的基础系统,就是考虑不做无用功,做最少的编译安装,只是比 clfs 在 /tools 里多5个左右的包。
回复 支持 反对

使用道具 举报

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

本版积分规则

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