source: live-build/trunk/fuentes/functions/stagefile.sh @ 900

Last change on this file since 900 was 900, checked in by kbut, 4 years ago

add original source

  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#!/bin/sh
2
3## live-build(7) - System Build Scripts
4## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
5##
6## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
7## This is free software, and you are welcome to redistribute it
8## under certain conditions; see COPYING for details.
9
10
11Check_stagefile ()
12{
13        FILE="${1}"
14        NAME="$(basename ${1})"
15
16        # Checking stage file
17        if [ -f "${FILE}" ]
18        then
19                if [ "${_FORCE}" != "true" ]
20                then
21                        # Skipping execution
22                        Echo_warning "skipping %s, already done" "${NAME}"
23                        exit 0
24                else
25                        # Forcing execution
26                        Echo_message "forcing %s" "${NAME}"
27                        rm -f "${FILE}"
28                fi
29        fi
30}
31
32Create_stagefile ()
33{
34        FILE="${1}"
35        DIRECTORY="$(dirname ${1})"
36
37        # Creating stage directory
38        mkdir -p "${DIRECTORY}"
39
40        # Creating stage file
41        touch "${FILE}"
42}
43
44Require_stagefile ()
45{
46        NAME="$(basename ${0})"
47        FILES="${@}"
48        NUMBER="$(echo ${@} | wc -w)"
49
50        for FILE in ${FILES}
51        do
52                # Find at least one of the required stages
53                if [ -f ${FILE} ]
54                then
55                        CONTINUE="true"
56                        NAME="${NAME} $(basename ${FILE})"
57                fi
58        done
59
60        if [ "${CONTINUE}" != "true" ]
61        then
62                if [ "${NUMBER}" -eq 1 ]
63                then
64                        Echo_error "%s: %s missing" "${NAME}" "${FILE}"
65                else
66                        Echo_error "%s: one of %s is missing" "${NAME}" "${FILES}"
67                fi
68
69                exit 1
70        fi
71}
Note: See TracBrowser for help on using the repository browser.