-#!/bin/bash -e
+#!/usr/bin/env bash
# Programs returning != 0 will not cause script to exit
set +e
ARCH=
WORD=
NO_UI=
+GIT_PROTOCOL=${GIT_PROTOCOL:="git"}
+GIT_URL=${GIT_URL:=$GIT_PROTOCOL"://factorcode.org/git/factor.git"}
+
ensure_program_installed() {
echo -n "Checking for $1..."
ensure_program_installed wget
ensure_program_installed gcc
ensure_program_installed make
+ case $OS in
+ netbsd) ensure_program_installed gmake;;
+ esac
check_gcc_version
}
*Darwin*) OS=macosx;;
*linux*) OS=linux;;
*Linux*) OS=linux;;
+ *NetBSD*) OS=netbsd;;
esac
}
echo MAKE_TARGET=$MAKE_TARGET
echo BOOT_IMAGE=$BOOT_IMAGE
echo MAKE_IMAGE_TARGET=$MAKE_IMAGE_TARGET
+ echo GIT_PROTOCOL=$GIT_PROTOCOL
+ echo GIT_URL=$GIT_URL
}
set_build_info() {
echo_build_info
}
+invoke_git() {
+ git $*
+ check_ret git
+}
+
git_clone() {
echo "Downloading the git repository from factorcode.org..."
- git clone git://factorcode.org/git/factor.git
- check_ret git
+ invoke_git clone $GIT_URL
}
git_pull_factorcode() {
echo "Updating the git repository from factorcode.org..."
- git pull git://factorcode.org/git/factor.git master
- check_ret git
-}
-
-http_git_pull_factorcode() {
- echo "Updating the git repository from factorcode.org..."
- git pull http://factorcode.org/git/factor.git master
- check_ret git
+ invoke_git pull $GIT_URL master
}
cd_factor() {
check_ret cd
}
+invoke_make() {
+ case $OS in
+ netbsd) make='gmake';;
+ *) make='make';;
+ esac
+ $make $*
+ check_ret $make
+}
+
make_clean() {
- make clean
- check_ret make
+ invoke_make clean
}
make_factor() {
- make NO_UI=$NO_UI $MAKE_TARGET -j5
- check_ret make
+ invoke_make NO_UI=$NO_UI $MAKE_TARGET -j5
}
delete_boot_images() {
echo "Deleting old images..."
rm $BOOT_IMAGE > /dev/null 2>&1
rm $BOOT_IMAGE.* > /dev/null 2>&1
- rm staging.*.image > /dev/null 2>&1
+ rm staging.*.image > /dev/null 2>&1
}
get_boot_image() {
}
get_config_info() {
- check_installed_programs
find_build_info
+ check_installed_programs
check_libraries
}
make_factor
}
-http_update() {
- get_config_info
- http_git_pull_factorcode
- make_clean
- make_factor
-}
-
update_bootstrap() {
delete_boot_images
get_boot_image
}
refresh_image() {
- ./$FACTOR_BINARY -script -e="refresh-all save 0 USE: system exit"
+ ./$FACTOR_BINARY -script -e="USE: vocabs.loader refresh-all USE: memory save 0 USE: system exit"
check_ret factor
}
usage() {
echo "usage: $0 install|install-x11|self-update|quick-update|update|bootstrap|wget-bootstrap"
+ echo "If you are behind a firewall, invoke as:"
+ echo "env GIT_PROTOCOL=http $0 <command>"
}
case "$1" in
self-update) update; make_boot_image; bootstrap;;
quick-update) update; refresh_image ;;
update) update; update_bootstrap ;;
- http-update) http_update; update_bootstrap ;;
bootstrap) get_config_info; bootstrap ;;
wget-bootstrap) get_config_info; delete_boot_images; get_boot_image; bootstrap ;;
*) usage ;;