2006-11-11 20:06:46 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=== 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"`
|
|
|
|
|
2007-02-26 21:18:52 +01:00
|
|
|
|
|
|
|
SHELL = /bin/bash
|
2006-11-11 20:55:13 +01:00
|
|
|
|
|
|
|
SRC = /sources
|
|
|
|
MOUNT_PT = $BUILDDIR
|
|
|
|
PKG_LST = $PKG_LST
|
|
|
|
LUSER = $LUSER
|
|
|
|
LGROUP = $LGROUP
|
2007-04-13 22:40:38 +02:00
|
|
|
LHOME = $LHOME
|
2006-11-11 20:55:13 +01:00
|
|
|
SCRIPT_ROOT = $SCRIPT_ROOT
|
|
|
|
|
|
|
|
BASEDIR = \$(MOUNT_PT)
|
|
|
|
SRCSDIR = \$(BASEDIR)/sources
|
2022-03-30 14:49:43 +02:00
|
|
|
CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$COMMANDS
|
2007-04-28 17:24:20 +02:00
|
|
|
LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$LOGDIRBASE
|
|
|
|
TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
|
2006-11-11 20:55:13 +01:00
|
|
|
|
2022-03-30 14:49:43 +02:00
|
|
|
crCMDSDIR = /\$(SCRIPT_ROOT)/$COMMANDS
|
2007-04-28 17:24:20 +02:00
|
|
|
crLOGDIR = /\$(SCRIPT_ROOT)/$LOGDIRBASE
|
|
|
|
crTESTLOGDIR = /\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
|
|
|
|
crFILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
|
2006-11-11 20:55:13 +01:00
|
|
|
|
2020-04-01 11:11:32 +02:00
|
|
|
SU_LUSER = sudo -H -u \$(LUSER) sh -c
|
2007-04-13 22:40:38 +02:00
|
|
|
LUSER_HOME = \$(LHOME)/\$(LUSER)
|
2006-11-11 20:55:13 +01:00
|
|
|
PRT_DU = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found \$(MOUNT_PT) \`\n"
|
2017-07-04 14:19:46 +02:00
|
|
|
PRT_DU_CR = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found --exclude /var/lib / \`\n"
|
2006-11-11 20:55:13 +01:00
|
|
|
|
2006-12-15 11:53:10 +01:00
|
|
|
ADD_REPORT = $REPORT
|
|
|
|
ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
|
|
|
|
ADD_BLFS_TOOLS = $BLFS_TOOL
|
2012-02-02 00:29:37 +01:00
|
|
|
PKGMNGT = $PKGMNGT
|
2017-07-04 14:17:11 +02:00
|
|
|
WRAP_INSTALL = $WRAP_INSTALL
|
2006-11-12 14:50:34 +01:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
#=======================
|
|
|
|
|
|
|
|
|
|
|
|
#==== TARGET HEADER ====
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
LUSER_wrt_target() { # Create target and initialize log file
|
|
|
|
#----------------------------------#
|
|
|
|
local i=$1
|
|
|
|
local PREV=$2
|
2013-10-05 19:45:52 +02:00
|
|
|
local version
|
|
|
|
if [ "$3" != "" ]; then
|
|
|
|
version=-$3
|
|
|
|
fi
|
2006-11-11 20:06:46 +01:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
|
|
|
|
$i: $PREV
|
|
|
|
@\$(call echo_message, Building)
|
2008-10-28 00:26:29 +01:00
|
|
|
${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
|
2013-10-05 19:45:52 +02:00
|
|
|
@echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@$version
|
2019-04-11 09:40:50 +02:00
|
|
|
@ : > envars
|
2006-11-11 20:06:46 +01:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
CHROOT_wrt_target() { # Create target and initialize log file
|
|
|
|
#----------------------------------#
|
|
|
|
local i=$1
|
|
|
|
local PREV=$2
|
2013-10-05 19:45:52 +02:00
|
|
|
local version
|
|
|
|
if [ "$3" != "" ]; then
|
|
|
|
version=-$3
|
|
|
|
fi
|
2006-11-11 20:06:46 +01:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
|
|
|
|
$i: $PREV
|
|
|
|
@\$(call echo_message, Building)
|
2008-10-28 00:26:29 +01:00
|
|
|
${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
|
2013-10-05 19:45:52 +02:00
|
|
|
@echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@$version
|
2019-04-11 09:40:50 +02:00
|
|
|
@ : > envars
|
2006-11-11 20:06:46 +01:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================
|
|
|
|
|
|
|
|
|
|
|
|
#======== UNPACK =======
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
|
|
|
|
#----------------------------------#
|
2021-06-04 21:13:04 +02:00
|
|
|
local FILE="$1"
|
|
|
|
local optSAVE_PREVIOUS="$2"
|
|
|
|
local version
|
|
|
|
if [ "$3" != "" ]; then
|
|
|
|
version=-"$3"
|
|
|
|
fi
|
2006-11-11 20:06:46 +01:00
|
|
|
|
|
|
|
if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@\$(call remove_existing_dirs,$FILE)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
fi
|
|
|
|
|
|
|
|
(
|
|
|
|
cat << EOF
|
2019-04-11 09:40:50 +02:00
|
|
|
@\$(PRT_DU) >>logs/\$@$version
|
2006-11-11 20:06:46 +01:00
|
|
|
@\$(call unpack,$FILE)
|
|
|
|
@\$(call get_pkg_root_LUSER)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
CHROOT_Unpack() { #
|
|
|
|
#----------------------------------#
|
|
|
|
local FILE=$1
|
|
|
|
local optSAVE_PREVIOUS=$2
|
2021-06-04 21:13:04 +02:00
|
|
|
local version
|
|
|
|
if [ "$3" != "" ]; then
|
|
|
|
version=-"$3"
|
|
|
|
fi
|
2006-11-11 20:06:46 +01:00
|
|
|
|
|
|
|
if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@\$(call remove_existing_dirs2,$FILE)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
fi
|
2019-04-11 09:40:50 +02:00
|
|
|
|
2006-11-11 20:06:46 +01:00
|
|
|
(
|
2019-04-11 09:40:50 +02:00
|
|
|
cat << EOF
|
|
|
|
@\$(PRT_DU_CR) >>logs/\$@$version
|
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
|
|
|
|
#----------------------------------#
|
2013-10-05 19:45:52 +02:00
|
|
|
local version
|
|
|
|
if [ "$2" != "" ]; then
|
|
|
|
version=-$2
|
|
|
|
fi
|
|
|
|
local TESTLOGFILE=$1$version
|
2006-11-11 20:06:46 +01:00
|
|
|
(
|
|
|
|
cat << EOF
|
2006-12-04 21:58:09 +01:00
|
|
|
@echo "export TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
|
2013-10-05 19:45:52 +02:00
|
|
|
echo "\$(nl_)\`date\`\$(nl_)" >\$(TESTLOGDIR)/$TESTLOGFILE
|
2006-11-11 20:06:46 +01:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
CHROOT_wrt_test_log() { #
|
|
|
|
#----------------------------------#
|
2013-10-05 19:45:52 +02:00
|
|
|
local version
|
|
|
|
if [ "$2" != "" ]; then
|
|
|
|
version=-$2
|
|
|
|
fi
|
|
|
|
local TESTLOGFILE=$1$version
|
2006-11-11 20:06:46 +01:00
|
|
|
(
|
|
|
|
cat << EOF
|
2006-11-11 22:20:15 +01:00
|
|
|
@echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
|
2013-10-05 19:45:52 +02:00
|
|
|
echo "\$(nl_)\`date\`\$(nl_)" >\$(crTESTLOGDIR)/$TESTLOGFILE
|
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
|
2013-10-05 19:45:52 +02:00
|
|
|
local version
|
|
|
|
if [ "$2" != "" ]; then
|
|
|
|
version=-$2
|
|
|
|
fi
|
2006-11-11 22:20:15 +01:00
|
|
|
local file=$1
|
2006-11-11 20:06:46 +01:00
|
|
|
|
|
|
|
(
|
|
|
|
cat << EOF
|
2022-03-01 21:09:30 +01:00
|
|
|
@export LFS=\$(MOUNT_PT) && \\
|
2022-03-30 14:49:43 +02:00
|
|
|
$COMMANDS/`dirname $file`/\$@ >>logs/\$@$version 2>&1
|
2006-11-11 20:06:46 +01:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------#
|
2007-05-26 23:16:18 +02:00
|
|
|
LUSER_wrt_RunAsUser() { # Calculate time with perl, footer to log file
|
2006-11-11 20:06:46 +01:00
|
|
|
#----------------------------------#
|
|
|
|
local file=$1
|
2013-10-05 19:45:52 +02:00
|
|
|
local version
|
|
|
|
if [ "$2" != "" ]; then
|
|
|
|
version=-$2
|
|
|
|
fi
|
2006-11-11 20:06:46 +01:00
|
|
|
|
|
|
|
(
|
|
|
|
cat << EOF
|
2007-08-17 18:24:47 +02:00
|
|
|
@source ~/.bashrc && \\
|
2022-04-03 21:42:25 +02:00
|
|
|
\$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@$version 2>&1
|
2006-11-11 20:06:46 +01:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
CHROOT_wrt_RunAsRoot() { #
|
|
|
|
#----------------------------------#
|
|
|
|
local file=$1
|
2013-10-05 19:45:52 +02:00
|
|
|
local version
|
|
|
|
if [ "$2" != "" ]; then
|
|
|
|
version=-$2
|
|
|
|
fi
|
2006-11-11 20:06:46 +01:00
|
|
|
(
|
|
|
|
cat << EOF
|
2007-08-17 18:24:47 +02:00
|
|
|
@source envars && \\
|
2022-04-03 21:42:25 +02:00
|
|
|
\$(crCMDSDIR)/`dirname $file`/\$@ >>\$(crLOGDIR)/\$@$version 2>&1
|
2006-11-11 20:06:46 +01:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================
|
|
|
|
|
|
|
|
|
|
|
|
#====== COPY FSTAB =====
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
LUSER_wrt_CopyFstab() { #
|
|
|
|
#----------------------------------#
|
|
|
|
(
|
|
|
|
cat << EOF
|
2007-08-17 18:24:47 +02:00
|
|
|
@cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 && \\
|
2007-05-26 23:16:18 +02:00
|
|
|
\$(PRT_DU) >>logs/\$@
|
2006-11-11 20:06:46 +01:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
CHROOT_wrt_CopyFstab() { #
|
|
|
|
#----------------------------------#
|
|
|
|
(
|
|
|
|
cat << EOF
|
2007-08-17 18:24:47 +02:00
|
|
|
@cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 && \\
|
2007-05-26 23:16:18 +02:00
|
|
|
\$(PRT_DU_CR) >>logs/\$@
|
2006-11-11 20:06:46 +01:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================
|
|
|
|
|
|
|
|
|
2007-04-28 17:24:20 +02:00
|
|
|
#==== INSTALLED FILES LOGS ====
|
|
|
|
|
2007-06-03 11:06:13 +02:00
|
|
|
#----------------------------------#
|
|
|
|
LUSER_wrt_TouchTimestamp() { #
|
|
|
|
#----------------------------------#
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@\$(call touch_timestamp_LUSER)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
2007-04-28 17:24:20 +02:00
|
|
|
#----------------------------------#
|
|
|
|
CHROOT_wrt_TouchTimestamp() { #
|
|
|
|
#----------------------------------#
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@\$(call touch_timestamp)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
2007-06-03 11:06:13 +02:00
|
|
|
#----------------------------------#
|
|
|
|
LUSER_wrt_LogNewFiles() { #
|
|
|
|
#----------------------------------#
|
|
|
|
(
|
|
|
|
cat << EOF
|
2020-06-20 19:16:22 +02:00
|
|
|
@\$(call log_new_files_LUSER,$1)
|
2007-06-03 11:06:13 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
2007-04-28 17:24:20 +02:00
|
|
|
#----------------------------------#
|
|
|
|
CHROOT_wrt_LogNewFiles() { #
|
|
|
|
#----------------------------------#
|
|
|
|
(
|
|
|
|
cat << EOF
|
2020-06-20 19:16:22 +02:00
|
|
|
@\$(call log_new_files,$1)
|
2007-04-28 17:24:20 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================
|
|
|
|
|
|
|
|
|
2006-11-11 20:06:46 +01:00
|
|
|
#==== RM BUILD DIRS ====
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
LUSER_RemoveBuildDirs() { #
|
|
|
|
#----------------------------------#
|
2012-02-12 19:54:37 +01:00
|
|
|
local name=`echo ${1} | sed 's/[0-9]-//'`
|
2006-11-11 20:06:46 +01:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@\$(call remove_build_dirs,$name)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
CHROOT_wrt_RemoveBuildDirs() { #
|
|
|
|
#----------------------------------#
|
2012-02-12 19:54:37 +01:00
|
|
|
local name=`echo ${1} | sed 's/[0-9]-//'`
|
2006-11-11 20:06:46 +01:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@\$(call remove_build_dirs2,$name)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================
|
|
|
|
|
|
|
|
|
|
|
|
#======== TOUCH ========
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
wrt_touch() { #
|
|
|
|
#----------------------------------#
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@\$(call housekeeping)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================
|