-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmsys2-shell
executable file
·127 lines (108 loc) · 3.13 KB
/
msys2-shell
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
#!/bin/bash
set -e
. /etc/msys2-env
if [ "${DEBUG_WRAPPER}" = "true" ]
then
set -x
fi
if [ "${DISPLAY}" = "" ]
then
export DISPLAY=:95
Xvfb :95 -ac -reset -terminate -screen 0 800x600x16 2>/dev/null &
sleep 3
fi
# workaround https://bugs.wine-staging.com/show_bug.cgi?id=403
if [ "${DRONE}" = "true" ]
then
if ! [ -d /drone/wineprefix ]
then
mv "${WINEPREFIX}" /drone/wineprefix
elif ! [ -d /drone/wineprefix/drive_c/${MSYS_DIR} ]
then
mv "${WINEPREFIX}/drive_c/${MSYS_DIR}" "/drone/wineprefix/drive_c/${MSYS_DIR}"
fi
export WINEPREFIX=/drone/wineprefix
export MSYS_ROOT=${WINEPREFIX}/drive_c/${MSYS_DIR}
fi
if [ "$1" = "-h" ] || [ "$1" = "--help" ]
then
echo Usage: $0 "-c commandline"
echo " " $0 "script-file"
echo " " cat script-file \| $0
echo
exit
fi
if [ "${WINEDEBUG}" = "" ]
then
export WINEDEBUG=fixme-all
fi
EXIT_CODE=exit_code.$$
if [ "${DRONE_BUILD_DIR}" ]
then
if ! [ -d ${MSYS_ROOT}/${DRONE_BUILD_DIR} ]
then
DRONE_BUILD_DIR_PARENT=$(dirname ${DRONE_BUILD_DIR})
mkdir -p ${MSYS_ROOT}/${DRONE_BUILD_DIR_PARENT}
ln -s ${DRONE_BUILD_DIR} ${MSYS_ROOT}/${DRONE_BUILD_DIR}
fi
MSYS_INIT_DIR=${MSYS_ROOT}/${DRONE_BUILD_DIR}
fi
if [ "${MSYS_INIT_DIR}" ]
then
cd ${MSYS_INIT_DIR}
else
cd ${MSYS_ROOT} # FIXME
fi
UNIXPWD=`pwd`
WINPWD=`winepath -w ${UNIXPWD}`
WINPWD=${WINPWD//\\/\/} # replace \ to /
if [ "${DEBUG_WRAPPER}" = "true" ]
then
echo "MSYS2 shell in ${MSYS_ROOT} in Wine on Linux"
echo "Entering MSYS2 shell >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
fi
if [ "$#" = "0" ]
then
cat > ${MSYS_ROOT}/tmp/command.sh
wine ${MSYS_ROOT}/usr/bin/mintty.exe --log - -e /usr/bin/bash.exe -l -c "(cd \"${WINPWD}\"; bash -e < /tmp/command.sh || echo \$? > ${EXIT_CODE})" | stdbuf -o0 -e0 tr -d '\r'
elif [ "$1" = "-c" ]
then
COMMAND=${@:2}
# Emulate MSYS2 COMMAND line prompt
echo ${USER}@${HOSTNAME} ${MSYSTEM} ${WINPWD}
echo \$ ${COMMAND}
wine ${MSYS_ROOT}/usr/bin/mintty.exe --log - -e /usr/bin/bash.exe -l -c "(cd \"${WINPWD}\"; bash -e -c \"${COMMAND}\" || echo \$? > ${EXIT_CODE})" | stdbuf -o0 -e0 tr -d '\r'
else
set -x
pushd `dirname $1` > /dev/null
UNIXPATH=`pwd`
popd > /dev/null
WINPATH=`winepath -w ${UNIXPATH}`
COMMAND_FILE=${WINPATH}\\`basename $1`
# Emulate MSYS2 COMMAND line prompt
echo ${USER}@${HOSTNAME} ${MSYSTEM} ${WINPWD}
echo \$ ${COMMAND_FILE}
wine ${MSYS_ROOT}/usr/bin/mintty.exe --log - -e /usr/bin/bash.exe -l -c "(cd \"${WINPWD}\"; bash -e \"${COMMAND_FILE}\" || echo \$? > ${EXIT_CODE})" | stdbuf -o0 -e0 tr -d '\r'
fi
if [ "$DEBUG_WRAPPER" = "true" ]
then
echo "Leaving MSYS2 shell <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
fi
wineserver -w
if test -f ${EXIT_CODE}
then
# clean up
exit_code=$(cat ${EXIT_CODE})
rm -f ${EXIT_CODE}
if [ "${DEBUG_WRAPPER}" = "true" ]
then
echo msys2-shell executed \`$COMMAND\` failed with exit code ${exit_code}.
echo
fi
exit ${exit_code}
fi
if [ "${DEBUG_WRAPPER}" = "true" ]
then
echo msys2-shell executed \`$COMMAND\` successfully.
fi
echo