source: common/common-functions@ 8825e69

ablfs-more trunk
Last change on this file since 8825e69 was fd4a798, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Remove $Id$ comments, they are useless with git

  • Property mode set to 100644
File size: 3.1 KB
RevLine 
[877cc6a]1#!/bin/bash
2
[4da2512]3set -e
[877cc6a]4
5
6no_empty_builddir() {
7 'clear'
8cat <<- -EOF-
9${DD_BORDER}
10
11${tab_}${tab_}${BOLD}${RED}W A R N I N G${OFF}
12 Looks like the \$BUILDDIR directory contains subdirectories
[a5e3400]13 from a previous build.
[877cc6a]14
15 Please format the partition mounted on \$BUILDDIR or set
[73e5448]16 a different build directory before running jhalfs.
[877cc6a]17${OFF}
18${DD_BORDER}
19-EOF-
20 exit
21}
22
23
24#----------------------------#
[261eea6]25run_make() { #
[877cc6a]26#----------------------------#
27 # Test if make must be run.
[401f81e]28 if [ "$RUNMAKE" = "y" ] ; then
[fe30c61]29 # Test to make sure we're not running the build as root
[045b2dc]30 if [ "$UID" = "0" ] ; then
31 echo "You must not be logged in as root to build the system."
[877cc6a]32 exit 1
33 fi
34 # Build the system
[0e4ddfa]35 if [ -e "$MKFILE" ] ; then
[877cc6a]36 echo -ne "Building the system...\n"
[9ef12f7]37 if { echo try tty; tty; }; then
[0e4ddfa]38 cd "$JHALFSDIR" && make
[877cc6a]39 echo -ne "done\n"
[9ef12f7]40 else echo there is no terminal!!; fi
[877cc6a]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
[fb63ddf]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
[e6ed1a1]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
[877cc6a]71 # Clean the build directory
[5468631]72 echo -n "Cleaning $BUILDDIR ..."
[9556f88]73 # First delete proc and sys directories, if they exist.
[d7390a5]74 # Both should be empty. If not, we exit, and the rmdir command
75 # has generated an error message
[a5e3400]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
[d5a739a]82 sudo rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib{,64,32,x32},media,mnt,run}
[21cab34]83 sudo rm -rf $BUILDDIR/{opt,root,sbin,srv,tmp,tools,cross-tools,usr,var}
[bb7f603]84 echo "done"
[2e1c1c3]85 if [[ "${BLFS_TOOL}" = "y" ]] ; then
[bb7f603]86 echo -n "Cleaning $BUILDDIR/$BLFS_ROOT ..."
[e576789]87 sudo rm -rf $BUILDDIR/$BLFS_ROOT
[bb7f603]88 echo "done"
[e576789]89 fi
[5468631]90 echo -n "Cleaning $JHALFSDIR ..."
91 sudo rm -rf $JHALFSDIR
92 echo "done"
[7072e1f]93 echo -n "Cleaning remaining extracted sources in $BUILDDIR/sources ..."
[8ea21f8]94 sudo rm -rf `find $BUILDDIR/sources -maxdepth 1 -mindepth 1 -type d`
[5468631]95 echo "done"
[5e4a124]96 echo -n "Removing dangling symlinks in / ..."
97 sudo rm -f /tools /cross-tools
98 echo "done"
[877cc6a]99 fi
100 fi
[d7390a5]101fi
[877cc6a]102}
Note: See TracBrowser for help on using the repository browser.