This is the mail archive of the cygwin-xfree mailing list for the Cygwin XFree86 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bug in "startXwin.bat"


>Larry Hall (Cygwin X) wrote:
>> Linda Walsh wrote:
>>> Larry Hall (Cygwin X) wrote:
>>>> Linda Walsh wrote:
>>>>> Larry Hall (Cygwin X) wrote:
>>>>>> Linda Walsh wrote:
>>>>>>> The startxwin.sh script works, but startxwin.bat does not work if
>>>>>>> your Cygwin installation isn't in the default location.

As Larry and others have pointed out, this is because cmd.exe batch files cannot know where Cygwin is installed. So startxwin.bat hardcodes the default installation location of Cygwin in it (SET CYGWIN_ROOT=\cygwin).

Linda and
http://sourceware.org/ml/cygwin-xfree/2009-01/msg00173.html
http://sourceware.org/ml/cygwin-xfree/2009-02/msg00052.html
they all belong to the case where
1. s/he installed Cygwin in a non-default location,
2. read Cygwin/X FAQ 3.3. "I can't find startxwin.bat to start the X server", and
3. tried the Start Menu item Cygwin-X/XWin Server.

Here are two possible solutions for this case, each with a patch.

The first one sets CYGWIN_ROOT to the parent of /bin where this startxwin.bat is installed. It uses cmd.exe batch parameter syntax to get the path value. The documentation for this cryptic parameter syntax can be found in
http://technet.microsoft.com/en-us/library/cc755880.aspx
http://www.computerhope.com/sethlp.htm
REMarks are just remarks and can be deleted if necessary. 

The second one avoids using startxwin.bat at all. It invokes /usr/bin/run.exe to run /bin/bash to run /usr/bin/startxwin.sh. Possibly, /usr/bin/startx can be used instead of startxwin.sh, but I picked startxwin.sh because it contains the code to delete /tmp/.X11-unix/X0. This solution is better than the first in that no cmd.exe batch file is used, but is worse in that two black cmd.exe windows flash and disappear before XWin starts up.

These two are not the ideal solution, but at least they work for the above case. I hope these patches help and get thoughtfully considered.

--
neomjp

diff -us /usr/bin/startxwin.bat /usr/bin/startxwin.bat.new.bat
--- /usr/bin/startxwin.bat      2009-01-19 15:43:42.001000000 +0900
+++ /usr/bin/startxwin.bat.new.bat      2009-02-14 05:52:03.843750000 +0900
@@ -3,21 +3,24 @@


REM 
-REM The path in the CYGWIN_ROOT environment variable assignment assume
-REM that Cygwin is installed in a directory called 'cygwin' in the root
-REM directory of the current drive.  You will only need to modify
-REM CYGWIN_ROOT if you have installed Cygwin in another directory.  For
-REM example, if you installed Cygwin in \foo\bar\baz\cygwin, you will need 
-REM to change \cygwin to \foo\bar\baz\cygwin.
-REM 
-REM This batch file will almost always be run from the same drive (and
-REM directory) as the drive that contains Cygwin/X, therefore you will
-REM not need to add a drive letter to CYGWIN_ROOT.  For example, you do
-REM not need to change \cygwin to c:\cygwin if you are running this
-REM batch file from the C drive.
-REM 
+REM The following assignment to the CYGWIN_ROOT environment variable
+REM assumes that this batch file is installed in /bin . (In
+REM default Cygwin installation, this /bin is also mounted as
+REM /usr/bin .) CYGWIN_ROOT is first set to the Windows format
+REM drive letter (~d) and parent path (p) of this batch file (%0).
+REM Then, the last four characters ("\bin") are removed.
+REM
+
+SET CYGWIN_ROOT=%~dp0
+SET CYGWIN_ROOT=%CYGWIN_ROOT:~0,-4%
+
+REM
+REM If you move/copy this batch file to another place, you need to
+REM set CYGWIN_ROOT explicitly to the Windows format path of the
+REM directory where Cygwin is installed, as in an example below.
+REM
+REM SET CYGWIN_ROOT=C\:cygwin

-SET CYGWIN_ROOT=\cygwin
SET RUN=%CYGWIN_ROOT%\bin\run -p /usr/bin

SET PATH=.;%CYGWIN_ROOT%\bin;%PATH%

diff -u /etc/postinstall/xinit.sh   /etc/postinstall/xinit.sh.new
--- /etc/postinstall/xinit.sh           2009-01-19 15:43:42.001000000 +0900
+++ /etc/postinstall/xinit.sh.new       2009-02-14 06:04:24.140625000 +0900
@@ -1,2 +1,2 @@
/usr/bin/mkdir -p "$(/usr/bin/cygpath -AP)/Cygwin-X"
-/usr/bin/mkshortcut -AP -i /usr/bin/XWin.exe -n "Cygwin-X/XWin Server" -w "" -a /usr/bin/startxwin.bat /usr/bin/run.exe
+/usr/bin/mkshortcut -AP -i /usr/bin/XWin.exe -n "Cygwin-X/XWin Server" -w "/usr/bin" -a "/bin/bash -l -c /usr/bin/startxwin.sh" /usr/bin/run.exe

--------------------------------------
Power up the Internet with Yahoo! Toolbar.
http://pr.mail.yahoo.co.jp/toolbar/

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]