source: common/common-functions@ 8c48f24

ablfs
Last change on this file since 8c48f24 was 0cc9d4e, checked in by Pierre Labastie <pierre@…>, 12 years ago

Merge trunk r3603, 3648, 3673, 3677

  • Property mode set to 100644
File size: 3.3 KB
RevLine 
[877cc6a]1#!/bin/bash
2
3# $Id$
4
[4da2512]5set -e
[877cc6a]6
7
8no_empty_builddir() {
9 'clear'
10cat <<- -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
[a5e3400]15 from a previous build.
[877cc6a]16
17 Please format the partition mounted on \$BUILDDIR or set
[73e5448]18 a different build directory before running jhalfs.
[877cc6a]19${OFF}
20${DD_BORDER}
21-EOF-
22 exit
23}
24
25
26#----------------------------#
[261eea6]27run_make() { #
[877cc6a]28#----------------------------#
29 # Test if make must be run.
[401f81e]30 if [ "$RUNMAKE" = "y" ] ; then
[fe30c61]31 # Test to make sure we're not running the build as root
[045b2dc]32 if [ "$UID" = "0" ] ; then
33 echo "You must not be logged in as root to build the system."
[877cc6a]34 exit 1
35 fi
36 # Build the system
37 if [ -e $MKFILE ] ; then
38 echo -ne "Building the system...\n"
[a167246]39 cd $JHALFSDIR && make
[877cc6a]40 echo -ne "done\n"
41 fi
42 fi
43}
44
45
46#----------------------------#
[261eea6]47clean_builddir() { #
[877cc6a]48#----------------------------#
[d7390a5]49# Test if the clean must be done.
50if [ "${CLEAN}" = "y" ]; then
51 # If empty (i.e. could contain lost+found), do not do anything
[9225661]52 if $(ls -d $BUILDDIR/* > /dev/null 2>&1) &&
[d7390a5]53 [ "$(ls $BUILDDIR)" != "lost+found" ]; then
[877cc6a]54 # Test to make sure that the build directory was populated by jhalfs
55 if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
[5468631]56 echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
[877cc6a]57 exit 1
[a5e3400]58 # Test that dev filesystems are not mounted in $BUILDDIR
59 elif mount | grep $BUILDDIR/dev > /dev/null ; then
[d7390a5]60 echo "Looks like kernel filesystems are still mounted on $BUILDDIR."
[a5e3400]61 exit 1
[877cc6a]62 else
63 # Clean the build directory
[5468631]64 echo -n "Cleaning $BUILDDIR ..."
[3cb432a0]65 # First delete proc and sys directories, if exist.
[d7390a5]66 # Both should be empty. If not, we exit, and the rmdir command
67 # has generated an error message
[a5e3400]68 if [ -d $BUILDDIR/proc ] ; then
69 sudo rmdir $BUILDDIR/proc || exit 1
70 fi
71 if [ -d $BUILDDIR/sys ] ; then
72 sudo rmdir $BUILDDIR/sys || exit 1
73 fi
[0cc9d4e]74 sudo rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib{,64},media,mnt,run}
[6faeb63]75 sudo rm -rf $BUILDDIR/{opt,root,sbin,srv,tmp,tools,cross-tools,usr,var}
[78e2ad2]76 if [[ "${BLFS_TOOL}" = "y" ]] ; then
77 sudo rm -rf $BUILDDIR/$BLFS_ROOT
78 fi
[5468631]79 echo "done"
80 echo -n "Cleaning $JHALFSDIR ..."
81 sudo rm -rf $JHALFSDIR
82 echo "done"
[7072e1f]83 echo -n "Cleaning remaining extracted sources in $BUILDDIR/sources ..."
[8ea21f8]84 sudo rm -rf `find $BUILDDIR/sources -maxdepth 1 -mindepth 1 -type d`
[5468631]85 echo "done"
[877cc6a]86 fi
87 fi
[d7390a5]88fi
[877cc6a]89}
90
[fe30c61]91VERBOSITY2=$VERBOSITY
[877cc6a]92
[fe30c61]93[[ $VERBOSITY2 > 0 ]] && echo ""
[877cc6a]94
[fe30c61]95[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_book_parser>..."
96source $COMMON_DIR/libs/func_book_parser
97[[ $? > 0 ]] && echo "file libs/func_book_parser did not load.." && exit 1
98[[ $VERBOSITY2 > 0 ]] && echo "OK"
[877cc6a]99
[7432834]100
[fe30c61]101[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_download_pkgs>..."
102source $COMMON_DIR/libs/func_download_pkgs
103[[ $? > 0 ]] && echo "file libs/func_download_pkgs did not load.." && exit 1
104[[ $VERBOSITY2 > 0 ]] && echo "OK"
[2639f65]105
106
[fe30c61]107[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_wrt_Makefile>..."
108source $COMMON_DIR/libs/func_wrt_Makefile
109[[ $? > 0 ]] && echo "file libs/func_wrt_Makefile did not load.." && exit 1
110[[ $VERBOSITY2 > 0 ]] && echo "OK"
[877cc6a]111
[4965fa8]112
[d7390a5]113[[ $VERBOSITY2 > 0 ]] && echo -n " ..."
Note: See TracBrowser for help on using the repository browser.