免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: kns1024wh
打印 上一主题 下一主题

如何定制个性化的Linux发行版?欢迎分享,欢迎提问!(获奖名单已公布) [复制链接]

论坛徽章:
0
111 [报告]
发表于 2012-03-29 17:02 |只看该作者
  1. #!/bin/bash
  2. if [ ! -e  /root/xiaosu.cfg ];then
  3. echo "you must put the kickstart file named xiaosu.cfg to /root/"
  4. exit 1
  5. fi
  6. yum -y install  yum-plugin-downloadonly createrepo genisoimage
  7. mv /etc/yum.repos.d/  /etc/yum.repos.d.bak
  8. mkdir /etc/yum.repos.d
  9. cat >/etc/yum.repos.d/suzezhi.repo << EOF
  10. [suzezhi-base]
  11. name=CentOS-$releasever - Base - 163.com
  12. baseurl=http://mirrors.163.com/centos/6/os/x86_64/
  13. gpgcheck=1
  14. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

  15. [suzezhi-updates]
  16. name=CentOS-$releasever - Updates - 163.com
  17. baseurl=http://mirrors.163.com/centos/6/updates/x86_64/
  18. gpgcheck=1
  19. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

  20. #additional packages that may be useful
  21. [suzezhi-extras]
  22. name=CentOS-$releasever - Extras - 163.com
  23. baseurl=http://mirrors.163.com/centos/6/extras/x86_64/
  24. gpgcheck=1
  25. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

  26. #additional packages that extend functionality of existing packages
  27. [suzezhi-centosplus]
  28. name=CentOS-$releasever - Plus - 163.com
  29. baseurl=http://mirrors.163.com/centos/6/centosplus/x86_64/
  30. gpgcheck=1
  31. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

  32. #contrib - packages by Centos Users
  33. [suzezhi-contrib]
  34. name=CentOS-$releasever - Contrib - 163.com
  35. baseurl=http://mirrors.163.com/centos/6/contrib/x86_64/
  36. gpgcheck=1
  37. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
  38. EOF

  39. mkdir -p /tmp/suzezhi/temp
  40. cd /tmp/suzezhi/temp
  41. wget -r --no-parent -c --cut-dirs=4 --reject=gz --exclude-directories=centos/6/os/x86_64/Packages http://mirrors.sohu.com/centos/6/os/x86_64/
  42. find . -name index.html -exec rm -f {} \;

  43. cat >> /tmp/suzezhi/temp/yum.conf <<EOF
  44. [main]
  45. cachedir=/var/cache/Packages
  46. keepcache=0
  47. debuglevel=2
  48. logfile=/var/log/yum.log
  49. exactarch=1
  50. obsoletes=1
  51. gpgcheck=1
  52. plugins=1
  53. installonly_limit=5
  54. bugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&ref=http://bugs.centos.org/bug_report_page.php?category=yum
  55. distroverpkg=centos-release
  56. EOF
  57. for i in $(awk '/^%packages$/,/^%end$/' /root/xiaosu.cfg  |grep -v -E  '%end|%packages'); do
  58. yum --installroot=/tmp/suzezhi/test -c yum.conf  --downloadonly --downloaddir=/tmp/suzezhi/Packages -y  install $i
  59. done
  60. rm -rf  /etc/yum.repos.d
  61. mv /etc/yum.repos.d.bak  /etc/yum.repos.d
  62. cd /tmp/suzezhi/
  63. mv Packages/ /tmp/suzezhi/temp/mirrors.sohu.com/
  64. cd /tmp/suzezhi/temp/mirrors.sohu.com
  65. cat > .discinfo  << EOF
  66. 1333560292.885204
  67. 6
  68. x86_64
  69. 1
  70. EOF
  71. cat > .treeinfo << EOF
  72. [general]
  73. family = CentOS
  74. timestamp = 1333560005.81
  75. variant =
  76. totaldiscs = 1
  77. version = 6
  78. discnum = 1
  79. packagedir = Packages
  80. arch = x86_64

  81. [images-x86_64]
  82. kernel = images/pxeboot/vmlinuz
  83. initrd = images/pxeboot/initrd.img

  84. [images-xen]
  85. kernel = images/pxeboot/vmlinuz
  86. initrd = images/pxeboot/initrd.img

  87. [stage2]
  88. mainimage = images/install.img
  89. EOF
  90. cp /root/xiaosu.cfg .
  91. sed -i "/menu default/d" isolinux/isolinux.cfg
  92. cat >> isolinux/isolinux.cfg << EOF
  93. label auto
  94.   menu label ^Auto install an  system
  95.   menu default
  96.   kernel vmlinuz
  97.   append ks=cdrom:/xiaosu.cfg initrd=initrd.img
  98. EOF
  99. mv repodata/*-comps.xml .
  100. rm -f repodata/*
  101. mv *-comps.xml repodata
  102. createrepo -d  --unique-md-filenames   -g repodata/*-comps.xml .
  103. cd ..
  104. mkisofs -R -J -T -r -l -d -joliet-long -allow-multidot -allow-leading-dots -no-bak -o /root/xiaosu.iso -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table mirrors.sohu.com/
  105. rm -rf /tmp/suzezhi
复制代码
下面解释一下大概的意思
先检测 /root目录下面有没有文件名为xiaosu.cfg的kickstart配置文件

然后安装制作ISO包和yum的插件还有创建yum源数据库的包

备份原来的yum配置文件

将163的源写入配置文件

创建目录

用wget从sohu的镜像源上下载ISO文件中必须的一些文件(比如initrd文件,install.img)

生成一个临时的yum配置文件

从kickstart配置文件中读取需要安装的包,然后用一个for循环遍历安装

恢复原来的配置文件

生成ISO中必须的文本文件.treeinfo 和 .discinfo

将kickstart的配置文件复制到光盘目录

用sed取消掉原来的默认选项  然后追加一个自动安装的选项(如刚才那个图片所示,开机之后,自动将光标停留在自动安装的选项上)

重新生成yum源的数据库

生成ISO文件,并放到/root目录下

论坛徽章:
0
112 [报告]
发表于 2012-03-29 17:04 |只看该作者
下面是我的xiaosu.cfg文件
  1. #platform=x86, AMD64, 或 Intel EM64T
  2. #version=DEVEL
  3. # Firewall configuration
  4. firewall --disabled
  5. # Install OS instead of upgrade
  6. install
  7. # Use CDROM installation media
  8. cdrom
  9. # Root password
  10. rootpw --iscrypted $1$oSWcILwo$7OFkCcL9u6jvQxFeavj5V0
  11. # System authorization information
  12. auth  --useshadow  --passalgo=sha512
  13. # Use graphical install
  14. graphical
  15. firstboot --disable
  16. # System keyboard
  17. keyboard us
  18. # System language
  19. lang en_US
  20. # SELinux configuration
  21. selinux --disabled
  22. # Installation logging level
  23. logging --level=info
  24. # Reboot after installation
  25. reboot
  26. # System timezone
  27. timezone  Asia/Shanghai
  28. # Network information
  29. network  --bootproto=dhcp --device=eth0 --onboot=on
  30. zerombr
  31. # System bootloader configuration
  32. bootloader --location=mbr
  33. # Partition clearing information
  34. clearpart --all
  35. # Disk partitioning information
  36. part / --fstype="ext4" --ondisk=sda --size=10000
  37. part /boot --fstype="ext4" --ondisk=sda --size=100
  38. part swap --fstype="swap" --ondisk=sda --size=1000

  39. %packages
  40. @base
  41. @client-mgmt-tools
  42. @chinese-support
  43. @core
  44. @basic-desktop
  45. @desktop-platform
  46. @fonts
  47. @general-desktop
  48. @graphical-admin-tools
  49. @input-methods
  50. @internet-applications
  51. @internet-browser
  52. @java-platform
  53. @legacy-x
  54. @server-platform
  55. @server-policy
  56. @x11
  57. mtools
  58. pax
  59. oddjob
  60. sgpio
  61. wodim
  62. abrt-gui
  63. certmonger
  64. pam_krb5
  65. krb5-workstation
  66. libXmu

  67. %end
复制代码

论坛徽章:
0
113 [报告]
发表于 2012-03-29 17:07 |只看该作者
这个脚本实现的定制不多,也没有将CentOS的logo之类的换掉,其实我个人更倾向去使用gentoo,但gentoo自动化程度不高,本人目前正努力的学习python,争取写出一个gentoo下的anaconda

欢迎大家拍砖

论坛徽章:
0
114 [报告]
发表于 2012-03-29 17:14 |只看该作者
回复 4# chenyx


    有createrepo这个命令可以自动化完成

论坛徽章:
0
115 [报告]
发表于 2012-03-29 17:25 |只看该作者
回复 46# spy0578


    你可以尝试根据需要裁减glibc 。。。。。

论坛徽章:
0
116 [报告]
发表于 2012-03-31 16:10 |只看该作者
本帖最后由 飞翔的单车 于 2012-03-31 16:11 编辑

回复 104# send_linux


    管理员大哥,这个活动结束了吗?  怎么都没人发言了?

论坛徽章:
49
15-16赛季CBA联赛之福建
日期:2016-06-22 16:22:002015年亚洲杯之中国
日期:2015-01-23 16:25:12丑牛
日期:2015-01-20 09:39:23未羊
日期:2015-01-14 23:55:57巳蛇
日期:2015-01-06 18:21:36双鱼座
日期:2015-01-02 22:04:33午马
日期:2014-11-25 09:58:35辰龙
日期:2014-11-18 10:40:07寅虎
日期:2014-11-13 22:47:15申猴
日期:2014-10-22 15:29:50摩羯座
日期:2014-08-27 10:49:43辰龙
日期:2014-08-21 10:47:58
117 [报告]
发表于 2012-03-31 17:51 |只看该作者
飞翔的单车 发表于 2012-03-31 16:10
回复 104# send_linux


已经结束了,很快会公布结果,这两天是假期,假期过后即可公布。

论坛徽章:
0
118 [报告]
发表于 2012-03-31 22:15 |只看该作者
回复 117# send_linux


    好的,不过感觉论坛上的人好像都不怎么活跃,并且感觉有技术含量的帖子也很少。。。。

论坛徽章:
0
119 [报告]
发表于 2012-04-11 05:54 |只看该作者
纯属支持,学习中的小鸟,对于定制还是望尘莫及

论坛徽章:
0
120 [报告]
发表于 2012-04-18 22:28 |只看该作者
怎么就没有人用过DEBIAN的呢?我喜欢DEBIAN
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP