source: common/common-functions@ adbd09b

ablfs-more legacy trunk
Last change on this file since adbd09b was 2e1c1c3, checked in by Pierre Labastie <pierre@…>, 7 years ago

Remove spaces at the end of lines

  • Property mode set to 100644
File size: 3.7 KB
Line 
1#!/bin/bash
2
3# $Id$
4
5set -e
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
15 from a previous build.
16
17 Please format the partition mounted on \$BUILDDIR or set
18 a different build directory before running jhalfs.
19${OFF}
20${DD_BORDER}
21-EOF-
22 exit
23}
24
25
26#----------------------------#
27run_make() { #
28#----------------------------#
29 # Test if make must be run.
30 if [ "$RUNMAKE" = "y" ] ; then
31 # Test to make sure we're not running the build as root
32 if [ "$UID" = "0" ] ; then
33 echo "You must not be logged in as root to build the system."
34 exit 1
35 fi
36 # Build the system
37 if [ -e $MKFILE ] ; then
38 echo -ne "Building the system...\n"
39 cd $JHALFSDIR && make
40 echo -ne "done\n"
41 fi
42 fi
43}
44
45
46#----------------------------#
47clean_builddir() { #
48#----------------------------#
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
52 if ls -d $BUILDDIR/* > /dev/null 2>&1 &&
53 [ "$(ls $BUILDDIR)" != "lost+found" ]; then
54 # Test to make sure that the build directory was populated by jhalfs
55 if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
56 echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
57 exit 1
58 # Test that dev filesystems are not mounted in $BUILDDIR
59 elif mount | grep $BUILDDIR/dev > /dev/null ; then
60 echo "Looks like kernel filesystems are still mounted on $BUILDDIR."
61 exit 1
62 else
63 if [ $JHALFSDIR/*gcc-pass1 != $JHALFSDIR/'*gcc-pass1' ]; then
64 echo -n "$BUILDDIR contains already built packages. Clean anyway? yes/no (yes): "
65 read ANSWER
66 if [ x${ANSWER:0:1} = "xn" -o x${ANSWER:0:1} = "xN" ] ; then
67 echo "${nl_}Rerun and change the option in the menu.${nl_}"
68 exit 1
69 fi
70 fi
71 # Clean the build directory
72 echo -n "Cleaning $BUILDDIR ..."
73 # First delete proc and sys directories, if they exist.
74 # Both should be empty. If not, we exit, and the rmdir command
75 # has generated an error message
76 if [ -d $BUILDDIR/proc ] ; then
77 sudo rmdir $BUILDDIR/proc || exit 1
78 fi
79 if [ -d $BUILDDIR/sys ] ; then
80 sudo rmdir $BUILDDIR/sys || exit 1
81 fi
82 sudo rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib{,64},media,mnt,run}
83 sudo rm -rf $BUILDDIR/{opt,root,sbin,srv,tmp,tools,cross-tools,usr,var}
84 echo "done"
85 if [[ "${BLFS_TOOL}" = "y" ]] ; then
86 echo -n "Cleaning $BUILDDIR/$BLFS_ROOT ..."
87 sudo rm -rf $BUILDDIR/$BLFS_ROOT
88 echo "done"
89 fi
90 echo -n "Cleaning $JHALFSDIR ..."
91 sudo rm -rf $JHALFSDIR
92 echo "done"
93 echo -n "Cleaning remaining extracted sources in $BUILDDIR/sources ..."
94 sudo rm -rf `find $BUILDDIR/sources -maxdepth 1 -mindepth 1 -type d`
95 echo "done"
96 fi
97 fi
98fi
99}
100
101VERBOSITY2=$VERBOSITY
102
103[[ $VERBOSITY2 > 0 ]] && echo ""
104
105[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_book_parser>..."
106source $COMMON_DIR/libs/func_book_parser
107[[ $? > 0 ]] && echo "file libs/func_book_parser did not load.." && exit 1
108[[ $VERBOSITY2 > 0 ]] && echo "OK"
109
110
111[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_download_pkgs>..."
112source $COMMON_DIR/libs/func_download_pkgs
113[[ $? > 0 ]] && echo "file libs/func_download_pkgs did not load.." && exit 1
114[[ $VERBOSITY2 > 0 ]] && echo "OK"
115
116
117[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_wrt_Makefile>..."
118source $COMMON_DIR/libs/func_wrt_Makefile
119[[ $? > 0 ]] && echo "file libs/func_wrt_Makefile did not load.." && exit 1
120[[ $VERBOSITY2 > 0 ]] && echo "OK"
121
122
123[[ $VERBOSITY2 > 0 ]] && echo -n " ..."
Note: See TracBrowser for help on using the repository browser.