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.

270 lines
8.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/Config
  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. if [ -z "${lines:=$LINES}" -o -z "${columns:=$COLUMNS}" ] ; then
  25. if [ "$( type -p stty )" ] ; then
  26. lines="$( stty size 2> /dev/null | cut -d' ' -f1 )"
  27. columns="$( stty size 2> /dev/null | cut -d' ' -f2 )"
  28. fi
  29. [ -z "$lines" -o "$lines" -le 0 ] 2> /dev/null && lines=24
  30. [ -z "$columns" -o "$columns" -le 0 ] 2> /dev/null && columns=80
  31. fi
  32. eval "$(egrep '^rockver=' scripts/parse-config)"
  33. config=default
  34. do_config_cycle=0
  35. delete_mode=0
  36. oldconfig=''
  37. nobashmod=''
  38. profile=""
  39. while [ "$1" ] ; do
  40. case "$1" in
  41. -cycle) do_config_cycle=1 ; shift ;;
  42. -delete) delete_mode=1 ; shift ;;
  43. -profile) profile='-profile' ; shift ;;
  44. -oldconfig) oldconfig='-oldconfig' ; shift ;;
  45. -nobashmod) nobashmod='-nobashmod' ; shift ;;
  46. -cfg) config="$2" ; shift ; shift ;;
  47. *)
  48. echo
  49. echo "Usage: $0 [ -delete | -oldconfig ] [ -cfg <config> ]"
  50. echo
  51. echo "Other options:"
  52. echo " -profile create a config.profile with profiling data"
  53. echo " -nobashmod don't use the bash config helper plugin"
  54. echo
  55. exit 1 ;;
  56. esac
  57. done
  58. if [ $delete_mode = 1 ] ; then
  59. rm -rv config/$config
  60. exit $?
  61. fi
  62. if [ $do_config_cycle = 0 ] ; then
  63. rm -f config.data config.dialog config.out config.help
  64. rm -f config.pcache.data config.pcache.cmd
  65. rm -f rockdialog.scrltmp # src/rockdialog.bin
  66. mkdir -p src
  67. if [ -z "$oldconfig" -a ! -f src/rockdialog.bin ] ; then
  68. echo "Creating rockdialog tool."
  69. command="gcc misc/rockdialog/*.c `
  70. `-Imisc/rockdialog -lncurses -o src/rockdialog.bin"
  71. echo "$command" ; eval "$command.$$"
  72. mv src/rockdialog.bin.$$ src/rockdialog.bin
  73. fi
  74. echo "Creating configuration script."
  75. cat << "EOT" > src/rockconfig.awk.$$
  76. #!/usr/bin/awk -f
  77. FNR == 1 {
  78. if ( lastfile ) {
  79. print "### END of " lastfile;
  80. }
  81. print "### BEGIN of " FILENAME;
  82. lastfile = FILENAME;
  83. }
  84. END {
  85. print "### END of " FILENAME;
  86. }
  87. $1 == "%include" {
  88. $1 = "awk -f src/rockconfig.awk";
  89. system($0);
  90. next;
  91. }
  92. $1 == "#" { next; }
  93. { print; }
  94. EOT
  95. mv src/rockconfig.awk.$$ src/rockconfig.awk
  96. awk -f src/rockconfig.awk scripts/config.in > src/rockconfig.in.$$ 2> /dev/null
  97. mv src/rockconfig.in.$$ src/rockconfig.in
  98. echo "Running ROCK Linux $rockver configuration ..."
  99. while "$0" -cfg $config $oldconfig $profile $nobashmod -cycle ; do : ; done
  100. exit 0
  101. fi
  102. if [ -z "$nobashmod" ]; then
  103. if [ ! -f src/config_helper.so -o misc/tools-source/config_helper.c -nt src/config_helper.so ]; then
  104. echo "Building src/config_helper.so."
  105. gcc -shared -fPIC -Wall -o src/config_helper.so misc/tools-source/config_helper.c || exit 1
  106. fi
  107. enable -f src/config_helper.so cfghlp || exit 1
  108. fi
  109. if [ -z "$profile" ]; then
  110. bprof() { :; }
  111. bprof_print() { :; }
  112. else
  113. if [ ! -f src/bash_profiler.so -o misc/tools-source/bash_profiler.c -nt src/bash_profiler.so ]; then
  114. echo "Building src/bash_profiler.so."
  115. gcc -shared -fPIC -Wall -o src/bash_profiler.so misc/tools-source/bash_profiler.c || exit 1
  116. fi
  117. enable -f src/bash_profiler.so bprof || exit 1
  118. bprof_print() {
  119. bprof all print >> config.profile
  120. awk '
  121. $4 == "profiled" { next; }
  122. $4 != "main" { count["profiled"]+=$1; time["profiled"]+=$2; }
  123. { count[$4]+=$1; time[$4]+=$2; }
  124. END {
  125. for (id in count)
  126. printf "%7d %7Ld %10.3f %s\n", count[id], time[id], time[id]/count[id], id;
  127. }
  128. ' < config.profile | sort -n -k1 > config.profile.new
  129. mv config.profile.new config.profile
  130. }
  131. fi
  132. bprof main start
  133. . scripts/config.func
  134. arch=none
  135. if expr "`uname -m`" : "i.86" > /dev/null ; then arch=x86 ; fi
  136. if expr "`uname -m`" : "alpha" > /dev/null ; then arch=alpha ; fi
  137. if expr "`uname -m`" : "ppc" > /dev/null ; then arch=powerpc ; fi
  138. if expr "`uname -m`" : "powerpc" > /dev/null ; then arch=powerpc ; fi
  139. current="" ; export ROCKCFG_ARCH="$arch" ; export ROCKCFG_EXPERT=0
  140. menu_this=0 ; menu_current=0 ; menu_counter=0
  141. menu_stack=x ; menu_back=-1 ; menu_backpos=-1
  142. mkdir -p config/$config
  143. touch config/$config/config config/$config/packages
  144. configtitle="$(printf ' %-50s %6s active packages ]' \
  145. "ROCK Linux $rockver Configuration - $config" \
  146. "[ $(echo `grep '^X' config/$config/packages | wc -l`)" )"
  147. bprof main stop
  148. . ./config/$config/config
  149. bprof main start
  150. rm -f config.dialog config.data config.help
  151. touch config.dialog config.data config.help
  152. echo -e "#\n# ROCK Linux $rockver Config File\n#" > config/$config/config
  153. spacer="" ; expert=0 ; tabspace="5" ; tabspace_list=""
  154. commentnr=0 ; editfilenr=0
  155. bprof mkpkglist start
  156. cmd="./scripts/Create-PkgList"
  157. [ "$ROCKCFG_DISABLE_BROKEN" = 1 ] && cmd="$cmd -nobroken"
  158. cmd="$cmd $ROCKCFG_ARCH"
  159. if [ "$cmd" != "`cat config.pcache.cmd 2> /dev/null`" ] ; then
  160. eval "$cmd" | tee config.pcache.data > config/$config/packages
  161. echo "$cmd" > config.pcache.cmd
  162. else
  163. cat config.pcache.data > config/$config/packages
  164. fi
  165. bprof mkpkglist stop
  166. export ROCKCFG_ID="$rockver"; pkgin; . src/rockconfig.in; pkgout
  167. echo "export ROCKCFG_ID='$ROCKCFG_ID'" >> config/$config/config
  168. rm -f config/$config/*.tmp
  169. cut -f1,2,4,5,8- -d' ' config/$config/packages | sed 's, [^ ]*$,,' | \
  170. tr ' ' '\t' | expand -t2,15,35, > config/$config/packages.txt
  171. configtitle="$(printf ' %-50s %6s active packages ]' \
  172. "ROCK Linux $rockver Configuration - $config" \
  173. "[ $(echo `grep '^X' config/$config/packages | wc -l`)" )"
  174. bprof main stop
  175. if [ -z "$oldconfig" ] ; then
  176. eval "./src/rockdialog.bin --title 'Build Config' \
  177. --backtitle '$configtitle' \
  178. --menu 'Arrow keys navigate the menu. Press <Enter> to activate menu items. Highlighted letters are hotkeys.' \
  179. $(( $lines - 4 )) $(( $columns - 5 )) $(( $lines - 12 )) \
  180. '$current' `tr '\n' ' ' < config.dialog`" 2> config.out
  181. returncode=$? ; item="`cat config.out`"
  182. else
  183. returncode=1
  184. fi
  185. bprof main start
  186. [ "$returncode" = 1 -a "$menu_back" -ne -1 ] && returncode="menu-back"
  187. case "$returncode" in
  188. 0|6)
  189. command="`grep "^$item " config.data | cut -f2-`"
  190. { echo -e "\n# Remember menu position:\ncurrent='$item'"
  191. echo -e "\n# Remember sub-menu:\nmenu_current='$menu_current'"
  192. echo -e "\n# Execute this config command:\n$command"
  193. } >> config/$config/config
  194. ;;
  195. menu-back)
  196. { echo -e "\n# New menu position:\ncurrent='$menu_backpos'"
  197. echo -e "\n# New sub-menu:\nmenu_current='$menu_back'"
  198. } >> config/$config/config
  199. ;;
  200. 1|255)
  201. rm -f config.data config.dialog config.out config.help
  202. rm -f config.pcache.data config.pcache.cmd
  203. rm -f rockdialog.scrltmp # src/rockdialog.bin
  204. echo "New config written to config/$config/*."
  205. echo "Cleaning up. Configuration finished."
  206. bprof main stop
  207. bprof_print
  208. exit 1 ;;
  209. 2)
  210. tempitem=$item
  211. item=$(echo $item | cut -f1 -d' ') # dialog(1) bug?
  212. { echo -e "\n# Remember menu position:\ncurrent='$item'"
  213. echo -e "\n# Remember sub-menu:\nmenu_current='$menu_current'"
  214. } >> config/$config/config
  215. get_help $item > config.dialog
  216. bprof main stop
  217. ./src/rockdialog.bin --title 'ROCK Linux Config - Help' \
  218. --backtitle "ROCK Linux $rockver Configuration" \
  219. --textbox config.dialog \
  220. $(( $lines - 4 )) $(( $columns - 5 ))
  221. bprof main start
  222. ;;
  223. *)
  224. echo "unknown returncode: $returncode"
  225. bprof main stop
  226. bprof_print
  227. exit 1 ;;
  228. esac
  229. bprof main stop
  230. bprof_print
  231. exit 0