2006-04-06 21:35:22 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
2006-08-29 20:16:27 +02:00
|
|
|
set -e
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
no_empty_builddir() {
|
|
|
|
'clear'
|
|
|
|
cat <<- -EOF-
|
|
|
|
${DD_BORDER}
|
|
|
|
|
|
|
|
${tab_}${tab_}${BOLD}${RED}W A R N I N G${OFF}
|
|
|
|
Looks like the \$BUILDDIR directory contains subdirectories
|
2007-02-18 13:37:10 +01:00
|
|
|
from a previous build.
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
Please format the partition mounted on \$BUILDDIR or set
|
2006-04-09 12:38:40 +02:00
|
|
|
a different build directory before running jhalfs.
|
2006-04-06 21:35:22 +02:00
|
|
|
${OFF}
|
|
|
|
${DD_BORDER}
|
|
|
|
-EOF-
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------#
|
2006-05-03 11:34:13 +02:00
|
|
|
run_make() { #
|
2006-04-06 21:35:22 +02:00
|
|
|
#----------------------------#
|
|
|
|
# Test if make must be run.
|
2006-08-16 19:42:54 +02:00
|
|
|
if [ "$RUNMAKE" = "y" ] ; then
|
2006-11-11 20:06:46 +01:00
|
|
|
# Test to make sure we're not running the build as root
|
2006-10-02 21:32:06 +02:00
|
|
|
if [ "$UID" = "0" ] ; then
|
|
|
|
echo "You must not be logged in as root to build the system."
|
2006-04-06 21:35:22 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
# Build the system
|
|
|
|
if [ -e $MKFILE ] ; then
|
|
|
|
echo -ne "Building the system...\n"
|
2006-04-17 13:15:24 +02:00
|
|
|
cd $JHALFSDIR && make
|
2006-04-06 21:35:22 +02:00
|
|
|
echo -ne "done\n"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------#
|
2006-05-03 11:34:13 +02:00
|
|
|
clean_builddir() { #
|
2006-04-06 21:35:22 +02:00
|
|
|
#----------------------------#
|
2012-02-10 10:33:23 +01:00
|
|
|
# Test if the clean must be done.
|
|
|
|
if [ "${CLEAN}" = "y" ]; then
|
|
|
|
# If empty (i.e. could contain lost+found), do not do anything
|
|
|
|
if $(ls $BUILDDIR/* > /dev/null 2>&1) &&
|
|
|
|
[ "$(ls $BUILDDIR)" != "lost+found" ]; then
|
2006-04-06 21:35:22 +02:00
|
|
|
# Test to make sure that the build directory was populated by jhalfs
|
|
|
|
if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
|
2006-10-07 21:11:58 +02:00
|
|
|
echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
|
2006-04-06 21:35:22 +02:00
|
|
|
exit 1
|
2007-02-18 13:37:10 +01:00
|
|
|
# Test that dev filesystems are not mounted in $BUILDDIR
|
|
|
|
elif mount | grep $BUILDDIR/dev > /dev/null ; then
|
2012-02-10 10:33:23 +01:00
|
|
|
echo "Looks like kernel filesystems are still mounted on $BUILDDIR."
|
2007-02-18 13:37:10 +01:00
|
|
|
exit 1
|
2006-04-06 21:35:22 +02:00
|
|
|
else
|
|
|
|
# Clean the build directory
|
2006-10-07 21:11:58 +02:00
|
|
|
echo -n "Cleaning $BUILDDIR ..."
|
2007-02-18 13:39:27 +01:00
|
|
|
# First delete proc and sys directories, if exist.
|
2012-02-10 10:33:23 +01:00
|
|
|
# Both should be empty. If not, we exit, and the rmdir command
|
|
|
|
# has generated an error message
|
2007-02-18 13:37:10 +01:00
|
|
|
if [ -d $BUILDDIR/proc ] ; then
|
|
|
|
sudo rmdir $BUILDDIR/proc || exit 1
|
|
|
|
fi
|
|
|
|
if [ -d $BUILDDIR/sys ] ; then
|
|
|
|
sudo rmdir $BUILDDIR/sys || exit 1
|
|
|
|
fi
|
|
|
|
sudo rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,root,sbin,srv,tmp,tools,cross-tools,usr,var}
|
2006-10-07 21:11:58 +02:00
|
|
|
echo "done"
|
|
|
|
echo -n "Cleaning $JHALFSDIR ..."
|
|
|
|
sudo rm -rf $JHALFSDIR
|
|
|
|
echo "done"
|
2012-02-02 00:29:37 +01:00
|
|
|
echo -n "Cleaning remaining extracted sources in $BUILDDIR/sources ..."
|
2006-10-07 21:11:58 +02:00
|
|
|
sudo rm -rf `find $BUILDDIR/sources/* -maxdepth 0 -type d`
|
|
|
|
echo "done"
|
2006-04-06 21:35:22 +02:00
|
|
|
fi
|
|
|
|
fi
|
2012-02-10 10:33:23 +01:00
|
|
|
fi
|
2006-04-06 21:35:22 +02:00
|
|
|
}
|
|
|
|
|
2006-11-11 20:06:46 +01:00
|
|
|
VERBOSITY2=$VERBOSITY
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2006-11-11 20:06:46 +01:00
|
|
|
[[ $VERBOSITY2 > 0 ]] && echo ""
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2006-11-11 20:06:46 +01:00
|
|
|
[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_book_parser>..."
|
|
|
|
source $COMMON_DIR/libs/func_book_parser
|
|
|
|
[[ $? > 0 ]] && echo "file libs/func_book_parser did not load.." && exit 1
|
|
|
|
[[ $VERBOSITY2 > 0 ]] && echo "OK"
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2006-07-23 16:44:13 +02:00
|
|
|
|
2006-11-11 20:06:46 +01:00
|
|
|
[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_download_pkgs>..."
|
|
|
|
source $COMMON_DIR/libs/func_download_pkgs
|
|
|
|
[[ $? > 0 ]] && echo "file libs/func_download_pkgs did not load.." && exit 1
|
|
|
|
[[ $VERBOSITY2 > 0 ]] && echo "OK"
|
2006-11-11 01:09:42 +01:00
|
|
|
|
|
|
|
|
2006-11-11 20:06:46 +01:00
|
|
|
[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_wrt_Makefile>..."
|
|
|
|
source $COMMON_DIR/libs/func_wrt_Makefile
|
|
|
|
[[ $? > 0 ]] && echo "file libs/func_wrt_Makefile did not load.." && exit 1
|
|
|
|
[[ $VERBOSITY2 > 0 ]] && echo "OK"
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2006-08-29 20:18:06 +02:00
|
|
|
|
2006-11-11 20:06:46 +01:00
|
|
|
[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_blfs_deps>..."
|
|
|
|
source $COMMON_DIR/libs/func_blfs_deps
|
|
|
|
[[ $? > 0 ]] && echo "file libs/func_blfs_deps did not load.." && exit 1
|
|
|
|
[[ $VERBOSITY2 > 0 ]] && echo "OK"
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2012-02-10 10:33:23 +01:00
|
|
|
[[ $VERBOSITY2 > 0 ]] && echo -n " ..."
|