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.

188 lines
5.0 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/Emerge-Pkg
  11. # ROCK Linux is Copyright (C) 1998 - 2003 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. exec 2>&1
  25. options=''
  26. config=default
  27. builddep=0
  28. debug=0
  29. ignore_chksum=0
  30. update=1
  31. recursive=0
  32. #
  33. # ---- Functions
  34. #
  35. . scripts/functions
  36. help_msg() {
  37. spacer=" "
  38. echo
  39. echo "Usage: ./scripts/Emerge-Pkg" \
  40. "[ -cfg <config> ] [ -dep ]"
  41. echo "$spacer [ -recursive ] [ -noupdate ] [ -debug ] pkg-name(s)"
  42. echo
  43. echo "Type './scripts/Help Emerge-Pkg' for details."
  44. echo
  45. }
  46. dep4pkg()
  47. {
  48. grep "$1:" scripts/dep_db.txt | cut -d ' ' -f 4-
  49. }
  50. fill_deplist()
  51. {
  52. local addlist=''
  53. echo "Parsing dependencies for $1"
  54. for package in `dep4pkg $1` ; do
  55. # make sure it is a valid package (and not a group)
  56. if [ "`echo $alllist | grep +$package+`" = "" ] ; then
  57. [ $debug = 1 ] && \
  58. echo " $package: not in target configuration (e.g. meta flag) - skipped."
  59. continue
  60. fi
  61. if [ "`echo $deplist | grep +$package+`" ] ; then
  62. [ $debug = 1 ] && \
  63. echo " $package: allready processed - skipped."
  64. continue
  65. fi
  66. confdir=""
  67. for x in package/* ; do
  68. if [ -d "$x/$package" ] ; then
  69. if [ "$confdir" ] ; then confdir=X
  70. else confdir="$x/$package" ; fi
  71. fi
  72. done
  73. if [ -z "$confdir" ] ; then
  74. [ $debug = 1 ] && \
  75. echo " $package: No such package."
  76. elif [ "$confdir" = X ] ; then
  77. [ $debug = 1 ] && \
  78. echo " $package: Package in multiple trees."
  79. elif [ ! -f /var/adm/packages/$package ] ; then
  80. [ $debug = 1 ] && \
  81. echo " $package: Not installed."
  82. addlist="$addlist $package"
  83. else
  84. o_ver=$(grep '^Package Name and Version' \
  85. /var/adm/packages/$package | cut -f6 -d' ')
  86. n_ver=$(grep '^\[V\] ' $confdir/$package.desc | cut -f2 -d' ')
  87. if [ "$o_ver" != "$n_ver" -a "$n_ver" != "0000" ] ; then
  88. [ $debug = 1 ] && \
  89. echo " $package: New version ($o_ver -> $n_ver)."
  90. addlist="$addlist $package"
  91. else
  92. if [ $ignore_chksum = 0 ] ; then
  93. o_ck=$(grep '^ROCK Linux Package Source Checksum' \
  94. /var/adm/packages/$package | cut -f6 -d' ')
  95. n_ck=$(md5sum package/*/$package/* 2> /dev/null | \
  96. grep -v '\.cache$' | md5sum | cut -f1 -d' ')
  97. if [ "$o_ck" != "$n_ck" ] ; then
  98. [ $debug = 1 ] && \
  99. echo " $package: New source checksum ($n_ck)."
  100. addlist="$addlist $package"
  101. else
  102. if [ -f /var/adm/cache/$package ] ; then
  103. if ! grep -q BUILDTIME /var/adm/cache/$package ; then
  104. [ $debug = 1 ] && \
  105. echo " $package: Former build was broken."
  106. addlist="$addlist $package"
  107. fi
  108. else
  109. [ $debug = 1 ] && \
  110. echo " $package: Equal source checksum ($n_ck), skipped."
  111. fi
  112. fi
  113. fi
  114. fi
  115. fi
  116. done
  117. for package in $addlist ; do
  118. deplist="$deplist +$package+"
  119. done
  120. if [ $recursive = 1 ] ; then
  121. for package in $addlist ; do
  122. fill_deplist $package
  123. done
  124. fi
  125. }
  126. #
  127. # ---- Parse options + config
  128. #
  129. while [ "$1" ] ; do
  130. case "$1" in
  131. -cfg) options="$options $1 $2" ; config="$2" ; shift ;;
  132. -debug) debug=1 ;;
  133. -dep) builddep=1 ;;
  134. -noupdate) update=0 ;;
  135. -recursive) recursive=1 ;;
  136. -*) help_msg ; exit 1 ;;
  137. *) break ;;
  138. esac
  139. shift
  140. done
  141. . ./scripts/parse-config
  142. deplist=''
  143. alllist=`./scripts/Create-PkgList $arch | grep ^X | cut -d ' ' -f 5 | \
  144. sed -e 's/$/+/' -e 's/^/+/'`
  145. if [ $builddep = 1 ] ; then
  146. # build a complete dependency graph
  147. fill_deplist $1
  148. else
  149. deplist=$1
  150. fi
  151. echo "Packages scheduled to build: $deplist"
  152. # the deplist is quite unsorted (in alphabetically sorted chunks)
  153. # so we need to work arround this here ...
  154. [ $update = 1 ] && options="$options -update"
  155. for package in $alllist ; do
  156. if [ "`echo $deplist | grep $package`" ] ; then
  157. package="` echo $package | sed -e s/^+// -e s/+$//`"
  158. ./scripts/Download -package $package
  159. ./scripts/Build-Pkg $options $package
  160. fi
  161. done