2006-11-11 20:06:46 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
#=== MAKEFILE HEADER ===
|
|
|
|
|
2006-11-11 20:55:13 +01:00
|
|
|
#----------------------------------#
|
|
|
|
wrt_Makefile_header() { #
|
|
|
|
#----------------------------------#
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
# This file is automatically generated by jhalfs
|
2006-11-11 20:06:46 +01:00
|
|
|
# DO NOT EDIT THIS FILE MANUALLY
|
|
|
|
#
|
2006-11-11 20:55:13 +01:00
|
|
|
# Generated on `date "+%F %X %Z"`
|
|
|
|
|
|
|
|
|
|
|
|
SRC = /sources
|
|
|
|
MOUNT_PT = $BUILDDIR
|
|
|
|
PKG_LST = $PKG_LST
|
|
|
|
LUSER = $LUSER
|
|
|
|
LGROUP = $LGROUP
|
|
|
|
SCRIPT_ROOT = $SCRIPT_ROOT
|
|
|
|
|
|
|
|
BASEDIR = \$(MOUNT_PT)
|
|
|
|
SRCSDIR = \$(BASEDIR)/sources
|
|
|
|
CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands
|
|
|
|
LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/logs
|
|
|
|
TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/test-logs
|
|
|
|
|
|
|
|
crCMDSDIR = /\$(SCRIPT_ROOT)/$PROGNAME-commands
|
|
|
|
crLOGDIR = /\$(SCRIPT_ROOT)/logs
|
|
|
|
crTESTLOGDIR = /\$(SCRIPT_ROOT)/test-logs
|
|
|
|
|
|
|
|
SU_LUSER = su - \$(LUSER) -c
|
|
|
|
LUSER_HOME = /home/\$(LUSER)
|
|
|
|
PRT_DU = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found \$(MOUNT_PT) \`\n"
|
|
|
|
PRT_DU_CR = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found / \`\n"
|
|
|
|
|
2006-11-12 14:50:34 +01:00
|
|
|
ADD_REPORT = $REPORT
|
|
|
|
ADD_BLFS_TOOLS = $BLFS_TOOL
|
|
|
|
|
|
|
|
|
2006-11-11 20:55:13 +01:00
|
|
|
export PATH := \${PATH}:/usr/sbin
|
|
|
|
|
|
|
|
include makefile-functions
|
|
|
|
|
|
|
|
EOF
|
|
|
|
) > $MKFILE
|
|
|
|
}
|
2006-11-11 20:06:46 +01:00
|
|
|
|
|
|
|
#=======================
|
|
|
|
|
|
|
|
|
|
|
|
#==== PACKAGES NAMES ===
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
get_package_tarball_name() { #
|
|
|
|
#----------------------------------#
|
|
|
|
local script_name=`echo ${1} | sed -e 's@[0-9]\{1\}-@@'`
|
|
|
|
|
|
|
|
# The use of 'head' is necessary to limit the return value to the FIRST match..
|
|
|
|
# hopefully this will not cause problems.
|
|
|
|
#
|
|
|
|
case $script_name in
|
|
|
|
tcl) echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 )
|
|
|
|
;;
|
2006-12-02 23:11:32 +01:00
|
|
|
uClibc)
|
|
|
|
if [[ "${PROGNAME}" = "clfs3" ]]; then
|
|
|
|
echo $(grep "^uClibc-" $JHALFSDIR/pkg_tarball_list | head -n1 )
|
|
|
|
else
|
|
|
|
echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
|
|
|
|
fi
|
|
|
|
;;
|
2006-11-11 20:06:46 +01:00
|
|
|
linux-headers)
|
2006-11-15 20:39:00 +01:00
|
|
|
if [[ "${PROGNAME}" = "lfs" ]] || [[ "${PROGNAME}" = "hlfs" ]] ; then
|
2006-11-11 20:06:46 +01:00
|
|
|
# Uses kernel headers directly
|
|
|
|
echo $(grep "^linux-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
|
|
|
|
else
|
2006-11-15 20:39:00 +01:00
|
|
|
# CLFS{,2,3} use massaged headers package
|
2006-11-11 20:06:46 +01:00
|
|
|
echo $(grep "^linux-headers-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*) echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================
|
|
|
|
|
|
|
|
|
|
|
|
#==== TARGET HEADER ====
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
LUSER_wrt_target() { # Create target and initialize log file
|
|
|
|
#----------------------------------#
|
|
|
|
local i=$1
|
|
|
|
local PREV=$2
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
|
|
|
|
$i: $PREV
|
|
|
|
@\$(call echo_message, Building)
|
|
|
|
@./progress_bar.sh \$@ \$\$PPID &
|
|
|
|
@echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
|
|
|
|
@\$(PRT_DU) >>logs/\$@
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
CHROOT_wrt_target() { # Create target and initialize log file
|
|
|
|
#----------------------------------#
|
|
|
|
local i=$1
|
|
|
|
local PREV=$2
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
|
|
|
|
$i: $PREV
|
|
|
|
@\$(call echo_message, Building)
|
|
|
|
@./progress_bar.sh \$@ \$\$PPID &
|
2006-12-04 21:58:09 +01:00
|
|
|
@echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
|
|
|
|
@\$(PRT_DU_CR) >>logs/\$@
|
2006-11-11 20:06:46 +01:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================
|
|
|
|
|
|
|
|
|
|
|
|
#======== UNPACK =======
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
|
|
|
|
#----------------------------------#
|
|
|
|
local FILE=$1
|
|
|
|
local optSAVE_PREVIOUS=$2
|
|
|
|
|
|
|
|
if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@\$(call remove_existing_dirs,$FILE)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
fi
|
|
|
|
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@\$(call unpack,$FILE)
|
|
|
|
@\$(call get_pkg_root_LUSER)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
CHROOT_Unpack() { #
|
|
|
|
#----------------------------------#
|
|
|
|
local FILE=$1
|
|
|
|
local optSAVE_PREVIOUS=$2
|
|
|
|
|
|
|
|
if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@\$(call remove_existing_dirs2,$FILE)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
fi
|
|
|
|
(
|
|
|
|
cat << EOF
|
2006-11-12 13:10:25 +01:00
|
|
|
@\$(call unpack2,$FILE)
|
2006-11-11 20:06:46 +01:00
|
|
|
@\$(call get_pkg_root2)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================
|
|
|
|
|
|
|
|
|
|
|
|
#===== TESTS LOGS ======
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
LUSER_wrt_test_log() { # Initialize testsuite log file
|
|
|
|
#----------------------------------#
|
|
|
|
local TESTLOGFILE=$1
|
|
|
|
(
|
|
|
|
cat << EOF
|
2006-12-04 21:58:09 +01:00
|
|
|
@echo "export TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
|
|
|
|
echo '\$(nl_)\`date\`\$(nl_)' >\$(TESTLOGDIR)/\$@
|
2006-11-11 20:06:46 +01:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
CHROOT_wrt_test_log() { #
|
|
|
|
#----------------------------------#
|
|
|
|
local TESTLOGFILE=$1
|
|
|
|
(
|
|
|
|
cat << EOF
|
2006-11-11 22:20:15 +01:00
|
|
|
@echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
|
2006-12-04 21:58:09 +01:00
|
|
|
echo "\$(nl_)\`date\`\$(nl_)" >test-logs/\$@
|
2006-11-11 20:06:46 +01:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================
|
|
|
|
|
|
|
|
|
|
|
|
#======== RUN AS =======
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
wrt_RunAsRoot() { # Some scripts must be run as root..
|
|
|
|
#----------------------------------#
|
|
|
|
local MOUNT_ENV
|
2006-11-11 22:20:15 +01:00
|
|
|
local file=$1
|
2006-11-11 20:06:46 +01:00
|
|
|
|
|
|
|
case ${PROGNAME} in
|
|
|
|
lfs ) MOUNT_ENV="LFS" ;;
|
|
|
|
clfs ) MOUNT_ENV="CLFS" ;;
|
|
|
|
clfs2 ) MOUNT_ENV="CLFS" ;;
|
|
|
|
clfs3 ) MOUNT_ENV="CLFS" ;;
|
|
|
|
hlfs ) MOUNT_ENV="HLFS" ;;
|
|
|
|
*) echo "undefined progname $PROGNAME"; exit 1 ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@( time { export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
|
|
|
|
\$(PRT_DU) >>logs/\$@
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
LUSER_wrt_RunAsUser() { # Execute script inside time { }, footer to log file
|
|
|
|
#----------------------------------#
|
|
|
|
local file=$1
|
|
|
|
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@( time { source ~/.bashrc && \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1; } ) 2>> logs/\$@ && \\
|
|
|
|
\$(PRT_DU) >> logs/\$@
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
CHROOT_wrt_RunAsRoot() { #
|
|
|
|
#----------------------------------#
|
|
|
|
local file=$1
|
|
|
|
(
|
|
|
|
cat << EOF
|
2006-11-11 22:20:15 +01:00
|
|
|
@( time { source envars && \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
|
2006-11-11 20:06:46 +01:00
|
|
|
\$(PRT_DU_CR) >>logs/\$@
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================
|
|
|
|
|
|
|
|
|
|
|
|
#====== COPY FSTAB =====
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
LUSER_wrt_CopyFstab() { #
|
|
|
|
#----------------------------------#
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@( time { cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
CHROOT_wrt_CopyFstab() { #
|
|
|
|
#----------------------------------#
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@( time { cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================
|
|
|
|
|
|
|
|
|
|
|
|
#==== RM BUILD DIRS ====
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
LUSER_RemoveBuildDirs() { #
|
|
|
|
#----------------------------------#
|
|
|
|
local name=$1
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@\$(call remove_build_dirs,$name)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
CHROOT_wrt_RemoveBuildDirs() { #
|
|
|
|
#----------------------------------#
|
|
|
|
local name=$1
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@\$(call remove_build_dirs2,$name)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================
|
|
|
|
|
|
|
|
|
|
|
|
#======== TOUCH ========
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
wrt_touch() { #
|
|
|
|
#----------------------------------#
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@\$(call housekeeping)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================
|