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.

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