This repository has been archived by the owner on Aug 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
base
executable file
·88 lines (70 loc) · 1.72 KB
/
base
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
#!/usr/bin/env bash
# Output stylization
RESET="\e[39m"
ACCENT="\e[96m"
# Working directories
ROOT_DIR=$(realpath $(dirname ${BASH_SOURCE[0]}))
# Repositories
REPO=("https://github.com/InfinityGhost/OpenTabletDriver" "$(realpath "${ROOT_DIR}/src/OpenTabletDriver")")
SRC_DIR="${REPO[1]}"
SRC_DIR_CONFIGURATIONS="${SRC_DIR}/OpenTabletDriver.Configurations/Configurations"
print() {
printf "${ACCENT}$@${RESET}\n"
}
get_group() {
if [[ "$1" =~ $2 ]]; then
echo ${BASH_REMATCH[$3]}
fi
}
# Package Information
PKG_VERSION="$(get_group "$(cat ${SRC_DIR}/Directory.Build.props)" '<VersionBase>(.+?)<\/VersionBase>' 1)${VERSION_SUFFIX}"
clone_repo() {
args=("$@")
if [ "${#args[@]}" -eq "2" ]; then
url="${args[0]}"
dir="${args[1]}"
if [ ! -e "$dir" ]; then
git clone "$url" "$dir"
fi
else
printf "${ACCENT_COLOR}Invalid clone arguments. ($@)${DEFAULT_COLOR}\n"
exit 1
fi;
}
prepare() {
clone_repo ${REPO[@]}
}
regex_edit() {
[ "$#" -ne 3 ] && exit 200
[ ! -f "${3}" ] && exit 201
sed -i "s/${1}/${2}/g" "${3}"
}
create_tarball() {
[ "$#" -ne 2 ] && exit 210
print "Creating '${2}' from '${1}'"
cd $(dirname "${2}")
tar -zcvf "${2}" "$(basename ${1})"
}
generate_rules() {
[ "$#" -ne 2 ] && exit 220
[ ! -d "${1}" ] && exit 221
print "Generating udev rules..."
"${SRC_DIR}/generate-rules.sh" -v "${1}" "${2}"
}
clean_target() {
[ "$#" -ne 2 ] && exit 230
if [ -e "${1}" ]; then
print "${2}"
if [ -f "${1}" ]; then
rm -vf "${1}"
elif [ -d "${1}" ]; then
rm -vrf "${1}"
fi
fi
}
clean_debug() {
[ "$#" -ne 1 ] && exit 240
[ ! -d "${1}" ] && exit 241
print "Removing all debug files... (.pdb)"
find "${1}" -name "*.pdb" -type f -exec rm {} ';'
}