OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

190 lines
4.8 KiB

  1. #!/bin/bash
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: scripts/Create-PkgQueue
  6. # Copyright (C) 2006 - 2008 The OpenSDE Project
  7. # Copyright (C) 2004 - 2006 The T2 SDE Project
  8. # Copyright (C) 1998 - 2003 Clifford Wolf
  9. #
  10. # More information can be found in the files COPYING and README.
  11. #
  12. # This program is free software; you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; version 2 of the License. A copy of the
  15. # GNU General Public License can be found in the file COPYING.
  16. # --- SDE-COPYRIGHT-NOTE-END ---
  17. config=default
  18. logdir=
  19. single=0
  20. debug=0
  21. nobrokendeps=0
  22. while [ "$1" ] ; do
  23. case "$1" in
  24. -cfg)
  25. config=$2 ; shift ; shift ;;
  26. -single)
  27. single=1 ; shift ;;
  28. -logdir)
  29. logdir=$2 ; shift ; shift ;;
  30. -debug)
  31. debug=1 ; shift ;;
  32. -nobrokendeps)
  33. nobrokendeps=1 ; shift ;;
  34. *)
  35. echo "Usage: $0 [ -cfg config ] [ -single ] \\"
  36. echo " ${0//?/ } [ -logdir logdir ] [ -debug ]"
  37. exit 1 ;;
  38. esac
  39. done
  40. . ./lib/parse-config
  41. gawk '
  42. function check_package() {
  43. split(pkgline, a); dep=a[2];
  44. if ( a[1] != "X" || ! index(a[2], stagelevel) ) return;
  45. repository = a[4];
  46. package = a[5];
  47. logfile = logfile_tpl;
  48. gsub("<stagelevel>", stagelevel, logfile);
  49. gsub("<repository>", repository, logfile);
  50. gsub("<package>", package, logfile);
  51. errfile = logfile; outfile = logfile;
  52. gsub("<log>", "log", logfile);
  53. gsub("<log>", "err", errfile);
  54. gsub("<log>", "out", outfile);
  55. if ( (getline dummy < logfile == -1) &&
  56. (getline dummy < errfile == -1) ) {
  57. build_this_package = 1;
  58. found_dependencies = 0;
  59. buildtime = 60;
  60. priority = 0;
  61. if ( getline dummy < outfile != -1 )
  62. build_this_package = 0;
  63. if ( index(not_present, " " package " ") ) {
  64. if (debug && build_this_package)
  65. print "DEBUG: Not building " stagelevel "-" \
  66. package ": earlier stages not done " \
  67. "for this package."
  68. build_this_package = 0;
  69. }
  70. if ( build_this_package && (package in database) ) {
  71. split(database[package], a);
  72. buildtime = a[2];
  73. priority = a[3];
  74. for (c in a) {
  75. # if ( a[c] == package ) continue;
  76. # if ( strtonum(c) <= 3 ) continue;
  77. if (debug && 0)
  78. print "DEBUG: Checking " stagelevel \
  79. "-" package ": needs " a[c];
  80. if ( index(not_present, " " a[c] " ") &&
  81. stagelevel != stage9_no_deps ) {
  82. if (debug && build_this_package)
  83. print "DEBUG: Not building " \
  84. stagelevel "-" package \
  85. ": " a[c] " is missing";
  86. build_this_package=0;
  87. }
  88. found_dependencies = 1;
  89. }
  90. }
  91. # Do not build packages parallel in stage 0
  92. #
  93. if ( stagelevel == 0 && not_present != "")
  94. build_this_package = 0;
  95. # Do not build packages from stages > 0 if packages
  96. # from stage 0 are still missing
  97. #
  98. if ( stagelevel == 0 )
  99. stage0_not_present=1;
  100. if ( stagelevel > 0 && stage0_not_present )
  101. build_this_package = 0;
  102. # Do not build packages from stages >= 2 if packages
  103. # from stages <= 1 are not build already.
  104. #
  105. if ( stagelevel <= 1 )
  106. stage01_not_present=1;
  107. if ( stagelevel >= 2 && stage01_not_present )
  108. build_this_package = 0;
  109. # Only ignore deps in stage 9 if everything < stage 9
  110. # is already there
  111. if ( stagelevel < 9 )
  112. stage9_no_deps = "x";
  113. # A packages without dependencies automatically depend
  114. # on all packages build before it
  115. if (found_dependencies == 0 && not_present != "" &&
  116. stagelevel != stage9_no_deps)
  117. build_this_package = 0;
  118. # sde-debug must be build _after_ all other packages
  119. if (package == "sde-debug" && not_present != "")
  120. build_this_package = 0;
  121. if (build_this_package) {
  122. sub("^X ", priority " ", pkgline);
  123. sub(" 0$", " " buildtime, pkgline);
  124. print stagelevel, pkgline;
  125. if (single) exit 0;
  126. }
  127. not_present = not_present " " package " ";
  128. }
  129. else
  130. if ( nobrokendeps )
  131. {
  132. close(errfile);
  133. if ( (getline dummy < errfile != -1) ) {
  134. not_present = not_present " " package " ";
  135. }
  136. }
  137. close(logfile); # ignore errors here if we
  138. close(errfile); # did not open this files
  139. close(outfile);
  140. close(depfile);
  141. }
  142. BEGIN {
  143. not_present="";
  144. stage0_not_present=0;
  145. stage01_not_present=0;
  146. stage9_no_deps=9;
  147. nobrokendeps='$nobrokendeps';
  148. config="'$config'"; single='$single'; debug='$debug';
  149. logdir="'"${logdir:-build/$SDECFG_ID/var/adm/logs}"'";
  150. logfile_tpl = logdir "/<stagelevel>-<package>.<log>";
  151. #depdb_file = "scripts/dep_db.txt";
  152. packages_file = "config/" config "/packages";
  153. #while ( (getline depline < depdb_file) > 0 )
  154. # { $0 = depline; sub(/:/, "", $1); database[$1]=$0; }
  155. #close(depdb_file);
  156. for (stagelevel=0; stagelevel<=9; stagelevel++) {
  157. while ( (getline pkgline < packages_file) > 0 ) {
  158. check_package();
  159. }
  160. close(packages_file);
  161. }
  162. }
  163. '