[hack] how to install cygwin (how to port cygwin‘s setup.exe with winelib)
时间:2008-08-02
来源:互联网
本文目标:在 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.exe 源代码 到同一个目录,比如/your_dir,
在X环境打开一个终端,执行下面命令(省略提示符,拷贝下来,修改路径,直接粘贴到终端执行即可)
请把/somewhere替换成你希望的地方,/somewhere必须是wine可以访问的路径。
现在你应该看到 cygwin 安装界面,正常安装即可。
一些额外修正:
1、默认设置的 wine 无法提供正确的 HOME 环境变量,影响 cygwin 的使用,一个比较好的解决方案是设置 cygwin 的 etc/passwd、etc/group,在cygwin的根目录执行下面脚本,或直接手工编辑这两个文件。
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“ 即可。
本文使用的 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: [email protected] # 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 /your_dir 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 /somewhere cd /somewhere wine setup.exe.so
现在你应该看到 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
上传的图像
上传的附件
cmd.exe.png (15.3 KB, 5 次查看) | |
cmd.exe-1.png (29.0 KB, 2 次查看) | |
Screenshot-~.png (34.7 KB, 5 次查看) | |
Screenshot-~-1.png (25.8 KB, 4 次查看) | |
cygwinX.png (5.2 KB, 3 次查看) | |
cygwin_urxvt.png (5.0 KB, 4 次查看) | |
Screenshot-xeyes.png (3.9 KB, 30 次查看) |
cygwin_setup-porting_with_winelib.patch.gz (9.0 KB, 2 次查看) |
作者: 聚焦深空 发布时间: 2008-08-02
相关资源:
wine-docs
http://ibiblio.org/pub/linux/system/...cs-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/wine.../wine-debugger
Porting with Winelib
http://wiki.winehq.org/Porting_with_Winelib
Porting with Winelib (maillist)
http://www.winehq.org/pipermail/wine...ne/007257.html
Winelib HOWTO
http://source.winehq.org/source/docu...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/0...cc-4.3-include
Porting DOS Applications to Linux
http://www.linuxjournal.com/article/1138
直接用cygwin setup.exe安装的一些成功结果
http://appdb.winehq.org/objectManage...estingId=23561
wikipedia Cygwin(不用翻墙,怪事,开始掰指头计时)
http://zh.wikipedia.org/wiki/Cygwin
wine-docs
http://ibiblio.org/pub/linux/system/...cs-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/wine.../wine-debugger
Porting with Winelib
http://wiki.winehq.org/Porting_with_Winelib
Porting with Winelib (maillist)
http://www.winehq.org/pipermail/wine...ne/007257.html
Winelib HOWTO
http://source.winehq.org/source/docu...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/0...cc-4.3-include
Porting DOS Applications to Linux
http://www.linuxjournal.com/article/1138
直接用cygwin setup.exe安装的一些成功结果
http://appdb.winehq.org/objectManage...estingId=23561
wikipedia Cygwin(不用翻墙,怪事,开始掰指头计时)
http://zh.wikipedia.org/wiki/Cygwin
作者: 聚焦深空 发布时间: 2008-08-02
Linux 下裝 Cygwin?
怎麼好像有點本末倒置的感覺?樓主可否說說此舉有何作用?
怎麼好像有點本末倒置的感覺?樓主可否說說此舉有何作用?
作者: d00m3d 发布时间: 2008-08-03
重复一下:
如果移植成功,则可在完全开源的环境下使用cygwin。
sourceforge上有不少开源软件只有win32版本,直接wine可能有不兼容的问题。
winelib提供了另一种选择,拿cygwin试试手,正好试试深浅。
另,本版有人用M$系统+cygwin进行CLFS,想验证一下,但又不想用M$的系统。
如果移植成功,则可在完全开源的环境下使用cygwin。
sourceforge上有不少开源软件只有win32版本,直接wine可能有不兼容的问题。
winelib提供了另一种选择,拿cygwin试试手,正好试试深浅。
另,本版有人用M$系统+cygwin进行CLFS,想验证一下,但又不想用M$的系统。
作者: 聚焦深空 发布时间: 2008-08-03
用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。
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-08-08
雖然是無功而還,但思路清析明確,不愧是 LFS/CLFS 玩家 :)
作者: d00m3d 发布时间: 2008-08-08
补丁已释出。
作者: 聚焦深空 发布时间: 2008-08-08
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28