|
本文目标:在 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 见附件。
- #
- # cygwin_setup-porting_with_winelib.patch
- #
- # Author: Eric Zhao
- # Email: ericzhao.nebula@gmail.com
- # source: http://cygwin.com/setup/snapshots/setup-2.588.tar.bz2
- # configure: CC="winegcc" CXX="wineg++" LIBS="-lcrtdll -lwininet" WINDRES=wrc ./configure --prefix=/somewhere --enable-shared=no
- #
- # We must link to "-lcrtdll" or "-lmscvrt" without "-mno-cygwin".
- # If we link to native glibc, the setup.exe will crash.
- # I can't explain why, perhaps you can. please fix it.
- #
- diff -dur setup-2.588-orig/ControlAdjuster.h setup-2.588/ControlAdjuster.h
- --- setup-2.588-orig/ControlAdjuster.h 2005-05-06 05:00:32.000000000 +0800
- +++ setup-2.588/ControlAdjuster.h 2008-08-08 10:56:26.000000000 +0800
- @@ -46,10 +46,10 @@
- class ControlDimension
- {
- public:
- - ControlDimension(long &anInt1, long &anInt2) :
- + ControlDimension(LONG &anInt1, LONG &anInt2) :
- left(anInt1), right (anInt2){}
- - long &left;
- - long &right;
- + LONG &left;
- + LONG &right;
- };
-
- class ControlAdjuster
- diff -dur setup-2.588-orig/UserSetting.cc setup-2.588/UserSetting.cc
- --- setup-2.588-orig/UserSetting.cc 2004-10-26 01:06:07.000000000 +0800
- +++ setup-2.588/UserSetting.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -23,7 +23,9 @@
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- -#include <process.h>
- +#ifndef __WINE__
- +# include <process.h>
- +#endif
- #include <algorithm>
-
- #include "LogSingleton.h"
- diff -dur setup-2.588-orig/UserSettings.cc setup-2.588/UserSettings.cc
- --- setup-2.588-orig/UserSettings.cc 2006-04-16 05:21:25.000000000 +0800
- +++ setup-2.588/UserSettings.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -23,7 +23,9 @@
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- -#include <process.h>
- +#ifndef __WINE__
- +# include <process.h>
- +#endif
- #include <algorithm>
-
- #include "LogSingleton.h"
- diff -dur setup-2.588-orig/autoload.c setup-2.588/autoload.c
- --- setup-2.588-orig/autoload.c 2008-04-09 07:50:54.000000000 +0800
- +++ setup-2.588/autoload.c 2008-08-08 10:56:26.000000000 +0800
- @@ -16,6 +16,8 @@
- static const char *cvsid = "\n%%% $Id: autoload.c,v 2.7 2008/04/08 23:50:54 briand Exp $\n";
- #endif
-
- +#ifndef __WINE__
- +
- #define WIN32_LEAN_AND_MEAN
- #include <windows.h>
-
- @@ -96,3 +98,5 @@
-
- *(int *)(&x-1) = (int)proc-5;
- }
- +
- +#endif //__WINE__
- diff -dur setup-2.588-orig/choose.cc setup-2.588/choose.cc
- --- setup-2.588-orig/choose.cc 2008-04-09 07:50:54.000000000 +0800
- +++ setup-2.588/choose.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -35,9 +35,13 @@
- #include <commctrl.h>
- #include <stdio.h>
- #include <stdlib.h>
- -#include <io.h>
- +#ifndef __WINE__
- +# include <io.h>
- +#endif
- #include <ctype.h>
- -#include <process.h>
- +#ifndef __WINE__
- +# include <process.h>
- +#endif
- #include <algorithm>
-
- #include "dialog.h"
- diff -dur setup-2.588-orig/compress_bz.cc setup-2.588/compress_bz.cc
- --- setup-2.588-orig/compress_bz.cc 2008-04-09 09:39:47.000000000 +0800
- +++ setup-2.588/compress_bz.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -61,7 +61,11 @@
-
- if (peeklen)
- {
- + #ifndef __WINE__
- ssize_t tmplen = std::min (peeklen, len);
- + #else
- + ssize_t tmplen = min (peeklen, len);
- + #endif
- peeklen -= tmplen;
- memcpy (buffer, peekbuf, tmplen);
- memmove (peekbuf, peekbuf + tmplen, tmplen);
- diff -dur setup-2.588-orig/desktop.cc setup-2.588/desktop.cc
- --- setup-2.588-orig/desktop.cc 2007-05-05 05:56:53.000000000 +0800
- +++ setup-2.588/desktop.cc 2008-08-08 10:57:20.000000000 +0800
- @@ -166,7 +166,11 @@
- static void
- make_cygwin_bat ()
- {
- +#ifndef __WINE__
- batname = backslash (cygpath ("/Cygwin.bat"));
- +#else //__WINE__
- + batname = wine_unix_path( cygpath ("/Cygwin.bat"));
- +#endif //__WINE__
-
- /* if the batch file exists, don't overwrite it */
- if (_access (batname.c_str(), 0) == 0)
- @@ -178,9 +182,15 @@
-
- fprintf (bat, "@echo off\n\n");
-
- +#ifndef __WINE__
- fprintf (bat, "%.2s\n", get_root_dir ().c_str());
- fprintf (bat, "chdir %s\n\n",
- replace(backslash(get_root_dir() + "/bin"), "%", "%%").c_str());
- +#else //__WINE__
- + fprintf (bat, "%.2s\n", (wine_dos_path (get_root_dir ())).c_str());
- + fprintf (bat, "chdir %s\n\n",
- + replace(backslash(wine_dos_path (get_root_dir ()) + "/bin"), "%", "%%").c_str());
- +#endif //__WINE__
-
- fprintf (bat, "bash --login -i\n");
-
- @@ -190,7 +200,11 @@
- static void
- save_icon ()
- {
- +#ifndef __WINE__
- iconname = backslash (cygpath ("/Cygwin.ico"));
- +#else //__WINE__
- + iconname = wine_unix_path (cygpath ("/Cygwin.ico"));
- +#endif //__WINE__
-
- HRSRC rsrc = FindResource (NULL, "CYGWIN.ICON", "FILE");
- if (rsrc == NULL)
- diff -dur setup-2.588-orig/download.cc setup-2.588/download.cc
- --- setup-2.588-orig/download.cc 2007-05-05 05:56:53.000000000 +0800
- +++ setup-2.588/download.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -29,7 +29,9 @@
-
- #include <stdio.h>
- #include <unistd.h>
- -#include <process.h>
- +#ifndef __WINE__
- +# include <process.h>
- +#endif
-
- #include "resource.h"
- #include "msg.h"
- diff -dur setup-2.588-orig/filemanip.cc setup-2.588/filemanip.cc
- --- setup-2.588-orig/filemanip.cc 2008-04-09 07:50:54.000000000 +0800
- +++ setup-2.588/filemanip.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -25,6 +25,9 @@
- #include "filemanip.h"
- #include "io_stream.h"
- #include "String++.h"
- +#ifdef __WINE__
- +# include "mount.h"
- +#endif
-
- using namespace std;
-
- @@ -118,7 +121,11 @@
- {
- *ver++ = 0;
- f.pkg = p;
- + #ifndef __WINE__
- f.what = strlwr (ver);
- + #else //__WINE__
- + f.what = ver; //FIXME
- + #endif //__WINE__
- ver = strchr (ver, '\0');
- break;
- }
- @@ -165,7 +172,11 @@
- std::string
- backslash(const std::string& s)
- {
- +#ifndef __WINE__
- std::string rv(s);
- +#else
- + std::string rv(wine_dos_path(s));
- +#endif
-
- for (std::string::iterator it = rv.begin(); it != rv.end(); ++it)
- if (*it == '/')
- diff -dur setup-2.588-orig/ini.cc setup-2.588/ini.cc
- --- setup-2.588-orig/ini.cc 2007-08-01 08:20:10.000000000 +0800
- +++ setup-2.588/ini.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -35,8 +35,9 @@
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdarg.h>
- -#include <process.h>
- -
- +#ifndef __WINE__
- +# include <process.h>
- +#endif
- #include "resource.h"
- #include "state.h"
- #include "geturl.h"
- diff -dur setup-2.588-orig/install.cc setup-2.588/install.cc
- --- setup-2.588-orig/install.cc 2008-04-09 10:25:27.000000000 +0800
- +++ setup-2.588/install.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -37,7 +37,9 @@
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <errno.h>
- -#include <process.h>
- +#ifndef __WINE__
- +# include <process.h>
- +#endif
-
- #include "resource.h"
- #include "dialog.h"
- diff -dur setup-2.588-orig/io_stream.h setup-2.588/io_stream.h
- --- setup-2.588-orig/io_stream.h 2008-04-09 09:39:47.000000000 +0800
- +++ setup-2.588/io_stream.h 2008-08-08 10:56:26.000000000 +0800
- @@ -33,7 +33,7 @@
- */
-
- //Where is this defined?
- -#if defined(_WIN32) && ! defined(__CYGWIN__)
- +#if defined(_WIN32) && ! defined(__CYGWIN__) && ! defined(__WINE__)
- typedef signed long ssize_t;
- #endif
-
- diff -dur setup-2.588-orig/io_stream_cygfile.cc setup-2.588/io_stream_cygfile.cc
- --- setup-2.588-orig/io_stream_cygfile.cc 2006-04-17 05:35:57.000000000 +0800
- +++ setup-2.588/io_stream_cygfile.cc 2008-08-08 10:57:57.000000000 +0800
- @@ -207,7 +207,11 @@
- case IO_STREAM_SYMLINK:
- // symlinks are arbitrary targets, can be anything, and are
- // not subject to translation
- + #ifndef __WINE__
- return mkcygsymlink (cygpath (from).c_str(), _to.c_str());
- + #else //__WINE__
- + return symlink (_to.c_str(), wine_unix_path(cygpath (from)).c_str());
- + #endif //__WINE__
- case IO_STREAM_HARDLINK:
- {
- /* For now, just copy */
- diff -dur setup-2.588-orig/io_stream_file.cc setup-2.588/io_stream_file.cc
- --- setup-2.588-orig/io_stream_file.cc 2006-04-17 05:35:57.000000000 +0800
- +++ setup-2.588/io_stream_file.cc 2008-08-08 10:58:15.000000000 +0800
- @@ -141,7 +141,7 @@
- {
- if (!from.size() || !to.size())
- return 1;
- -#if defined(WIN32) && !defined (_CYGWIN_)
- +#if defined(WIN32) && !defined (_CYGWIN_) && !defined (__WINE__)
- switch (linktype)
- {
- case IO_STREAM_SYMLINK:
- diff -dur setup-2.588-orig/localdir.cc setup-2.588/localdir.cc
- --- setup-2.588-orig/localdir.cc 2006-04-16 05:21:25.000000000 +0800
- +++ setup-2.588/localdir.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -76,6 +76,11 @@
- }
- if (((std::string)LocalDirOption).size())
- local_dir = ((std::string)LocalDirOption);
- +
- +#ifdef __WINE__
- + local_dir = wine_unix_path (local_dir);
- +#endif
- +
- inited = 1;
- }
-
- @@ -85,7 +90,12 @@
- io_stream *f = UserSettings::Instance().settingFileForSave("last-cache");
- if (f)
- {
- + #ifndef __WINE__
- f->write (local_dir.c_str(), local_dir.size());
- + #else //__WINE__
- + std::string s = wine_dos_path (local_dir);
- + f->write (s.c_str(), s.size());
- + #endif //__WINE__
- delete f;
- }
- if (source == IDC_SOURCE_DOWNLOAD || !get_root_dir ().size())
- @@ -111,14 +121,23 @@
- static void
- load_dialog (HWND h)
- {
- +#ifndef __WINE__
- eset (h, IDC_LOCAL_DIR, local_dir);
- +#else //__WINE__
- + eset (h, IDC_LOCAL_DIR, wine_dos_path(local_dir));
- +#endif //__WINE__
- +
- check_if_enable_next (h);
- }
-
- static void
- save_dialog (HWND h)
- {
- +#ifndef __WINE__
- local_dir = egetString (h, IDC_LOCAL_DIR);
- +#else //__WINE__
- + local_dir = wine_unix_path (egetString (h, IDC_LOCAL_DIR));
- +#endif //__WINE__
- }
-
-
- diff -dur setup-2.588-orig/main.cc setup-2.588/main.cc
- --- setup-2.588-orig/main.cc 2007-02-28 08:55:04.000000000 +0800
- +++ setup-2.588/main.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -31,6 +31,10 @@
- "\n%%% $Id: main.cc,v 2.44 2007/02/28 00:55:04 briand Exp $\n";
- #endif
-
- +#ifdef __WINE__
- + #include <errno.h>
- +#endif
- +
- #include "win32.h"
- #include <commctrl.h>
-
- @@ -83,7 +87,7 @@
- // so we make the actual logger available to the appropriate routine(s).
- LogFile *theLog;
-
- -#ifndef __CYGWIN__
- +#if ! defined(__CYGWIN__) && ! defined(__WINE__)
- int WINAPI
- WinMain (HINSTANCE h,
- HINSTANCE hPrevInstance, LPSTR command_line, int cmd_show)
- @@ -104,7 +108,7 @@
-
- // TODO: make an equivalent for __argv under cygwin.
- char **_argv;
- -#ifndef __CYGWIN__
- +#if ! defined(__CYGWIN__) && ! defined(__WINE__)
- int argc;
- for (argc = 0, _argv = __argv; *_argv; _argv++)
- ++argc;
- @@ -125,9 +129,11 @@
-
- // Ensure files created by postinstall and preremove scripts
- // get sane permissions.
- +#ifndef __WINE__ //FIXME
- if (putenv ("CYGWIN=nontsec") != 0)
- log (LOG_PLAIN) << "Failed to set CYGWIN=nontsec (errno " << errno
- << ": " << strerror(errno) << ")" << endLog;
- +#endif //__WINE__
-
- UserSettings::Instance ().loadAllSettings ();
-
- diff -dur setup-2.588-orig/mklink2.cc setup-2.588/mklink2.cc
- --- setup-2.588-orig/mklink2.cc 2004-12-26 07:05:57.000000000 +0800
- +++ setup-2.588/mklink2.cc 2008-08-08 10:58:38.000000000 +0800
- @@ -45,7 +45,7 @@
- mkcygsymlink (const char *from, const char *to)
- {
- char buf[512];
- - unsigned long w;
- + unsigned int w;
- HANDLE h = CreateFileA (from, GENERIC_WRITE, 0, 0, CREATE_NEW,
- FILE_ATTRIBUTE_NORMAL, 0);
- if (h == INVALID_HANDLE_VALUE)
- diff -dur setup-2.588-orig/mount.cc setup-2.588/mount.cc
- --- setup-2.588-orig/mount.cc 2007-02-28 08:55:04.000000000 +0800
- +++ setup-2.588/mount.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -97,6 +97,39 @@
-
- struct mnt *root_here = NULL;
-
- +#ifdef __WINE__
- +# include <winbase.h>
- +
- +std::string
- +wine_unix_path(const std::string& s)
- +{
- + if (s.empty())
- + return std::string ();
- + if (s.c_str()[0] == '/')
- + return std::string (s);
- +
- + WCHAR wtmp[4000];
- + memset (wtmp, 0, sizeof (wtmp));
- + MultiByteToWideChar(CP_ACP, 0, s.c_str(), -1, wtmp, 4000);
- + return std::string (wine_get_unix_file_name (wtmp));
- +}
- +
- +std::string
- +wine_dos_path(const std::string& s)
- +{
- + if (s.empty())
- + return std::string ();
- + if (s.c_str()[0] != '/')
- + return std::string (s);
- +
- +
- + char tmp[4000];
- + memset (tmp, 0, sizeof (tmp));
- + WideCharToMultiByte(CP_ACP, 0, wine_get_dos_file_name (s.c_str()), -1, tmp, 4000, NULL, NULL);
- + return std::string (tmp);
- +}
- +#endif //__WINE__
- +
- static std::string
- find2 (HKEY rkey, int *istext, const std::string& what)
- {
- @@ -155,8 +188,15 @@
- if (rv != ERROR_SUCCESS)
- fatal ("mount", rv);
-
- +#ifndef __WINE__
- RegSetValueEx (key, "native", 0, REG_SZ, (BYTE *) win32.c_str (),
- win32.size () + 1);
- +#else
- + std::string wine_win32 = wine_dos_path (win32);
- + RegSetValueEx (key, "native", 0, REG_SZ, (BYTE *) wine_win32.c_str (),
- + wine_win32.size () + 1);
- +#endif
- +
- flags = 0;
- if (!istext)
- flags |= MOUNT_BINARY;
- @@ -445,7 +485,11 @@
- void
- set_root_dir (const std::string val)
- {
- +#ifndef __WINE__
- root_here->native = val;
- +#else //__WINE__
- + root_here->native = wine_unix_path (val);
- +#endif //__WINE__
- }
-
- const std::string
- diff -dur setup-2.588-orig/mount.h setup-2.588/mount.h
- --- setup-2.588-orig/mount.h 2006-04-16 23:37:49.000000000 +0800
- +++ setup-2.588/mount.h 2008-08-08 10:56:26.000000000 +0800
- @@ -23,6 +23,11 @@
- #include <string>
- #include "String++.h"
-
- +#ifdef __WINE__
- +std::string wine_unix_path(const std::string& s);
- +std::string wine_dos_path(const std::string& s);
- +#endif //__WINE__
- +
- char *find_mount (int *istext, int *issystem, char *path);
-
- /* Similar to the mount and umount functions, but simplified */
- diff -dur setup-2.588-orig/netio.cc setup-2.588/netio.cc
- --- setup-2.588-orig/netio.cc 2005-05-04 22:52:34.000000000 +0800
- +++ setup-2.588/netio.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -233,7 +233,7 @@
- return 0;
- }
-
- -static BOOL CALLBACK
- +static INT_PTR CALLBACK
- auth_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch (message)
- diff -dur setup-2.588-orig/nio-http.cc setup-2.588/nio-http.cc
- --- setup-2.588-orig/nio-http.cc 2006-04-16 05:21:25.000000000 +0800
- +++ setup-2.588/nio-http.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -34,9 +34,15 @@
- #include "netio.h"
- #include "nio-http.h"
-
- -#ifndef _strnicmp
- -#define _strnicmp strncasecmp
- -#endif
- +#ifndef __WINE__
- +# ifndef _strnicmp
- +# define _strnicmp strncasecmp
- +# endif
- +#else //__WINE__
- +# ifndef _strncasecmp
- +# define _strncasecmp strncasecmp
- +# endif
- +#endif //__WINE__
-
- static char six2pr[64] = {
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
- @@ -143,6 +149,7 @@
- {
- while ((l = s->gets ()) != 0)
- {
- + #ifndef __WINE__
- if (_strnicmp (l, "Location:", 9) == 0)
- {
- char *
- @@ -154,6 +161,19 @@
- s;
- goto retry_get;
- }
- + #else //__WINE__
- + if (_strncasecmp (l, "Location:", 9) == 0)
- + {
- + char *
- + u = l + 9;
- + while (*u == ' ' || *u == '\t')
- + u++;
- + set_url (u);
- + delete
- + s;
- + goto retry_get;
- + }
- + #endif //__WINE__
- }
- }
- if (code == 401) /* authorization required */
- @@ -194,8 +214,13 @@
- // Eat the header, picking out the Content-Length in the process
- while (((l = s->gets ()) != NULL) && (*l != '\0'))
- {
- + #ifndef __WINE__
- if (_strnicmp (l, "Content-Length:", 15) == 0)
- sscanf (l, "%*s %d", &file_size);
- + #else
- + if (_strncasecmp (l, "Content-Length:", 15) == 0)
- + sscanf (l, "%*s %d", &file_size);
- + #endif
- }
- }
-
- diff -dur setup-2.588-orig/package_source.cc setup-2.588/package_source.cc
- --- setup-2.588-orig/package_source.cc 2006-04-18 00:13:17.000000000 +0800
- +++ setup-2.588/package_source.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -22,6 +22,9 @@
- "\n%%% $Id: package_source.cc,v 2.10 2006/04/17 16:13:17 maxb Exp $\n";
- #endif
-
- +#ifdef __WINE__
- +# include <string.h>
- +#endif
- #include <stdlib.h>
- #include <strings.h>
- #include "package_source.h"
- diff -dur setup-2.588-orig/prereq.cc setup-2.588/prereq.cc
- --- setup-2.588-orig/prereq.cc 2006-04-16 05:21:25.000000000 +0800
- +++ setup-2.588/prereq.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -21,9 +21,13 @@
- #include "win32.h"
- #include <commctrl.h>
- #include <stdio.h>
- -#include <io.h>
- +#ifndef __WINE__
- +# include <io.h>
- +#endif
- #include <ctype.h>
- -#include <process.h>
- +#ifndef __WINE__
- +# include <process.h>
- +#endif
-
- #include "prereq.h"
- #include "dialog.h"
- diff -dur setup-2.588-orig/proppage.cc setup-2.588/proppage.cc
- --- setup-2.588-orig/proppage.cc 2006-04-16 05:21:25.000000000 +0800
- +++ setup-2.588/proppage.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -81,7 +81,7 @@
- return true;
- }
-
- -BOOL CALLBACK
- +INT_PTR CALLBACK
- PropertyPage::FirstDialogProcReflector (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam)
- {
- diff -dur setup-2.588-orig/proppage.h setup-2.588/proppage.h
- --- setup-2.588-orig/proppage.h 2006-04-16 05:21:25.000000000 +0800
- +++ setup-2.588/proppage.h 2008-08-08 10:56:26.000000000 +0800
- @@ -42,7 +42,7 @@
- // For setting the back/finish buttons properly.
- bool IsFirst, IsLast;
-
- - static BOOL CALLBACK FirstDialogProcReflector (HWND hwnd, UINT message,
- + static INT_PTR CALLBACK FirstDialogProcReflector (HWND hwnd, UINT message,
- WPARAM wParam,
- LPARAM lParam);
- static BOOL CALLBACK DialogProcReflector (HWND hwnd, UINT message,
- diff -dur setup-2.588-orig/propsheet.cc setup-2.588/propsheet.cc
- --- setup-2.588-orig/propsheet.cc 2003-11-01 15:21:28.000000000 +0800
- +++ setup-2.588/propsheet.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -433,8 +433,13 @@
- PropSheet::SetActivePageByID (int resource_id)
- {
- // Posts a message to the message queue, so this won't block
- +#ifndef __WINE__
- return static_cast < bool >
- (::PropSheet_SetCurSelByID (GetHWND (), resource_id));
- +#else
- + return static_cast < bool >
- + (PropSheet_SetCurSelByID (GetHWND (), resource_id));
- +#endif
- }
-
- void
- diff -dur setup-2.588-orig/res.rc setup-2.588/res.rc
- --- setup-2.588-orig/res.rc 2008-04-09 10:27:37.000000000 +0800
- +++ setup-2.588/res.rc 2008-08-08 10:56:26.000000000 +0800
- @@ -1,5 +1,8 @@
- #include "resource.h"
- #include "windows.h"
- +#include "winuser.h"
- +#include "winnt.h"
- +#include "commctrl.h"
-
- LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-
- @@ -71,8 +74,8 @@
- BEGIN
- LTEXT "Select Local Package Directory",IDC_STATIC_HEADER_TITLE,
- 7,0,258,8,NOT WS_GROUP
- - LTEXT "Select a directory where you want Setup to store the "
- - "installation files it downloads. The directory will be "
- + LTEXT "Select a directory where you want Setup to store the "\
- + "installation files it downloads. The directory will be "\
- "created if it does not already exist.",IDC_STATIC,
- 21,9,248,16,NOT WS_GROUP
- ICON IDI_CYGWIN,IDC_HEADICON,290,0,21,20
- @@ -91,7 +94,7 @@
- BEGIN
- LTEXT "Select Root Install Directory",IDC_STATIC_HEADER_TITLE,
- 7,0,258,8,NOT WS_GROUP
- - LTEXT "Select the directory where you want to install Cygwin. "
- + LTEXT "Select the directory where you want to install Cygwin. "\
- "Also choose a few installation parameters.",
- IDC_STATIC,21,9,239,16,NOT WS_GROUP
- ICON IDI_CYGWIN,IDC_HEADICON,290,0,21,20
- @@ -112,17 +115,17 @@
- BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP,170,89,130,8
- CONTROL "D&OS / text",IDC_ROOT_TEXT,"Button",BS_AUTORADIOBUTTON |
- WS_TABSTOP,170,130,130,8
- - LTEXT "Cygwin will be available to all users of the system. "
- - "NOTE: This is required if you wish to run services like "
- + LTEXT "Cygwin will be available to all users of the system. "\
- + "NOTE: This is required if you wish to run services like "\
- "sshd, etc.",IDC_ALLUSERS_TEXT,25,101,125,28
- - LTEXT "Cygwin will only be available to the current user. "
- - "Only select this if you lack Admin. privileges or you "
- + LTEXT "Cygwin will only be available to the current user. "\
- + "Only select this if you lack Admin. privileges or you "\
- "have specific needs.",IDC_JUSTME_TEXT,25,140,125,32
-
- - LTEXT "No line translation done; all files opened in binary mode."
- + LTEXT "No line translation done; all files opened in binary mode."\
- " Files on disk will have LF line endings.", IDC_MODE_BIN,
- 181,101,125,27
- - LTEXT "Line endings will be translated from unix (LF) to DOS "
- + LTEXT "Line endings will be translated from unix (LF) to DOS "\
- "(CR-LF) on write and vice versa on read.",IDC_MODE_TEXT,
- 181,140,125,26
- LTEXT "Read more about file modes...",IDC_FILEMODES_LINK,
- @@ -253,15 +256,15 @@
- // CONTROL "",IDC_STATIC,"Static",SS_WHITERECT,0,0,95,178
- LTEXT "Cygwin Net Release Setup Program",
- IDC_STATIC_WELCOME_TITLE,115,1,195,24
- - LTEXT "This setup program is used for the initial installation "
- - "of the Cygwin environment as well as all subsequent "
- - "updates. Make sure to remember where you saved it.\r\n\r\n"
- - "The pages that follow will guide you through the "
- - "installation. Please note that Cygwin consists of a "
- - "large number of packages spanning a wide variety of "
- - "purposes. We only install a base set of packages by "
- - "default. You can always run this program at any time in "
- - "the future to add, remove, or upgrade packages as "
- + LTEXT "This setup program is used for the initial installation "\
- + "of the Cygwin environment as well as all subsequent "\
- + "updates. Make sure to remember where you saved it.\r\n\r\n"\
- + "The pages that follow will guide you through the "\
- + "installation. Please note that Cygwin consists of a "\
- + "large number of packages spanning a wide variety of "\
- + "purposes. We only install a base set of packages by "\
- + "default. You can always run this program at any time in "\
- + "the future to add, remove, or upgrade packages as "\
- "necessary.",IDC_SPLASH_TEXT,115,25,195,90
- ICON IDI_CYGWIN,IDC_SPLASH_ICON,114,114,21,20,WS_GROUP
- LTEXT "Version (unknown)",IDC_VERSION,115,137,195,10
- @@ -350,7 +353,7 @@
- ICON IDI_CYGWIN,IDC_HEADICON,290,0,21,20
- LTEXT "Warning! Unmet Dependencies Found",IDC_STATIC_HEADER_TITLE
- ,7,0,258,8,NOT WS_GROUP
- - LTEXT "The following packages are required but have not been "
- + LTEXT "The following packages are required but have not been "\
- "selected.",IDC_STATIC,21,9,239,16,NOT WS_GROUP
- CONTROL "&Install these packages to meet dependencies (RECOMMENDED)"
- ,IDC_PREREQ_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
- @@ -367,16 +370,16 @@
- FONT 8, "MS Shell Dlg"
- BEGIN
- LTEXT "Warning:",IDC_STATIC,7,8,40,8
- - LTEXT "One or more mirrors you have selected is/are not on the"
- - "list of official Cygwin mirrors any more. "
- - "It/They may be out of date or missing some packages.\n"
- + LTEXT "One or more mirrors you have selected is/are not on the"\
- + "list of official Cygwin mirrors any more. "\
- + "It/They may be out of date or missing some packages.\n"\
- "This affects the following mirror(s):",
- IDC_STATIC,47,8,263,32
- EDITTEXT IDC_DROP_MIRRORS,7,40,303,40,WS_VSCROLL | WS_HSCROLL |
- ES_LEFT | ES_MULTILINE | ES_READONLY | ES_AUTOHSCROLL |
- ES_AUTOVSCROLL
- - LTEXT "If you experience installation problems consider trying "
- - "official mirrors only.\n\n"
- + LTEXT "If you experience installation problems consider trying "\
- + "official mirrors only.\n\n"\
- "Do you want to continue, using this/these mirror(s)?",
- IDC_STATIC,7,88,303,24
- CONTROL "&Don't warn me about this/these mirror(s) again",
- @@ -454,34 +457,34 @@
- IDS_WINDOW_INIT_BADMSG "Fatal Error: Unexpected windows message %u received too early in window initialization."
- IDS_UNCAUGHT_EXCEPTION "Fatal Error: Uncaught Exception\nThread: %s\nType: %s\nMessage: %s"
- IDS_UNCAUGHT_EXCEPTION_WITH_ERRNO "Fatal Error: Uncaught Exception\nThread: %s\nType: %s\nMessage: %s\nAppErrNo: %d"
- - IDS_TRUSTKEEP_TOOLTIP "Sets all packages to their currently installed "
- - "version. This is equivalent to telling setup not to make any "
- + IDS_TRUSTKEEP_TOOLTIP "Sets all packages to their currently installed "\
- + "version. This is equivalent to telling setup not to make any "\
- "changes to any package."
- - IDS_TRUSTPREV_TOOLTIP "Globally select the version marked as 'Prev', "
- - "which generally means the version that was last considered stable "
- + IDS_TRUSTPREV_TOOLTIP "Globally select the version marked as 'Prev', "\
- + "which generally means the version that was last considered stable "\
- "prior to the current stable version."
- - IDS_TRUSTCURR_TOOLTIP "Globally select the version that is currently "
- + IDS_TRUSTCURR_TOOLTIP "Globally select the version that is currently "\
- "considered the most stable. (RECOMMENDED)"
- - IDS_TRUSTEXP_TOOLTIP "Globally select the most recent version, even if "
- + IDS_TRUSTEXP_TOOLTIP "Globally select the most recent version, even if "\
- "that version is considered Experimental or for test use by the maintainer."
- - IDS_VIEWBUTTON_TOOLTIP "Cycles the package view. This determines "
- - "which packages are shown in the chooser below.\r\n"
- - "\r\n"
- - "Category: Group by package category. Click on '+' to expand.\r\n"
- - "\r\n"
- - "Full: Show all packages.\r\n"
- - "\r\n"
- - "Partial: Show only packages that are about to be installed, removed, "
- - "or upgraded. This tells you everything that setup is about to change "
- - "when you press 'Next'.\r\n"
- - "\r\n"
- - "Up To Date: Show installed packages that need no action because they "
- - "are at the desired version already.\r\n"
- - "\r\n"
- - "Not installed: Show packages that are are not currently installed "
- + IDS_VIEWBUTTON_TOOLTIP "Cycles the package view. This determines "\
- + "which packages are shown in the chooser below.\r\n"\
- + "\r\n"\
- + "Category: Group by package category. Click on '+' to expand.\r\n"\
- + "\r\n"\
- + "Full: Show all packages.\r\n"\
- + "\r\n"\
- + "Partial: Show only packages that are about to be installed, removed, "\
- + "or upgraded. This tells you everything that setup is about to change "\
- + "when you press 'Next'.\r\n"\
- + "\r\n"\
- + "Up To Date: Show installed packages that need no action because they "\
- + "are at the desired version already.\r\n"\
- + "\r\n"\
- + "Not installed: Show packages that are are not currently installed "\
- "and haven't been selected for installation."
- - IDS_HIDEOBS_TOOLTIP "If selected, setup will hide packages in categories "
- - "with names that begin with '_'. Such packages are usually empty "
- - "placeholders for packages that have been removed or renamed, or are "
- + IDS_HIDEOBS_TOOLTIP "If selected, setup will hide packages in categories "\
- + "with names that begin with '_'. Such packages are usually empty "\
- + "placeholders for packages that have been removed or renamed, or are "\
- "infrastructure packages that are handled automatically."
- END
- diff -dur setup-2.588-orig/root.cc setup-2.588/root.cc
- --- setup-2.588-orig/root.cc 2006-04-07 00:45:19.000000000 +0800
- +++ setup-2.588/root.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -79,7 +79,13 @@
- {
- rbset (h, rb, root_text);
- rbset (h, su, root_scope);
- +
- +#ifndef __WINE__
- eset (h, IDC_ROOT_DIR, get_root_dir ());
- +#else //__WINE__
- + eset (h, IDC_ROOT_DIR, wine_dos_path(get_root_dir ()));
- +#endif //__WINE__
- +
- check_if_enable_next (h);
- }
-
- @@ -216,6 +222,10 @@
-
- save_dialog (h);
-
- +#ifdef __WINE__ //FIXME
- + return 0;
- +#endif
- +
- if (!directory_is_absolute ())
- {
- note (h, IDS_ROOT_ABSOLUTE);
- diff -dur setup-2.588-orig/script.cc setup-2.588/script.cc
- --- setup-2.588-orig/script.cc 2007-02-28 08:55:04.000000000 +0800
- +++ setup-2.588/script.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -33,6 +33,10 @@
- #include "script.h"
- #include "mkdir.h"
-
- +#ifdef __WINE__
- +# include "mount.h"
- +#endif
- +
- static std::string sh;
- static const char *cmd = 0;
-
- @@ -49,7 +53,11 @@
- {
- for (int i = 0; shells[i]; i++)
- {
- +#ifndef __WINE__
- sh = backslash (cygpath (shells[i]));
- +#else
- + sh = wine_unix_path (cygpath (shells[i]));
- +#endif
- if (_access (sh.c_str(), 0) == 0)
- break;
- sh.clear();
- @@ -57,10 +65,17 @@
-
- char old_path[MAX_PATH];
- GetEnvironmentVariable ("PATH", old_path, sizeof (old_path));
- +#ifndef __WINE__
- SetEnvironmentVariable ("PATH", backslash (cygpath ("/bin") + ";" +
- cygpath ("/usr/bin") + ";" +
- old_path).c_str());
- SetEnvironmentVariable ("CYGWINROOT", get_root_dir ().c_str());
- +#else //__WINE__
- + SetEnvironmentVariable ("PATH", (backslash (cygpath ("/bin")) + ";" +
- + backslash (cygpath ("/usr/bin")) + ";" +
- + old_path).c_str()); //FIXME
- + SetEnvironmentVariable ("CYGWINROOT", wine_dos_path( get_root_dir ()).c_str());
- +#endif //__WINE__
-
- if (IsWindowsNT ())
- cmd = "cmd.exe";
- @@ -209,7 +224,12 @@
- postinstall script by the same name. When we are called the second
- time the file has already been renamed to .done, and if we don't
- return here we end up erroniously deleting this .done file. */
- +#ifndef __WINE__
- std::string windowsName = backslash (cygpath (scriptName));
- +#else
- + std::string windowsName = wine_unix_path (cygpath (scriptName));
- +#endif
- +
- if (_access (windowsName.c_str(), 0) == -1)
- {
- log(LOG_PLAIN) << "can't run " << scriptName << ": No such file"
- @@ -220,6 +240,8 @@
- int retval;
- char tmp_pat[] = "/var/log/setup.log.postinstallXXXXXXX";
- OutputLog file_out = std::string (mktemp (tmp_pat));
- +
- +#ifndef __WINE__
- if (sh.size() && stricmp (extension(), ".sh") == 0)
- {
- log(LOG_PLAIN) << "running: " << sh << " -c " << scriptName << endLog;
- @@ -232,6 +254,20 @@
- }
- else
- return -ERROR_INVALID_DATA;
- +#else //__WINE__
- + if (sh.size() && strcasecmp (extension(), ".sh") == 0)
- + {
- + log(LOG_PLAIN) << "running: " << sh << " -c " << scriptName << endLog;
- + retval = ::run (sh.c_str(), "-c", scriptName.c_str(), file_out);
- + }
- + else if (cmd && strcasecmp (extension(), ".bat") == 0)
- + {
- + log(LOG_PLAIN) << "running: " << cmd << " /c " << windowsName << endLog;
- + retval = ::run (cmd, "/c", windowsName.c_str(), file_out);
- + }
- + else
- + return -ERROR_INVALID_DATA;
- +#endif //__WINE__
-
- if (!file_out.isEmpty ())
- log(LOG_BABBLE) << file_out << endLog;
- diff -dur setup-2.588-orig/site.cc setup-2.588/site.cc
- --- setup-2.588-orig/site.cc 2008-04-09 07:50:54.000000000 +0800
- +++ setup-2.588/site.cc 2008-08-08 10:56:26.000000000 +0800
- @@ -28,7 +28,9 @@
- #include "win32.h"
- #include <stdio.h>
- #include <stdlib.h>
- -#include <process.h>
- +#ifndef __WINE__
- +# include <process.h>
- +#endif
-
- #include "dialog.h"
- #include "resource.h"
- @@ -189,13 +191,21 @@
- bool
- site_list_type::operator == (site_list_type const &rhs) const
- {
- +#ifndef __WINE__
- return stricmp (key.c_str(), rhs.key.c_str()) == 0;
- +#else
- + return strcasecmp (key.c_str(), rhs.key.c_str()) == 0;
- +#endif
- }
-
- bool
- site_list_type::operator < (site_list_type const &rhs) const
- {
- +#ifndef __WINE__
- return stricmp (key.c_str(), rhs.key.c_str()) < 0;
- +#else
- + return strcasecmp (key.c_str(), rhs.key.c_str()) < 0;
- +#endif
- }
-
- static void
- @@ -359,10 +369,17 @@
- {
- /* Don't default to certain machines ever since they suffer
- from bandwidth limitations. */
- + #ifndef __WINE__
- if (strnicmp (site, NOSAVE1, NOSAVE1_LEN) == 0
- || strnicmp (site, NOSAVE2, NOSAVE2_LEN) == 0
- || strnicmp (site, NOSAVE3, NOSAVE3_LEN) == 0)
- return;
- + #else //__WINE__
- + if (strncasecmp (site, NOSAVE1, NOSAVE1_LEN) == 0
- + || strncasecmp (site, NOSAVE2, NOSAVE2_LEN) == 0
- + || strncasecmp (site, NOSAVE3, NOSAVE3_LEN) == 0)
- + return;
- + #endif //__WINE__
- SiteList result;
- merge (all_site_list.begin(), all_site_list.end(),
- &tempSite, &tempSite + 1,
- @@ -450,7 +467,7 @@
- CreateThread (NULL, 0, do_download_site_info_thread, context, 0, &threadID);
- }
-
- -static BOOL CALLBACK
- +static INT_PTR CALLBACK
- drop_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch (message)
复制代码 使用方法如下:
下载 补丁 和 cygwin 的 setup.exe 源代码 到同一个目录,比如/your_dir,
在X环境打开一个终端,执行下面命令(省略提示符,拷贝下来,修改路径,直接粘贴到终端执行即可)
- cd [color=Red]/your_dir[/color]
- gunzip cygwin_setup-porting_with_winelib.patch.gz
- tar -xvf setup-2.588.tar.bz2
- cd setup-2.588
- patch -p1 < ../cygwin_setup-porting_with_winelib.patch
- CC="winegcc" CXX="wineg++" LIBS="-lcrtdll -lwininet" WINDRES=wrc ./configure --prefix=/somewhere --enable-shared=no
- make
- cp -a setup.exe.so [color=Red]/somewhere[/color]
- cd [color=Red]/somewhere[/color]
- wine setup.exe.so
复制代码 请把/somewhere替换成你希望的地方,/somewhere必须是wine可以访问的路径。
现在你应该看到 cygwin 安装界面,正常安装即可。
一些额外修正:
1、默认设置的 wine 无法提供正确的 HOME 环境变量,影响 cygwin 的使用,一个比较好的解决方案是设置 cygwin 的 etc/passwd、etc/group,在cygwin的根目录执行下面脚本,或直接手工编辑这两个文件。
- #!/bin/sh
- #fix /etc/passwd /etc/group
- echo "`whoami`::`id -u`:`id -g`::/home/`whoami`:/bin/bash" >> etc/passwd
- 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
|