-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathproduce-script
More file actions
executable file
·79 lines (69 loc) · 1.99 KB
/
produce-script
File metadata and controls
executable file
·79 lines (69 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/sh
# Produces a package script by concatenating snippets according to the following
# rules:
#
# type = <deb|rpm|depot|bff|pkg>
# action = <install|remove>
#
# <type>-script-common.sh
# script-header.sh
# <type>-script-common-<action>.sh
# script-common.sh
# script-common-<action>.sh
# script-common-header-last.sh
# ../cfengine-PROJECT[-hub]/<pre|post><install|remove>.sh
#
# Any script that is missing will simply be skipped.
if [ $# -ne 3 ]; then
echo "Usage: $0 cfengine-PROJECT[-hub] <pre|post><install|remove> pkg-type"
exit 1
fi
SCRIPTDIR="`dirname $0`"
TEMPLATEDIR="$SCRIPTDIR/script-templates"
PROJECT_TYPE="$1"
SCRIPT_TYPE="$2"
PKG_TYPE="$3"
include_script()
{
if [ -f "$1" ]; then
cat "$1"
fi
}
include_script "$TEMPLATEDIR/$PKG_TYPE-script-common.sh"
include_script "$TEMPLATEDIR/script-header.sh"
case "$PKG_TYPE" in
deb|rpm)
echo "set -e"
;;
esac
echo "PKG_TYPE=$PKG_TYPE"
echo "SCRIPT_TYPE=$SCRIPT_TYPE"
echo "PROJECT_TYPE=$PROJECT_TYPE"
echo "BUILT_ON_OS=$OS"
BUILT_ON_OS_VERSION="`expr "$OS_VERSION" : "\([0-9]*\)"`"
echo "BUILT_ON_OS_VERSION=$BUILT_ON_OS_VERSION"
case "$SCRIPT_TYPE" in
*install)
include_script "$TEMPLATEDIR/$PKG_TYPE-script-common-install.sh"
include_script "$TEMPLATEDIR/script-common.sh"
include_script "$TEMPLATEDIR/script-common-install.sh"
include_script "$TEMPLATEDIR/script-common-$SCRIPT_TYPE.sh"
;;
*remove)
include_script "$TEMPLATEDIR/$PKG_TYPE-script-common-remove.sh"
include_script "$TEMPLATEDIR/script-common.sh"
include_script "$TEMPLATEDIR/script-common-remove.sh"
include_script "$TEMPLATEDIR/script-common-$SCRIPT_TYPE.sh"
;;
esac
include_script "$TEMPLATEDIR/script-common-header-last.sh"
# Not having a script is not an error. Not all scripts are used,
# and not all projects are ported over.
case "$PROJECT_TYPE" in
cfengine-nova-hub)
include_script "$SCRIPTDIR/cfengine-hub/$SCRIPT_TYPE.sh"
;;
*)
include_script "$SCRIPTDIR/cfengine-non-hub/$SCRIPT_TYPE.sh"
;;
esac