Chinaunix首页 | 论坛 | 博客
  • 博客访问: 495308
  • 博文数量: 87
  • 博客积分: 4086
  • 博客等级: 上校
  • 技术积分: 900
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-23 15:55
文章分类

全部博文(87)

文章存档

2012年(3)

2010年(13)

2009年(7)

2008年(64)

我的朋友

分类: LINUX

2012-04-21 19:21:48


点击(此处)折叠或打开

  1. #!/bin/sh

  2. ROOT_NAME=rootfs
  3. ARCH=armv4t
  4. CROSS_COMPILE=arm-none-linux-gnueabi
  5. CC=$CROSS_COMPILE-gcc
  6. STRIP=$CROSS_COMPILE-strip


  7. echo "Build root filesystem start..."

  8. createROOT()
  9. {
  10.     echo Create $ROOT_NAME...
  11.     rm -rf $ROOT_NAME || return 1
  12.     mkdir $ROOT_NAME || return 1
  13.     cd $ROOT_NAME
  14.     echo "Create all dir needed..."
  15.     mkdir dev etc home lib mnt proc sys tmp || return 1

  16.     return 0
  17. }

  18. copyLIBS()
  19. {
  20.     echo "Copy all runtime libraries from toolchain directory..."
  21.     TMP_DIR=`$CC -march=$ARCH -print-sysroot`/lib
  22.     cp $TMP_DIR/ld-linux.so.3                 lib || return 1
  23.     cp $TMP_DIR/libc.so.6                     lib || return 1
  24.     cp $TMP_DIR/libgcc_s.so.1                 lib || return 1
  25.     cp $TMP_DIR/libpthread.so.0             lib || return 1
  26.     cp $TMP_DIR/librt.so.1                    lib || return 1
  27.     cp $TMP_DIR/libcrypt.so.1                 lib || return 1
  28.     cp $TMP_DIR/libdl.so.2                 lib || return 1
  29.     cp $TMP_DIR/libm.so.6                 lib || return 1
  30.     cp $TMP_DIR/libresolv.so.2             lib || return 1
  31.     cp $TMP_DIR/libutil.so.1                lib || return 1
  32.     $STRIP lib/*


  33.     return 0
  34. }

  35. buildETC()
  36. {
  37.     cd etc

  38.     echo "Create inittab in etc directory..."
  39.     echo "null::sysinit:/bin/mount -a" > inittab                    || return 1
  40.     echo "null::sysinit:/bin/hostname -F /home/yqliu29" >> inittab    || return 1
  41.     echo "::sysinit:/etc/init.d/rcS" >> inittab                        || return 1
  42.     echo "::askfirst:-/bin/sh" >> inittab                            || return 1
  43.     echo "::restart:/sbin/init" >> inittab                            || return 1
  44.     echo "::ctrlaltdel:/sbin/reboot" >> inittab                        || return 1
  45.     echo "::shutdown:/bin/umount -a -r" >> inittab                    || return 1
  46.     echo "::shutdown:/sbin/swapoff -a" >> inittab                    || return 1
  47.     chmod +x inittab

  48.     echo "Create fstab in etc directory..."
  49.     echo "devpts /dev/pts devpts defaults,gid=5,mod=620 0 0" > fstab    || return 1
  50.     echo "proc /proc proc 0 0" >> fstab    || return 1
  51.     echo "tmpfs /tmp tmpfs defaults 0 0" >> fstab    || return 1
  52.     echo "sysfs /sys sysfs defaults 0 0" >> fstab    || return 1

  53.     echo "Create mdev.conf in etc..."
  54.     touch mdev.conf || return 1

  55.     echo "Create profile in etc..."
  56.     echo "PS1='[\u@\h \w]'" > profile                        || return 1
  57.     echo "PATH=/bin:/sbin:/usr/bin:/usr/sbin" >> profile    || return 1
  58.     echo "export PS1 PATH" >> profile                        || return 1
  59.     echo "export LD_LIBRARY_PATH=/lib" >> profile            || return 1

  60.     echo "Create rcS in etc/init.d..."
  61.     mkdir init.d    || return 1
  62.     cd init.d        || return 1

  63.     echo "#! /bin/sh" > rcS                                                            || return 1
  64.     echo "echo /sbin/mdev > /proc/sys/kernel/hotplug" >> rcS                        || return 1
  65.     echo "mdev -s" >> rcS                                                            || return 1
  66.     echo "/sbin/ifconfig lo 127.0.0.1 up" >> rcS                                    || return 1
  67.     echo "/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo" >> rcS                || return 1
  68.     echo "/sbin/ifconfig eth0 192.168.2.56 netmask 255.255.255.0" >> rcS            || return 1
  69.     echo "/sbin/route add default gw 192.168.2.1" >> rcS                            || return 1
  70.     echo "echo \"*******************************************************\"" >> rcS    || return 1
  71.     echo "echo \"* Linux-2.6.34.4 YAFFS BOOT *\"" >> rcS    || return 1
  72.     echo "echo \"* yqliu29@163.com *\"" >> rcS    || return 1
  73.     echo "echo \"*******************************************************\"" >> rcS    || return 1
  74.     chmod +x rcS

  75.     cd ../..

  76.     return 0
  77. }

  78. buildHOME()
  79. {
  80.     echo "Build files in /home..."
  81.     cd home    || return 1
  82.     mkdir yqliu29    || return 1
  83.     cd yqliu29        || return 1
  84.     echo "yqliu29" > yqliu29 || return 1

  85.     cd ../..                || return 1
  86.     return 0
  87. }

  88. BUSY_BOX_ADDRESS=
  89. BUSY_BOX_VERSION=1.19.4

  90. buildBUSYBOX()
  91. {
  92.     echo "Build Busybox..."

  93.     cd .. || return 1

  94.     if [ ! -f busybox-$BUSY_BOX_VERSION.tar.bz2 ]
  95.     then
  96.         wget $BUSY_BOX_ADDRESS/busybox-$BUSY_BOX_VERSION.tar.bz2        || return 1
  97.     fi

  98.     if [ ! -d busybox-$BUSY_BOX_VERSION ]
  99.     then
  100.         tar xvf busybox-$BUSY_BOX_VERSION.tar.bz2                        || return 1
  101.     fi
  102.     
  103.     cd busybox-$BUSY_BOX_VERSION || return 1

  104.     OLD_MAKE_INFO=`grep 'CROSS_COMPILE ?=' Makefile`

  105.     if [ "$OLD_MAKE_INFO" == "CROSS_COMPILE ?=" ]
  106.     then
  107.         sed -i 's/CROSS_COMPILE ?=/CROSS_COMPILE ?= arm-none-linux-gnueabi-/' Makefile || return 1
  108.     fi

  109.     make defconfig    || return 1
  110.     make            || return 1
  111.     make install    || return 1

  112.     cp _install/* ../$ROOT_NAME -r || return 1

  113.     return 0
  114. }

  115. createROOT         || exit 1
  116. copyLIBS        || exit 1
  117. buildETC        || exit 1
  118. buildHOME        || exit 1
  119. buildBUSYBOX    || exit 1

  120. echo Build $ROOT_NAME finished normally!

阅读(2754) | 评论(0) | 转发(0) |
0

上一篇:DES加密算法的一种实现

下一篇:没有了

给主人留下些什么吧!~~