-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·65 lines (49 loc) · 2.16 KB
/
build.sh
File metadata and controls
executable file
·65 lines (49 loc) · 2.16 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
#!/usr/bin/env bash
################################
# git-get build script
#
# builds git-get for distribution
#
# The git-get script in the root of the repo
# is intended for development, since it uses source to add the parser
# This is done to declutter the main script for ease of use during development
# But this isn't ideal for production since it means you'd need to distribute 2 files
# This build script will combine the parser and git-get script into a single file
# that will be copied by the install script into the directory of git
#
# 1. creates parser/parser.sh
# 2. creates dist/git-get
#
#
#################################
SCRIPT_DIR=
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
#build the parser
#this creates the parser/parser.sh script
"$SCRIPT_DIR"/parser/parser-build.sh "git-get"
#prepare the git-get script for distribution by in-lining the parser.
#do this by splitting the development version of ./git-get in half ( a header and footer), and appending the peices together with
# the parser in between
mkdir -p "$SCRIPT_DIR"/dist/
cp "$SCRIPT_DIR"/git-get "$SCRIPT_DIR"/dist/git-get-header
cp "$SCRIPT_DIR"/git-get "$SCRIPT_DIR"/dist/git-get-footer
# remove the bottom part of the script to create the 'header'
#perl -0777 -i -pe "s|^#.*?_ADD_PARSER_HERE_#.*?\n||m" "$SCRIPT_DIR"/dist/git-get-header
perl -0777 -i -pe "s|^#.*?_ADD_PARSER_HERE_#(.*\n)*.*||m" "$SCRIPT_DIR"/dist/git-get-header
# remove the top part of the script to create the 'footer'
# m = multiple line match
# .* to match very last line that doesnt have a newline
perl -0777 -i -pe "s|(.*\n)*.*_ADD_PARSER_HERE_.*$||m" "$SCRIPT_DIR"/dist/git-get-footer
# append all the pieces together
parser_script=$(cat "$SCRIPT_DIR/parser/parser.sh")
header=$(cat "$SCRIPT_DIR"/dist/git-get-header)
footer=$(cat "$SCRIPT_DIR"/dist/git-get-footer)
echo -e "$header" > "$SCRIPT_DIR"/dist/git-get
echo -e "$parser_script" >> "$SCRIPT_DIR"/dist/git-get
echo -e "$footer" >> "$SCRIPT_DIR"/dist/git-get
# remove source statement sinec we in-lining it
sed -ri 's/(.?.?source .*\/parser.*)//' dist/git-get
rm "$SCRIPT_DIR"/dist/git-get-header
rm "$SCRIPT_DIR"/dist/git-get-footer
#############################
# Main