Chinaunix首页 | 论坛 | 博客
  • 博客访问: 138698
  • 博文数量: 20
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 247
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-12 22:24
个人简介

学霸

文章分类

全部博文(20)

文章存档

2016年(1)

2015年(11)

2014年(8)

我的朋友

分类: LINUX

2015-07-21 15:30:29

点击(此处)折叠或打开

  1. #!/bin/sh

  2. #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
  3. # build scripts for source
  4. #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#



  5. usage()
  6. {
  7.    cat<<HELP

  8.        $ `basename $0` [--release] [--preboot] [--boss]
  9.        Used to compile binary for current platform.
  10.     
  11.        $ `basename $0`
  12.          --release build release version(default debug version)
  13. HELP
  14. }

  15. #Parse the arguments passed to the script and set up global booleans
  16. parse_command_line() {
  17.     echo argc: $#, argv: $@
  18.     while [ $# -gt 0 ]
  19.     do
  20.         ARG=`echo $1 | tr '[:upper:]' '[:lower:]'`
  21.         shift
  22.         if [ $ARG == "--help" ] || [ $ARG == "-h" ]
  23.         then
  24.             usage
  25.             exit 0
  26.         elif [ $ARG == "--release" ]
  27.         then
  28.             echo specify to build release version
  29.             build_type="release"
  30.         fi
  31.     done
  32. }


  33. ## get compile OS name & version
  34. detect_os_type() {
  35.     if 'which xlsb_release >/dev/null 2>&1'; then
  36.         os=`lsb_release -i | awk '{print $3}' | tr "[:upper:]" "[:lower:]"`
  37.         version=`lsb_release -r | awk '{print $2}' | cut -d. -f1`
  38.     else
  39.         os=`find /etc -iregex '/etc/\(suse\|redhat\)-release' 2>/dev/null | xargs head -1 | tr "[:upper:]" "[:lower:]"`
  40.         version=`echo ${os} | awk '{split($0, a); print a[length(a)-1];}' | cut -d. -f1`
  41.     fi

  42.     case $os in
  43.     red*)
  44.         osname="rhel"$version
  45.         ;;
  46.     suse*)
  47.         osname="sles"$version
  48.         ;;
  49.     *)
  50.         echo "unknown compile os"
  51.         osname="unknown"
  52.         ;;
  53.     esac
  54.     
  55.     osname_upper=`echo $osname | tr "[:lower:]" "[:upper:]"`
  56.     arch=`uname -m | sed 's/686/386/g'`
  57.     
  58.     echo get os name as $osname, arch as $arch,version as $version
  59. }


  60. ## ................... start main ................ ##

  61. #init enviroment
  62. #if -z, Whether a variable has a value,detail in
  63. if [ -z $BUILDNUMBER ]; then
  64. ## You can change build_number to correct value here
  65.     build_number=unknown
  66. else
  67.     build_number=$BUILDNUMBER
  68. fi

  69. #parser parameter
  70. parse_command_line $@

  71. #get system information
  72. detect_os_type

  73. exit 0
compile_linux.zip   attachment_if.zip
阅读(1866) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~