Improved install program.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@802 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
meep-eep
2003-02-23 22:28:08 +00:00
parent a2e54e5f32
commit 619640d01c
10 changed files with 458 additions and 165 deletions
+4 -1
View File
@@ -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
+20 -2
View File
@@ -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
+66 -24
View File
@@ -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)"
RESULT="Yes"
else
echo "Yes"
RESULT="No"
fi
else
if [ "$TEMP_DEFAULT" = "CHECKED" ]; then
echo "No"
else
echo "No (default)"
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
MENU_TYPE="$1"
START_MENU="$2"
SAVE_FILE="$3"
START_MENU="$1"
SAVE_FILE="$2"
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"
}
+16
View File
@@ -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
+6 -5
View File
@@ -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"
+58 -13
View File
@@ -6,14 +6,14 @@ TEMPDIR="/tmp/buildinstaller_$$"
if [ $# -ne 2 ]; then
cat >&2 << EOF
Usage: buildinstaller.sh <installername> <contentfiles>
Usage: buildinstaller.sh <installername> <template>
where 'installername' is the name you want to give the final installer
and 'contentfiles' is a space-seperated list of possible content files.
and 'template' is the template file describing the installer.
EOF
exit 1
fi
DESTFILE="$1"
CONTENTFILES="$2"
TEMPLATE="$2"
if [ ! -d src -o ! -d build ]; then
cat >&2 << EOF
@@ -38,23 +38,68 @@ if [ "$?" -ne 0 ]; then
exit 1
fi
mkdir -- "${TEMPDIR}/lib" "${TEMPDIR}/lib/uqm" "${TEMPDIR}/lib/uqm/doc"
. "$TEMPLATE"
cp -- AUTHORS COPYING ChangeLog WhatsNew README doc/users/manual.txt \
"${TEMPDIR}/lib/uqm/doc/"
cp -- uqm "${TEMPDIR}/lib/uqm/"
chmod -R go+rX "${TEMPDIR}/lib"
while read FILE DEST; do
DESTDIR="${TEMPDIR}/attach/${DEST%/*}"
if [ ! -d "$DESTDIR" ]; then
mkdir -p -- "$DESTDIR" || exit 1
fi
cp -- "$FILE" "${TEMPDIR}/attach/$DEST" || exit 1
done << EOF
$UQM_ATTACH_FILES
EOF
chmod -R go+rX "${TEMPDIR}/attach"
echo "Making tar.gz file for everything except from the content."
echo "Using maximum compression; this may take a moment."
tar -c -C "${TEMPDIR}/lib/" uqm | gzip -9 > "${TEMPDIR}/libpkg.tar.gz"
tar -c -C "${TEMPDIR}/attach/" . | gzip -9 > "${TEMPDIR}/attach.tar.gz"
{
cat << EOF
UQM_VERSION="$UQM_VERSION"
UQM_PACKAGES="$UQM_PACKAGES"
EOF
for PACKAGE in $UQM_PACKAGES; do
eval PACKAGE_NAME="\$UQM_PACKAGE_${PACKAGE}_NAME"
eval PACKAGE_TITLE="\$UQM_PACKAGE_${PACKAGE}_TITLE"
eval PACKAGE_OPTIONAL="\$UQM_PACKAGE_${PACKAGE}_OPTIONAL"
eval PACKAGE_DEFAULT="\$UQM_PACKAGE_${PACKAGE}_DEFAULT"
cat << EOF
UQM_PACKAGE_${PACKAGE}_NAME="$PACKAGE_NAME"
UQM_PACKAGE_${PACKAGE}_TITLE="$PACKAGE_TITLE"
UQM_PACKAGE_${PACKAGE}_OPTIONAL="$PACKAGE_OPTIONAL"
UQM_PACKAGE_${PACKAGE}_DEFAULT="$PACKAGE_DEFAULT"
EOF
done
} > "${TEMPDIR}/packages"
# A slow way, but a reliable way.
ATTACHLEN=`wc -c < "${TEMPDIR}/attach.tar.gz"`
LICENSE_TEXT="$(cat $UQM_LICENSE_FILE)"
# Now we've got all the parts, we can make the final .sh file.
echo "Making final executable."
sh build/unix_installer/mkinstall "$DESTFILE" "${TEMPDIR}/libpkg.tar.gz" \
"$CONTENTFILES" COPYING
rm -r -- "$TEMPDIR"
{
for SCRIPT in ${TEMPDIR}/packages $UQM_SCRIPT_FILES; do
echo "# --- Start ${SCRIPT##*/} ---"
# Very ugly, but I can't get sed to replace a pattern by the contents
# of a file.
FILEDATA="$(cat $SCRIPT)"
sed -e "s/@ATTACHLEN@/$ATTACHLEN/" \
-e "s/@CONTENT_FILES@/$CONTENT_FILES/" << EOF
${FILEDATA/@LICENCE@/$LICENSE_TEXT}
EOF
echo "# --- End ${SCRIPT##*/} ---"
done
cat "${TEMPDIR}/attach.tar.gz"
} > "$DESTFILE"
chmod 755 "$DESTFILE"
rm -r -- "$TEMPDIR"
echo "Done."
+110 -75
View File
@@ -2,8 +2,6 @@
# Installation program for binaries.
# By Serge van den Boom, 2002-11-26
CONTENT_FILES="@CONTENT_FILES@"
quithandler() {
echo
echo "Bye."
@@ -17,48 +15,17 @@ cat << EOF
-== The Ur-Quan Masters installation ==-
Hi, I'm your friendly neighbourhood installation program.
I will make you very happy, but first, we've got some business to take care
of.
I will make you very happy, but first, we've got some business to take
care of.
EOF
CONTENT_FILE=""
have_content_file() {
for FILE in $CONTENT_FILES; do
if [ -r "$CONTENT_PATH$FILE" ]; then
CONTENT_FILE="$FILE"
return 0
fi
done
return 1
}
CONTENT_PATH="./"
have_content_file
if [ "$?" -ne 0 ]; then
cat << EOF
I need a content .tgz package and I can't find one in
the $CONTENT_PATH dir. I really can't work without it.
If you don't have it, please press CTRL-C and quickly get it, before I get
swapped out.
EOF
echo -n "Otherwise, please tell me where you've hidden it: "
while :; do
read CONTENT_PATH
CONTENT_PATH="${CONTENT_PATH%/}/"
have_content_file && break
echo "There's nothing there, I tell you."
echo -n "Guess again: "
done
echo "Yay! Found it."
echo
fi
CONTENT_FILE="$CONTENT_PATH$CONTENT_FILE"
PAGER="${PAGER:-more}"
type "$PAGER" > /dev/null 2>&1
if [ "$?" -ne 0 ]; then
echo "I can't find a good pager. I need one. That's all folks."
cat << EOF
I can't find a good pager. I need one. Sorry. Here's your prompt back.
EOF
exit 1
fi
@@ -93,32 +60,25 @@ EOF
done
echo
if [ "$(id -u)" -eq "0" ]; then
INSTALL_BASE=/usr/local/games/
else
INSTALL_BASE="$HOME/uqm/"
fi
echo "I've got a lot of files, and I need somewhere to put them. "
echo "My invisible friend tells me $INSTALL_BASE is a good place."
echo "I would put an executable there in a bin/ dir and a lot of junk "
echo "together in a subdir under lib/"
echo -n "But you're the boss, so where shall I put them [$INSTALL_BASE]? "
cat << EOF
Now I need somewhere to put all those Ur-Quan Masters files.
My invisible friend tells me $INPUT_install_prefix_DEFAULT is a good place.
I would put an executable there in a bin/ dir and a lot of junk together
in a subdir under lib/
But you're the boss, so where shall I put them?"
EOF
while :; do
read TEMP
show_install_prefix_menu
echo
if [ "$TEMP" = "/dev/null" ]; then
PREFIX="$INPUT_install_prefix_VALUE"
if [ "$PREFIX" = "/dev/null" ]; then
echo "Ok, done. That was quick, wasn't it? Well, have fun."
echo
exit 0
fi
if [ -z "$TEMP" ]; then
TEMP="$INSTALL_BASE"
else
TEMP="${TEMP%/}/"
fi
if [ ! -d "$TEMP" ]; then
if [ ! -d "$PREFIX" ]; then
cat << EOF
There's no such directory. If you want me to stuff it all in /dev/null,
just say so. No need to toy with me.
@@ -130,20 +90,19 @@ EOF
echo
case "$TEMP2" in
y|Y|yes|Yes|YES)
mkdir -p "$TEMP" 2> /dev/null
mkdir -p "$PREFIX" 2> /dev/null
if [ "$?" -gt 0 ]; then
cat << EOF
I cannot do it, captain! I don't have enough power!
Erm... I mean 'permission denied'. Sorry about that.
I guess we'll need to find another place.
EOF
echo -n "So what shall it be [$INSTALL_BASE]? "
echo "So what shall it be?"
else
cat << EOF
Ok, I've created that dir for you, even though it isn't in my job
description. Now let's get on with the copying.
EOF
INSTALL_BASE="$TEMP"
break;
fi
;;
@@ -151,33 +110,106 @@ EOF
echo "Great! That saves me some work."
echo "Then where DO you want me to put my files?"
echo "I promise I'll handle them with care."
echo -n "[$INSTALL_BASE]? "
;;
*)
echo "I'll take that as a 'no'."
echo -n "So, where should I put my files [$INSTALL_BASE]? "
echo -n "So, where should I put my files?"
;;
esac
continue
fi
if [ ! -w "$TEMP" ]; then
if [ ! -w "$PREFIX" ]; then
cat << EOF
Ooh, a very fine place indeed. Unfortunately it's not your fine place.
You can't write there, and for some strange cosmological coincidence,
neither can I. I think we need another place."
EOF
echo -n "So, what shall it be [$INSTALL_BASE]? "
echo "So, what shall it be?"
continue
fi
INSTALL_BASE="$TEMP"
break
done
cat << EOF
$INSTALL_BASE it is. I can work with that.
$PREFIX it is. I can work with that.
EOF
if [ -d "${PREFIX}/lib/uqm/content" ]; then
if [ -f "${PREFIX}/lib/uqm/content/version" ]; then
read UQM_OLDVERSION < "${PREFIX}/lib/uqm/content/version"
else
UQM_OLDVERSION=0.1
fi
if [ `expr "$UQM_VERSION" ">" "$UQM_OLDVERSION"` = "0" ]; then
# NB: 'expr' echoes '1' for true, while sh uses '0'
echo "Hey! I see you've got an old version there."
echo "You'll be happy to know this one is even better."
echo "(yes, this is a hardcoded string in the installer)"
echo
UQM_INSTALL=UPGRADE
elif [ `expr "$UQM_VERSION" "<" "$UQM_OLDVERSION"` = "0" ]; then
UQM_INSTALL=DOWNGRADE
else
UQM_INSTALL=REINSTALL
fi
else
UQM_INSTALL=NEW
fi
check_content_path() {
local OPTIONAL TITLE HAVE FAIL
echo "Looking for packages to install..."
FAIL="0"
for PACKAGE in $UQM_PACKAGES; do
eval OPTIONAL="\$UQM_PACKAGE_${PACKAGE}_OPTIONAL"
eval TITLE="\$UQM_PACKAGE_${PACKAGE}_TITLE"
package_available "$PACKAGE"
HAVE="$?"
echo -n "- Package for '$TITLE'"
if [ "$OPTIONAL" = TRUE ]; then
echo -n " (optional)"
else
echo -n " (required)"
fi
if [ "$HAVE" -eq 0 ]; then
echo " found."
continue
fi
echo " not found."
if [ "$OPTIONAL" = FALSE ]; then
FAIL=1
fi
done
return "$FAIL"
}
CONTENT_PATH="$INPUT_content_path_DEFAULT"
check_content_path
if [ "$?" -ne 0 ]; then
cat << EOF
I haven't found the files I need in the $CONTENT_PATH dir.
I really can't work without them.
If you don't have them, please press CTRL-C and quickly get it, before I get
swapped out.
EOF
echo "Otherwise, please tell me where you've hidden them."
while :; do
show_content_path_menu
CONTENT_PATH="$INPUT_content_path_VALUE"
check_content_path && break
echo "That's not it. Guess again."
done
echo "Yay! Found them."
echo
fi
set_components_menu
show_components_menu
cat << EOF
Ok, I'm ready now to start filling your hard drive.
It might take some time though, so don't hold your breath.
@@ -190,28 +222,31 @@ echo "A word as good as any."
echo
echo "Making directories..."
mkdir -p -- "$INSTALL_BASE"/lib/uqm 2> /dev/null
mkdir -p -- "$INSTALL_BASE"/bin 2> /dev/null
mkdir -p -- "$PREFIX"/lib/uqm 2> /dev/null
mkdir -p -- "$PREFIX"/bin 2> /dev/null
echo "Unpacking content..."
gzip -dc "$CONTENT_FILE" | tar -xf - -C "$INSTALL_BASE"lib/uqm
echo "Unpacking packages..."
for PACKAGE in `selected_components`; do
gzip -dc "$CONTENT_FILE" | tar -xf - -C "$PREFIX"/
done
echo "Unpacking other stuff..."
tail -c @ATTACHLEN@ < "$0" | gzip -dc | tar -xf - -C "$INSTALL_BASE"lib/
tail -c @ATTACHLEN@ < "$0" | gzip -dc | tar -xf - -C "$PREFIX"/
echo "Creating wrapper script..."
cat << EOF > "$INSTALL_BASE"bin/uqm
cat << EOF > "$PREFIX"bin/uqm
#!/bin/sh
# Wrapper script for starting The Ur-Quan Masters
"${INSTALL_BASE}lib/uqm/uqm" "--contentdir=${INSTALL_BASE}lib/uqm/content" "\$@"
"${PREFIX}lib/uqm/uqm" "--contentdir=${PREFIX}lib/uqm/content" "\$@"
EOF
chmod 755 "$INSTALL_BASE"bin/uqm
chmod 755 "$PREFIX"bin/uqm
cat << EOF
All done. Now you can play The Ur-Quan masters.
I told you I was going to make you very happy.
And if you're looking for documentation, you can find some in
${INSTALL_BASE}lib/uqm/doc/. If you aren't looking for documentation, too.
${PREFIX}lib/uqm/doc/. If you aren't looking for documentation, too.
But feel free to delete them. You know where to find them.
EOF
+139
View File
@@ -0,0 +1,139 @@
MENU_main_ITEMS="components install_prefix"
MENU_main_TITLE="The Ur-Quan Masters installation"
MENU_main_ITEM_components_TYPE=MENU
MENU_main_ITEM_install_prefix_TYPE=INPUT
MENU_components_TITLE="Optional components"
MENU_components_TEXT=\
" Here you can select which components you'd like to have installed. If you
can spare the space, you are adviced to select all, for the maximum game
experience.
"
package_filename() {
local FILENAME PACKNAME
eval PACKNAME="\${UQM_PACKAGE_$1_NAME}"
# Check complete package first for reinstall or downgrade.
# If they're not found, we'll settle for an upgrade package,
# maybe it will work, maybe it won't.
case "$UQM_INSTALL" in
NEW|REINSTALL|DOWNGRADE)
FILENAME="${CONTENT_PATH}/uqm-${UQM_VERSION}-$PACKNAME.zip"
if [ -f "$FILENAME" ]; then
# Found complete package.
echo "$FILENAME"
return 0
fi
;;
esac
# A full package is needed for a new install
if [ "$UQM_INSTALL" = NEW ]; then
return 1
fi
# Check for upgrade package.
FILENAME="${CONTENT_PATH}/uqm-${UQM_OLDVERSION}_to_${UQM_VERSION}-$PACKNAME.zip"
if [ -f "$FILENAME" ]; then
# Found upgrade package.
echo "$FILENAME"
return 0
fi
# Check complete package again, as you can upgrade with a complete
# package.
if [ "$UQM_INSTALL" = UPGRADE ]; then
FILENAME="${CONTENT_PATH}/uqm-${UQM_VERSION}-$PACKNAME.zip"
if [ -f "$FILENAME" ]; then
# Found complete package.
echo "$FILENAME"
return 0
fi
fi
return 1
}
package_available() {
package_filename "$@" > /dev/null
return $?
}
set_components_menu() {
local TITLE OPTIONAL DEFAULT
MENU_install_components_TITLE="Optional components selection"
MENU_install_components_ITEMS="$UQM_PACKAGES"
for PACKAGE in $UQM_PACKAGES; do
eval TITLE="\"\${UQM_PACKAGE_${PACKAGE}_TITLE}\""
eval OPTIONAL="\${UQM_PACKAGE_${PACKAGE}_OPTIONAL}"
eval DEFAULT="\${UQM_PACKAGE_${PACKAGE}_DEFAULT}"
eval MENU_install_components_ITEM_${PACKAGE}_TYPE=CHECK
eval CHECK_${PACKAGE}_TITLE=\"\$TITLE\"
if [ "$DEFAULT" = "TRUE" ]; then
eval CHECK_${PACKAGE}_DEFAULT=CHECKED
else
eval CHECK_${PACKAGE}_DEFAULT=UNCHECKED
fi
if package_available "$PACKAGE"; then
if [ "$OPTIONAL" = "FALSE" ]; then
eval CHECK_${PACKAGE}_VALUE=CHECKED
eval CHECK_${PACKAGE}_FIXED=TRUE
fi
else
if [ "$OPTIONAL" = "TRUE" ]; then
eval CHECK_${PACKAGE}_VALUE=UNCHECKED
eval CHECK_${PACKAGE}_FIXED=TRUE
else
echo "Can't find '$PACKAGE' package"
return 1
fi
fi
done
return 0
}
show_components_menu() {
do_menu MENU install_components ""
}
INPUT_install_prefix_TITLE="Installation prefix"
#INPUT_install_prefix_TEXT=\
#" This is the top directory where the game data will be installed.
# In the directory you specify directories like 'lib' and 'bin' will
# be used.
#"
if [ "$(id -u)" -eq 0 ]; then
INPUT_install_prefix_DEFAULT="/usr/local/games/"
else
INPUT_install_prefix_DEFAULT="$HOME/uqm/"
fi
INPUT_install_prefix_VALIDATOR=validate_path
show_install_prefix_menu() {
do_menu INPUT install_prefix ""
INPUT_install_prefix_VALUE="${INPUT_install_prefix_VALUE%/}/"
}
INPUT_content_path_TITLE="Location of content packages"
INPUT_content_path_DEFAULT="${PWD%/}/"
INPUT_content_path_VALIDATOR=validate_path
show_content_path_menu() {
do_menu INPUT content_path ""
INPUT_content_path_VALUE="${INPUT_content_path_VALUE%/}/"
}
selected_components() {
local RESULT COMPONENT VALUE
RESULT=""
for COMPONENT in $MENU_install_components_ITEMS; do
eval VALUE="\$MENU_install_components_ITEM_$COMPONENT"
if [ "$VALUE" = checked ]; then
RESULT="${RESULT:+$RESULT }$((package_filename $COMPONENT))"
fi
done
echo "$RESULT"
}
-43
View File
@@ -1,43 +0,0 @@
#!/bin/sh
# Script for creating install.sh from install.sh.in
# By Serge van den Boom, 2002-11-26
if [ $# -ne 4 ]; then
echo "Usage: mkinstall <attachment> <contentfiles> <licence>"
echo "'attachment' is the .tgz file to attach to the script."
echo "contentfiles is a space-seperated list of possible content files."
exit 1
fi
OUTFILE="$1"
ATTACHMENT="$2"
CONTENT_FILES="$3"
LICENSE="$4"
case "$0" in
*/*) EXECDIR="${0%/*}/" ;;
*) EXECDIR="" ;;
esac
INFILE="${EXECDIR}install.sh.in"
# A slow way, but a reliable way.
ATTACHLEN=`wc -c < $ATTACHMENT`
#ATTACHLEN="$(du -b $ATTACHMENT | cut -f 1)"
# Very ugly, but I can't get sed to replace a pattern by the contents
# of a file.
FILEDATA="$(cat $INFILE)"
LICENSE_TEXT="$(cat $LICENSE)"
sed -e "s/@ATTACHLEN@/$ATTACHLEN/" \
-e "s/@CONTENT_FILES@/$CONTENT_FILES/" > "$OUTFILE" << EOF
${FILEDATA/@LICENCE@/$LICENSE_TEXT}
EOF
#sed -e "s/@ATTACHLEN@/$ATTACHLEN/" \
# -e "s/@CONTENT_FILES@/$CONTENT_FILES/" \
# -e "s/@LICENSE@/$LICENSE_TEXT/" \
# < "$INFILE" > "$OUTFILE"
cat "$ATTACHMENT" >> "$OUTFILE"
+37
View File
@@ -0,0 +1,37 @@
# Template file for building the UQM installer for unix Systems.
# By Serge van den Boom, 2003-02-23
UQM_VERSION="0.2"
UQM_LICENSE_FILE="COPYING"
UQM_PACKAGES="content voice 3domusic"
UQM_PACKAGE_content_NAME="content"
UQM_PACKAGE_content_TITLE="General game data"
UQM_PACKAGE_content_OPTIONAL="FALSE"
UQM_PACKAGE_content_DEFAULT="TRUE"
UQM_PACKAGE_voice_NAME="voice"
UQM_PACKAGE_voice_TITLE="Spoken alien communication"
UQM_PACKAGE_voice_OPTIONAL="TRUE"
UQM_PACKAGE_voice_DEFAULT="TRUE"
UQM_PACKAGE_3domusic_NAME="3domusic"
UQM_PACKAGE_3domusic_TITLE="Music from the 3DO version"
UQM_PACKAGE_3domusic_OPTIONAL="TRUE"
UQM_PACKAGE_3domusic_DEFAULT="TRUE"
UQM_SCRIPT_FILES="
${UQM_TOP}build/unix/ansi
${UQM_TOP}build/unix/menu_functions
${UQM_TOP}build/unix_installer/installer.config
${UQM_TOP}build/unix_installer/install.sh.in
"
# File destination
UQM_ATTACH_FILES=\
"${UQM_TOP}AUTHORS lib/uqm/doc/
${UQM_TOP}COPYING lib/uqm/doc/
${UQM_TOP}ChangeLog lib/uqm/doc/
${UQM_TOP}WhatsNew lib/uqm/doc/
${UQM_TOP}README lib/uqm/doc/
${UQM_TOP}doc/users/manual.txt lib/uqm/doc/
${UQM_TOP}uqm lib/uqm/"