LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1668|回复: 6

[hack] how to install cygwin (how to port cygwin‘s setup.exe with winelib)

[复制链接]
发表于 2008-8-2 00:08:24 | 显示全部楼层 |阅读模式
本文目标:在 GNU/linux+wine 系统环境下,安装 cygwin。

本文使用的 GNU/linux+wine 系统主要软件列表:
linux-kernel-2.6.25.7
binutils-2.18
glibc-2.7
gcc-4.3.1
xorg-7.3
wine-1.1.2
上面系统,直接使用cygwin提供的setup.exe无法完成安装。

笔者已经用 wine 提供的 winelib 方式移植 cygwin 的 setup.exe 到本地。
使用移植的 setup.exe 可顺利完成 cygwin 安装、升级。

本文使用下面版本 cygwin 的 setup.exe 源代码:
http://cygwin.com/setup/snapshots/setup-2.588.tar.bz2
补丁 cygwin_setup-porting_with_winelib.patch.gz 见附件。
  1. #
  2. # cygwin_setup-porting_with_winelib.patch
  3. #
  4. # Author:       Eric Zhao
  5. # Email:        ericzhao.nebula@gmail.com
  6. # source:       http://cygwin.com/setup/snapshots/setup-2.588.tar.bz2
  7. # configure:    CC="winegcc" CXX="wineg++" LIBS="-lcrtdll -lwininet" WINDRES=wrc ./configure --prefix=/somewhere --enable-shared=no
  8. #
  9. # We must link to "-lcrtdll" or "-lmscvrt" without "-mno-cygwin".
  10. # If we link to native glibc, the setup.exe will crash.
  11. # I can't explain why, perhaps you can. please fix it.
  12. #

  13. diff -dur setup-2.588-orig/ControlAdjuster.h setup-2.588/ControlAdjuster.h
  14. --- setup-2.588-orig/ControlAdjuster.h    2005-05-06 05:00:32.000000000 +0800
  15. +++ setup-2.588/ControlAdjuster.h    2008-08-08 10:56:26.000000000 +0800
  16. @@ -46,10 +46,10 @@
  17. class ControlDimension
  18. {
  19.    public:
  20. -    ControlDimension(long &anInt1, long &anInt2) :
  21. +    ControlDimension(LONG &anInt1, LONG &anInt2) :
  22.        left(anInt1), right (anInt2){}
  23. -    long &left;
  24. -    long &right;
  25. +    LONG &left;
  26. +    LONG &right;
  27. };

  28. class ControlAdjuster
  29. diff -dur setup-2.588-orig/UserSetting.cc setup-2.588/UserSetting.cc
  30. --- setup-2.588-orig/UserSetting.cc    2004-10-26 01:06:07.000000000 +0800
  31. +++ setup-2.588/UserSetting.cc    2008-08-08 10:56:26.000000000 +0800
  32. @@ -23,7 +23,9 @@
  33. #include <stdio.h>
  34. #include <stdlib.h>
  35. #include <string.h>
  36. -#include <process.h>
  37. +#ifndef __WINE__
  38. +#  include <process.h>
  39. +#endif
  40. #include <algorithm>

  41. #include "LogSingleton.h"
  42. diff -dur setup-2.588-orig/UserSettings.cc setup-2.588/UserSettings.cc
  43. --- setup-2.588-orig/UserSettings.cc    2006-04-16 05:21:25.000000000 +0800
  44. +++ setup-2.588/UserSettings.cc    2008-08-08 10:56:26.000000000 +0800
  45. @@ -23,7 +23,9 @@
  46. #include <stdio.h>
  47. #include <stdlib.h>
  48. #include <string.h>
  49. -#include <process.h>
  50. +#ifndef __WINE__
  51. +#  include <process.h>
  52. +#endif
  53. #include <algorithm>

  54. #include "LogSingleton.h"
  55. diff -dur setup-2.588-orig/autoload.c setup-2.588/autoload.c
  56. --- setup-2.588-orig/autoload.c    2008-04-09 07:50:54.000000000 +0800
  57. +++ setup-2.588/autoload.c    2008-08-08 10:56:26.000000000 +0800
  58. @@ -16,6 +16,8 @@
  59. static const char *cvsid = "\n%%% $Id: autoload.c,v 2.7 2008/04/08 23:50:54 briand Exp $\n";
  60. #endif

  61. +#ifndef __WINE__
  62. +
  63. #define WIN32_LEAN_AND_MEAN
  64. #include <windows.h>

  65. @@ -96,3 +98,5 @@

  66.    *(int *)(&x-1) = (int)proc-5;
  67. }
  68. +
  69. +#endif //__WINE__
  70. diff -dur setup-2.588-orig/choose.cc setup-2.588/choose.cc
  71. --- setup-2.588-orig/choose.cc    2008-04-09 07:50:54.000000000 +0800
  72. +++ setup-2.588/choose.cc    2008-08-08 10:56:26.000000000 +0800
  73. @@ -35,9 +35,13 @@
  74. #include <commctrl.h>
  75. #include <stdio.h>
  76. #include <stdlib.h>
  77. -#include <io.h>
  78. +#ifndef __WINE__
  79. +#  include <io.h>
  80. +#endif
  81. #include <ctype.h>
  82. -#include <process.h>
  83. +#ifndef __WINE__
  84. +#  include <process.h>
  85. +#endif
  86. #include <algorithm>

  87. #include "dialog.h"
  88. diff -dur setup-2.588-orig/compress_bz.cc setup-2.588/compress_bz.cc
  89. --- setup-2.588-orig/compress_bz.cc    2008-04-09 09:39:47.000000000 +0800
  90. +++ setup-2.588/compress_bz.cc    2008-08-08 10:56:26.000000000 +0800
  91. @@ -61,7 +61,11 @@

  92.    if (peeklen)
  93.      {
  94. +    #ifndef __WINE__
  95.        ssize_t tmplen = std::min (peeklen, len);
  96. +    #else
  97. +      ssize_t tmplen = min (peeklen, len);
  98. +    #endif
  99.        peeklen -= tmplen;
  100.        memcpy (buffer, peekbuf, tmplen);
  101.        memmove (peekbuf, peekbuf + tmplen, tmplen);
  102. diff -dur setup-2.588-orig/desktop.cc setup-2.588/desktop.cc
  103. --- setup-2.588-orig/desktop.cc    2007-05-05 05:56:53.000000000 +0800
  104. +++ setup-2.588/desktop.cc    2008-08-08 10:57:20.000000000 +0800
  105. @@ -166,7 +166,11 @@
  106. static void
  107. make_cygwin_bat ()
  108. {
  109. +#ifndef __WINE__
  110.    batname = backslash (cygpath ("/Cygwin.bat"));
  111. +#else //__WINE__
  112. +  batname = wine_unix_path( cygpath ("/Cygwin.bat"));
  113. +#endif //__WINE__

  114.    /* if the batch file exists, don't overwrite it */
  115.    if (_access (batname.c_str(), 0) == 0)
  116. @@ -178,9 +182,15 @@

  117.    fprintf (bat, "@echo off\n\n");

  118. +#ifndef __WINE__
  119.    fprintf (bat, "%.2s\n", get_root_dir ().c_str());
  120.    fprintf (bat, "chdir %s\n\n",
  121.         replace(backslash(get_root_dir() + "/bin"), "%", "%%").c_str());
  122. +#else //__WINE__
  123. +  fprintf (bat, "%.2s\n", (wine_dos_path (get_root_dir ())).c_str());
  124. +  fprintf (bat, "chdir %s\n\n",
  125. +       replace(backslash(wine_dos_path (get_root_dir ()) + "/bin"), "%", "%%").c_str());
  126. +#endif //__WINE__

  127.    fprintf (bat, "bash --login -i\n");

  128. @@ -190,7 +200,11 @@
  129. static void
  130. save_icon ()
  131. {
  132. +#ifndef __WINE__
  133.    iconname = backslash (cygpath ("/Cygwin.ico"));
  134. +#else //__WINE__
  135. +  iconname = wine_unix_path (cygpath ("/Cygwin.ico"));
  136. +#endif //__WINE__

  137.    HRSRC rsrc = FindResource (NULL, "CYGWIN.ICON", "FILE");
  138.    if (rsrc == NULL)
  139. diff -dur setup-2.588-orig/download.cc setup-2.588/download.cc
  140. --- setup-2.588-orig/download.cc    2007-05-05 05:56:53.000000000 +0800
  141. +++ setup-2.588/download.cc    2008-08-08 10:56:26.000000000 +0800
  142. @@ -29,7 +29,9 @@

  143. #include <stdio.h>
  144. #include <unistd.h>
  145. -#include <process.h>
  146. +#ifndef __WINE__
  147. +#  include <process.h>
  148. +#endif

  149. #include "resource.h"
  150. #include "msg.h"
  151. diff -dur setup-2.588-orig/filemanip.cc setup-2.588/filemanip.cc
  152. --- setup-2.588-orig/filemanip.cc    2008-04-09 07:50:54.000000000 +0800
  153. +++ setup-2.588/filemanip.cc    2008-08-08 10:56:26.000000000 +0800
  154. @@ -25,6 +25,9 @@
  155. #include "filemanip.h"
  156. #include "io_stream.h"
  157. #include "String++.h"
  158. +#ifdef __WINE__
  159. +#  include "mount.h"
  160. +#endif

  161. using namespace std;

  162. @@ -118,7 +121,11 @@
  163.          {
  164.              *ver++ = 0;
  165.              f.pkg = p;
  166. +       #ifndef __WINE__
  167.              f.what = strlwr (ver);
  168. +       #else  //__WINE__
  169. +            f.what = ver; //FIXME
  170. +       #endif //__WINE__
  171.              ver = strchr (ver, '\0');
  172.              break;
  173.          }
  174. @@ -165,7 +172,11 @@
  175. std::string
  176. backslash(const std::string& s)
  177. {
  178. +#ifndef __WINE__
  179.    std::string rv(s);
  180. +#else
  181. +  std::string rv(wine_dos_path(s));
  182. +#endif
  183.    
  184.    for (std::string::iterator it = rv.begin(); it != rv.end(); ++it)
  185.      if (*it == '/')
  186. diff -dur setup-2.588-orig/ini.cc setup-2.588/ini.cc
  187. --- setup-2.588-orig/ini.cc    2007-08-01 08:20:10.000000000 +0800
  188. +++ setup-2.588/ini.cc    2008-08-08 10:56:26.000000000 +0800
  189. @@ -35,8 +35,9 @@
  190. #include <stdio.h>
  191. #include <stdlib.h>
  192. #include <stdarg.h>
  193. -#include <process.h>
  194. -
  195. +#ifndef __WINE__
  196. +#  include <process.h>
  197. +#endif
  198. #include "resource.h"
  199. #include "state.h"
  200. #include "geturl.h"
  201. diff -dur setup-2.588-orig/install.cc setup-2.588/install.cc
  202. --- setup-2.588-orig/install.cc    2008-04-09 10:25:27.000000000 +0800
  203. +++ setup-2.588/install.cc    2008-08-08 10:56:26.000000000 +0800
  204. @@ -37,7 +37,9 @@
  205. #include <sys/types.h>
  206. #include <sys/stat.h>
  207. #include <errno.h>
  208. -#include <process.h>
  209. +#ifndef __WINE__
  210. +#  include <process.h>
  211. +#endif

  212. #include "resource.h"
  213. #include "dialog.h"
  214. diff -dur setup-2.588-orig/io_stream.h setup-2.588/io_stream.h
  215. --- setup-2.588-orig/io_stream.h    2008-04-09 09:39:47.000000000 +0800
  216. +++ setup-2.588/io_stream.h    2008-08-08 10:56:26.000000000 +0800
  217. @@ -33,7 +33,7 @@
  218.   */

  219. //Where is this defined?
  220. -#if defined(_WIN32) && ! defined(__CYGWIN__)
  221. +#if defined(_WIN32) && ! defined(__CYGWIN__) && ! defined(__WINE__)
  222. typedef signed long ssize_t;
  223. #endif

  224. diff -dur setup-2.588-orig/io_stream_cygfile.cc setup-2.588/io_stream_cygfile.cc
  225. --- setup-2.588-orig/io_stream_cygfile.cc    2006-04-17 05:35:57.000000000 +0800
  226. +++ setup-2.588/io_stream_cygfile.cc    2008-08-08 10:57:57.000000000 +0800
  227. @@ -207,7 +207,11 @@
  228.      case IO_STREAM_SYMLINK:
  229.        // symlinks are arbitrary targets, can be anything, and are
  230.        // not subject to translation
  231. +    #ifndef __WINE__
  232.        return mkcygsymlink (cygpath (from).c_str(), _to.c_str());
  233. +    #else //__WINE__
  234. +      return symlink (_to.c_str(), wine_unix_path(cygpath (from)).c_str());
  235. +    #endif //__WINE__
  236.      case IO_STREAM_HARDLINK:
  237.        {
  238.      /* For now, just copy */
  239. diff -dur setup-2.588-orig/io_stream_file.cc setup-2.588/io_stream_file.cc
  240. --- setup-2.588-orig/io_stream_file.cc    2006-04-17 05:35:57.000000000 +0800
  241. +++ setup-2.588/io_stream_file.cc    2008-08-08 10:58:15.000000000 +0800
  242. @@ -141,7 +141,7 @@
  243. {
  244.    if (!from.size() || !to.size())
  245.      return 1;
  246. -#if defined(WIN32) && !defined (_CYGWIN_)
  247. +#if defined(WIN32) && !defined (_CYGWIN_) && !defined (__WINE__)
  248.    switch (linktype)
  249.      {
  250.      case IO_STREAM_SYMLINK:
  251. diff -dur setup-2.588-orig/localdir.cc setup-2.588/localdir.cc
  252. --- setup-2.588-orig/localdir.cc    2006-04-16 05:21:25.000000000 +0800
  253. +++ setup-2.588/localdir.cc    2008-08-08 10:56:26.000000000 +0800
  254. @@ -76,6 +76,11 @@
  255.      }
  256.    if (((std::string)LocalDirOption).size())
  257.      local_dir = ((std::string)LocalDirOption);
  258. +
  259. +#ifdef __WINE__
  260. +  local_dir = wine_unix_path (local_dir);
  261. +#endif
  262. +
  263.    inited = 1;
  264. }

  265. @@ -85,7 +90,12 @@
  266.    io_stream *f = UserSettings::Instance().settingFileForSave("last-cache");
  267.    if (f)
  268.      {
  269. +    #ifndef __WINE__
  270.        f->write (local_dir.c_str(), local_dir.size());
  271. +    #else //__WINE__
  272. +      std::string s = wine_dos_path (local_dir);
  273. +      f->write (s.c_str(), s.size());
  274. +    #endif //__WINE__
  275.        delete f;
  276.      }
  277.    if (source == IDC_SOURCE_DOWNLOAD || !get_root_dir ().size())
  278. @@ -111,14 +121,23 @@
  279. static void
  280. load_dialog (HWND h)
  281. {
  282. +#ifndef __WINE__
  283.    eset (h, IDC_LOCAL_DIR, local_dir);
  284. +#else //__WINE__
  285. +  eset (h, IDC_LOCAL_DIR, wine_dos_path(local_dir));
  286. +#endif //__WINE__
  287. +
  288.    check_if_enable_next (h);
  289. }

  290. static void
  291. save_dialog (HWND h)
  292. {
  293. +#ifndef __WINE__
  294.    local_dir = egetString (h, IDC_LOCAL_DIR);
  295. +#else //__WINE__
  296. +  local_dir = wine_unix_path (egetString (h, IDC_LOCAL_DIR));
  297. +#endif //__WINE__
  298. }


  299. diff -dur setup-2.588-orig/main.cc setup-2.588/main.cc
  300. --- setup-2.588-orig/main.cc    2007-02-28 08:55:04.000000000 +0800
  301. +++ setup-2.588/main.cc    2008-08-08 10:56:26.000000000 +0800
  302. @@ -31,6 +31,10 @@
  303.    "\n%%% $Id: main.cc,v 2.44 2007/02/28 00:55:04 briand Exp $\n";
  304. #endif

  305. +#ifdef __WINE__
  306. +  #include <errno.h>
  307. +#endif
  308. +
  309. #include "win32.h"
  310. #include <commctrl.h>

  311. @@ -83,7 +87,7 @@
  312. // so we make the actual logger available to the appropriate routine(s).
  313. LogFile *theLog;

  314. -#ifndef __CYGWIN__
  315. +#if ! defined(__CYGWIN__) && ! defined(__WINE__)
  316. int WINAPI
  317. WinMain (HINSTANCE h,
  318.       HINSTANCE hPrevInstance, LPSTR command_line, int cmd_show)
  319. @@ -104,7 +108,7 @@

  320.      // TODO: make an equivalent for __argv under cygwin.
  321.      char **_argv;
  322. -#ifndef __CYGWIN__
  323. +#if ! defined(__CYGWIN__) && ! defined(__WINE__)
  324.      int argc;
  325.      for (argc = 0, _argv = __argv; *_argv; _argv++)
  326.        ++argc;
  327. @@ -125,9 +129,11 @@

  328.      // Ensure files created by postinstall and preremove scripts
  329.      // get sane permissions.
  330. +#ifndef __WINE__ //FIXME
  331.      if (putenv ("CYGWIN=nontsec") != 0)
  332.        log (LOG_PLAIN) << "Failed to set CYGWIN=nontsec (errno " << errno
  333.              << ": " << strerror(errno) << ")" << endLog;
  334. +#endif //__WINE__
  335.      
  336.      UserSettings::Instance ().loadAllSettings ();

  337. diff -dur setup-2.588-orig/mklink2.cc setup-2.588/mklink2.cc
  338. --- setup-2.588-orig/mklink2.cc    2004-12-26 07:05:57.000000000 +0800
  339. +++ setup-2.588/mklink2.cc    2008-08-08 10:58:38.000000000 +0800
  340. @@ -45,7 +45,7 @@
  341. mkcygsymlink (const char *from, const char *to)
  342. {
  343.    char buf[512];
  344. -  unsigned long w;
  345. +  unsigned int w;
  346.    HANDLE h = CreateFileA (from, GENERIC_WRITE, 0, 0, CREATE_NEW,
  347.             FILE_ATTRIBUTE_NORMAL, 0);
  348.    if (h == INVALID_HANDLE_VALUE)
  349. diff -dur setup-2.588-orig/mount.cc setup-2.588/mount.cc
  350. --- setup-2.588-orig/mount.cc    2007-02-28 08:55:04.000000000 +0800
  351. +++ setup-2.588/mount.cc    2008-08-08 10:56:26.000000000 +0800
  352. @@ -97,6 +97,39 @@

  353. struct mnt *root_here = NULL;

  354. +#ifdef __WINE__
  355. +#  include <winbase.h>
  356. +
  357. +std::string
  358. +wine_unix_path(const std::string& s)
  359. +{
  360. +  if (s.empty())
  361. +    return std::string ();
  362. +  if (s.c_str()[0] == '/')
  363. +    return std::string (s);
  364. +
  365. +  WCHAR wtmp[4000];
  366. +  memset (wtmp, 0, sizeof (wtmp));
  367. +  MultiByteToWideChar(CP_ACP, 0, s.c_str(), -1, wtmp, 4000);
  368. +  return std::string (wine_get_unix_file_name (wtmp));
  369. +}
  370. +
  371. +std::string
  372. +wine_dos_path(const std::string& s)
  373. +{
  374. +  if (s.empty())
  375. +    return std::string ();
  376. +  if (s.c_str()[0] != '/')
  377. +    return std::string (s);
  378. +
  379. +
  380. +  char tmp[4000];
  381. +  memset (tmp, 0, sizeof (tmp));
  382. +  WideCharToMultiByte(CP_ACP, 0, wine_get_dos_file_name (s.c_str()), -1, tmp, 4000, NULL, NULL);
  383. +  return std::string (tmp);
  384. +}
  385. +#endif //__WINE__
  386. +
  387. static std::string
  388. find2 (HKEY rkey, int *istext, const std::string& what)
  389. {
  390. @@ -155,8 +188,15 @@
  391.    if (rv != ERROR_SUCCESS)
  392.      fatal ("mount", rv);

  393. +#ifndef __WINE__
  394.    RegSetValueEx (key, "native", 0, REG_SZ, (BYTE *) win32.c_str (),
  395.           win32.size () + 1);
  396. +#else
  397. +  std::string wine_win32 = wine_dos_path (win32);
  398. +  RegSetValueEx (key, "native", 0, REG_SZ, (BYTE *) wine_win32.c_str (),
  399. +         wine_win32.size () + 1);
  400. +#endif
  401. +
  402.    flags = 0;
  403.    if (!istext)
  404.      flags |= MOUNT_BINARY;
  405. @@ -445,7 +485,11 @@
  406. void
  407. set_root_dir (const std::string val)
  408. {
  409. +#ifndef __WINE__
  410.    root_here->native = val;
  411. +#else //__WINE__
  412. +  root_here->native = wine_unix_path (val);
  413. +#endif //__WINE__
  414. }

  415. const std::string
  416. diff -dur setup-2.588-orig/mount.h setup-2.588/mount.h
  417. --- setup-2.588-orig/mount.h    2006-04-16 23:37:49.000000000 +0800
  418. +++ setup-2.588/mount.h    2008-08-08 10:56:26.000000000 +0800
  419. @@ -23,6 +23,11 @@
  420. #include <string>
  421. #include "String++.h"

  422. +#ifdef __WINE__
  423. +std::string wine_unix_path(const std::string& s);
  424. +std::string wine_dos_path(const std::string& s);
  425. +#endif //__WINE__
  426. +
  427. char *find_mount (int *istext, int *issystem, char *path);

  428. /* Similar to the mount and umount functions, but simplified */
  429. diff -dur setup-2.588-orig/netio.cc setup-2.588/netio.cc
  430. --- setup-2.588-orig/netio.cc    2005-05-04 22:52:34.000000000 +0800
  431. +++ setup-2.588/netio.cc    2008-08-08 10:56:26.000000000 +0800
  432. @@ -233,7 +233,7 @@
  433.    return 0;
  434. }

  435. -static BOOL CALLBACK
  436. +static INT_PTR CALLBACK
  437. auth_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam)
  438. {
  439.    switch (message)
  440. diff -dur setup-2.588-orig/nio-http.cc setup-2.588/nio-http.cc
  441. --- setup-2.588-orig/nio-http.cc    2006-04-16 05:21:25.000000000 +0800
  442. +++ setup-2.588/nio-http.cc    2008-08-08 10:56:26.000000000 +0800
  443. @@ -34,9 +34,15 @@
  444. #include "netio.h"
  445. #include "nio-http.h"

  446. -#ifndef _strnicmp
  447. -#define _strnicmp strncasecmp
  448. -#endif
  449. +#ifndef __WINE__
  450. +#  ifndef _strnicmp
  451. +#    define _strnicmp strncasecmp
  452. +#  endif
  453. +#else //__WINE__
  454. +#  ifndef _strncasecmp
  455. +#    define _strncasecmp strncasecmp
  456. +#  endif
  457. +#endif //__WINE__

  458. static char six2pr[64] = {
  459.    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
  460. @@ -143,6 +149,7 @@
  461.      {
  462.        while ((l = s->gets ()) != 0)
  463.      {
  464. +     #ifndef __WINE__
  465.        if (_strnicmp (l, "Location:", 9) == 0)
  466.          {
  467.            char *
  468. @@ -154,6 +161,19 @@
  469.          s;
  470.            goto retry_get;
  471.          }
  472. +     #else //__WINE__
  473. +      if (_strncasecmp (l, "Location:", 9) == 0)
  474. +        {
  475. +          char *
  476. +        u = l + 9;
  477. +          while (*u == ' ' || *u == '\t')
  478. +        u++;
  479. +          set_url (u);
  480. +          delete
  481. +        s;
  482. +          goto retry_get;
  483. +        }
  484. +     #endif //__WINE__
  485.      }
  486.      }
  487.    if (code == 401)        /* authorization required */
  488. @@ -194,8 +214,13 @@
  489.    // Eat the header, picking out the Content-Length in the process
  490.    while (((l = s->gets ()) != NULL) && (*l != '\0'))
  491.      {
  492. +    #ifndef __WINE__
  493.        if (_strnicmp (l, "Content-Length:", 15) == 0)
  494.      sscanf (l, "%*s %d", &file_size);
  495. +    #else
  496. +      if (_strncasecmp (l, "Content-Length:", 15) == 0)
  497. +    sscanf (l, "%*s %d", &file_size);
  498. +    #endif
  499.      }
  500. }

  501. diff -dur setup-2.588-orig/package_source.cc setup-2.588/package_source.cc
  502. --- setup-2.588-orig/package_source.cc    2006-04-18 00:13:17.000000000 +0800
  503. +++ setup-2.588/package_source.cc    2008-08-08 10:56:26.000000000 +0800
  504. @@ -22,6 +22,9 @@
  505.    "\n%%% $Id: package_source.cc,v 2.10 2006/04/17 16:13:17 maxb Exp $\n";
  506. #endif

  507. +#ifdef __WINE__
  508. +#  include <string.h>
  509. +#endif
  510. #include <stdlib.h>
  511. #include <strings.h>
  512. #include "package_source.h"
  513. diff -dur setup-2.588-orig/prereq.cc setup-2.588/prereq.cc
  514. --- setup-2.588-orig/prereq.cc    2006-04-16 05:21:25.000000000 +0800
  515. +++ setup-2.588/prereq.cc    2008-08-08 10:56:26.000000000 +0800
  516. @@ -21,9 +21,13 @@
  517. #include "win32.h"
  518. #include <commctrl.h>
  519. #include <stdio.h>
  520. -#include <io.h>
  521. +#ifndef __WINE__
  522. +#  include <io.h>
  523. +#endif
  524. #include <ctype.h>
  525. -#include <process.h>
  526. +#ifndef __WINE__
  527. +#  include <process.h>
  528. +#endif

  529. #include "prereq.h"
  530. #include "dialog.h"
  531. diff -dur setup-2.588-orig/proppage.cc setup-2.588/proppage.cc
  532. --- setup-2.588-orig/proppage.cc    2006-04-16 05:21:25.000000000 +0800
  533. +++ setup-2.588/proppage.cc    2008-08-08 10:56:26.000000000 +0800
  534. @@ -81,7 +81,7 @@
  535.    return true;
  536. }

  537. -BOOL CALLBACK
  538. +INT_PTR CALLBACK
  539. PropertyPage::FirstDialogProcReflector (HWND hwnd, UINT message,
  540.                      WPARAM wParam, LPARAM lParam)
  541. {
  542. diff -dur setup-2.588-orig/proppage.h setup-2.588/proppage.h
  543. --- setup-2.588-orig/proppage.h    2006-04-16 05:21:25.000000000 +0800
  544. +++ setup-2.588/proppage.h    2008-08-08 10:56:26.000000000 +0800
  545. @@ -42,7 +42,7 @@
  546.    // For setting the back/finish buttons properly.
  547.    bool IsFirst, IsLast;
  548.    
  549. -  static BOOL CALLBACK FirstDialogProcReflector (HWND hwnd, UINT message,
  550. +  static INT_PTR CALLBACK FirstDialogProcReflector (HWND hwnd, UINT message,
  551.                           WPARAM wParam,
  552.                           LPARAM lParam);
  553.    static BOOL CALLBACK DialogProcReflector (HWND hwnd, UINT message,
  554. diff -dur setup-2.588-orig/propsheet.cc setup-2.588/propsheet.cc
  555. --- setup-2.588-orig/propsheet.cc    2003-11-01 15:21:28.000000000 +0800
  556. +++ setup-2.588/propsheet.cc    2008-08-08 10:56:26.000000000 +0800
  557. @@ -433,8 +433,13 @@
  558. PropSheet::SetActivePageByID (int resource_id)
  559. {
  560.    // Posts a message to the message queue, so this won't block
  561. +#ifndef __WINE__
  562.    return static_cast < bool >
  563.      (::PropSheet_SetCurSelByID (GetHWND (), resource_id));
  564. +#else
  565. +  return static_cast < bool >
  566. +    (PropSheet_SetCurSelByID (GetHWND (), resource_id));
  567. +#endif
  568. }

  569. void
  570. diff -dur setup-2.588-orig/res.rc setup-2.588/res.rc
  571. --- setup-2.588-orig/res.rc    2008-04-09 10:27:37.000000000 +0800
  572. +++ setup-2.588/res.rc    2008-08-08 10:56:26.000000000 +0800
  573. @@ -1,5 +1,8 @@
  574. #include "resource.h"
  575. #include "windows.h"
  576. +#include "winuser.h"
  577. +#include "winnt.h"
  578. +#include "commctrl.h"

  579. LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US

  580. @@ -71,8 +74,8 @@
  581. BEGIN
  582.      LTEXT           "Select Local Package Directory",IDC_STATIC_HEADER_TITLE,
  583.                      7,0,258,8,NOT WS_GROUP
  584. -    LTEXT           "Select a directory where you want Setup to store the "
  585. -                    "installation files it downloads.  The directory will be "
  586. +    LTEXT           "Select a directory where you want Setup to store the "\
  587. +                    "installation files it downloads.  The directory will be "\
  588.                      "created if it does not already exist.",IDC_STATIC,
  589.                      21,9,248,16,NOT WS_GROUP
  590.      ICON            IDI_CYGWIN,IDC_HEADICON,290,0,21,20
  591. @@ -91,7 +94,7 @@
  592. BEGIN
  593.      LTEXT           "Select Root Install Directory",IDC_STATIC_HEADER_TITLE,
  594.                      7,0,258,8,NOT WS_GROUP
  595. -    LTEXT           "Select the directory where you want to install Cygwin.  "
  596. +    LTEXT           "Select the directory where you want to install Cygwin.  "\
  597.                      "Also choose a few installation parameters.",
  598.                      IDC_STATIC,21,9,239,16,NOT WS_GROUP
  599.      ICON            IDI_CYGWIN,IDC_HEADICON,290,0,21,20
  600. @@ -112,17 +115,17 @@
  601.                      BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP,170,89,130,8
  602.      CONTROL         "D&OS / text",IDC_ROOT_TEXT,"Button",BS_AUTORADIOBUTTON |
  603.                      WS_TABSTOP,170,130,130,8
  604. -    LTEXT           "Cygwin will be available to all users of the system.  "
  605. -                    "NOTE: This is required if you wish to run services like "
  606. +    LTEXT           "Cygwin will be available to all users of the system.  "\
  607. +                    "NOTE: This is required if you wish to run services like "\
  608.                      "sshd, etc.",IDC_ALLUSERS_TEXT,25,101,125,28
  609. -    LTEXT           "Cygwin will only be available to the current user.  "
  610. -                    "Only select this if you lack Admin. privileges or you "
  611. +    LTEXT           "Cygwin will only be available to the current user.  "\
  612. +                    "Only select this if you lack Admin. privileges or you "\
  613.                      "have specific needs.",IDC_JUSTME_TEXT,25,140,125,32

  614. -    LTEXT           "No line translation done; all files opened in binary mode."
  615. +    LTEXT           "No line translation done; all files opened in binary mode."\
  616.                      "  Files on disk will have LF line endings.", IDC_MODE_BIN,
  617.                      181,101,125,27
  618. -    LTEXT           "Line endings will be translated from unix (LF) to DOS "
  619. +    LTEXT           "Line endings will be translated from unix (LF) to DOS "\
  620.                      "(CR-LF) on write and vice versa on read.",IDC_MODE_TEXT,
  621.                      181,140,125,26
  622.      LTEXT           "Read more about file modes...",IDC_FILEMODES_LINK,
  623. @@ -253,15 +256,15 @@
  624. //    CONTROL         "",IDC_STATIC,"Static",SS_WHITERECT,0,0,95,178
  625.      LTEXT           "Cygwin Net Release Setup Program",
  626.                      IDC_STATIC_WELCOME_TITLE,115,1,195,24
  627. -    LTEXT           "This setup program is used for the initial installation "
  628. -                    "of the Cygwin environment as well as all subsequent "
  629. -                    "updates.  Make sure to remember where you saved it.\r\n\r\n"
  630. -                    "The pages that follow will guide you through the "
  631. -                    "installation.  Please note that Cygwin consists of a "
  632. -                    "large number of packages spanning a wide variety of "
  633. -                    "purposes.  We only install a base set of packages by "
  634. -                    "default.  You can always run this program at any time in "
  635. -                    "the future to add, remove, or upgrade packages as "
  636. +    LTEXT           "This setup program is used for the initial installation "\
  637. +                    "of the Cygwin environment as well as all subsequent "\
  638. +                    "updates.  Make sure to remember where you saved it.\r\n\r\n"\
  639. +                    "The pages that follow will guide you through the "\
  640. +                    "installation.  Please note that Cygwin consists of a "\
  641. +                    "large number of packages spanning a wide variety of "\
  642. +                    "purposes.  We only install a base set of packages by "\
  643. +                    "default.  You can always run this program at any time in "\
  644. +                    "the future to add, remove, or upgrade packages as "\
  645.                      "necessary.",IDC_SPLASH_TEXT,115,25,195,90
  646.      ICON            IDI_CYGWIN,IDC_SPLASH_ICON,114,114,21,20,WS_GROUP
  647.      LTEXT           "Version (unknown)",IDC_VERSION,115,137,195,10
  648. @@ -350,7 +353,7 @@
  649.      ICON            IDI_CYGWIN,IDC_HEADICON,290,0,21,20
  650.      LTEXT           "Warning!  Unmet Dependencies Found",IDC_STATIC_HEADER_TITLE
  651.                      ,7,0,258,8,NOT WS_GROUP
  652. -    LTEXT           "The following packages are required but have not been "
  653. +    LTEXT           "The following packages are required but have not been "\
  654.                      "selected.",IDC_STATIC,21,9,239,16,NOT WS_GROUP
  655.      CONTROL         "&Install these packages to meet dependencies (RECOMMENDED)"
  656.                      ,IDC_PREREQ_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
  657. @@ -367,16 +370,16 @@
  658. FONT 8, "MS Shell Dlg"
  659. BEGIN
  660.      LTEXT           "Warning:",IDC_STATIC,7,8,40,8
  661. -    LTEXT           "One or more mirrors you have selected is/are not on the"
  662. -                    "list of official Cygwin mirrors any more. "
  663. -                    "It/They may be out of date or missing some packages.\n"
  664. +    LTEXT           "One or more mirrors you have selected is/are not on the"\
  665. +                    "list of official Cygwin mirrors any more. "\
  666. +                    "It/They may be out of date or missing some packages.\n"\
  667.                      "This affects the following mirror(s):",
  668.                      IDC_STATIC,47,8,263,32
  669.      EDITTEXT        IDC_DROP_MIRRORS,7,40,303,40,WS_VSCROLL | WS_HSCROLL |
  670.                      ES_LEFT | ES_MULTILINE | ES_READONLY | ES_AUTOHSCROLL |
  671.                      ES_AUTOVSCROLL
  672. -    LTEXT           "If you experience installation problems consider trying "
  673. -                    "official mirrors only.\n\n"
  674. +    LTEXT           "If you experience installation problems consider trying "\
  675. +                    "official mirrors only.\n\n"\
  676.                      "Do you want to continue, using this/these mirror(s)?",
  677.                      IDC_STATIC,7,88,303,24
  678.      CONTROL         "&Don't warn me about this/these mirror(s) again",
  679. @@ -454,34 +457,34 @@
  680.      IDS_WINDOW_INIT_BADMSG  "Fatal Error: Unexpected windows message %u received too early in window initialization."
  681.      IDS_UNCAUGHT_EXCEPTION  "Fatal Error: Uncaught Exception\nThread: %s\nType: %s\nMessage: %s"
  682.      IDS_UNCAUGHT_EXCEPTION_WITH_ERRNO  "Fatal Error: Uncaught Exception\nThread: %s\nType: %s\nMessage: %s\nAppErrNo: %d"
  683. -    IDS_TRUSTKEEP_TOOLTIP   "Sets all packages to their currently installed "
  684. -       "version.  This is equivalent to telling setup not to make any "
  685. +    IDS_TRUSTKEEP_TOOLTIP   "Sets all packages to their currently installed "\
  686. +       "version.  This is equivalent to telling setup not to make any "\
  687.         "changes to any package."
  688. -    IDS_TRUSTPREV_TOOLTIP   "Globally select the version marked as 'Prev', "
  689. -       "which generally means the version that was last considered stable "
  690. +    IDS_TRUSTPREV_TOOLTIP   "Globally select the version marked as 'Prev', "\
  691. +       "which generally means the version that was last considered stable "\
  692.         "prior to the current stable version."
  693. -    IDS_TRUSTCURR_TOOLTIP   "Globally select the version that is currently "
  694. +    IDS_TRUSTCURR_TOOLTIP   "Globally select the version that is currently "\
  695.         "considered the most stable. (RECOMMENDED)"
  696. -    IDS_TRUSTEXP_TOOLTIP    "Globally select the most recent version, even if "
  697. +    IDS_TRUSTEXP_TOOLTIP    "Globally select the most recent version, even if "\
  698.         "that version is considered Experimental or for test use by the maintainer."
  699. -    IDS_VIEWBUTTON_TOOLTIP  "Cycles the package view.  This determines "
  700. -       "which packages are shown in the chooser below.\r\n"
  701. -       "\r\n"
  702. -       "Category: Group by package category.  Click on '+' to expand.\r\n"
  703. -       "\r\n"
  704. -       "Full: Show all packages.\r\n"
  705. -       "\r\n"
  706. -       "Partial: Show only packages that are about to be installed, removed, "
  707. -       "or upgraded.  This tells you everything that setup is about to change "
  708. -       "when you press 'Next'.\r\n"
  709. -       "\r\n"
  710. -       "Up To Date: Show installed packages that need no action because they "
  711. -       "are at the desired version already.\r\n"
  712. -       "\r\n"
  713. -       "Not installed: Show packages that are are not currently installed "
  714. +    IDS_VIEWBUTTON_TOOLTIP  "Cycles the package view.  This determines "\
  715. +       "which packages are shown in the chooser below.\r\n"\
  716. +       "\r\n"\
  717. +       "Category: Group by package category.  Click on '+' to expand.\r\n"\
  718. +       "\r\n"\
  719. +       "Full: Show all packages.\r\n"\
  720. +       "\r\n"\
  721. +       "Partial: Show only packages that are about to be installed, removed, "\
  722. +       "or upgraded.  This tells you everything that setup is about to change "\
  723. +       "when you press 'Next'.\r\n"\
  724. +       "\r\n"\
  725. +       "Up To Date: Show installed packages that need no action because they "\
  726. +       "are at the desired version already.\r\n"\
  727. +       "\r\n"\
  728. +       "Not installed: Show packages that are are not currently installed "\
  729.         "and haven't been selected for installation."
  730. -    IDS_HIDEOBS_TOOLTIP     "If selected, setup will hide packages in categories "
  731. -       "with names that begin with '_'.  Such packages are usually empty "
  732. -       "placeholders for packages that have been removed or renamed, or are "
  733. +    IDS_HIDEOBS_TOOLTIP     "If selected, setup will hide packages in categories "\
  734. +       "with names that begin with '_'.  Such packages are usually empty "\
  735. +       "placeholders for packages that have been removed or renamed, or are "\
  736.         "infrastructure packages that are handled automatically."
  737. END
  738. diff -dur setup-2.588-orig/root.cc setup-2.588/root.cc
  739. --- setup-2.588-orig/root.cc    2006-04-07 00:45:19.000000000 +0800
  740. +++ setup-2.588/root.cc    2008-08-08 10:56:26.000000000 +0800
  741. @@ -79,7 +79,13 @@
  742. {
  743.    rbset (h, rb, root_text);
  744.    rbset (h, su, root_scope);
  745. +
  746. +#ifndef __WINE__
  747.    eset (h, IDC_ROOT_DIR, get_root_dir ());
  748. +#else //__WINE__
  749. +  eset (h, IDC_ROOT_DIR, wine_dos_path(get_root_dir ()));
  750. +#endif //__WINE__
  751. +
  752.    check_if_enable_next (h);
  753. }

  754. @@ -216,6 +222,10 @@

  755.    save_dialog (h);

  756. +#ifdef __WINE__ //FIXME
  757. +  return 0;
  758. +#endif
  759. +
  760.    if (!directory_is_absolute ())
  761.      {
  762.        note (h, IDS_ROOT_ABSOLUTE);
  763. diff -dur setup-2.588-orig/script.cc setup-2.588/script.cc
  764. --- setup-2.588-orig/script.cc    2007-02-28 08:55:04.000000000 +0800
  765. +++ setup-2.588/script.cc    2008-08-08 10:56:26.000000000 +0800
  766. @@ -33,6 +33,10 @@
  767. #include "script.h"
  768. #include "mkdir.h"

  769. +#ifdef __WINE__
  770. +#  include "mount.h"
  771. +#endif
  772. +
  773. static std::string sh;
  774. static const char *cmd = 0;

  775. @@ -49,7 +53,11 @@
  776. {
  777.    for (int i = 0; shells[i]; i++)
  778.      {
  779. +#ifndef __WINE__
  780.        sh = backslash (cygpath (shells[i]));
  781. +#else
  782. +      sh = wine_unix_path (cygpath (shells[i]));
  783. +#endif
  784.        if (_access (sh.c_str(), 0) == 0)
  785.      break;
  786.        sh.clear();
  787. @@ -57,10 +65,17 @@
  788.    
  789.    char old_path[MAX_PATH];
  790.    GetEnvironmentVariable ("PATH", old_path, sizeof (old_path));
  791. +#ifndef __WINE__
  792.    SetEnvironmentVariable ("PATH", backslash (cygpath ("/bin") + ";" +
  793.                           cygpath ("/usr/bin") + ";" +
  794.                           old_path).c_str());
  795.    SetEnvironmentVariable ("CYGWINROOT", get_root_dir ().c_str());
  796. +#else //__WINE__
  797. +  SetEnvironmentVariable ("PATH", (backslash (cygpath ("/bin")) + ";" +
  798. +                         backslash (cygpath ("/usr/bin")) + ";" +
  799. +                         old_path).c_str()); //FIXME
  800. +  SetEnvironmentVariable ("CYGWINROOT", wine_dos_path( get_root_dir ()).c_str());
  801. +#endif //__WINE__

  802.    if (IsWindowsNT ())
  803.      cmd = "cmd.exe";
  804. @@ -209,7 +224,12 @@
  805.       postinstall script by the same name.  When we are called the second
  806.       time the file has already been renamed to .done, and if we don't
  807.       return here we end up erroniously deleting this .done file.  */
  808. +#ifndef __WINE__
  809.    std::string windowsName = backslash (cygpath (scriptName));
  810. +#else
  811. +  std::string windowsName = wine_unix_path (cygpath (scriptName));
  812. +#endif
  813. +
  814.    if (_access (windowsName.c_str(), 0) == -1)
  815.      {
  816.        log(LOG_PLAIN) << "can't run " << scriptName << ": No such file"
  817. @@ -220,6 +240,8 @@
  818.    int retval;
  819.    char tmp_pat[] = "/var/log/setup.log.postinstallXXXXXXX";
  820.    OutputLog file_out = std::string (mktemp (tmp_pat));
  821. +
  822. +#ifndef __WINE__
  823.    if (sh.size() && stricmp (extension(), ".sh") == 0)
  824.      {
  825.        log(LOG_PLAIN) << "running: " << sh << " -c " << scriptName << endLog;
  826. @@ -232,6 +254,20 @@
  827.      }
  828.    else
  829.      return -ERROR_INVALID_DATA;
  830. +#else //__WINE__
  831. +  if (sh.size() && strcasecmp (extension(), ".sh") == 0)
  832. +    {
  833. +      log(LOG_PLAIN) << "running: " << sh << " -c " << scriptName << endLog;
  834. +      retval = ::run (sh.c_str(), "-c", scriptName.c_str(), file_out);
  835. +    }
  836. +  else if (cmd && strcasecmp (extension(), ".bat") == 0)
  837. +    {
  838. +      log(LOG_PLAIN) << "running: " << cmd << " /c " << windowsName << endLog;
  839. +      retval = ::run (cmd, "/c", windowsName.c_str(), file_out);
  840. +    }
  841. +  else
  842. +    return -ERROR_INVALID_DATA;
  843. +#endif //__WINE__

  844.    if (!file_out.isEmpty ())
  845.      log(LOG_BABBLE) << file_out << endLog;
  846. diff -dur setup-2.588-orig/site.cc setup-2.588/site.cc
  847. --- setup-2.588-orig/site.cc    2008-04-09 07:50:54.000000000 +0800
  848. +++ setup-2.588/site.cc    2008-08-08 10:56:26.000000000 +0800
  849. @@ -28,7 +28,9 @@
  850. #include "win32.h"
  851. #include <stdio.h>
  852. #include <stdlib.h>
  853. -#include <process.h>
  854. +#ifndef __WINE__
  855. +#  include <process.h>
  856. +#endif

  857. #include "dialog.h"
  858. #include "resource.h"
  859. @@ -189,13 +191,21 @@
  860. bool
  861. site_list_type::operator == (site_list_type const &rhs) const
  862. {
  863. +#ifndef __WINE__
  864.    return stricmp (key.c_str(), rhs.key.c_str()) == 0;
  865. +#else
  866. +  return strcasecmp (key.c_str(), rhs.key.c_str()) == 0;
  867. +#endif
  868. }

  869. bool
  870. site_list_type::operator < (site_list_type const &rhs) const
  871. {
  872. +#ifndef __WINE__
  873.    return stricmp (key.c_str(), rhs.key.c_str()) < 0;
  874. +#else
  875. +  return strcasecmp (key.c_str(), rhs.key.c_str()) < 0;
  876. +#endif
  877. }

  878. static void
  879. @@ -359,10 +369,17 @@
  880.      {
  881.        /* Don't default to certain machines ever since they suffer
  882.       from bandwidth limitations. */
  883. +    #ifndef __WINE__
  884.        if (strnicmp (site, NOSAVE1, NOSAVE1_LEN) == 0
  885.        || strnicmp (site, NOSAVE2, NOSAVE2_LEN) == 0
  886.        || strnicmp (site, NOSAVE3, NOSAVE3_LEN) == 0)
  887.      return;
  888. +    #else //__WINE__
  889. +      if (strncasecmp (site, NOSAVE1, NOSAVE1_LEN) == 0
  890. +      || strncasecmp (site, NOSAVE2, NOSAVE2_LEN) == 0
  891. +      || strncasecmp (site, NOSAVE3, NOSAVE3_LEN) == 0)
  892. +    return;
  893. +    #endif //__WINE__
  894.        SiteList result;
  895.        merge (all_site_list.begin(), all_site_list.end(),
  896.           &tempSite, &tempSite + 1,
  897. @@ -450,7 +467,7 @@
  898.    CreateThread (NULL, 0, do_download_site_info_thread, context, 0, &threadID);
  899. }

  900. -static BOOL CALLBACK
  901. +static INT_PTR CALLBACK
  902. drop_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam)
  903. {
  904.    switch (message)
复制代码
使用方法如下:
下载 补丁 和 cygwin 的 setup.exe 源代码 到同一个目录,比如/your_dir
在X环境打开一个终端,执行下面命令(省略提示符,拷贝下来,修改路径,直接粘贴到终端执行即可)

  1. cd [color=Red]/your_dir[/color]

  2. gunzip cygwin_setup-porting_with_winelib.patch.gz
  3. tar -xvf setup-2.588.tar.bz2
  4. cd setup-2.588
  5. patch -p1 < ../cygwin_setup-porting_with_winelib.patch

  6. CC="winegcc" CXX="wineg++" LIBS="-lcrtdll -lwininet" WINDRES=wrc ./configure --prefix=/somewhere --enable-shared=no
  7. make

  8. cp -a setup.exe.so [color=Red]/somewhere[/color]
  9. cd [color=Red]/somewhere[/color]
  10. wine setup.exe.so
复制代码
请把/somewhere替换成你希望的地方,/somewhere必须是wine可以访问的路径。
现在你应该看到 cygwin 安装界面,正常安装即可。

一些额外修正:
1、默认设置的 wine 无法提供正确的 HOME 环境变量,影响 cygwin 的使用,一个比较好的解决方案是设置 cygwin 的 etc/passwd、etc/group,在cygwin的根目录执行下面脚本,或直接手工编辑这两个文件。
  1. #!/bin/sh

  2. #fix /etc/passwd /etc/group
  3. echo "`whoami`::`id -u`:`id -g`::/home/`whoami`:/bin/bash" >> etc/passwd
  4. echo "`whoami`:x:`id -g`:" >> etc/group
复制代码

2、中文环境,默认安装的桌面图标无法启动,原因是 wine 无法找到适用于终端的中文字体,需要设置 cygwin 的 locale 为 POSIX 或 en_US.UTF-8,使用你喜爱的编辑器打开~/Desktop/Cygwin.desktop,找到"Exec=env WINEPREFIX"开头的行,修改为 ”Exec=env LANG= LC_ALL= WINEPREFIX“ 或 ”Exec=env LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 WINEPREFIX“ 即可。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
 楼主| 发表于 2008-8-2 00:18:01 | 显示全部楼层
相关资源:
wine-docs
http://ibiblio.org/pub/linux/sys ... ne-docs-1.0.tar.bz2

Winelib
http://www.winehq.org/site/winelib

Winelib User's Guide
http://www.winehq.org/docs/en/winelib-guide.html

Wine Developer's Guide
http://www.winehq.org/site/docs/winedev-guide/index

Using the Wine Debugger
http://www.winehq.org/site/docs/winedev-guide/wine-debugger

Porting with Winelib
http://wiki.winehq.org/Porting_with_Winelib

Porting with Winelib (maillist)
http://www.winehq.org/pipermail/wine-users/2001-June/007257.html

Winelib HOWTO
http://source.winehq.org/source/ ... elib?v=wine20030911

Debunking Wine Myths
http://www.winehq.org/site/myths

GCC 4.3 related build problems: missing #include
http://www.cyrius.com/journal/2007/05/10#gcc-4.3-include

Porting DOS Applications to Linux
http://www.linuxjournal.com/article/1138

直接用cygwin setup.exe安装的一些成功结果
http://appdb.winehq.org/objectMa ... mp;iTestingId=23561

wikipedia Cygwin([color="Red"]不用翻墙,怪事,开始掰指头计时)
http://zh.wikipedia.org/wiki/Cygwin
回复 支持 反对

使用道具 举报

发表于 2008-8-3 12:58:21 | 显示全部楼层
Linux 下裝 Cygwin?

怎麼好像有點本末倒置的感覺?樓主可否說說此舉有何作用?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-8-3 14:22:02 | 显示全部楼层
重复一下:
如果移植成功,则可在完全开源的环境下使用cygwin。

sourceforge上有不少开源软件只有win32版本,直接wine可能有不兼容的问题。
winelib提供了另一种选择,拿cygwin试试手,正好试试深浅。

另,本版有人用M$系统+cygwin进行CLFS,想验证一下,但又不想用M$的系统。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-8-7 20:03:49 | 显示全部楼层
用winelib移植 cygwin setup.exe 的过程表明,winelib不适于移植c++程序。
cygwin setup.exe 几乎是用c++写成的,却大量使用c库函数,winelib没有提供c++接口。
这样用winelib提供的 libc msvcrt.dll 成为不可能的任务,只好使用本地glibc。
这样又引出严重的路径不兼容问题,时间大半花在这种体力活上。

安装的cygwin,链接文件有问题,解决中。
刚刚用wine+cygwin安装linux-header,没计时,感觉20分钟都不止,双核cpu占用率长时间超60%。
解压占了大半时间,看来wine+cygwin的双重模拟,对 file i/o 性能影响严重,无法忍受。
也许只能把cygwin当玩具玩,编译个木马什么的还是不成问题的。

大略看过cygwin1.dll的源码结构,初步设想是用winelib移植并链接到本地glibc,由本地glibc提供文件读写,但cygwin1.dll整合了newlib的libc,有可能需重写cygwin1.dll代码的大部分,工作量巨大,投入产出严重不平衡,也许该放弃了。
毕竟只是想试试用 cygwin CLFS,而不是反向移植cygwin。
回复 支持 反对

使用道具 举报

发表于 2008-8-7 20:30:17 | 显示全部楼层
雖然是無功而還,但思路清析明確,不愧是 LFS/CLFS 玩家 :)
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-8-8 16:59:30 | 显示全部楼层
补丁已释出。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表