This repository has been archived on 2024-10-17. You can view files and clone it, but cannot push or open issues or pull requests.
MahiroOS-jhalfs/common/libs/func_wrt_Makefile

228 lines
4.3 KiB
Text
Raw Normal View History

#!/bin/bash
# $Id$
#=== MAKEFILE HEADER ===
#----------------------------------#
wrt_Makefile_header() { #
#----------------------------------#
(
cat << EOF
# This file is automatically generated by jhalfs
# DO NOT EDIT THIS FILE MANUALLY
#
# Generated on `date "+%F %X %Z"`
SHELL = /bin/bash
SRC = /sources
MOUNT_PT = $BUILDDIR
LUSER = $LUSER
LGROUP = $LGROUP
LHOME = $LHOME
SCRIPT_ROOT = $SCRIPT_ROOT
BASEDIR = \$(MOUNT_PT)
SRCSDIR = \$(BASEDIR)/sources
CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands
LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$LOGDIRBASE
TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
crCMDSDIR = /\$(SCRIPT_ROOT)/$PROGNAME-commands
crLOGDIR = /\$(SCRIPT_ROOT)/$LOGDIRBASE
crTESTLOGDIR = /\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
crFILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
SU_LUSER = su - \$(LUSER) -c
LUSER_HOME = \$(LHOME)/\$(LUSER)
ADD_REPORT = $REPORT
ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
ADD_BLFS_TOOLS = $BLFS_TOOL
export PATH := \${PATH}:/usr/sbin
include makefile-functions
EOF
) > $MKFILE
}
#=======================
#==== TARGET HEADER ====
#----------------------------------#
LUSER_wrt_target() { # Create target
#----------------------------------#
local i=$1
local PREV=$2
(
cat << EOF
$i: $PREV
@\$(call echo_message, Building)
@export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
2007-09-25 21:12:36 +02:00
CHROOT_wrt_target() { #
#----------------------------------#
local i=$1
local PREV=$2
(
cat << EOF
$i: $PREV
@\$(call echo_message, Building)
@export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
EOF
) >> $MKFILE.tmp
}
#=======================
#======== RUN AS =======
#----------------------------------#
wrt_RunAsRoot() { # Some scripts must be run as root..
#----------------------------------#
local MOUNT_ENV
local file=$1
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
2007-09-27 21:26:14 +02:00
@export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname $file`/\$@ > $LOGDIRBASE/\$@ 2>&1
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
2007-09-25 21:12:36 +02:00
LUSER_wrt_RunAsUser() { #
#----------------------------------#
local file=$1
(
cat << EOF
2007-09-27 21:26:14 +02:00
@\$(CMDSDIR)/`dirname $file`/\$@ > $LOGDIRBASE/\$@ 2>&1
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
CHROOT_wrt_RunAsRoot() { #
#----------------------------------#
local file=$1
(
cat << EOF
2007-09-27 21:26:14 +02:00
@\$(crCMDSDIR)/`dirname $file`/\$@ > $LOGDIRBASE/\$@ 2>&1
EOF
) >> $MKFILE.tmp
}
#=======================
#====== COPY FSTAB =====
#----------------------------------#
LUSER_wrt_CopyFstab() { #
#----------------------------------#
(
cat << EOF
2007-09-27 21:26:14 +02:00
@cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab > $LOGDIRBASE/\$@ 2>&1
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
CHROOT_wrt_CopyFstab() { #
#----------------------------------#
(
cat << EOF
2007-09-27 21:26:14 +02:00
@cp -v /sources/fstab /etc/fstab > $LOGDIRBASE/\$@ 2>&1
EOF
) >> $MKFILE.tmp
}
#=======================
#==== INSTALLED FILES LOGS ====
#----------------------------------#
LUSER_wrt_TouchTimestamp() { #
#----------------------------------#
(
cat << EOF
@\$(call touch_timestamp_LUSER)
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
CHROOT_wrt_TouchTimestamp() { #
#----------------------------------#
(
cat << EOF
@\$(call touch_timestamp)
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
LUSER_wrt_LogNewFiles() { #
#----------------------------------#
local name=$1
(
cat << EOF
@\$(call log_new_files_LUSER,$name)
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
CHROOT_wrt_LogNewFiles() { #
#----------------------------------#
local name=$1
(
cat << EOF
@\$(call log_new_files,$name)
EOF
) >> $MKFILE.tmp
}
#=======================
#======== TOUCH ========
#----------------------------------#
wrt_touch() { #
#----------------------------------#
(
cat << EOF
@\$(call housekeeping)
EOF
) >> $MKFILE.tmp
}
#=======================