From 619640d01c778dce7d7af8cb9f338dcfd1099382 Mon Sep 17 00:00:00 2001 From: meep-eep Date: Sun, 23 Feb 2003 22:28:08 +0000 Subject: [PATCH] Improved install program. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@802 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/build/unix/build.config | 5 +- sc2/build/unix/build.docs | 22 ++- sc2/build/unix/menu_functions | 94 ++++++++--- sc2/build/unix/todo | 16 ++ sc2/build/unix_installer/USAGE | 11 +- sc2/build/unix_installer/buildinstaller.sh | 71 ++++++-- sc2/build/unix_installer/install.sh.in | 185 ++++++++++++--------- sc2/build/unix_installer/installer.config | 139 ++++++++++++++++ sc2/build/unix_installer/mkinstall | 43 ----- sc2/build/unix_installer/template | 37 +++++ 10 files changed, 458 insertions(+), 165 deletions(-) create mode 100644 sc2/build/unix/todo create mode 100644 sc2/build/unix_installer/installer.config delete mode 100644 sc2/build/unix_installer/mkinstall create mode 100644 sc2/build/unix_installer/template diff --git a/sc2/build/unix/build.config b/sc2/build/unix/build.config index 0c6e7c35a..42b2cc74b 100644 --- a/sc2/build/unix/build.config +++ b/sc2/build/unix/build.config @@ -50,6 +50,9 @@ CHOICE_debug_OPTIONS="nodebug debug strictdebug" CHOICE_debug_TITLE="Include debugging information" CHOICE_debug_OPTION_nodebug_TITLE="No debugging information" CHOICE_debug_OPTION_nodebug_ACTION='nodebug_action' +CHOICE_debug_TEXT=" bla + bla + bla" nodebug_action() { CFLAGS="$CFLAGS -O3" DEBUG=0 @@ -161,7 +164,7 @@ INPUT_install_libdir_VALIDATOR=validate_path # Show the menu and let people set things -do_menu main config.state +do_menu MENU main config.state echo "Configuration complete." # Set INSTALL_LIBDIR and INSTALL_BINDIR by to their set values, replacing diff --git a/sc2/build/unix/build.docs b/sc2/build/unix/build.docs index 18224b6b3..208c373b2 100644 --- a/sc2/build/unix/build.docs +++ b/sc2/build/unix/build.docs @@ -23,6 +23,8 @@ There are three types of menu items. - Variables: - MENU_${NAME}_TITLE The title of the menu. + - MENU_${NAME}_TEXT (optional) + The text to show with the menu. - MENU_${NAME}_ITEMS The names of the menu items (space-seperated). - MENU_${NAME}_ITEM_${ITEMNAME}_TYPE @@ -32,6 +34,8 @@ There are three types of menu items. - Variables: - CHOICE_${NAME}_TITLE The title of the choice menu. + - CHOICE_${NAME}_TEXT (optional) + The text to show with the choice menu. - CHOICE_${NAME}_OPTIONS The names of the options (space-seperated). - CHOICE_${NAME}_OPTION_${OPTIONNAME}_TITLE @@ -49,19 +53,33 @@ There are three types of menu items. - Type INPUT: A string that is user-definable. - Variables: - - INPUT_${NAME}_DEFAULT (optional) - The default value. - INPUT_${NAME}_TITLE The title of the input field. + - INPUT_${NAME}_TEXT (optional) + The text to show with the input field. - INPUT_${NAME}_VALIDATOR (optional) A function to call after the user supplied a new value which checks if the value is allowed. It should accept the new value as an argument, and return 1 if the value is not allowed, or return 0 and output the (possibly modified) value, to accept it. + - INPUT_${NAME}_DEFAULT (optional) + The default value. - INPUT_${NAME}_VALUE (set by the config program) The current value. - INPUT_${NAME}_OLD_VALUE (set by the config program) The value as it was at the start of the config program. +- Type CHECK: + An option that can either be on or off, like a checkbox. + - Variables: + - CHECK_${NAME}_TITLE + The title of the input field. + - CHECK_${NAME}_DEFAULT (optional) + The default value, either 'CHECKED' or 'UNCHECKED'. + - CHECK_${NAME}_VALUE (set by the config program) + The current value, either 'CHECKED' or 'UNCHECKED'. + - CHECK_${NAME}_FIXED (optional) + A string that evaluates to 0 if this checkbox may not be changed. + Program info diff --git a/sc2/build/unix/menu_functions b/sc2/build/unix/menu_functions index d29abd2e7..bc9d52896 100644 --- a/sc2/build/unix/menu_functions +++ b/sc2/build/unix/menu_functions @@ -141,6 +141,7 @@ menu_init_input() { menu_init_check() { local CHECKBOX TEMP_VALUE TEMP_DEFAULT CHECKBOX="$1" + eval TEMP_VALUE="\$CHECK_${CHECKBOX}_VALUE" eval TEMP_DEFAULT="\$CHECK_${CHECKBOX}_DEFAULT" @@ -207,22 +208,28 @@ EOF # Arguments: $1 - the name of the checkbox item # Outputs: The value of the given checkbox menu_print_value_check() { - local TEMP_VALUE TEMP_DEFAULT + local TEMP_VALUE TEMP_DEFAULT TEMP_FIXED RESULT EXTRA eval TEMP_VALUE="\$CHECK_$1_VALUE" eval TEMP_DEFAULT="\$CHECK_$1_DEFAULT" + eval TEMP_FIXED="\$CHECK_$1_FIXED" + if [ "$TEMP_VALUE" = "CHECKED" ]; then - if [ "$TEMP_DEFAULT" = "CHECKED" ]; then - echo "Yes (default)" - else - echo "Yes" - fi + RESULT="Yes" else - if [ "$TEMP_DEFAULT" = "CHECKED" ]; then - echo "No" - else - echo "No (default)" - fi + RESULT="No" fi + + EXTRA="" + if [ "$TEMP_VALUE" = "$TEMP_DEFAULT" ]; then + EXTRA="default" + fi + + if [ "$TEMP_FIXED" = "TRUE" ]; then + EXTRA="${EXTRA:+$EXTRA, }unchangable" + fi + + RESULT="$RESULT${EXTRA:+ ($EXTRA)}" + echo "$RESULT" } # Description: Print the string describing the value of a menu item. @@ -239,8 +246,10 @@ menu_handle() { # Description: Process a menu-type menu item # Arguments: $1 - The name of the menu menu_handle_menu() { - local TEMP_ITEMS I CHOICE NUM_ITEMS TEMP_TYPE MENU ITEM TEMP_TITLE + local TEMP_ITEMS I CHOICE NUM_ITEMS TEMP_TYPE MENU ITEM TEMP_TITLE \ + TEMP_TEXT eval TEMP_ITEMS="\$MENU_$1_ITEMS" + eval TEMP_TEXT="\$MENU_$1_TEXT" MENU="$1" while :; do @@ -249,6 +258,13 @@ menu_handle_menu() { cat << EOF $ANSI_BOLD-= $TEMP_TITLE =-$ANSI_NORMAL EOF + + if [ -n "$TEMP_TEXT" ]; then + cat << EOF +$TEMP_TEXT +EOF + fi + I=0 for ITEM in $TEMP_ITEMS; do I=$(($I + 1)) @@ -302,8 +318,9 @@ EOF # Arguments: $1 - The name of the menu menu_handle_choice() { local TEMP_OPTIONS I CHOICE NUM_OPTIONS TEMP_TYPE MENU OPTION \ - TEMP_VALUE TEMP_TITLE SELECTED + TEMP_VALUE TEMP_TITLE SELECTED TEMP_TEXT eval TEMP_OPTIONS="\$CHOICE_$1_OPTIONS" + eval TEMP_TEXT="\$CHOICE_$1_TEXT" MENU="$1" while :; do @@ -312,6 +329,12 @@ menu_handle_choice() { cat << EOF $ANSI_BOLD-= $TEMP_TITLE =-$ANSI_NORMAL EOF + if [ -n "$TEMP_TEXT" ]; then + cat << EOF +$TEMP_TEXT +EOF + fi + eval TEMP_VALUE="\$CHOICE_${MENU}_VALUE" # Check in advance which options are present, so that that @@ -388,15 +411,25 @@ EOF # Description: Process an input-type menu item # Arguments: $1 - The name of the menu menu_handle_input() { - local ITEM TEMP_TITLE TEMP_VALUE TEMP_DEFAULT NEW_VALUE TEMP_VALIDATOR + local ITEM TEMP_TITLE TEMP_VALUE TEMP_DEFAULT NEW_VALUE \ + TEMP_VALIDATOR TEMP_TEXT ITEM="$1" eval TEMP_TITLE="\$INPUT_${ITEM}_TITLE" + eval TEMP_TEXT="\$INPUT_${ITEM}_TEXT" + while :; do echo cat << EOF $ANSI_BOLD-= $TEMP_TITLE =-$ANSI_NORMAL EOF + + if [ -n "$TEMP_TEXT" ]; then + cat << EOF +$TEMP_TEXT +EOF + fi + eval TEMP_VALUE="\$INPUT_${ITEM}_VALUE" eval TEMP_DEFAULT="\$INPUT_${ITEM}_DEFAULT" echo " Default value: $TEMP_DEFAULT" @@ -426,16 +459,23 @@ EOF # Description: Process an checkbox-type menu item # Arguments: $1 - The name of the checkbox menu_handle_check() { - local ITEM OLD_VALUE NEW_VALUE + local CHECKBOX OLD_VALUE NEW_VALUE TEMP_FIXED - ITEM="$1" - eval OLD_VALUE="\$CHECK_${ITEM}_VALUE" + CHECKBOX="$1" + eval TEMP_FIXED="\$CHECK_${CHECKBOX}_FIXED" + + if [ "$TEMP_FIXED" = "TRUE" ]; then + # Unchangable + return; + fi + + eval OLD_VALUE="\$CHECK_${CHECKBOX}_VALUE" if [ "$OLD_VALUE" = "CHECKED" ]; then NEW_VALUE="UNCHECKED" else NEW_VALUE="CHECKED" fi - eval "CHECK_${ITEM}_VALUE"=\"\$NEW_VALUE\" + eval "CHECK_${CHECKBOX}_VALUE"=\"\$NEW_VALUE\" } # Description: echo the current state of a menu item in a form that can be @@ -561,21 +601,23 @@ menu_process_check() { } do_menu() { - local START_MENU SAVE_FILE + local MENU_TYPE START_MENU SAVE_FILE - START_MENU="$1" - SAVE_FILE="$2" + MENU_TYPE="$1" + START_MENU="$2" + SAVE_FILE="$3" + if [ -n "$SAVE_FILE" -a -e config.state ]; then . config.state fi - menu_init MENU "$1" - menu_handle MENU "$1" + menu_init "$MENU_TYPE" "$START_MENU" + menu_handle "$MENU_TYPE" "$START_MENU" echo if [ -n "$SAVE_FILE" ]; then echo "Saving choices..." - menu_save MENU "$1" > config.state + menu_save "$MENU_TYPE" "$START_MENU" > config.state fi - echo "Propagating choices..." - menu_process MENU "$1" +# echo "Propagating choices..." + menu_process "$MENU_TYPE" "$START_MENU" } diff --git a/sc2/build/unix/todo b/sc2/build/unix/todo new file mode 100644 index 000000000..24192955d --- /dev/null +++ b/sc2/build/unix/todo @@ -0,0 +1,16 @@ +- flag for an option to set if changing it will trigger a new 'make depend' +- same for 'make clean' +- Specify files to be removed on clean. +- PROG_*_DETECT, LIB_*_DETECT +- static compilation +- error message for './build.sh uqm asdasddsa' + +some docs + - sc2_LDFLAGS etc are only relevant in the top dir + - some variables are 'inherited' from parent dir + - files are sourced (.) + - make clean + - make distclean + - .depend files + - description of files + diff --git a/sc2/build/unix_installer/USAGE b/sc2/build/unix_installer/USAGE index 28fbb2a55..ec6048c15 100644 --- a/sc2/build/unix_installer/USAGE +++ b/sc2/build/unix_installer/USAGE @@ -2,11 +2,12 @@ Making a release binary: - Build the game in release mode. -- From the top of the cvs tree, run the following command, but - change the actual arguments to suit your needs. - The first one is the name of the final executable, the second a - space-seperated list of possible content files the installer will look - for. +- Change build/unix_installer/template to suit your needs. + +- From the top of the cvs tree, run the following command, changing + the arguments if necessary. + The first one is the name of the final executable, the second + the template to use. build/unix_installer/buildinstaller.sh uqm-0.2-linux-dynamic.sh \ "content.tgz" diff --git a/sc2/build/unix_installer/buildinstaller.sh b/sc2/build/unix_installer/buildinstaller.sh index 2661fcd7c..b57525307 100755 --- a/sc2/build/unix_installer/buildinstaller.sh +++ b/sc2/build/unix_installer/buildinstaller.sh @@ -6,14 +6,14 @@ TEMPDIR="/tmp/buildinstaller_$$" if [ $# -ne 2 ]; then cat >&2 << EOF -Usage: buildinstaller.sh +Usage: buildinstaller.sh