2007-09-23 08:04:46 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-09-02 11:12:37 +00:00
|
|
|
## live-build(7) - System Build Scripts
|
2020-03-11 09:07:21 -01:00
|
|
|
## Copyright (C) 2016-2020 The Debian Live team
|
2015-01-04 18:05:39 -01:00
|
|
|
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
|
2010-09-02 11:12:37 +00:00
|
|
|
##
|
2012-07-29 23:59:00 +00:00
|
|
|
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
|
2010-09-02 11:12:37 +00:00
|
|
|
## 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
|
|
|
|
2020-03-13 16:11:53 -01:00
|
|
|
# Get the default filename for a script's stagefile (the name of the script
|
|
|
|
# file itself). A suffix can be appended via providing as a param.
|
|
|
|
Stagefile_name ()
|
|
|
|
{
|
|
|
|
local SUFFIX="${1}"
|
|
|
|
local FILENAME
|
|
|
|
FILENAME="$(basename $0)"
|
|
|
|
echo ${FILENAME}${SUFFIX:+.$SUFFIX}
|
|
|
|
}
|
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
Check_stagefile ()
|
|
|
|
{
|
2020-03-13 16:11:53 -01:00
|
|
|
local FILE
|
|
|
|
local NAME
|
|
|
|
FILE=".build/${1:-$(Stagefile_name)}"
|
2020-03-12 00:21:39 -01:00
|
|
|
NAME="$(basename ${FILE})"
|
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
|
2009-12-13 19:17:45 -01:00
|
|
|
if [ "${_FORCE}" != "true" ]
|
2007-09-23 08:04:48 +00:00
|
|
|
then
|
2015-01-06 02:10:15 -01:00
|
|
|
# Skip 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
|
2015-01-06 02:10:15 -01:00
|
|
|
# Force 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 ()
|
|
|
|
{
|
2020-03-13 16:11:53 -01:00
|
|
|
local FILE
|
|
|
|
local DIRECTORY
|
|
|
|
FILE=".build/${1:-$(Stagefile_name)}"
|
2020-03-12 00:21:39 -01:00
|
|
|
DIRECTORY="$(dirname ${FILE})"
|
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
|
|
|
}
|
|
|
|
|
2020-03-12 00:21:39 -01:00
|
|
|
Remove_stagefile ()
|
|
|
|
{
|
2020-03-13 16:11:53 -01:00
|
|
|
local FILE
|
|
|
|
FILE=".build/${1:-$(Stagefile_name)}"
|
|
|
|
rm -f "${FILE}"
|
2020-03-12 00:21:39 -01:00
|
|
|
}
|
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
Require_stagefile ()
|
|
|
|
{
|
2020-02-20 05:58:11 -01:00
|
|
|
local NAME
|
|
|
|
local FILES
|
|
|
|
local NUMBER
|
2007-09-24 06:47:42 +00:00
|
|
|
NAME="$(basename ${0})"
|
2020-02-20 05:58:11 -01:00
|
|
|
FILES="${@}" #must be on separate line to 'local' declaration to avoid error
|
2007-09-24 06:47:42 +00:00
|
|
|
NUMBER="$(echo ${@} | wc -w)"
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2020-02-20 05:58:11 -01:00
|
|
|
local FILE
|
|
|
|
local CONTINUE=false
|
2007-09-23 08:04:52 +00:00
|
|
|
for FILE in ${FILES}
|
|
|
|
do
|
2020-03-12 00:21:39 -01:00
|
|
|
FILE=".build/${FILE}"
|
2007-09-23 08:04:52 +00:00
|
|
|
# Find at least one of the required stages
|
|
|
|
if [ -f ${FILE} ]
|
|
|
|
then
|
2020-02-20 05:57:46 -01:00
|
|
|
CONTINUE=true
|
2007-09-24 06:47:42 +00:00
|
|
|
NAME="${NAME} $(basename ${FILE})"
|
2007-09-23 08:04:52 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2020-02-20 05:57:46 -01:00
|
|
|
if ! $CONTINUE
|
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
|
2008-08-11 20:28:54 +00:00
|
|
|
Echo_error "%s: %s missing" "${NAME}" "${FILE}"
|
2007-09-23 08:05:16 +00:00
|
|
|
else
|
2008-08-11 20:28:54 +00:00
|
|
|
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
|
|
|
|
}
|