daily pastebin goal
44%
SHARE
TWEET

ESXi 5.0 Build Environment Setup Script

robertgraham1906 Nov 10th, 2013 924 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. ###############################################################################
  4. ## Contact Information:
  5. ## Robert Graham <robertgraham1906@gmail.com>
  6. ###############################################################################
  7. ### VMware ESXi 5.0.0u2 Build Environment Setup Script
  8. ### https://my.vmware.com/web/vmware/details?productId=229&downloadGroup=VSPHERE50U2_OSS
  9. ###############################################################################
  10.  
  11. VMWARE_FOLDER=$HOME/vmware-esxi-5.0
  12. BUILD_FOLDER=$PWD
  13.  
  14. # Verify Root
  15. if [ "$(id -u)" -ne "0" ]
  16. then
  17.    echo "ERROR: This should be run as root"
  18.    exit 1
  19. fi
  20.  
  21. if [ -z "$1" ] || [ -n "$2" ]
  22. then
  23.    echo "ERROR: incorrect input params"
  24.    echo "$(basename $0) <path_to_vmkernel_source_tarball>"
  25.    exit 1
  26. fi
  27.  
  28. VMWARE_FILE="$1"
  29.  
  30. if [ ! -f $VMWARE_FILE ]
  31. then
  32.    echo "ERROR: Missing $VMWARE_FILE"
  33.    exit 1
  34. fi
  35.  
  36. # Download required packages
  37.  
  38. echo "Checking for required packages ..."
  39.  
  40. # Check Distro Type
  41. if [ -f /etc/debian_version ]
  42. then
  43.    OS=deb
  44.    echo "Querying for required packages ..."
  45.    dpkg -l build-essential rpm2cpio ncurses-dev flex bison
  46.    if [ $? -ne 0 ]
  47.    then
  48.       echo "ERROR: missing one or more required packages."
  49.       echo "Required: build-essential rpm2cpio ncurses-dev flex bison"
  50.       exit
  51.    fi
  52. elif [ -f /etc/redhat-release ]
  53. then
  54.    OS=rpm
  55.    echo "Installing required packages ..."
  56.    if [ ! -n "$(yum list installed | grep 'rpm\.')" ] \
  57.       || [ ! -n "$(yum list installed | grep 'ncurses-devel\.')" ] \
  58.       || [ ! -n "$(yum list installed | grep 'flex\.')" ] \
  59.       || [ ! -n "$(yum list installed | grep 'bison\.')" ] \
  60.       || [ ! -n "$(yum list installed | grep 'kernel-devel\.')" ] \
  61.       || [ ! -n "$(yum list installed | grep 'rpm-build\.')" ]
  62.    then
  63.       echo "ERROR: missing one or more required packages."
  64.       echo "Required: rpm ncurses-devel flex bison kernel-devel rpm-build"
  65.       exit 1
  66.    fi
  67. else
  68.   echo "ERROR: Unable to determine distro type [deb or rpm]"
  69.   exit 1
  70. fi
  71.  
  72. # Delete vmware esxi folder
  73. if [ -d $VMWARE_FOLDER ]
  74. then
  75.    rm -rf $VMWARE_FOLDER
  76. fi
  77.  
  78. # Build/Install Texinfo 4.9
  79. echo "Downloading and installing Texinfo 4.9 (Required) ..."
  80.  
  81. mkdir -p $VMWARE_FOLDER/texinfo
  82. cd $VMWARE_FOLDER/texinfo
  83. wget http://ftp.gnu.org/gnu/texinfo/texinfo-4.9.tar.gz > /dev/null
  84. tar zxvf texinfo-4.9.tar.gz > /dev/null || \
  85.    { echo "ERROR: texinfo-4.9.tar.gz does not exist" ; exit 1 ; }
  86. cd texinfo-4.9
  87. ./configure
  88. make > /dev/null
  89. make install
  90. cd ../
  91.  
  92. # Create output folders
  93.  
  94. mkdir -p $VMWARE_FOLDER/vsphere
  95. mkdir -p $VMWARE_FOLDER/toolchain
  96.  
  97. cd $VMWARE_FOLDER/vsphere
  98.  
  99. # Extract VMware ESXI source code
  100. echo "Extracting VMware ESXi Source Code ..."
  101. tar -zxvf $VMWARE_FILE > /dev/null || \
  102.    { echo "ERROR: VMware open source file does not exist" ; exit 1 ; }
  103.  
  104. # Update glibc 2.3.2-95
  105.  
  106. echo "Building glibc 2.3.2-95 ..."
  107.  
  108. cd vmkdrivers-gpl || \
  109.    { echo "ERROR: folder does not exist" ; exit 1 ; }
  110. cd glibc-2.3.2-95.44 || \
  111.    { echo "ERROR: folder does not exist" ; exit 1 ; }
  112.  
  113. grep -rl "TROOT=/build/toolchain" . \
  114.    | xargs sed -i "s@TROOT=/build/toolchain@TROOT=$VMWARE_FOLDER/toolchain@g"
  115.  
  116. bash BUILD.txt > /dev/null
  117. if [ $? -ne 0 ]
  118. then
  119.    echo "ERROR: $PWD/BUILD.txt failed"
  120.    exit 1
  121. fi
  122.  
  123. # Refresh the Environment, as makeinfo and glibc were built manually
  124. echo "Refreshing environment by running commands in new shell"
  125.  
  126. exec su - $USER << EOF
  127.  
  128. cd $VMWARE_FOLDER/vsphere/vmkdrivers-gpl
  129.  
  130.  
  131. # Build binutils-2.17.50.0.15-modcall
  132.  
  133. echo "Building binutils-2.17.50.0.15-modcall ..."
  134.  
  135. cd binutils-2.17.50.0.15-modcall || \
  136.    { echo "ERROR: folder does not exist" ; exit 1 ; }
  137.  
  138. grep -rl "TROOT=/build/toolchain" . \
  139.    | xargs sed -i "s@TROOT=/build/toolchain@TROOT=$VMWARE_FOLDER/toolchain@g"
  140.  
  141.  
  142. export CFLAGS="-w"
  143.  
  144. bash BUILD.txt > /dev/null
  145. if [ $? -ne 0 ]
  146. then
  147.    echo "ERROR: $PWD/BUILD.txt failed"
  148.    exit 1
  149. fi
  150.  
  151. cd ../
  152.  
  153. # Build GCC 4.1.2-9
  154.  
  155. echo "Building GCC 4.1.2-9 ..."
  156.  
  157. cd gcc-4.1.2-9 || { echo "ERROR: folder does not exist" ; exit 1 ; }
  158.  
  159. grep -rl "TROOT=/build/toolchain" . \
  160.    | xargs sed -i "s@TROOT=/build/toolchain@TROOT=$VMWARE_FOLDER/toolchain@g"
  161.  
  162. export CFLAGS=""
  163.  
  164. bash BUILD.txt > /dev/null
  165. if [ $? -ne 0 ]
  166. then
  167.    echo "ERROR: $PWD/BUILD.txt failed"
  168.    exit 1
  169. fi
  170.  
  171. cd ../
  172.  
  173. # Build ESXi 5.0 Drivers (OPTIONAL)
  174.    
  175. echo "Building ESXi 5.0 Drivers ..."
  176.    
  177. tar zxvf vmkdrivers-gpl.tgz || \
  178. { echo "ERROR: vmkdrivers-gpl.tgz file dne\n" ; exit 1 ; }
  179.    
  180. grep -rl "CC=/build/toolchain" . \
  181. | xargs sed -i "s@CC=/build/toolchain@CC=$VMWARE_FOLDER/toolchain@g"
  182. grep -rl "LD=/build/toolchain" . \
  183. | xargs sed -i "s@LD=/build/toolchain@LD=$VMWARE_FOLDER/toolchain@g"
  184.    
  185. ./build-vmkdrivers.sh
  186. if [ $? -ne 0 ]
  187.    then
  188.    echo "ERROR: $PWD/build-vmkdrivers.sh failed"
  189.    exit 1
  190. fi
  191.  
  192. echo "VMware ESXi 5.0 kernel source output to $VMWARE_FOLDER"
  193.  
  194. EOF
  195.  
  196. if [ $? -ne 0 ]
  197. then
  198.    exit 1
  199. else
  200.    exit 0
  201. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top