package_distrib.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. #!/bin/sh
  2. ## Copyright (c) 2014 Minoca Corp. All Rights Reserved.
  3. ##
  4. ## Script Name:
  5. ##
  6. ## package_distrib.sh
  7. ##
  8. ## Abstract:
  9. ##
  10. ## This script creates the final distributable archives based on the latest
  11. ## build.
  12. ##
  13. ## Author:
  14. ##
  15. ## Evan Green 10-Nov-2014
  16. ##
  17. ## Environment:
  18. ##
  19. ## Minoca (Windows) Build
  20. ##
  21. set -e
  22. SAVE_IFS="$IFS"
  23. IFS='
  24. '
  25. export SRCROOT=`echo $SRCROOT | sed 's_\\\\_/_g'`
  26. IFS="$SAVE_IFS"
  27. unset SAVE_IFS
  28. if test -z $SRCROOT; then
  29. echo "SRCROOT must be set."
  30. exit 1
  31. fi
  32. if test -z $ARCH; then
  33. echo "ARCH must be set."
  34. exit 1
  35. fi
  36. if test -z $DEBUG; then
  37. echo "DEBUG must be set."
  38. exit 1
  39. fi
  40. export TMPDIR=$PWD
  41. export TEMP=$TMPDIR
  42. OUTROOT="$SRCROOT/$ARCH$VARIANT$DEBUG"
  43. export PATH="$SRCROOT/tools/win32/mingw/bin;$SRCROOT/tools;$OUTROOT/bin;$OUTROOT/testbin;$OUTROOT/bin/tools/bin;$SRCROOT/tools/win32/scripts;$SRCROOT/tools/win32/swiss;$SRCROOT/tools/win32/bin;$SRCROOT/tools/win32/ppython/app;$SRCROOT/tools/win32/ppython/App/Scripts;$PATH"
  44. ##
  45. ## Download the latest build.
  46. ##
  47. if ! test -d ./bin; then
  48. barch=$ARCH$VARIANT
  49. last_native_build=`python ../../client.py --query "Native Pilot $barch"`
  50. if test -z $last_native_build; then
  51. echo "Error: Failed to get last Native Pilot $barch build."
  52. exit 1
  53. fi
  54. file=minoca-bin-$ARCH$VARIANT$DEBUG.tar.gz
  55. echo "Downloading $file from schedule instance ID $last_native_build"
  56. python ../../client.py --pull $file $file $last_native_build
  57. echo "Extracting $file"
  58. tar -xzf $file || echo "Ignoring failures from tar."
  59. fi
  60. if ! test -d ./bin; then
  61. ls -la
  62. pwd
  63. echo "Error: missing bin directory."
  64. exit 1
  65. fi
  66. ##
  67. ## Copy the original bin directory.
  68. ##
  69. if ! test -d "$OUTROOT"; then
  70. mkdir -p "$OUTROOT"
  71. fi
  72. BINROOT="$OUTROOT/bin"
  73. SAVED_BINROOT="$OUTROOT/bin.orig"
  74. if test -d "$BINROOT"; then
  75. if test -d "$SAVED_BINROOT"; then
  76. echo "Removing previous $SAVED_BINROOT."
  77. rm -rf "$SAVED_BINROOT"
  78. fi
  79. echo "Moving original binroot to $SAVED_BINROOT"
  80. mv -f "$BINROOT" "$SAVED_BINROOT"
  81. fi
  82. ##
  83. ## Move the extracted binroot into place.
  84. ##
  85. mv ./bin "$BINROOT"
  86. ##
  87. ## Copy the tools back in.
  88. ##
  89. if [ -d "$SAVED_BINROOT/tools" ] ; then
  90. cp -rp "$SAVED_BINROOT/tools" "$BINROOT/"
  91. fi
  92. ##
  93. ## Copy the debugger files from x86.
  94. ##
  95. DEBUGROOT="$SRCROOT/x86$DEBUG/bin"
  96. if test "x$ARCH$VARIANT" = "xx86"; then
  97. DEBUGROOT="$SAVED_BINROOT"
  98. fi
  99. for file in debugui.exe debug.exe kexts.dll dbgext.a msetup_build.exe; do
  100. cp -v $DEBUGROOT/$file "$BINROOT/"
  101. done
  102. ##
  103. ## Build the distribution files.
  104. ##
  105. ORIGINAL_DIRECTORY=`pwd`
  106. cd "$BINROOT"
  107. if test "$ARCH$VARIANT" = "x86"; then
  108. echo "Running gen_bin.sh"
  109. sh "$SRCROOT/os/tasks/distrib/gen_bin.sh"
  110. echo "Running gen_sdk.sh"
  111. sh "$SRCROOT/os/tasks/distrib/gen_sdk.sh"
  112. echo "Running gen_tp.sh"
  113. sh "$SRCROOT/os/tasks/distrib/gen_tp.sh"
  114. fi
  115. echo "Running gen_plats.sh"
  116. sh "$SRCROOT/os/tasks/distrib/gen_plats.sh"
  117. echo "Running gen_syms.sh"
  118. sh "$SRCROOT/os/tasks/distrib/gen_syms.sh"
  119. echo "Running gen_inst.sh"
  120. sh "$SRCROOT/os/tasks/distrib/gen_inst.sh"
  121. ##
  122. ## Upload the files.
  123. ##
  124. if test "$ARCH$VARIANT" = "x86"; then
  125. REVISION=`cat $BINROOT/build-revision`
  126. file=MinocaOS-Starter-$REVISION.zip
  127. file_size=`ls -l $file | \
  128. sed -n 's/[^ ]* *[^ ]* *[^ ]* *[^ ]* *\([0123456789]*\).*/\1/p'`
  129. if test -n "$MBUILD_STEP_ID"; then
  130. python $SRCROOT/client.py --result "MinocaOS Size" integer "$file_size"
  131. python $SRCROOT/client.py --upload schedule $file $file
  132. echo Uploaded file $file, size $file_size
  133. fi
  134. ##
  135. ## The SDK includes all architectures.
  136. ##
  137. file=MinocaSDK-$REVISION.zip
  138. file_size=`ls -l $file | \
  139. sed -n 's/[^ ]* *[^ ]* *[^ ]* *[^ ]* *\([0123456789]*\).*/\1/p'`
  140. if test -n "$MBUILD_STEP_ID"; then
  141. python $SRCROOT/client.py --result "MinocaSDK Size" integer "$file_size"
  142. python $SRCROOT/client.py --upload schedule $file $file
  143. echo Uploaded file $file, size $file_size
  144. fi
  145. ##
  146. ## Third-party is just source, so the architecture is irrelevant and
  147. ## therefore unspecified.
  148. ##
  149. file=MinocaTP-$REVISION.zip
  150. file_size=`ls -l $file | \
  151. sed -n 's/[^ ]* *[^ ]* *[^ ]* *[^ ]* *\([0123456789]*\).*/\1/p'`
  152. if test -n "$MBUILD_STEP_ID"; then
  153. python $SRCROOT/client.py --result "MinocaTP Size" integer "$file_size"
  154. python $SRCROOT/client.py --upload schedule $file $file
  155. echo Uploaded file $file, size $file_size
  156. fi
  157. fi
  158. ##
  159. ## Remove the original binroot.
  160. ##
  161. cd "$ORIGINAL_DIRECTORY"
  162. if test -d "$SAVED_BINROOT"; then
  163. echo "Removing original BINROOT."
  164. rm -rf "$SAVED_BINROOT"
  165. fi
  166. echo "Completed generating distributables."
  167. exit 0