Author: cfinck
Date: Wed Nov 7 19:46:04 2007
New Revision: 30243
URL:
http://svn.reactos.org/svn/reactos?rev=30243&view=rev
Log:
Add a feature to update an existing RosBE-Unix installation and only recompile the changed
tools in this case
Modified:
trunk/tools/RosBE-Unix/RosBE-Builder.sh
Modified: trunk/tools/RosBE-Unix/RosBE-Builder.sh
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/RosBE-Unix/RosBE-Builder.sh?…
==============================================================================
--- trunk/tools/RosBE-Unix/RosBE-Builder.sh (original)
+++ trunk/tools/RosBE-Unix/RosBE-Builder.sh Wed Nov 7 19:46:04 2007
@@ -8,6 +8,7 @@
# Constants
ROSBE_VERSION="0.3.7-SVN"
+KNOWN_ROSBE_VERSIONS="0.3.6 0.3.7-SVN"
DEFAULT_INSTALL_DIR="/usr/RosBE"
NEEDED_TOOLS="bison flex gcc g++ grep makeinfo" # GNU Make has a special
check
@@ -54,6 +55,36 @@
fi
fi
}
+
+showchoice()
+{
+ default_value="$1"
+ valid_choices="$2"
+
+ breakloop=false
+ choice=""
+
+ while true; do
+ read -p "Your choice [$default_value]: " choice
+
+ if [ "$choice" = "" ]; then
+ choice="$default_value"
+ break
+ fi
+
+ for valid_choice in $valid_choices; do
+ if [ "$choice" = "$valid_choice" ]; then
+ breakloop=true
+ break
+ fi
+ done
+
+ if $breakloop; then
+ break
+ fi
+ done
+}
+
echo
"*******************************************************************************"
echo "* ReactOS Build Environment for Unix-based Operating Systems
*"
@@ -144,6 +175,7 @@
createdir=false
installdir=""
+update=false
while [ "$installdir" = "" ]; do
read -p "[$DEFAULT_INSTALL_DIR] " installdir
@@ -162,14 +194,54 @@
elif [ -d "$installdir" ]; then
# Check if the directory is empty
if [ ! "`ls $installdir`" = "" ]; then
- echo "The directory \"$installdir\" is not empty. Do you really want to
continue? (yes/no)"
- read -p "[no] " answer
- echo
-
- if [ "$answer" != "yes" ]; then
- echo "Please enter another directory!"
+ if [ -f "$installdir/RosBE-Version" ]; then
+ # Allow the user to update an already installed RosBE version
+ choice=""
+ installed_version=`cat "$installdir/RosBE-Version"`
+
+ for known_version in $KNOWN_ROSBE_VERSIONS; do
+ if [ "$known_version" = "$installed_version" ]; then
+ if [ "$installed_version" = "$ROSBE_VERSION" ]; then
+ echo "The current version of the Build Environment is already installed in
this directory."
+ echo "Please choose one of the following options:"
+ echo
+ echo " (R)einstall all components of the Build Environment"
+ echo " (C)hoose a different installation directory"
+ echo
+
+ showchoice "R" "r R c C"
+ else
+ echo "An older version of the Build Environment has been found in this
directory."
+ echo "Please choose one of the following options:"
+ echo
+ echo " (U)pdate the existing Build Environment"
+ echo " (R)einstall all new components of the Build Environment"
+ echo " (C)hoose a different installation directory"
+ echo
+
+ showchoice "U" "u U r R c C"
+ fi
+
+ echo
+ break
+ fi
+ done
+
+ if [ "$choice" = "U" ] || [ "$choice" = "u"
]; then
+ update=true
+ elif [ "$choice" = "C" ] || [ "$choice" = "c"
]; then
+ echo "Please enter another directory!"
+ installdir=""
+ fi
+ else
+ echo "The directory \"$installdir\" is not empty. Do you really want
to continue? (yes/no)"
+ read -p "[no] " answer
echo
- installdir=""
+
+ if [ "$answer" != "yes" ]; then
+ echo "Please enter another directory!"
+ installdir=""
+ fi
fi
fi
@@ -191,11 +263,54 @@
exit 1
fi
-# Create the directory if necessary
-if $createdir; then
- if ! mkdir -p "$installdir"; then
- redmsg "Could not create \"$installdir\", aborted!"
- exit 1
+if $update; then
+ setvalues=false
+
+ process_cpucount=false
+ process_mingwruntime=false
+ process_w32api=false
+ process_binutils=false
+ process_gcc=false
+ process_make=false
+ process_nasm=false
+ process_buildtime=false
+
+ # Logic behind this update part:
+ # - KNOWN_ROSBE_VERSIONS contains all versions from the oldest to the newest one (in
this order!)
+ # - setvalues will be set to true, when the iterator reaches the installed version
+ # - Then the processing settings of the installed and the later versions will be
applied.
+ # (i.e. if gcc changed from 0.3.7 to 0.3.8, but not from 0.3.6 to 0.3.7, the gcc
build will correctly be reprocessed
+ # if the user has an installed RosBE 0.3.6 and wants to update to 0.3.8)
+ for known_version in $KNOWN_ROSBE_VERSIONS; do
+ if [ "$known_version" = "$installed_version" ]; then
+ setvalues=true
+ fi
+
+ if $setvalues; then
+ case "$known_version" in
+ "0.3.6")
+ # TODO: Define what has to be reprocessed, when updating from 0.3.6 to the next
version
+ process_cpucount=true
+ ;;
+ esac
+ fi
+ done
+else
+ process_cpucount=true
+ process_mingwruntime=true
+ process_w32api=true
+ process_binutils=true
+ process_gcc=true
+ process_make=true
+ process_nasm=true
+ process_buildtime=true
+
+ # Create the directory if necessary
+ if $createdir; then
+ if ! mkdir -p "$installdir"; then
+ redmsg "Could not create \"$installdir\", aborted!"
+ exit 1
+ fi
fi
fi
@@ -214,150 +329,168 @@
mkdir -p "$installdir/mingw32" >& /dev/null
# cpucount
-echo -n "Compiling cpucount... "
-gcc -o "$installdir/bin/cpucount" "$SCRIPTDIR/tools/cpucount.c"
-checkrun
+if $process_cpucount; then
+ echo -n "Compiling cpucount... "
+ gcc -o "$installdir/bin/cpucount" "$SCRIPTDIR/tools/cpucount.c"
+ checkrun
+fi
+
CPUCOUNT=`$installdir/bin/cpucount`
+cd "$installdir/mingw32"
# mingw-runtime
-echo -n "Extracting mingw-runtime... "
-cd "$installdir/mingw32"
-tar -xjf "$SOURCEDIR/mingw-runtime.tar.bz2" >&
"$SCRIPTDIR/tar.log"
-checkrun "tar"
+if $process_mingwruntime; then
+ echo -n "Extracting mingw-runtime... "
+ tar -xjf "$SOURCEDIR/mingw-runtime.tar.bz2" >&
"$SCRIPTDIR/tar.log"
+ checkrun "tar"
+fi
# w32api
-echo -n "Extracting w32api... "
-tar -xjf "$SOURCEDIR/w32api.tar.bz2" >& "$SCRIPTDIR/tar.log"
-checkrun "tar"
+if $process_w32api; then
+ echo -n "Extracting w32api... "
+ tar -xjf "$SOURCEDIR/w32api.tar.bz2" >& "$SCRIPTDIR/tar.log"
+ checkrun "tar"
+fi
+
cd "$SOURCEDIR"
# binutils
-rm -rf "binutils"
-rm -rf "binutils-build"
-
-echo -n "Extracting binutils... "
-tar -xjf "binutils.tar.bz2" >& "$SCRIPTDIR/tar.log"
-checkrun "tar"
-
-echo -n "Configuring binutils... "
-mkdir "binutils-build"
-cd "binutils-build"
-../binutils/configure --prefix="$installdir" --target=mingw32 --disable-nls
--with-gcc \
- --with-gnu-as --with-gnu-ld --disable-shared >&
"$SCRIPTDIR/configure.log"
-checkrun "configure"
-
-echo -n "Building binutils... "
-$makecmd -j $CPUCOUNT CFLAGS="-O2 -fno-exceptions" LDFLAGS="-s"
>& "$SCRIPTDIR/make.log"
-checkrun "make"
-
-echo -n "Installing binutils... "
-$makecmd install >& "$SCRIPTDIR/make.log"
-checkrun "make"
-
-echo -n "Cleaning up binutils... "
-cd "$SOURCEDIR"
-rm -rf "binutils-build"
-rm -rf "binutils"
-checkrun
+if $process_binutils; then
+ rm -rf "binutils"
+ rm -rf "binutils-build"
+
+ echo -n "Extracting binutils... "
+ tar -xjf "binutils.tar.bz2" >& "$SCRIPTDIR/tar.log"
+ checkrun "tar"
+
+ echo -n "Configuring binutils... "
+ mkdir "binutils-build"
+ cd "binutils-build"
+ ../binutils/configure --prefix="$installdir" --target=mingw32 --disable-nls
--with-gcc \
+ --with-gnu-as --with-gnu-ld --disable-shared >&
"$SCRIPTDIR/configure.log"
+ checkrun "configure"
+
+ echo -n "Building binutils... "
+ $makecmd -j $CPUCOUNT CFLAGS="-O2 -fno-exceptions" LDFLAGS="-s"
>& "$SCRIPTDIR/make.log"
+ checkrun "make"
+
+ echo -n "Installing binutils... "
+ $makecmd install >& "$SCRIPTDIR/make.log"
+ checkrun "make"
+
+ echo -n "Cleaning up binutils... "
+ cd "$SOURCEDIR"
+ rm -rf "binutils-build"
+ rm -rf "binutils"
+ checkrun
+fi
# gcc
-rm -rf "gcc"
-rm -rf "gcc-build"
-
-echo -n "Extracting gcc... "
-tar -xjf "gcc.tar.bz2" >& "$SCRIPTDIR/tar.log"
-checkrun "tar"
-
-echo -n "Configuring gcc... "
-mkdir "gcc-build"
-cd "gcc-build"
-../gcc/configure --prefix="$installdir" --target=mingw32 \
- --with-headers="$installdir/mingw32/include"--with-gcc
--with-gnu-ld \
- --with-gnu-as --enable-languages=c,c++ --enable-checking=release \
- --enable-threads=win32 --disable-win32-registry --disable-nls \
- --disable-shared >& "$SCRIPTDIR/configure.log"
-checkrun "configure"
-
-echo -n "Building gcc... "
-$makecmd -j $CPUCOUNT CFLAGS="-O2" CXXFLAGS="-O2"
LDFLAGS="-s" >& "$SCRIPTDIR/make.log"
-checkrun "make"
-
-echo -n "Installing gcc... "
-$makecmd install >& "$SCRIPTDIR/make.log"
-checkrun "make"
-
-echo -n "Cleaning up gcc... "
-cd "$SOURCEDIR"
-rm -rf "gcc-build"
-rm -rf "gcc"
-checkrun
+if $process_gcc; then
+ rm -rf "gcc"
+ rm -rf "gcc-build"
+
+ echo -n "Extracting gcc... "
+ tar -xjf "gcc.tar.bz2" >& "$SCRIPTDIR/tar.log"
+ checkrun "tar"
+
+ echo -n "Configuring gcc... "
+ mkdir "gcc-build"
+ cd "gcc-build"
+ ../gcc/configure --prefix="$installdir" --target=mingw32 \
+ --with-headers="$installdir/mingw32/include"--with-gcc --with-gnu-ld \
+ --with-gnu-as --enable-languages=c,c++ --enable-checking=release \
+ --enable-threads=win32 --disable-win32-registry --disable-nls \
+ --disable-shared >& "$SCRIPTDIR/configure.log"
+ checkrun "configure"
+
+ echo -n "Building gcc... "
+ $makecmd -j $CPUCOUNT CFLAGS="-O2" CXXFLAGS="-O2"
LDFLAGS="-s" >& "$SCRIPTDIR/make.log"
+ checkrun "make"
+
+ echo -n "Installing gcc... "
+ $makecmd install >& "$SCRIPTDIR/make.log"
+ checkrun "make"
+
+ echo -n "Cleaning up gcc... "
+ cd "$SOURCEDIR"
+ rm -rf "gcc-build"
+ rm -rf "gcc"
+ checkrun
+fi
# make
-rm -rf "make"
-rm -rf "make-build"
-
-echo -n "Extracting make... "
-tar -xjf "make.tar.bz2" >& "$SCRIPTDIR/tar.log"
-checkrun "tar"
-
-echo -n "Configuring make... "
-mkdir "make-build"
-cd "make-build"
-../make/configure --prefix="$installdir" --target=mingw32 \
- --disable-dependency-tracking --disable-nls \
- --enable-case-insensitive-file-system --disable-job-server
--disable-rpath \
- --program-prefix=mingw32- >&
"$SCRIPTDIR/configure.log"
-checkrun "configure"
-
-echo -n "Building make... "
-$makecmd -j $CPUCOUNT CFLAGS="-s -O2 -mms-bitfields" >&
"$SCRIPTDIR/make.log"
-checkrun "make"
-
-echo -n "Installing make... "
-$makecmd install >& "$SCRIPTDIR/make.log"
-checkrun "make"
-
-echo -n "Cleaning up make... "
-cd "$SOURCEDIR"
-rm -rf "make-build"
-rm -rf "make"
-checkrun
+if $process_make; then
+ rm -rf "make"
+ rm -rf "make-build"
+
+ echo -n "Extracting make... "
+ tar -xjf "make.tar.bz2" >& "$SCRIPTDIR/tar.log"
+ checkrun "tar"
+
+ echo -n "Configuring make... "
+ mkdir "make-build"
+ cd "make-build"
+ ../make/configure --prefix="$installdir" --target=mingw32 \
+ --disable-dependency-tracking --disable-nls \
+ --enable-case-insensitive-file-system --disable-job-server --disable-rpath \
+ --program-prefix=mingw32- >& "$SCRIPTDIR/configure.log"
+ checkrun "configure"
+
+ echo -n "Building make... "
+ $makecmd -j $CPUCOUNT CFLAGS="-s -O2 -mms-bitfields" >&
"$SCRIPTDIR/make.log"
+ checkrun "make"
+
+ echo -n "Installing make... "
+ $makecmd install >& "$SCRIPTDIR/make.log"
+ checkrun "make"
+
+ echo -n "Cleaning up make... "
+ cd "$SOURCEDIR"
+ rm -rf "make-build"
+ rm -rf "make"
+ checkrun
+fi
# nasm
-rm -rf "nasm"
-rm -rf "nasm-build"
-
-echo -n "Extracting nasm... "
-tar -xjf "nasm.tar.bz2" >& "$SCRIPTDIR/tar.log"
-checkrun "tar"
-
-echo -n "Configuring nasm... "
-mkdir "nasm-build"
-cd "nasm-build"
-../nasm/configure --prefix="$installdir" --target=mingw32 >&
"$SCRIPTDIR/configure.log"
-checkrun "configure"
-
-echo -n "Building nasm... "
-$makecmd -j $CPUCOUNT >& "$SCRIPTDIR/make.log"
-checkrun "make"
-
-echo -n "Installing nasm... "
-$makecmd install >& "$SCRIPTDIR/make.log"
-checkrun "make"
-
-echo -n "Cleaning up nasm... "
-cd "$SOURCEDIR"
-rm -rf "nasm-build"
-rm -rf "nasm"
-checkrun
+if $process_nasm; then
+ rm -rf "nasm"
+ rm -rf "nasm-build"
+
+ echo -n "Extracting nasm... "
+ tar -xjf "nasm.tar.bz2" >& "$SCRIPTDIR/tar.log"
+ checkrun "tar"
+
+ echo -n "Configuring nasm... "
+ mkdir "nasm-build"
+ cd "nasm-build"
+ ../nasm/configure --prefix="$installdir" --target=mingw32 >&
"$SCRIPTDIR/configure.log"
+ checkrun "configure"
+
+ echo -n "Building nasm... "
+ $makecmd -j $CPUCOUNT >& "$SCRIPTDIR/make.log"
+ checkrun "make"
+
+ echo -n "Installing nasm... "
+ $makecmd install >& "$SCRIPTDIR/make.log"
+ checkrun "make"
+
+ echo -n "Cleaning up nasm... "
+ cd "$SOURCEDIR"
+ rm -rf "nasm-build"
+ rm -rf "nasm"
+ checkrun
+fi
# Final actions
echo
boldmsg "Final actions"
-echo -n "Compiling buildtime... "
-gcc -o "$installdir/bin/buildtime" "$SCRIPTDIR/tools/buildtime.c"
-checkrun
+if $process_buildtime; then
+ echo -n "Compiling buildtime... "
+ gcc -o "$installdir/bin/buildtime" "$SCRIPTDIR/tools/buildtime.c"
+ checkrun
+fi
echo -n "Removing unneeded files... "
rm -rf "$installdir/mingw32/sys-include"