source: common/common-functions@ 2ac2fc5

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

When cleaning BUILD_DIR, clean also 32 bit library dirs in case multilib
has been used

  • Property mode set to 100644
File size: 3.1 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 if { echo try tty; tty; }; then
40 cd "$JHALFSDIR" && make
41 echo -ne "done\n"
42 else echo there is no terminal!!; fi
43 fi
44 fi
45}
46
47
48#----------------------------#
49clean_builddir() { #
50#----------------------------#
51# Test if the clean must be done.
52if [ "${CLEAN}" = "y" ]; then
53 # If empty (i.e. could contain lost+found), do not do anything
54 if ls -d $BUILDDIR/* > /dev/null 2>&1 &&
55 [ "$(ls $BUILDDIR)" != "lost+found" ]; then
56 # Test to make sure that the build directory was populated by jhalfs
57 if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
58 echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
59 exit 1
60 # Test that dev filesystems are not mounted in $BUILDDIR
61 elif mount | grep $BUILDDIR/dev > /dev/null ; then
62 echo "Looks like kernel filesystems are still mounted on $BUILDDIR."
63 exit 1
64 else
65 if [ $JHALFSDIR/*gcc-pass1 != $JHALFSDIR/'*gcc-pass1' ]; then
66 echo -n "$BUILDDIR contains already built packages. Clean anyway? yes/no (yes): "
67 read ANSWER
68 if [ x${ANSWER:0:1} = "xn" -o x${ANSWER:0:1} = "xN" ] ; then
69 echo "${nl_}Rerun and change the option in the menu.${nl_}"
70 exit 1
71 fi
72 fi
73 # Clean the build directory
74 echo -n "Cleaning $BUILDDIR ..."
75 # First delete proc and sys directories, if they exist.
76 # Both should be empty. If not, we exit, and the rmdir command
77 # has generated an error message
78 if [ -d $BUILDDIR/proc ] ; then
79 sudo rmdir $BUILDDIR/proc || exit 1
80 fi
81 if [ -d $BUILDDIR/sys ] ; then
82 sudo rmdir $BUILDDIR/sys || exit 1
83 fi
84 sudo rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib{,64,32,x32},media,mnt,run}
85 sudo rm -rf $BUILDDIR/{opt,root,sbin,srv,tmp,tools,cross-tools,usr,var}
86 echo "done"
87 if [[ "${BLFS_TOOL}" = "y" ]] ; then
88 echo -n "Cleaning $BUILDDIR/$BLFS_ROOT ..."
89 sudo rm -rf $BUILDDIR/$BLFS_ROOT
90 echo "done"
91 fi
92 echo -n "Cleaning $JHALFSDIR ..."
93 sudo rm -rf $JHALFSDIR
94 echo "done"
95 echo -n "Cleaning remaining extracted sources in $BUILDDIR/sources ..."
96 sudo rm -rf `find $BUILDDIR/sources -maxdepth 1 -mindepth 1 -type d`
97 echo "done"
98 echo -n "Removing dangling symlinks in / ..."
99 sudo rm -f /tools /cross-tools
100 echo "done"
101 fi
102 fi
103fi
104}
Note: See TracBrowser for help on using the repository browser.