live-build/functions/stagefile.sh

60 lines
985 B
Bash
Raw Normal View History

2007-09-23 08:04:46 +00:00
#!/bin/sh
# stagefile.sh - handle stage files
2007-09-23 08:04:48 +00:00
# Copyright (C) 2006-2007 Daniel Baumann <daniel@debian.org>
#
# live-helper 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
set -e
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
2007-09-23 08:04:51 +00:00
if [ "${LH_FORCE}" != "enabled" ]
2007-09-23 08:04:48 +00:00
then
# Skipping execution
2007-09-23 08:04:49 +00:00
Echo_warning "skipping ${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 ${NAME}"
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:04:49 +00:00
if [ ! -d "${DIRECTORY}" ]
2007-09-23 08:04:46 +00:00
then
2007-09-23 08:04:49 +00:00
mkdir -p "${DIRECTORY}"
2007-09-23 08:04:46 +00:00
fi
# Creating stage file
2007-09-23 08:04:49 +00:00
touch "${FILE}"
2007-09-23 08:04:46 +00:00
}
Require_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
2007-09-23 08:04:49 +00:00
Echo_error "${NAME} missing"
2007-09-23 08:04:46 +00:00
exit 1
fi
}