[0170229] | 1 | #!/bin/bash
|
---|
[dd810ea] | 2 |
|
---|
| 3 | # $Id$
|
---|
| 4 |
|
---|
[0818ea6] | 5 | set -e
|
---|
[0170229] | 6 |
|
---|
| 7 |
|
---|
| 8 | no_empty_builddir() {
|
---|
| 9 | 'clear'
|
---|
| 10 | cat <<- -EOF-
|
---|
| 11 | ${DD_BORDER}
|
---|
| 12 |
|
---|
| 13 | ${tab_}${tab_}${BOLD}${RED}W A R N I N G${OFF}
|
---|
| 14 | Looks like the \$BUILDDIR directory contains subdirectories
|
---|
[9c9775f] | 15 | from a previous build.
|
---|
[0170229] | 16 |
|
---|
| 17 | Please format the partition mounted on \$BUILDDIR or set
|
---|
[9c9775f] | 18 | a different build directory before running jhalfs.
|
---|
[0170229] | 19 | ${OFF}
|
---|
| 20 | ${DD_BORDER}
|
---|
| 21 | -EOF-
|
---|
| 22 | exit
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 |
|
---|
| 26 | #----------------------------#
|
---|
[65d83a6] | 27 | run_make() { #
|
---|
[0170229] | 28 | #----------------------------#
|
---|
| 29 | # Test if make must be run.
|
---|
[47fddc8] | 30 | if [ "$RUNMAKE" = "y" ] ; then
|
---|
[9c9775f] | 31 | # Test to make sure we're not running the build as root
|
---|
[621f01f] | 32 | if [ "$UID" = "0" ] ; then
|
---|
[7d4cc81] | 33 | echo "You must not be logged in as root to build the system."
|
---|
[0170229] | 34 | exit 1
|
---|
| 35 | fi
|
---|
| 36 | # Build the system
|
---|
| 37 | if [ -e $MKFILE ] ; then
|
---|
[60b56fd] | 38 | echo -ne "Building the system...\n"
|
---|
[54b4b32] | 39 | cd $JHALFSDIR && make
|
---|
[0170229] | 40 | echo -ne "done\n"
|
---|
| 41 | fi
|
---|
| 42 | fi
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 |
|
---|
| 46 | #----------------------------#
|
---|
[65d83a6] | 47 | clean_builddir() { #
|
---|
[0170229] | 48 | #----------------------------#
|
---|
| 49 | # Test if the clean must be done.
|
---|
[47fddc8] | 50 | if [ "${CLEAN}" = "y" ]; then
|
---|
[0170229] | 51 | # Test to make sure that the build directory was populated by jhalfs
|
---|
| 52 | if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
|
---|
[9c9775f] | 53 | echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
|
---|
| 54 | exit 1
|
---|
| 55 | # Test that dev filesystems are not mounted in $BUILDDIR
|
---|
| 56 | elif mount | grep $BUILDDIR/dev > /dev/null ; then
|
---|
| 57 | echo "Looks like kernel fylesystems are yet mounted on $BUILDDIR."
|
---|
[0170229] | 58 | exit 1
|
---|
| 59 | else
|
---|
| 60 | # Clean the build directory
|
---|
[2ee1d11] | 61 | echo -n "Cleaning $BUILDDIR ..."
|
---|
[9c9775f] | 62 | # First delete proc and sys directories, if exist.
|
---|
| 63 | # Both should be empty, if not be sure to exit.
|
---|
| 64 | if [ -d $BUILDDIR/proc ] ; then
|
---|
| 65 | sudo rmdir $BUILDDIR/proc || exit 1
|
---|
| 66 | fi
|
---|
| 67 | if [ -d $BUILDDIR/sys ] ; then
|
---|
| 68 | sudo rmdir $BUILDDIR/sys || exit 1
|
---|
| 69 | fi
|
---|
| 70 | sudo rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,root,sbin,srv,tmp,tools,cross-tools,usr,var}
|
---|
[2ee1d11] | 71 | echo "done"
|
---|
| 72 | echo -n "Cleaning $JHALFSDIR ..."
|
---|
| 73 | sudo rm -rf $JHALFSDIR
|
---|
| 74 | echo "done"
|
---|
| 75 | echo -n "Cleaning remainig extracted sources in $BUILDDIR/sources ..."
|
---|
| 76 | sudo rm -rf `find $BUILDDIR/sources/* -maxdepth 0 -type d`
|
---|
| 77 | echo "done"
|
---|
[0170229] | 78 | fi
|
---|
| 79 | fi
|
---|
| 80 | }
|
---|
| 81 |
|
---|
[9c9775f] | 82 | VERBOSITY2=$VERBOSITY
|
---|
[0170229] | 83 |
|
---|
[9c9775f] | 84 | [[ $VERBOSITY2 > 0 ]] && echo ""
|
---|
[3b63c8c] | 85 |
|
---|
[9c9775f] | 86 | [[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_book_parser>..."
|
---|
| 87 | source $COMMON_DIR/libs/func_book_parser
|
---|
| 88 | [[ $? > 0 ]] && echo "file libs/func_book_parser did not load.." && exit 1
|
---|
| 89 | [[ $VERBOSITY2 > 0 ]] && echo "OK"
|
---|
[0170229] | 90 |
|
---|
| 91 |
|
---|
[9c9775f] | 92 | [[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_download_pkgs>..."
|
---|
| 93 | source $COMMON_DIR/libs/func_download_pkgs
|
---|
| 94 | [[ $? > 0 ]] && echo "file libs/func_download_pkgs did not load.." && exit 1
|
---|
| 95 | [[ $VERBOSITY2 > 0 ]] && echo "OK"
|
---|
[0170229] | 96 |
|
---|
[3b63c8c] | 97 |
|
---|
[9c9775f] | 98 | [[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_wrt_Makefile>..."
|
---|
| 99 | source $COMMON_DIR/libs/func_wrt_Makefile
|
---|
| 100 | [[ $? > 0 ]] && echo "file libs/func_wrt_Makefile did not load.." && exit 1
|
---|
| 101 | [[ $VERBOSITY2 > 0 ]] && echo "OK"
|
---|
[dd810ea] | 102 |
|
---|
[3c5ca23] | 103 |
|
---|
[9c9775f] | 104 | [[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_blfs_deps>..."
|
---|
| 105 | source $COMMON_DIR/libs/func_blfs_deps
|
---|
| 106 | [[ $? > 0 ]] && echo "file libs/func_blfs_deps did not load.." && exit 1
|
---|
| 107 | [[ $VERBOSITY2 > 0 ]] && echo "OK"
|
---|
[0170229] | 108 |
|
---|
[9c9775f] | 109 | [[ $VERBOSITY2 > 0 ]] && echo -n " ..." |
---|