package_distrib.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. #!/bin/sh
  2. ## Copyright (c) 2014 Minoca Corp.
  3. ##
  4. ## This file is licensed under the terms of the GNU General Public License
  5. ## version 3. Alternative licensing terms are available. Contact
  6. ## info@minocacorp.com for details. See the LICENSE file at the root of this
  7. ## project for complete licensing information..
  8. ##
  9. ## Script Name:
  10. ##
  11. ## package_distrib.sh
  12. ##
  13. ## Abstract:
  14. ##
  15. ## This script creates the final distributable archives based on the latest
  16. ## build.
  17. ##
  18. ## Author:
  19. ##
  20. ## Evan Green 10-Nov-2014
  21. ##
  22. ## Environment:
  23. ##
  24. ## Minoca (Windows) Build
  25. ##
  26. set -xe
  27. SAVE_IFS="$IFS"
  28. IFS='
  29. '
  30. export SRCROOT=`echo $SRCROOT | sed 's_\\\\_/_g'`
  31. IFS="$SAVE_IFS"
  32. unset SAVE_IFS
  33. if test -z $SRCROOT; then
  34. echo "SRCROOT must be set."
  35. exit 1
  36. fi
  37. if test -z $ARCH; then
  38. echo "ARCH must be set."
  39. exit 1
  40. fi
  41. if test -z $DEBUG; then
  42. echo "DEBUG must be set."
  43. exit 1
  44. fi
  45. export TMPDIR=$PWD
  46. export TEMP=$TMPDIR
  47. OUTROOT="$SRCROOT/$ARCH$VARIANT$DEBUG"
  48. export PATH="$SRCROOT/tools/win32/mingw/bin;$OUTROOT/tools/bin;$OUTROOT/testbin;$SRCROOT/tools/win32/scripts;$SRCROOT/tools/win32/swiss;$SRCROOT/tools/win32/bin;$SRCROOT/tools/win32/ppython/app;$SRCROOT/tools/win32/ppython/App/Scripts;$PATH"
  49. ##
  50. ## Download the latest build.
  51. ##
  52. if ! test -d ./bin; then
  53. barch=$ARCH$VARIANT
  54. last_native_build=`python ../../client.py --query "Native Pilot $barch"`
  55. if test -z $last_native_build; then
  56. echo "Error: Failed to get last Native Pilot $barch build."
  57. exit 1
  58. fi
  59. file=minoca-bin-$ARCH$VARIANT$DEBUG.tar.gz
  60. echo "Downloading $file from schedule instance ID $last_native_build"
  61. python ../../client.py --pull schedule $file $file $last_native_build
  62. echo "Extracting $file"
  63. tar -xzf $file || echo "Ignoring failures from tar."
  64. fi
  65. if ! test -d ./bin; then
  66. ls -la
  67. pwd
  68. echo "Error: missing bin directory."
  69. exit 1
  70. fi
  71. ##
  72. ## Copy the original bin directory.
  73. ##
  74. if ! test -d "$OUTROOT"; then
  75. mkdir -p "$OUTROOT"
  76. fi
  77. BINROOT="$OUTROOT/bin"
  78. SAVED_BINROOT="$OUTROOT/bin.orig"
  79. if test -d "$BINROOT"; then
  80. if test -d "$SAVED_BINROOT"; then
  81. echo "Removing previous $SAVED_BINROOT."
  82. rm -rf "$SAVED_BINROOT"
  83. fi
  84. echo "Moving original binroot to $SAVED_BINROOT"
  85. mv -f "$BINROOT" "$SAVED_BINROOT"
  86. fi
  87. ##
  88. ## Move the extracted binroot into place.
  89. ##
  90. mv ./bin "$BINROOT"
  91. ##
  92. ## Copy the debugger files from x86.
  93. ##
  94. DEBUGROOT="$SRCROOT/x86$DEBUG/tools/bin"
  95. for file in debugui.exe debug.exe kexts.dll msetup.exe; do
  96. cp -v $DEBUGROOT/$file "$BINROOT" || true;
  97. done
  98. ##
  99. ## Prepare the production upload.
  100. ##
  101. . "$SRCROOT/os/tasks/distrib/upload.sh"
  102. prepare_for_upload
  103. ##
  104. ## Build the distribution files.
  105. ##
  106. ORIGINAL_DIRECTORY=`pwd`
  107. cd "$BINROOT"
  108. if test "$ARCH$VARIANT" = "x86"; then
  109. echo "Running gen_bin.sh"
  110. sh "$SRCROOT/os/tasks/distrib/gen_bin.sh"
  111. fi
  112. echo "Running gen_plats.sh"
  113. . "$SRCROOT/os/tasks/distrib/gen_plats.sh"
  114. echo "Running gen_syms.sh"
  115. sh "$SRCROOT/os/tasks/distrib/gen_syms.sh"
  116. echo "Running gen_inst.sh"
  117. sh "$SRCROOT/os/tasks/distrib/gen_inst.sh"
  118. cd "$ORIGINAL_DIRECTORY"
  119. echo "Running upload_packages.sh"
  120. . "$SRCROOT/os/tasks/distrib/upload_packages.sh"
  121. update_production_latest "$ARCH$VARIANT"
  122. ##
  123. ## Upload the files.
  124. ##
  125. cd "$BINROOT"
  126. if test "$ARCH$VARIANT" = "x86"; then
  127. REVISION=`cat $BINROOT/build-revision`
  128. file=MinocaOS-Starter-$REVISION.zip
  129. file_size=`ls -l $file | \
  130. sed -n 's/[^ ]* *[^ ]* *[^ ]* *[^ ]* *\([0123456789]*\).*/\1/p'`
  131. if test -n "$MBUILD_STEP_ID"; then
  132. python $SRCROOT/client.py --result "MinocaOS Size" integer "$file_size"
  133. python $SRCROOT/client.py --upload schedule $file $file
  134. echo Uploaded file $file, size $file_size
  135. fi
  136. fi
  137. ##
  138. ## Remove the original binroot.
  139. ##
  140. cd "$ORIGINAL_DIRECTORY"
  141. if test -d "$SAVED_BINROOT"; then
  142. echo "Removing original BINROOT."
  143. rm -rf "$SAVED_BINROOT"
  144. fi
  145. echo "Completed generating distributables."
  146. exit 0