mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-28 11:43:25 +02:00
make.sh: Add helper function to run a make command
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
93
make.sh
93
make.sh
@@ -748,38 +748,91 @@ lfsmake1() {
|
|||||||
print_status DONE
|
print_status DONE
|
||||||
}
|
}
|
||||||
|
|
||||||
lfsmake2() {
|
run_command() {
|
||||||
lfsmakecommoncheck $*
|
local pkg
|
||||||
|
local action
|
||||||
|
|
||||||
|
local chroot="false"
|
||||||
|
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case "${1}" in
|
||||||
|
--chroot)
|
||||||
|
chroot="true"
|
||||||
|
;;
|
||||||
|
|
||||||
|
-*)
|
||||||
|
echo "Unknown argument: ${1}" >&2
|
||||||
|
return 2
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
# Set pkg
|
||||||
|
if [ -z "${pkg}" ]; then
|
||||||
|
pkg="${1}"
|
||||||
|
|
||||||
|
# Set action
|
||||||
|
elif [ -z "${action}" ]; then
|
||||||
|
action="${1}"
|
||||||
|
|
||||||
|
# Fail on everything else
|
||||||
|
else
|
||||||
|
echo "Unknown argument: ${1}" >&2
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# Run the common check
|
||||||
|
lfsmakecommoncheck "${pkg}"
|
||||||
[ $? == 1 ] && return 0
|
[ $? == 1 ] && return 0
|
||||||
|
|
||||||
enterchroot \
|
local command=(
|
||||||
bash -x -c "cd /usr/src/lfs && \
|
# Run a shell
|
||||||
make -f $* \
|
"bash"
|
||||||
LFS_BASEDIR=/usr/src install" \
|
|
||||||
>> ${LOGFILE} 2>&1 &
|
|
||||||
|
|
||||||
if ! wait_until_finished $!; then
|
# Enable tracing
|
||||||
|
"-x"
|
||||||
|
|
||||||
|
# Run the following command
|
||||||
|
"-c" "cd /usr/src/lfs && make -f ${pkg} LFS_BASEDIR=/usr/src ${action}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Run this in chroot?
|
||||||
|
case "${chroot}" in
|
||||||
|
true)
|
||||||
|
command=( "enterchroot" "${command[@]}" )
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Run the command and pipe all output to the logfile
|
||||||
|
if ! "${command[@]}" >> "${LOGFILE}" 2>&1; then
|
||||||
print_status FAIL
|
print_status FAIL
|
||||||
exiterror "Building $*"
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# All done
|
||||||
print_status DONE
|
print_status DONE
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
lfsmake2() {
|
||||||
|
local pkg="${1}"
|
||||||
|
|
||||||
|
# Run install on the package
|
||||||
|
if ! run_command --chroot "${pkg}" install; then
|
||||||
|
exiterror "Building ${pkg}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
ipfiredist() {
|
ipfiredist() {
|
||||||
lfsmakecommoncheck $*
|
local pkg="${1}"
|
||||||
[ $? == 1 ] && return 0
|
|
||||||
|
|
||||||
enterchroot \
|
# Run dist on the package
|
||||||
bash -x -c "cd /usr/src/lfs && make -f $* LFS_BASEDIR=/usr/src dist" \
|
if ! run_command --chroot "${pkg}" dist; then
|
||||||
>> ${LOGFILE} 2>&1 &
|
exiterror "Packging ${pkg}"
|
||||||
|
|
||||||
if ! wait_until_finished $!; then
|
|
||||||
print_status FAIL
|
|
||||||
exiterror "Packaging $*"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_status DONE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wait_until_finished() {
|
wait_until_finished() {
|
||||||
|
|||||||
Reference in New Issue
Block a user