LinuxSir.cn,穿越时空的Linuxsir!

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

[原创脚本] 零起步创建自己的Archlive——基于Arch GNU/Linux的发行版

[复制链接]
发表于 2009-9-7 17:36:21 | 显示全部楼层 |阅读模式
mkarchlive 脚本实际上放googlecode上近一年了!  功能也达到空前强大! 可定制参数相当多了!

为了简化定制的难度, 今天写个自动化创建的脚本如下:
(脚本随时更新于http://archlive.googlecode.com/h ... /autobuild_archlive)

希望大家定制出自己喜欢的archlive。。。


  1. #!/bin/bash
  2. #
  3. ######################################################################################
  4. #  Author: Carbon Jiao <http://archlive.googlecode.com> <http://archlive-pkg.googlecode.com>
  5. #  Write this scripts to simplify the procedure of make your own Live system (LiveHD LiveUSB
  6. #  or LiveCD) with mkarchlive scripts.                                                                  
  7. #  作者 Carbon Jiao <http://archlive.googlecode.com><http://archlive-pkg.googlecode.com>   
  8. #  写该脚本的目的是为了简化 使用mkarchlive脚本制作自己的基于Arch GNU/Linux的Live系统(LiveHD
  9. #  LiveUSB or LiveCD)的过程.                                                                          
  10. #  2009-09-07 1st Revision                                                                          
  11. ######################################################################################
  12. #
  13. #
  14. APPNAME=$(basename "${0}")
  15. cmdline=$@
  16. # Checking the envirment...
  17. # 检查语言环境
  18. lang=$(locale | grep LANG | awk -F "=" '{print $2}')

  19. # Default value, you can use "-r <workdir>" to change it.
  20. # 默认工作目录, 可以使用 -r <workdir> 来更改.
  21. workdir="/$(date +%m%d)"

  22. usage (){
  23.         echo ""
  24.    if [ "${lang%_*}x" = "zhx" ]; then
  25.         echo "用法: sh ./${APPNAME} [选项]"
  26.         echo "选项:"
  27.         echo "       -r <workdir>   workdir为工作目录——本脚本所有操作均局限于该目录下;"
  28.         echo "       -h         本帮助信息."
  29.    else
  30.         echo "Usage: sh ./${APPNAME} [Options]"
  31.         echo "Options:"
  32.         echo "       -r <workdir>   workdir is the working directory, all actions from this scripts under this folder;"
  33.         echo "       -h         This help."
  34.    fi
  35.    exit $1
  36. }

  37. # Check the input
  38. # 检测输入的选项
  39. while getopts 'r:h:?' arg; do
  40.    case "${arg}" in
  41.         r) workdir="${OPTARG}" ;;
  42.         h|?) usage 0 ;;
  43.         *) if [ "${lang%_*}x" = "zhx" ]; then
  44.                 echo "错误: 无效参数 '${arg}'"
  45.            else
  46.                 echo "Wrong option '${arg}'"
  47.            fi
  48.            usage 1 ;;
  49.    esac
  50. done

  51. if [ "x${workdir}" = "x" ]; then
  52.         if [ "${lang%_*}x" = "zhx" ]; then
  53.                 echo "没有指定工作目录? 使用默认工作目录"/$(date +%m%d)" "
  54.         else
  55.                 echo "No workdir pointed out? Use the default "/$(date +%m%d)" "
  56.         fi
  57.         workdir="/$(date +%m%d)"
  58. fi

  59. shift `expr $OPTIND - 1`
  60. if [ "x$@" != "x" ]; then
  61.         if [ "${lang%_*}x" = "zhx" ]; then
  62.                 echo "错误:无法识别的参数或命令: $@"
  63.         else
  64.                 echo "Wrong: Unexpected options or command:$@"
  65.         fi
  66.         usage 1
  67. fi

  68. # Confirm to continue
  69. # 确认后继续
  70. if [ "${lang%_*}x" = "zhx" ]; then
  71.         echo -n -e "本脚本可能需要sudo来安装Mercurial(如果还没有安装), 会产生目录${workdir}, \
  72.                 \n所有操作将局限于该目录中,请确保硬盘 / 分区有足够空间——如果包含X,需要3G左右空间. \
  73.                 \n输入"y"继续: "
  74. else
  75.         echo -n -e "This scripts will use sudo install Mercurial(If haven't installed), and will create folder ${workdir}, \
  76.                 \nAll actions will be operated within this folder. Ensue your / partion have enough free space. \
  77.                 \n——Need about 3GB if you build Archlive with X. \n \
  78.                 \nInput "y" to continue: "
  79. fi
  80. read confirm
  81. case $confirm in
  82.         Y|y) ;;
  83.         *) if [ "${lang%_*}x" = "zhx" ]; then
  84.                 echo "输入无效,退出脚本..."
  85.                 exit 1
  86.            else
  87.                 echo "No "Y" or "y" inputed, exit the scripts..."
  88.                 exit 1
  89.            fi
  90.         ;;
  91. esac

  92. # Checking the hg tools
  93. # 检查获取mkarchlive脚本的工具是否存在
  94. hgrevision=$(hg -v 2>/dev/null | head -1 | awk '{print $5}')
  95. hgrevision=${hgrevision%)}

  96. # Install Mercurial if not installed
  97. # 如果没有hg功能,则安装Mercurial
  98. if [ "x${hgrevision}" = "x" ]; then
  99.         if [ "${lang%_*}x" = "zhx" ]; then echo "系统还没有装Mercurial."; else echo "No mercurial installed."; fi
  100.         if [ -f /etc/pacman.conf ]; then
  101.                 if [ "${lang%_*}x" = "zhx" ]; then
  102.                         echo "现在安装mercurial - 一个版本管理程序..."
  103.                 else
  104.                         echo "Start to install Mercurial-- A scalable distributed SCM tool ..."
  105.                 fi
  106.                 sudo pacman -S --noconfirm mercurial >/dev/null
  107.                 if [ $? -eq 0 ]; then
  108.                         if [ "${lang%_*}x" = "zhx" ]; then echo "Mercurial 安装完成!"; else echo "Mercurial installing finished!"; fi
  109.                 else
  110.                         if [ "${lang%_*}x" = "zhx" ]; then
  111.                                 echo "安装Mercurial失败,请自行手动安装..."
  112.                         else
  113.                                 echo "Install Mercurial failed, try again after you installed Mercurial."
  114.                         fi
  115.                 fi
  116.         else
  117.                 if [ "${lang%_*}x" = "zhx" ]; then
  118.                         echo "宿主系统不是Arch,请先安装mercurial再执行本脚本..."
  119.                 else
  120.                         echo "Host system is not Arch GNU/Linux, try again after you installed Mercurial -- A scalable distributed SCM tool."
  121.                 fi
  122.                 exit 1
  123.         fi
  124. fi

  125. hgrevision=$(hg -v 2>/dev/null | head -1 | awk '{print $5}')
  126. hgrevision=${hgrevision%)}

  127. echo "Mercurial版本为 ${hgrevision}..."

  128. # Create working directory (mkarchlive scripts and archlive working tmp all store in this foder.)
  129. # 创建工作目录 (制作脚本及制作工作目录均存于此目录下.)
  130. if [ -d ${workdir} ]; then
  131.         if [ "${lang%_*}x" = "zhx" ]; then
  132.                 echo "工作目录${workdir}已经存在,是否删除?不删除则继续在改目录下制作archlive..."
  133.         else
  134.                 echo "Working directory ${workdir} already exist, delete? You can rebuild Archlive without delete this folder..."
  135.         fi
  136.         sudo rm -ri ${workdir}
  137. fi
  138. sudo install -dm777 ${workdir}
  139. sudo chown -R 1001:100 ${workdir}

  140. # Check out the scripts
  141. # 检出制作代码
  142. cd ${workdir}
  143. hg clone http://mkarchlive.archlive.googlecode.com/hg mkarchlive

  144. # Start to build
  145. # 开始自动创建
  146. cd mkarchlive
  147. log=${workdir}/$(whoami)-$(date +'%F-%H%M%S').log
  148. sudo sh ./mkarchlive -f all ${workdir} 2>&1 | tee ${log}

  149. # Clean the working directories
  150. # 清理系统
  151. cd ../
  152. sudo umount -l ${workdir}/union 2>&1 >/dev/null
  153. if [ "${lang%_*}x" = "zhx" ]; then
  154.         echo "现在工作缓存目录...也可以不删除缩减下次制作时间..."
  155. else
  156.         echo "Now, clean the $workdir, you also keep these directories to save time when you create Archlive next time."
  157. fi
  158. sudo rm -ri ${workdir}/{img_*,*_modules,sync,union}  2>&1 >/dev/null
  159. tar -czvpf mkarchlive_build_log.tgz log ${log} list  2>&1 >/dev/null

  160. if [ "${lang%_*}x" = "zhx" ]; then
  161.         echo "如果制作过程中有什么其他问题,将mkarchlive_build_log.tgz发邮件到 carbonjiao alt gmail dot com,感谢支持!"
  162. else
  163.         echo "If you have some problems, you can send the log file "mkarchlive_build_log.tgz" to carbonjiao alt gmail dot com, thanks for your support!"
  164. fi

复制代码
发表于 2009-9-7 17:45:06 | 显示全部楼层
up up
水平有限 只能纯支持了
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-9-7 19:20:36 | 显示全部楼层
Post by 马甲321;2024819
up up
水平有限 只能纯支持了


好久没有见你提供PKGBUILD到googlecode或者aur上了!

忙啥呢
回复 支持 反对

使用道具 举报

发表于 2009-9-7 19:38:19 | 显示全部楼层
支持老大~~
回复 支持 反对

使用道具 举报

发表于 2009-9-7 19:55:34 | 显示全部楼层
Post by carbonjiao;2024862
好久没有见你提供PKGBUILD到googlecode或者aur上了!

忙啥呢


呵呵~在 oss 和 alsa 中徘徊了几次
追新 x264.git mplayer-mt.git ffmpeg-mt.git ...
回复 支持 反对

使用道具 举报

发表于 2009-9-7 21:24:12 | 显示全部楼层
instantbird   昨天在网上看到instantbird这聊天工具支持的东东挺多的,用yaourt总是安装不上,提示如下:
  1. configure: error: /sdk/include/xpcom-config.h doesn't exist
  2. *** Fix above errors and then restart with               "make -f client.mk build"
  3. make[1]: *** [configure] 错误 1
  4. make[1]: Leaving directory `/tmp/yaourt-tmp-asins/aur-instantbird/instantbird/src/instantbird-0.1.3.1-src'
  5. make: *** [/tmp/yaourt-tmp-asins/aur-instantbird/instantbird/src/instantbird-0.1.3.1-src/../obj-instantbird/Makefile] 错误 2
  6. ==> 错误: 创建失败。
  7.     正在放弃...
  8. Error: Makepkg was unable to build instantbird package.
复制代码

是什么问题啊,我电脑不存在/sdk/include/xpcom-config.h  这个目录就更不用说文件了
回复 支持 反对

使用道具 举报

发表于 2009-9-7 22:45:06 | 显示全部楼层
这个必须支持下!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-9-8 09:28:37 | 显示全部楼层
Post by 马甲321;2024883
呵呵~在 oss 和 alsa 中徘徊了几次
追新 x264.git mplayer-mt.git ffmpeg-mt.git ...


编译好了传到googlecode上大家分享下了!

我已经编译了 20090906的git内核到googlecode。。。
回复 支持 反对

使用道具 举报

发表于 2009-9-8 15:36:38 | 显示全部楼层
支持, 有条件就帮忙测试脚本
回复 支持 反对

使用道具 举报

发表于 2009-9-8 15:48:14 | 显示全部楼层
看了这么多,究竟这个 脚本是干什么的,是不是运行这个能生成一个ISO文件?
回复 支持 反对

使用道具 举报

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

本版积分规则

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