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


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

[PATCH 1/2] Copy setup.exe to /bin/cygwin-setup.exe


Make a copy of setup.exe as /bin/cygwin-setup.exe.

This enables a few useful things:
- Register that copy of setup.exe with Add/Remove programs
- Add a start menu item pointing to that copy of setup.exe
- Type 'cygwin-setup -q -P<package>' to install a package

Questions:

Would setup.exe be a better choice of name?

Does Add/Remove item for cygwin behave at all sensibly with multiple
cygwin installations?

2011-02-02  Jon TURNEY  <jon.turney@dronecode.org.uk>

	* desktop.cc (copy_setup): Leave a copy of ourselves in /bin.
	(uninstall_reg_key): Add that copy to Add/Remove programs.
	(do_desktop_setup): Add a link to that copy to Cygwin start menu.
	(OnFinish): Always copy our icon, as it's now always used.
	* res.rc (IDD_SPLASH): Remove admonition to remember where
	this program is.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
---
 desktop.cc |   45 +++++++++++++++++++++++++++++++++++++++++++--
 res.rc     |    5 +++--
 2 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/desktop.cc b/desktop.cc
index 65501c8..d1e839a 100644
--- a/desktop.cc
+++ b/desktop.cc
@@ -62,6 +62,7 @@ static BoolOption NoDesktopOption (false, 'd', "no-desktop", "Disable creation o
 
 static std::string batname;
 static std::string iconname;
+static std::string setupname;
 
 static ControlAdjuster::ControlInfo DesktopControlsInfo[] = {
   {IDC_DESKTOP_SEPARATOR, 	CP_STRETCH, CP_BOTTOM},
@@ -204,6 +205,42 @@ make_cygwin_bat ()
 }
 
 static void
+copy_setup(void)
+{
+  setupname = backslash (cygpath ("/bin/cygwin-setup.exe"));
+
+  /*
+    Copy this executable to the cygwin bin directory
+    (this might fail we are already running from there... :-))
+  */
+  TCHAR filename[MAX_PATH+1];
+  GetModuleFileName(NULL, filename, MAX_PATH);
+  CopyFile(filename, setupname.c_str(), FALSE);
+}
+
+#define UNINSTALL_DISPLAY_NAME "Cygwin"
+#define UNINSTALL_HELP_LINK "http://www.cygwin.com/";
+
+static void
+uninstall_reg_key(void)
+{
+  HKEY key;
+
+  int issystem = (root_scope == IDC_ROOT_SYSTEM) ? 1 : 0;
+  HKEY kr = issystem ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
+  if (RegCreateKeyEx(kr, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Cygwin\\",
+                     0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL) == ERROR_SUCCESS)
+    {
+      RegSetValueEx(key, "DisplayName", 0, REG_SZ, (BYTE *)UNINSTALL_DISPLAY_NAME, strlen(UNINSTALL_DISPLAY_NAME)+1);
+      RegSetValueEx(key, "HelpLink", 0, REG_SZ, (BYTE *)UNINSTALL_HELP_LINK, strlen(UNINSTALL_HELP_LINK)+1);
+      RegSetValueEx(key, "UninstallString", 0, REG_SZ, (BYTE *)setupname.c_str(), setupname.size()+1);
+      RegSetValueEx(key, "DisplayIcon", 0, REG_SZ, (BYTE *)iconname.c_str(), iconname.size()+1);
+    }
+
+  RegCloseKey (key);
+}
+
+static void
 save_icon ()
 {
   iconname = backslash (cygpath ("/Cygwin.ico"));
@@ -239,13 +276,12 @@ save_icon ()
 static void
 do_desktop_setup ()
 {
-  save_icon ();
-
   make_cygwin_bat ();
 
   if (root_menu)
     {
       start_menu ("Cygwin Bash Shell", batname);
+      start_menu ("Cygwin Setup", setupname);
     }
 
   if (root_desktop)
@@ -456,6 +492,11 @@ DesktopSetupPage::OnFinish ()
 {
   HWND h = GetHWND ();
   save_dialog (h);
+
+  save_icon ();
+  copy_setup();
+  uninstall_reg_key();
+
   if (source != IDC_SOURCE_DOWNLOAD)
     do_desktop_setup ();
 
diff --git a/res.rc b/res.rc
index 92454eb..1a549a2 100644
--- a/res.rc
+++ b/res.rc
@@ -262,12 +262,13 @@ BEGIN
                     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"
+                    "updates.\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 "
+                    "default.\r\n\r\n"
+                    "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
-- 
1.7.3.3


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