-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathinstall
183 lines (158 loc) · 7.75 KB
/
install
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/usr/bin/bash
# By Yifei Zhang, Nov. 12 2015
# Read LICENSE file before use
# Config
TEMPLATE_SHELL="bash"
# TEMPLATE_SHELL="zsh"
# Colors
ESC_SEQ="\e["
COL_RESET=$ESC_SEQ"0m"
COL_RED=$ESC_SEQ"31m"
COL_GREEN=$ESC_SEQ"32m"
COL_YELLOW=$ESC_SEQ"33m"
COL_BLUE=$ESC_SEQ"34m"
COL_MAGENTA=$ESC_SEQ"35m"
COL_CYAN=$ESC_SEQ"36m"
COL_WHITE=$ESC_SEQ"97m"
# warning
echo -e "${COL_RED}WARNING: THIS SCRIPT WILL OVERWRITE SOME .bat FILES IN THE"
echo -e "CURRENT DIRECTORY. PLEASE BACKUP BEFORE USE${COL_RESET}"
echo -e "${COL_CYAN}"
echo -e "[ msys2/mingw right-click shortcut menu ]"
echo -e "[ Yifei Zhang, Nov 2015 ]"
echo -e "${COL_RESET}"
echo -e "${COL_WHITE}Checking environment...${COL_RESET}"
if ! ( \
[ -s install ] && \
[ -s bash_here.template ] && \
[ -s bash_here_start_shell.template ] && \
[ -s reg_aio_${TEMPLATE_SHELL}_msys2_shell.template ] && \
[ -s reg.template ] && \
[ -s reg_clang32.template ] && \
[ -s reg_clang64.template ] && \
[ -s reg_clangarm64.template ] && \
[ -s reg_ucrt64.template ] && \
[ -s reg_mingw64.template ] && \
[ -s reg_mingw32.template ] && \
[ -s reg_msys2.template ]); then
echo -e "${COL_RED}Error! Cannot find some of the required files!"
echo -e "Please run this script from its directory${COL_RESET}"
echo -e "If you are using zsh, please copy-and-edit your own"
echo -e "reg_aio_${TEMPLATE_SHELL}_msys2_shell.template."
exit 1
fi
MSYS2_INSTALL_DIR=$({ cd / && pwd -W; } | sed 's|/|\\\\|g')
PWD_WIN_ESCAPED=$(pwd -W | sed -e 's|/|\\\\|g')\\\\
echo "MSYS Install Path is"
echo -e "${MSYS2_INSTALL_DIR}"
echo "Current Directory is"
echo -e "${PWD_WIN_ESCAPED}"
echo
read -p "Correct? (y/n)" option
echo
if [[ ! $option =~ [yY](es)* ]]; then
exit 0
fi
if [ "$1" = '--user' ]; then
ROOT_KEY="HKEY_CURRENT_USER"
echo -e "${COL_GREEN}"
echo -e "Configuration will be stored in user context only ('HKEY_CURRENT_USER')"
echo -e "${COL_RESET}"
else
ROOT_KEY="HKEY_LOCAL_MACHINE"
echo -e "${COL_GREEN}"
echo -e "Configuration will be stored for all users on this machine ('HKEY_LOCAL_MACHINE')"
echo -e "If this is not working, run this script again appending --user for user context only"
echo -e "${COL_RESET}"
fi
TEMPLATE="${TEMPLATE_SHELL}_here.template"
if [[ -f /start_shell.cmd ]]; then
TEMPLATE="${TEMPLATE_SHELL}_here_start_shell.template"
echo -e "Using MSYS2 version with start_shell.cmd"
fi
REG_FILE="install_right_click_menu.reg"
echo -e "${COL_WHITE}Generating scripts...${COL_RESET}"
if ( \
[ -s clang32_shell.bat ] && \
[ -s clang64_shell.bat ] && \
[ -s clangarm64_shell.bat ] && \
[ -s ucrt64.bat ] && \
[ -s mingw32_shell.bat ] && \
[ -s mingw64_shell.bat ] && \
[ -s msys2_shell.bat ]); then
echo "Using legacy bat+reg template"
echo "Please do not delete this directory after install is done"
MINGW32_SHELL="mingw32_shell.bat"
MINGW64_SHELL="mingw64_shell.bat"
MSYS2_SHELL="msys2_shell.bat"
CLANGARM64_SHELL="clangarm64_shell.bat"
CLANG32_SHELL="clang32_shell.bat"
CLANG64_SHELL="clang64_shell.bat"
UCRT64_SHELL="ucrt64_shell.bat"
MINGW32_HERE="mingw32_here.bat"
MINGW64_HERE="mingw64_here.bat"
MSYS2_HERE="msys2_here.bat"
CLANGARM64_HERE="clangarm64_here.bat"
CLANG32_HERE="clang32_here.bat"
CLANG64_HERE="clang64_here.bat"
UCRT64_HERE="ucrt64_here.bat"
MINGW32_SHELL_PATH="${MSYS2_INSTALL_DIR}${MINGW32_SHELL}"
MINGW64_SHELL_PATH="${MSYS2_INSTALL_DIR}${MINGW64_SHELL}"
MSYS2_SHELL_PATH="${MSYS2_INSTALL_DIR}${MSYS2_SHELL}"
CLANGARM64_SHELL_PATH="${MSYS2_INSTALL_DIR}${CLANGARM64_SHELL}"
CLANG32_SHELL_PATH="${MSYS2_INSTALL_DIR}${CLANG32_SHELL}"
CLANG64_SHELL_PATH="${MSYS2_INSTALL_DIR}${CLANG64_SHELL}"
UCRT64_SHELL_PATH="${MSYS2_INSTALL_DIR}${UCRT64_SHELL}"
MINGW32_HERE_PATH="${PWD_WIN_ESCAPED}${MINGW32_HERE}"
MINGW64_HERE_PATH="${PWD_WIN_ESCAPED}${MINGW64_HERE}"
MSYS2_HERE_PATH="${PWD_WIN_ESCAPED}${MSYS2_HERE}"
CLANGARM64_HERE_PATH="${PWD_WIN_ESCAPED}${CLANGARM64_HERE}"
CLANG32_HERE_PATH="${PWD_WIN_ESCAPED}${CLANG32_HERE}"
CLANG64_HERE_PATH="${PWD_WIN_ESCAPED}${CLANG64_HERE}"
UCRT64_HERE_PATH="${PWD_WIN_ESCAPED}${UCRT64_HERE}"
cat $TEMPLATE | sed -e "s/{SHELL_PATH_WIN}/$MINGW32_SHELL_PATH/g" | sed 's/$/\r/' > $MINGW32_HERE
cat $TEMPLATE | sed -e "s/{SHELL_PATH_WIN}/$MINGW64_SHELL_PATH/g" | sed 's/$/\r/' > $MINGW64_HERE
cat $TEMPLATE | sed -e "s/{SHELL_PATH_WIN}/$MSYS2_SHELL_PATH/g" | sed 's/$/\r/' > $MSYS2_HERE
cat $TEMPLATE | sed -e "s/{SHELL_PATH_WIN}/$CLANGARM64_SHELL_PATH/g" | sed 's/$/\r/' > $CLANGARM64_HERE
cat $TEMPLATE | sed -e "s/{SHELL_PATH_WIN}/$CLANG32_SHELL_PATH/g" | sed 's/$/\r/' > $CLANG32_HERE
cat $TEMPLATE | sed -e "s/{SHELL_PATH_WIN}/$CLANG64_SHELL_PATH/g" | sed 's/$/\r/' > $CLANG64_HERE
cat $TEMPLATE | sed -e "s/{SHELL_PATH_WIN}/$UCRT64_SHELL_PATH/g" | sed 's/$/\r/' > $UCRT64_HERE
MINGW32_HERE_PATH=$(echo $MINGW32_HERE_PATH | sed 's/\\/\\\\/g')
MINGW64_HERE_PATH=$(echo $MINGW64_HERE_PATH | sed 's/\\/\\\\/g')
MSYS2_HERE_PATH=$(echo $MSYS2_HERE_PATH | sed 's/\\/\\\\/g')
CLANGARM64_HERE_PATH=$(echo $CLANGARM64_HERE_PATH | sed 's/\\/\\\\/g')
CLANG32_HERE_PATH=$(echo $CLANG32_HERE_PATH | sed 's/\\/\\\\/g')
CLANG64_HERE_PATH=$(echo $CLANG64_HERE_PATH | sed 's/\\/\\\\/g')
UCRT64_HERE_PATH=$(echo $UCRT64_HERE_PATH | sed 's/\\/\\\\/g')
MSYS2_INSTALL_DIR=$(echo $MSYS2_INSTALL_DIR | sed 's/\\/\\\\/g')
cat reg.template | sed 's/$/\r/' > $REG_FILE
cat reg_mingw32.template | sed -e "s/{SCRIPT_HERE_PATH_WIN}/$MINGW32_HERE_PATH/g" | sed -e "s/{MSYS2_INSTALL_DIR}/$MSYS2_INSTALL_DIR/g" | sed -e "s/{ROOT_KEY}/$ROOT_KEY/g" | sed 's/$/\r/' >> $REG_FILE
cat reg_mingw64.template | sed -e "s/{SCRIPT_HERE_PATH_WIN}/$MINGW64_HERE_PATH/g" | sed -e "s/{MSYS2_INSTALL_DIR}/$MSYS2_INSTALL_DIR/g" | sed -e "s/{ROOT_KEY}/$ROOT_KEY/g" | sed 's/$/\r/' >> $REG_FILE
cat reg_msys2.template | sed -e "s/{SCRIPT_HERE_PATH_WIN}/$MSYS2_HERE_PATH/g" | sed -e "s/{MSYS2_INSTALL_DIR}/$MSYS2_INSTALL_DIR/g" | sed -e "s/{ROOT_KEY}/$ROOT_KEY/g" | sed 's/$/\r/' >> $REG_FILE
cat reg_clangarm64.template | sed -e "s/{SCRIPT_HERE_PATH_WIN}/$CLANGARM64_HERE_PATH/g" | sed -e "s/{MSYS2_INSTALL_DIR}/$MSYS2_INSTALL_DIR/g" | sed -e "s/{ROOT_KEY}/$ROOT_KEY/g" | sed 's/$/\r/' >> $REG_FILE
cat reg_clang32.template | sed -e "s/{SCRIPT_HERE_PATH_WIN}/$CLANG32_HERE_PATH/g" | sed -e "s/{MSYS2_INSTALL_DIR}/$MSYS2_INSTALL_DIR/g" | sed -e "s/{ROOT_KEY}/$ROOT_KEY/g" | sed 's/$/\r/' >> $REG_FILE
cat reg_clang64.template | sed -e "s/{SCRIPT_HERE_PATH_WIN}/$CLANG64_HERE_PATH/g" | sed -e "s/{MSYS2_INSTALL_DIR}/$MSYS2_INSTALL_DIR/g" | sed -e "s/{ROOT_KEY}/$ROOT_KEY/g" | sed 's/$/\r/' >> $REG_FILE
cat reg_ucrt64.template | sed -e "s/{SCRIPT_HERE_PATH_WIN}/$UCRT64_HERE_PATH/g" | sed -e "s/{MSYS2_INSTALL_DIR}/$MSYS2_INSTALL_DIR/g" | sed -e "s/{ROOT_KEY}/$ROOT_KEY/g" | sed 's/$/\r/' >> $REG_FILE
else
echo "Using all-in-one reg file template"
echo "You can delete this directory after merging the reg file"
MSYS2_INSTALL_DIR=$(echo $MSYS2_INSTALL_DIR | sed 's/\\/\\\\/g')
cat reg_aio_${TEMPLATE_SHELL}_msys2_shell.template | sed -e "s/{MSYS2_INSTALL_DIR}/$MSYS2_INSTALL_DIR/g" | sed -e "s/{ROOT_KEY}/$ROOT_KEY/g" | sed 's/$/\r/' > $REG_FILE
FILESYSTEM_VERSION=$(pacman -Q filesystem | cut -d " " -f 2)
echo "Filesystem version: ${FILESYSTEM_VERSION}"
if [[ $(vercmp $FILESYSTEM_VERSION '2016.07-2') -ge 0 ]]; then
cat $REG_FILE | sed -e 's/\-here/\-where/g' > ${REG_FILE}.tmp
mv ${REG_FILE}.tmp $REG_FILE
fi
fi
echo
echo "Done!"
echo
echo -e "${COL_MAGENTA}"
echo -e "!!!IMPORTANT!!!"
echo -e "Please merge the file ${REG_FILE}"
echo -e "by double-clicking on it to finish the installation"
echo -e "${COL_RESET}"
echo
start ${REG_FILE}
exit 0