Copy factor.image to factor.image.fresh after bootstrapping. Use $ECHO in more places.

db4
Doug Coleman 2010-04-23 23:14:53 -05:00
parent 654e4d48f5
commit 6809ac0855
1 changed files with 43 additions and 35 deletions

View File

@ -25,7 +25,7 @@ test_program_installed() {
exit_script() { exit_script() {
if [[ $FIND_MAKE_TARGET -eq true ]] ; then if [[ $FIND_MAKE_TARGET -eq true ]] ; then
echo $MAKE_TARGET; $ECHO $MAKE_TARGET;
fi fi
exit $1 exit $1
} }
@ -37,7 +37,7 @@ ensure_program_installed() {
$ECHO -n "Checking for $i..." $ECHO -n "Checking for $i..."
test_program_installed $i test_program_installed $i
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
echo -n "not " $ECHO -n "not "
else else
installed=$(( $installed + 1 )) installed=$(( $installed + 1 ))
fi fi
@ -194,8 +194,8 @@ find_architecture() {
} }
write_test_program() { write_test_program() {
echo "#include <stdio.h>" > $C_WORD.c $ECHO "#include <stdio.h>" > $C_WORD.c
echo "int main(){printf(\"%ld\", (long)(8*sizeof(void*))); return 0; }" >> $C_WORD.c $ECHO "int main(){printf(\"%ld\", (long)(8*sizeof(void*))); return 0; }" >> $C_WORD.c
} }
c_find_word_size() { c_find_word_size() {
@ -247,6 +247,7 @@ set_factor_library() {
set_factor_image() { set_factor_image() {
FACTOR_IMAGE=factor.image FACTOR_IMAGE=factor.image
FACTOR_IMAGE_FRESH=factor.image.fresh
} }
echo_build_info() { echo_build_info() {
@ -275,7 +276,7 @@ check_os_arch_word() {
$ECHO "WORD: $WORD" $ECHO "WORD: $WORD"
$ECHO "OS, ARCH, or WORD is empty. Please report this." $ECHO "OS, ARCH, or WORD is empty. Please report this."
echo $MAKE_TARGET $ECHO $MAKE_TARGET
exit_script 5 exit_script 5
fi fi
} }
@ -344,22 +345,22 @@ invoke_git() {
} }
git_clone() { git_clone() {
echo "Downloading the git repository from factorcode.org..." $ECHO "Downloading the git repository from factorcode.org..."
invoke_git clone $GIT_URL invoke_git clone $GIT_URL
} }
update_script_name() { update_script_name() {
echo `dirname $0`/_update.sh $ECHO `dirname $0`/_update.sh
} }
update_script() { update_script() {
update_script=`update_script_name` update_script=`update_script_name`
bash_path=`which bash` bash_path=`which bash`
echo "#!$bash_path" >"$update_script" $ECHO "#!$bash_path" >"$update_script"
echo "git pull \"$GIT_URL\" master" >>"$update_script" $ECHO "git pull \"$GIT_URL\" master" >>"$update_script"
echo "if [[ \$? -eq 0 ]]; then exec \"$0\" $SCRIPT_ARGS; else echo \"git pull failed\"; exit 2; fi" \ $ECHO "if [[ \$? -eq 0 ]]; then exec \"$0\" $SCRIPT_ARGS; else echo \"git pull failed\"; exit 2; fi" \
>>"$update_script" >>"$update_script"
echo "exit 0" >>"$update_script" $ECHO "exit 0" >>"$update_script"
chmod 755 "$update_script" chmod 755 "$update_script"
exec "$update_script" exec "$update_script"
@ -370,16 +371,16 @@ update_script_changed() {
} }
git_fetch_factorcode() { git_fetch_factorcode() {
echo "Fetching the git repository from factorcode.org..." $ECHO "Fetching the git repository from factorcode.org..."
rm -f `update_script_name` rm -f `update_script_name`
invoke_git fetch "$GIT_URL" master invoke_git fetch "$GIT_URL" master
if update_script_changed; then if update_script_changed; then
echo "Updating and restarting the factor.sh script..." $ECHO "Updating and restarting the factor.sh script..."
update_script update_script
else else
echo "Updating the working tree..." $ECHO "Updating the working tree..."
invoke_git pull "$GIT_URL" master invoke_git pull "$GIT_URL" master
fi fi
} }
@ -414,11 +415,11 @@ backup_factor() {
check_makefile_exists() { check_makefile_exists() {
if [[ ! -e "GNUmakefile" ]] ; then if [[ ! -e "GNUmakefile" ]] ; then
echo "" $ECHO ""
echo "***GNUmakefile not found***" $ECHO "***GNUmakefile not found***"
echo "You are likely in the wrong directory." $ECHO "You are likely in the wrong directory."
echo "Run this script from your factor directory:" $ECHO "Run this script from your factor directory:"
echo " ./build-support/factor.sh" $ECHO " ./build-support/factor.sh"
exit_script 6 exit_script 6
fi fi
} }
@ -438,7 +439,7 @@ make_factor() {
} }
update_boot_images() { update_boot_images() {
echo "Deleting old images..." $ECHO "Deleting old images..."
$DELETE checksums.txt* > /dev/null 2>&1 $DELETE checksums.txt* > /dev/null 2>&1
# delete boot images with one or two characters after the dot # delete boot images with one or two characters after the dot
$DELETE $BOOT_IMAGE.{?,??} > /dev/null 2>&1 $DELETE $BOOT_IMAGE.{?,??} > /dev/null 2>&1
@ -451,10 +452,10 @@ update_boot_images() {
netbsd) disk_md5=`md5 $BOOT_IMAGE | cut -f4 -d' '`;; netbsd) disk_md5=`md5 $BOOT_IMAGE | cut -f4 -d' '`;;
*) disk_md5=`$MD5SUM $BOOT_IMAGE|cut -f1 -d' '` ;; *) disk_md5=`$MD5SUM $BOOT_IMAGE|cut -f1 -d' '` ;;
esac esac
echo "Factorcode md5: $factorcode_md5"; $ECHO "Factorcode md5: $factorcode_md5";
echo "Disk md5: $disk_md5"; $ECHO "Disk md5: $disk_md5";
if [[ "$factorcode_md5" == "$disk_md5" ]] ; then if [[ "$factorcode_md5" == "$disk_md5" ]] ; then
echo "Your disk boot image matches the one on factorcode.org." $ECHO "Your disk boot image matches the one on factorcode.org."
else else
$DELETE $BOOT_IMAGE > /dev/null 2>&1 $DELETE $BOOT_IMAGE > /dev/null 2>&1
get_boot_image; get_boot_image;
@ -465,7 +466,7 @@ update_boot_images() {
} }
get_boot_image() { get_boot_image() {
echo "Downloading boot image $BOOT_IMAGE." $ECHO "Downloading boot image $BOOT_IMAGE."
get_url http://factorcode.org/images/latest/$BOOT_IMAGE get_url http://factorcode.org/images/latest/$BOOT_IMAGE
} }
@ -473,7 +474,7 @@ get_url() {
if [[ $DOWNLOADER -eq "" ]] ; then if [[ $DOWNLOADER -eq "" ]] ; then
set_downloader; set_downloader;
fi fi
echo $DOWNLOADER $1 ; $ECHO $DOWNLOADER $1 ;
$DOWNLOADER $1 $DOWNLOADER $1
check_ret $DOWNLOADER check_ret $DOWNLOADER
} }
@ -484,8 +485,15 @@ get_config_info() {
check_libraries check_libraries
} }
copy_fresh_image() {
$ECHO "Copying $FACTOR_IMAGE to $FACTOR_IMAGE_FRESH..."
$COPY $FACTOR_IMAGE $FACTOR_IMAGE_FRESH
$ECHO "done."
}
bootstrap() { bootstrap() {
./$FACTOR_BINARY -i=$BOOT_IMAGE ./$FACTOR_BINARY -i=$BOOT_IMAGE
copy_fresh_image
} }
install() { install() {
@ -532,22 +540,22 @@ install_build_system_port() {
test_program_installed git test_program_installed git
if [[ $? -ne 1 ]] ; then if [[ $? -ne 1 ]] ; then
ensure_program_installed yes ensure_program_installed yes
echo "git not found." $ECHO "git not found."
echo "This script requires either git-core or port." $ECHO "This script requires either git-core or port."
echo "If it fails, install git-core or port and try again." $ECHO "If it fails, install git-core or port and try again."
ensure_program_installed port ensure_program_installed port
echo "Installing git-core with port...this will take awhile." $ECHO "Installing git-core with port...this will take awhile."
yes | sudo port install git-core yes | sudo port install git-core
fi fi
} }
usage() { usage() {
echo "usage: $0 install|install-x11|install-macosx|self-update|quick-update|update|bootstrap|dlls|net-bootstrap|make-target|report [optional-target]" $ECHO "usage: $0 install|install-x11|install-macosx|self-update|quick-update|update|bootstrap|dlls|net-bootstrap|make-target|report [optional-target]"
echo "If you are behind a firewall, invoke as:" $ECHO "If you are behind a firewall, invoke as:"
echo "env GIT_PROTOCOL=http $0 <command>" $ECHO "env GIT_PROTOCOL=http $0 <command>"
echo "" $ECHO ""
echo "Example for overriding the default target:" $ECHO "Example for overriding the default target:"
echo " $0 update macosx-x86-32" $ECHO " $0 update macosx-x86-32"
} }
MAKE_TARGET=unknown MAKE_TARGET=unknown