source: common/common-functions@ 4ed4a32

ablfs-more legacy trunk
Last change on this file since 4ed4a32 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
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
[0e4ddfa]37 if [ -e "$MKFILE" ] ; then
[877cc6a]38 echo -ne "Building the system...\n"
[9ef12f7]39 if { echo try tty; tty; }; then
[0e4ddfa]40 cd "$JHALFSDIR" && make
[877cc6a]41 echo -ne "done\n"
[9ef12f7]42 else echo there is no terminal!!; fi
[877cc6a]43 fi
44 fi
45}
46
47
48#----------------------------#
[261eea6]49clean_builddir() { #
[877cc6a]50#----------------------------#
[d7390a5]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
[fb63ddf]54 if ls -d $BUILDDIR/* > /dev/null 2>&1 &&
[d7390a5]55 [ "$(ls $BUILDDIR)" != "lost+found" ]; then
[877cc6a]56 # Test to make sure that the build directory was populated by jhalfs
57 if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
[5468631]58 echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
[877cc6a]59 exit 1
[a5e3400]60 # Test that dev filesystems are not mounted in $BUILDDIR
61 elif mount | grep $BUILDDIR/dev > /dev/null ; then
[d7390a5]62 echo "Looks like kernel filesystems are still mounted on $BUILDDIR."
[a5e3400]63 exit 1
[877cc6a]64 else
[e6ed1a1]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
[877cc6a]73 # Clean the build directory
[5468631]74 echo -n "Cleaning $BUILDDIR ..."
[9556f88]75 # First delete proc and sys directories, if they exist.
[d7390a5]76 # Both should be empty. If not, we exit, and the rmdir command
77 # has generated an error message
[a5e3400]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
[d5a739a]84 sudo rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib{,64,32,x32},media,mnt,run}
[21cab34]85 sudo rm -rf $BUILDDIR/{opt,root,sbin,srv,tmp,tools,cross-tools,usr,var}
[bb7f603]86 echo "done"
[2e1c1c3]87 if [[ "${BLFS_TOOL}" = "y" ]] ; then
[bb7f603]88 echo -n "Cleaning $BUILDDIR/$BLFS_ROOT ..."
[e576789]89 sudo rm -rf $BUILDDIR/$BLFS_ROOT
[bb7f603]90 echo "done"
[e576789]91 fi
[5468631]92 echo -n "Cleaning $JHALFSDIR ..."
93 sudo rm -rf $JHALFSDIR
94 echo "done"
[7072e1f]95 echo -n "Cleaning remaining extracted sources in $BUILDDIR/sources ..."
[8ea21f8]96 sudo rm -rf `find $BUILDDIR/sources -maxdepth 1 -mindepth 1 -type d`
[5468631]97 echo "done"
[5e4a124]98 echo -n "Removing dangling symlinks in / ..."
99 sudo rm -f /tools /cross-tools
100 echo "done"
[877cc6a]101 fi
102 fi
[d7390a5]103fi
[877cc6a]104}
Note: See TracBrowser for help on using the repository browser.