mirror of the now-defunct rocklinux.org
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.

203 lines
5.3 KiB

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