live-build/functions/stagefile.sh

72 lines
1.3 KiB
Bash
Raw Normal View History

2007-09-23 08:04:46 +00:00
#!/bin/sh
## live-build(7) - System Build Scripts
2014-02-08 15:47:02 -01:00
## Copyright (C) 2006-2014 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.
2007-09-23 08:04:46 +00:00
Check_stagefile ()
{
2007-09-23 08:04:49 +00:00
FILE="${1}"
NAME="$(basename ${1})"
2007-09-23 08:04:46 +00:00
# Checking stage file
2007-09-23 08:04:49 +00:00
if [ -f "${FILE}" ]
2007-09-23 08:04:46 +00:00
then
if [ "${_FORCE}" != "true" ]
2007-09-23 08:04:48 +00:00
then
# Skipping execution
Echo_warning "skipping %s, already done" "${NAME}"
2007-09-23 08:04:48 +00:00
exit 0
2007-09-23 08:04:51 +00:00
else
# Forcing execution
Echo_message "forcing %s" "${NAME}"
2007-09-23 08:04:51 +00:00
rm -f "${FILE}"
2007-09-23 08:04:48 +00:00
fi
2007-09-23 08:04:46 +00:00
fi
}
Create_stagefile ()
{
2007-09-23 08:04:49 +00:00
FILE="${1}"
DIRECTORY="$(dirname ${1})"
2007-09-23 08:04:46 +00:00
# Creating stage directory
2007-09-23 08:05:11 +00:00
mkdir -p "${DIRECTORY}"
2007-09-23 08:04:46 +00:00
# Creating stage file
2007-09-23 08:04:49 +00:00
touch "${FILE}"
2007-09-23 08:04:46 +00:00
}
Require_stagefile ()
{
NAME="$(basename ${0})"
2007-09-23 08:04:52 +00:00
FILES="${@}"
NUMBER="$(echo ${@} | wc -w)"
2007-09-23 08:04:46 +00:00
2007-09-23 08:04:52 +00:00
for FILE in ${FILES}
do
# Find at least one of the required stages
if [ -f ${FILE} ]
then
CONTINUE="true"
NAME="${NAME} $(basename ${FILE})"
2007-09-23 08:04:52 +00:00
fi
done
if [ "${CONTINUE}" != "true" ]
2007-09-23 08:04:46 +00:00
then
2007-09-23 08:05:16 +00:00
if [ "${NUMBER}" -eq 1 ]
2007-09-23 08:04:52 +00:00
then
Echo_error "%s: %s missing" "${NAME}" "${FILE}"
2007-09-23 08:05:16 +00:00
else
Echo_error "%s: one of %s is missing" "${NAME}" "${FILES}"
2007-09-23 08:04:52 +00:00
fi
2007-09-23 08:04:46 +00:00
exit 1
fi
}