-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcygwin-shell
executable file
·131 lines (111 loc) · 3.65 KB
/
cygwin-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
128
129
130
131
#!/bin/bash
set -e
. /etc/cygwin-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
fi
export WINEPREFIX=/drone/wineprefix
export CYGWIN_ROOT=${WINEPREFIX}/drive_c/${CYGWIN_DIR}
echo "# Workaround docker image limitation"
echo "# FIXME: These packages can't be preinstalled inside docker image because docker image does not support cygwin symlink."
echo "Installing autoconf,automake,gawk,texinfo,python,asciidoc,gettext-devel,git,intltool,scons,xmlto,wget"
WINEDEBUG=-all wine c:/cygwin-installer.exe --site http://mirrors.tea-ci.org/cygwin --local-package-dir Z:/tmp/cygwin -W -x gawk,python,ca-certificates -P gawk,python,ca-certificates -q &> /dev/null
WINEDEBUG=-all wine c:/cygwin-installer.exe --site http://mirrors.tea-ci.org/cygwin --local-package-dir Z:/tmp/cygwin -W -P autoconf,automake,gawk,texinfo,python,asciidoc,gettext-devel,git,intltool,scons,xmlto,wget -q &> /dev/null
echo
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 ${CYGWIN_ROOT}/${DRONE_BUILD_DIR} ]
then
DRONE_BUILD_DIR_PARENT=$(dirname ${DRONE_BUILD_DIR})
mkdir -p ${CYGWIN_ROOT}/${DRONE_BUILD_DIR_PARENT}
ln -s ${DRONE_BUILD_DIR} ${CYGWIN_ROOT}/${DRONE_BUILD_DIR}
fi
CYGWIN_INIT_DIR=${CYGWIN_ROOT}/${DRONE_BUILD_DIR}
fi
if [ "${CYGWIN_INIT_DIR}" ]
then
cd ${CYGWIN_INIT_DIR}
else
cd ${CYGWIN_ROOT} # FIXME
fi
UNIXPWD=`pwd`
WINPWD=`winepath -w ${UNIXPWD}`
WINPWD=${WINPWD//\\/\/} # replace \ to /
if [ "${DEBUG_WRAPPER}" = "true" ]
then
echo "CYGWIN shell in ${CYGWIN_ROOT} in Wine on Linux"
echo "Entering CYGWIN shell >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
fi
if [ "$#" = "0" ]
then
cat > ${CYGWIN_ROOT}/tmp/command.sh
wine ${CYGWIN_ROOT}/bin/mintty.exe --log - -e /bin/bash.exe -l -c "(cd \"${WINPWD}\"; bash -e < /tmp/command.sh || echo \$? > ${EXIT_CODE})" | tee
elif [ "$1" = "-c" ]
then
COMMAND=${@:2}
# Emulate CYGWIN COMMAND line prompt
echo ${USER}@${HOSTNAME} ${CYGWINTEM} ${WINPWD}
echo \$ ${COMMAND}
wine ${CYGWIN_ROOT}/bin/mintty.exe --log - -e /bin/bash.exe -l -c "(cd \"${WINPWD}\"; bash -e -c \"${COMMAND}\" || echo \$? > ${EXIT_CODE})" | tee
else
set -x
pushd `dirname $1` > /dev/null
UNIXPATH=`pwd`
popd > /dev/null
WINPATH=`winepath -w ${UNIXPATH}`
COMMAND_FILE=${WINPATH}\\`basename $1`
# Emulate CYGWIN COMMAND line prompt
echo ${USER}@${HOSTNAME} ${CYGWINTEM} ${WINPWD}
echo \$ ${COMMAND_FILE}
wine ${CYGWIN_ROOT}/bin/mintty.exe --log - -e /bin/bash.exe -l -c "(cd \"${WINPWD}\"; bash -e \"${COMMAND_FILE}\" || echo \$? > ${EXIT_CODE})" | tee
fi
if [ "$DEBUG_WRAPPER" = "true" ]
then
echo "Leaving CYGWIN 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 cygwin-shell executed \`$COMMAND\` failed with exit code ${exit_code}.
echo
fi
exit ${exit_code}
fi
if [ "${DEBUG_WRAPPER}" = "true" ]
then
echo cygwin-shell executed \`$COMMAND\` successfully.
fi
echo