-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathautobuild
executable file
·102 lines (88 loc) · 2.52 KB
/
autobuild
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
99
100
101
#!/bin/bash
#
# Script for building the udp sender
PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
TEMP_DIR="./tmp"
TARGET_FORMAT="deb"
pkg_name="sendts"
pkg_description="Sending ts file(s) as a ts udp stream"
pkg_vendor="Kwikflix"
pkg_maintainer="Kwikflix"
pkg_version="1.0"
pkg_iteration="$(git rev-list HEAD --count)"
################################################################################
# Parse options
# Arguments:
# Script Arguments
# Returns:
# None
################################################################################
options_func() {
while getopts "ht:b:" OPTION
do
case "${OPTION}" in
b) TEMP_DIR="${OPTARG}" ;;
t) TARGET_FORMAT="${OPTARG}" ;;
h) usage_func ;;
?) usage_func ;;
*) usage_func ;;
esac
done
readonly TARGET_FORMAT
readonly TEMP_DIR
} # options_func()
################################################################################
# Prereqs checks
# Arguments:
# None
# Returns:
# None
################################################################################
prereqs_func() {
# check fpm package
which fpm > /dev/null
if [ "$?" -ne "0" ]; then
err "fpm package is not installed."
echo "Please use the following commands to install it:"
echo -e "sudo apt-get install ruby-dev gcc\e[0m"
echo -e "sudo gem install fpm"
exit 1;
fi
} # prereqs_func()
################################################################################
# Prints usage for this script
# Arguments:
# None
# Returns:
# None
################################################################################
usage_func() {
echo "Usage: $0 [-t TARGET_FORMAT] [-b TEMP_DIR]
-b TEMP_DIR Temp Directory used for building. (default: ./tmp)
Cleared on each execution.
-t TARGET_FORMAT Target format (example: rpm, deb; default: deb)
-h Print this help
" >&2
exit 1
} # end usage_func()
err() {
echo -e "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: ${@}" >&2
} # err()
main() {
options_func "$@"
prereqs_func
make
pkg_cmd="fpm -f -s dir "
pkg_cmd+="-t ${TARGET_FORMAT} "
pkg_cmd+="--prefix \"/opt/${pkg_name}/bin\" "
pkg_cmd+="--name \"${pkg_name}\" "
pkg_cmd+="--description \"${pkg_description}\" "
pkg_cmd+="--vendor \"${pkg_vendor}\" "
pkg_cmd+="--maintainer \"${pkg_maintainer}\" "
pkg_cmd+="--version \"${pkg_version}\" "
pkg_cmd+="--iteration ${pkg_iteration} "
pkg_cmd+="./${pkg_name} "
echo "${pkg_cmd}"
eval "${pkg_cmd}"
} # end main()
main "$@"