LinuxSir.cn,穿越时空的Linuxsir!

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

[更新]中文portage同步脚本:glc_sync

[复制链接]
发表于 2004-11-21 00:49:12 | 显示全部楼层 |阅读模式
处理了本地中文portage的目录可能不是portage的情形,将配置独立出来到/etc/glc.conf
配置文件如下:

  1. ###
  2. ###the glc portage config file
  3. ###

  4. ###the glc portage directory that you have set in /etc/make.conf
  5. ###WARNING:NO space near the "="

  6. GLCPORTAGE=/usr/local/portage
复制代码

警告:等号两边不要有空格。
glc_sync脚本下载
glc_sync脚本源码:

  1. #!/bin/bash
  2. ###
  3. ### sync with the chinese portages
  4. ###

  5. source /etc/glc.conf
  6. if [ -z ${GLCPORTAGE} ]
  7. then
  8.         echo "!!!GLCPORTAGE is empty,so use the default value"
  9.         GLCPORTAGE=/usr/local/portage
  10. fi

  11. TMPDIR=/tmp
  12. PORTAGEDIR=${GLCPORTAGE%/*}
  13. PORTAGE=${GLCPORTAGE##*/}
  14. # reset CTRL+C signal
  15. trap "clean_and_exit" 2

  16. function clean_and_exit ()
  17. {
  18.         printf "\n!!!Received KILL signal, NOW exit\n"
  19.         rm -f ${TMPDIR}/portage.tar.gz
  20.         rm -rf ${TMPDIR}/portage
  21.         exit
  22. }

  23. if [ `whoami` != "root" ]
  24. then
  25.         echo "!!!Sorry, you need to be root to do this"
  26.         exit
  27. fi

  28. #the download loop
  29. #if something went wrong, retry
  30. while :
  31. do
  32.         echo "Start downloading the glc snapshot...."
  33.         wget http://www.magiclinux.org/cgi-bin/viewcvs.cgi/gentoo/portage.tar.gz?view=tar -O ${TMPDIR}/portage.tar.gz

  34.         if [ $? -ne 0 ]
  35.         then
  36.                 echo "!!!Something went wrong when downloading"
  37.                 rm -f ${TMPDIR}/portage.tar.gz
  38.                 echo "Now retry to download"
  39.                 continue
  40.         fi

  41.         echo "Download successfully"

  42.         echo "Extracting files..."
  43.         rm -rf ${TMPDIR}/portage
  44.         tar zxvf ${TMPDIR}/portage.tar.gz -C ${TMPDIR}

  45.         if [ $? -ne 0 ]
  46.         then
  47.                 echo "!!!Something went wrong when extracting"
  48.                 echo "Now retry to download"
  49.                 rm -f ${TMPDIR}/portage.tar.gz
  50.                 continue
  51.         fi

  52.         #download successfully
  53.         break
  54. done

  55. rm -rf ${PORTAGEDIR}/${PORTAGE}
  56. mv ${TMPDIR}/portage ${PORTAGEDIR}/${PORTAGE}

  57. echo "Removing the temp file..."
  58. rm -f ${TMPDIR}/portage.tar.gz

  59. echo "Sync completed successfully, enjoy!"

复制代码
发表于 2004-11-21 07:54:37 | 显示全部楼层
# glc-sync
/usr/sbin/glc-sync: line 7: ${ GLCPORTAGE }: bad substitution
/usr/sbin/glc-sync: line 10: ${ GLCPORTAGE%/* }: bad substitution
/usr/sbin/glc-sync: line 11: ${ GLCPORTAGE##*/ }: bad substitution
Start downloading the glc snapshot....
/usr/sbin/glc-sync: line 34: ${ TMPDIR }/portage.tar.gz: bad substitution
/usr/sbin/glc-sync: line 36: ${ PORTAGEDIR }/${ PORTAGE }: bad substitution
/usr/sbin/glc-sync: line 37: ${ TMPDIR }/portage: bad substitution
Removing the temp file...
/usr/sbin/glc-sync: line 40: ${ TMPDIR }/portage.tar.gz: bad substitution
Sync completed successfully, enjoy!
发表于 2004-11-21 09:24:51 | 显示全部楼层
删除变量中的空格,比如${ GLCPORTAGE%/* }大括号两边的空格
 楼主| 发表于 2004-11-21 18:20:20 | 显示全部楼层
是论坛的问题
好了现在。
发表于 2004-11-21 20:57:51 | 显示全部楼层
这个不错,更新中文portage非常方便!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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