2006-04-06 19:35:22 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
2006-08-29 18:16:27 +00:00
|
|
|
set -e
|
2006-04-06 19:35:22 +00: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 12:37:10 +00:00
|
|
|
from a previous build.
|
2006-04-06 19:35:22 +00:00
|
|
|
|
|
|
|
Please format the partition mounted on \$BUILDDIR or set
|
2006-04-09 10:38:40 +00:00
|
|
|
a different build directory before running jhalfs.
|
2006-04-06 19:35:22 +00:00
|
|
|
${OFF}
|
|
|
|
${DD_BORDER}
|
|
|
|
-EOF-
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------#
|
2006-05-03 09:34:13 +00:00
|
|
|
run_make() { #
|
2006-04-06 19:35:22 +00:00
|
|
|
#----------------------------#
|
|
|
|
# Test if make must be run.
|
2006-08-16 17:42:54 +00:00
|
|
|
if [ "$RUNMAKE" = "y" ] ; then
|
2006-11-11 19:06:46 +00:00
|
|
|
# Test to make sure we're not running the build as root
|
2006-10-02 19:32:06 +00:00
|
|
|
if [ "$UID" = "0" ] ; then
|
|
|
|
echo "You must not be logged in as root to build the system."
|
2006-04-06 19:35:22 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
# Build the system
|
2019-04-13 16:31:24 +00:00
|
|
|
if [ -e "$MKFILE" ] ; then
|
2006-04-06 19:35:22 +00:00
|
|
|
echo -ne "Building the system...\n"
|
2020-06-05 10:18:27 +00:00
|
|
|
if { echo try tty; tty; }; then
|
2019-04-13 16:31:24 +00:00
|
|
|
cd "$JHALFSDIR" && make
|
2006-04-06 19:35:22 +00:00
|
|
|
echo -ne "done\n"
|
2020-06-05 10:18:27 +00:00
|
|
|
else echo there is no terminal!!; fi
|
2006-04-06 19:35:22 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------#
|
2006-05-03 09:34:13 +00:00
|
|
|
clean_builddir() { #
|
2006-04-06 19:35:22 +00:00
|
|
|
#----------------------------#
|
2012-02-10 09:33:23 +00:00
|
|
|
# Test if the clean must be done.
|
|
|
|
if [ "${CLEAN}" = "y" ]; then
|
|
|
|
# If empty (i.e. could contain lost+found), do not do anything
|
2017-11-01 14:39:34 +00:00
|
|
|
if ls -d $BUILDDIR/* > /dev/null 2>&1 &&
|
2012-02-10 09:33:23 +00:00
|
|
|
[ "$(ls $BUILDDIR)" != "lost+found" ]; then
|
2006-04-06 19:35:22 +00:00
|
|
|
# Test to make sure that the build directory was populated by jhalfs
|
|
|
|
if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
|
2006-10-07 19:11:58 +00:00
|
|
|
echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
|
2006-04-06 19:35:22 +00:00
|
|
|
exit 1
|
2007-02-18 12:37:10 +00:00
|
|
|
# Test that dev filesystems are not mounted in $BUILDDIR
|
|
|
|
elif mount | grep $BUILDDIR/dev > /dev/null ; then
|
2012-02-10 09:33:23 +00:00
|
|
|
echo "Looks like kernel filesystems are still mounted on $BUILDDIR."
|
2007-02-18 12:37:10 +00:00
|
|
|
exit 1
|
2006-04-06 19:35:22 +00:00
|
|
|
else
|
2017-11-01 14:40:53 +00:00
|
|
|
if [ $JHALFSDIR/*gcc-pass1 != $JHALFSDIR/'*gcc-pass1' ]; then
|
|
|
|
echo -n "$BUILDDIR contains already built packages. Clean anyway? yes/no (yes): "
|
|
|
|
read ANSWER
|
|
|
|
if [ x${ANSWER:0:1} = "xn" -o x${ANSWER:0:1} = "xN" ] ; then
|
|
|
|
echo "${nl_}Rerun and change the option in the menu.${nl_}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2006-04-06 19:35:22 +00:00
|
|
|
# Clean the build directory
|
2006-10-07 19:11:58 +00:00
|
|
|
echo -n "Cleaning $BUILDDIR ..."
|
2017-11-01 14:40:09 +00:00
|
|
|
# First delete proc and sys directories, if they exist.
|
2012-02-10 09:33:23 +00:00
|
|
|
# Both should be empty. If not, we exit, and the rmdir command
|
|
|
|
# has generated an error message
|
2007-02-18 12:37:10 +00: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
|
2013-01-11 13:27:58 +00:00
|
|
|
sudo rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib{,64},media,mnt,run}
|
2012-12-30 16:26:22 +00:00
|
|
|
sudo rm -rf $BUILDDIR/{opt,root,sbin,srv,tmp,tools,cross-tools,usr,var}
|
2013-12-15 07:34:58 +00:00
|
|
|
echo "done"
|
2018-01-13 09:08:56 +00:00
|
|
|
if [[ "${BLFS_TOOL}" = "y" ]] ; then
|
2013-12-15 07:34:58 +00:00
|
|
|
echo -n "Cleaning $BUILDDIR/$BLFS_ROOT ..."
|
2013-10-29 15:42:03 +00:00
|
|
|
sudo rm -rf $BUILDDIR/$BLFS_ROOT
|
2013-12-15 07:34:58 +00:00
|
|
|
echo "done"
|
2013-10-29 15:42:03 +00:00
|
|
|
fi
|
2006-10-07 19:11:58 +00:00
|
|
|
echo -n "Cleaning $JHALFSDIR ..."
|
|
|
|
sudo rm -rf $JHALFSDIR
|
|
|
|
echo "done"
|
2012-02-01 23:29:37 +00:00
|
|
|
echo -n "Cleaning remaining extracted sources in $BUILDDIR/sources ..."
|
2012-02-22 10:18:02 +00:00
|
|
|
sudo rm -rf `find $BUILDDIR/sources -maxdepth 1 -mindepth 1 -type d`
|
2006-10-07 19:11:58 +00:00
|
|
|
echo "done"
|
2020-03-29 13:05:48 +00:00
|
|
|
echo -n "Removing dangling symlinks in / ..."
|
|
|
|
sudo rm -f /tools /cross-tools
|
|
|
|
echo "done"
|
2006-04-06 19:35:22 +00:00
|
|
|
fi
|
|
|
|
fi
|
2012-02-10 09:33:23 +00:00
|
|
|
fi
|
2006-04-06 19:35:22 +00:00
|
|
|
}
|