-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.sh
executable file
·98 lines (84 loc) · 1.9 KB
/
make.sh
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/sh
# Set variables
PRODUCT="dotfiles"
VERSION="10"
PROG="$(basename -- "$0")"
D="$(dirname -- "$0")"
D="$(cd -- "${D}" ; pwd)"
SRCDIR="${D}"
OUTDIR="${D}/out"
OUTFILE="${PRODUCT}-v${VERSION}.sh"
SH="$(command -pv sh)"
SPXGEN="$(command -v spxgen)"
MKDEPLOY="$(command -v mkdeploy)"
INSTALL_SHT="${SRCDIR}/install.sht"
INSTALL="${SRCDIR}/install.sh"
FILELIST="dot.bashrc dot.exrc dot.inputrc dot.profile dot.vimrc"
# Generate 'install.sh' script
build ()
{
if test -z "${SPXGEN}" ; then
printf "%s: command 'spxgen' not found\n" "${PROG}"
return 1
fi
if test -f "${INSTALL_SHT}" ; then
${SPXGEN} -o "${INSTALL}" "${INSTALL_SHT}" || return 1
else
printf "%s: file '%s' not found\n" "${PROG}" "${INSTALL_SHT}"
return 1
fi
}
# Create deploy script
deploy ()
{
# Build scripts first
build || return 1
if test -z "${MKDEPLOY}" ; then
printf "%s: command 'mkdeploy' not found\n" "${PROG}"
return 1
fi
${MKDEPLOY} \
-s "${SRCDIR}" \
-o "${OUTDIR}/${PRODUCT}-v${VERSION}.sh" \
-P "${PRODUCT}" -V "${VERSION}" \
-i "${INSTALL}" \
-f "${FILELIST}" \
|| return 1
}
# Call install script
install ()
{
# Build scripts first
build || return 1
${SH} "${INSTALL}" || return 1
}
# Show usage information
usage ()
{
cat << EOF
Usage: ${PROG} target
'target' is one of the following ('all' if missed):
all build all
build build installation script
deploy create deploy script
install call installation script
EOF
}
# Main subroutine
main ()
{
# Check command line arguments
test $# -le 1 || { usage ; return 1 ; }
test $# -gt 0 && _target="$1" || _target="all"
# Create output directory
test -d "${OUTDIR}" || mkdir -p "${OUTDIR}" || return 1
case "${_target}" in
( "all" ) build ;;
( "build" ) build ;;
( "deploy" ) deploy ;;
( "install" ) install ;;
( * ) usage ; return 1 ;;
esac
}
# Call main subroutine
main "$@"