public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* [PATCH setup] Add new option --no-write-registry
@ 2022-07-09 15:59 Christian Franke
  2022-07-12 12:50 ` Jon Turney
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Franke @ 2022-07-09 15:59 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: text/plain, Size: 566 bytes --]

IMO useful for temporary test installs or "portable" installs to USB 
devices.

The 0002-patch adds a related log message.


BTW: During testing I found that the "All Users" <> "Just Me" GUI 
setting has no effect at all. If setup is run elevated, "All Users" is 
always implied.

This is likely because read_mounts() is called again after the "Root" 
dialog. It resets root_scope and does not re-read the registry.

read_mounts (const std::string val)
{
...
   root_scope = (nt_sec.isRunAsAdmin ())? IDC_ROOT_SYSTEM : IDC_ROOT_USER;
...
}

-- 
Regards,
Christian


[-- Attachment #2: 0001-Add-new-option-no-write-registry.patch --]
[-- Type: text/plain, Size: 1248 bytes --]

From ab3c94ebf0e78606c3660bec8e0c04c6e6b8ddd4 Mon Sep 17 00:00:00 2001
From: Christian Franke <christian.franke@t-online.de>
Date: Sat, 9 Jul 2022 16:52:47 +0200
Subject: [PATCH 1/2] Add new option --no-write-registry

If specified, the rootdir is not written to the registry and no
registry key is created.
---
 install.cc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/install.cc b/install.cc
index 1fdc699..eb7b1b2 100644
--- a/install.cc
+++ b/install.cc
@@ -70,6 +70,7 @@ static long long int total_bytes_sofar = 0;
 static int package_bytes = 0;
 
 static BoolOption NoReplaceOnReboot (false, 'r', "no-replaceonreboot", IDS_HELPTEXT_NO_REPLACEONREBOOT);
+static BoolOption NoWriteRegistry (false, '\0', "no-write-registry" /*, TODO: IDS_HELPTEXT_... */);
 
 struct std_dirs_t {
   const char *name;
@@ -833,8 +834,9 @@ do_install_thread (HINSTANCE h, HWND owner)
   int df = diskfull (get_root_dir ().c_str());
   Progress.SetBar3 (df);
 
-  /* Writes Cygwin/setup/rootdir registry value */
-  create_install_root ();
+  if (!NoWriteRegistry)
+    /* Writes Cygwin/setup/rootdir registry value */
+    create_install_root ();
 
   std::vector <packageversion> install_q, uninstall_q, sourceinstall_q;
 
-- 
2.36.1


[-- Attachment #3: 0002-Log-writes-to-rootdir-registry-entry.patch --]
[-- Type: text/plain, Size: 902 bytes --]

From 467b30e19e506ecb4b1e9ed9c4d7528d77db0228 Mon Sep 17 00:00:00 2001
From: Christian Franke <christian.franke@t-online.de>
Date: Sat, 9 Jul 2022 16:57:31 +0200
Subject: [PATCH 2/2] Log writes to rootdir registry entry

---
 mount.cc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mount.cc b/mount.cc
index f63edd4..0136396 100644
--- a/mount.cc
+++ b/mount.cc
@@ -135,6 +135,12 @@ create_install_root ()
     mbox (NULL, IDS_MOUNT_REGISTRY_KEY_FAILED, MB_OK | MB_ICONWARNING);
   RegCloseKey (key);
 
+  Log (LOG_TIMESTAMP) << "Registry value set: HKEY_"
+		      << (root_scope == IDC_ROOT_USER ? "CURRENT_USER\\"
+						      : "LOCAL_MACHINE\\")
+		      << buf << "\\rootdir = \"" << get_root_dir () << "\""
+		      << endLog;
+
   // The mount table is already in the right shape at this point.
   // Reading it again is not necessary.
   //read_mounts (std::string ());
-- 
2.36.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH setup] Add new option --no-write-registry
  2022-07-09 15:59 [PATCH setup] Add new option --no-write-registry Christian Franke
@ 2022-07-12 12:50 ` Jon Turney
  2022-07-12 17:04   ` Christian Franke
  0 siblings, 1 reply; 4+ messages in thread
From: Jon Turney @ 2022-07-12 12:50 UTC (permalink / raw)
  To: Christian Franke, cygwin-apps

On 09/07/2022 16:59, Christian Franke wrote:
> IMO useful for temporary test installs or "portable" installs to USB 
> devices.
> 
> The 0002-patch adds a related log message.

These patches are ok.

If you can provide a help-text for the new option, I will apply them.

> BTW: During testing I found that the "All Users" <> "Just Me" GUI 
> setting has no effect at all. If setup is run elevated, "All Users" is 
> always implied.
> 
> This is likely because read_mounts() is called again after the "Root" 
> dialog. It resets root_scope and does not re-read the registry.

Yeah.  Thanks just seems like a bug, as what is selected in the UI/via 
command line options should be controlling.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH setup] Add new option --no-write-registry
  2022-07-12 12:50 ` Jon Turney
@ 2022-07-12 17:04   ` Christian Franke
  2022-07-16 13:48     ` Jon Turney
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Franke @ 2022-07-12 17:04 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: text/plain, Size: 469 bytes --]

Jon Turney wrote:
> On 09/07/2022 16:59, Christian Franke wrote:
>> IMO useful for temporary test installs or "portable" installs to USB 
>> devices.
>>
>> The 0002-patch adds a related log message.
>
> These patches are ok.
>
> If you can provide a help-text for the new option, I will apply them.

Attached new version of 0001-... patch which includes a help text.
Does not include the *.po* changes, sorry ('pip install 
translate-toolkit' failed for some reason),


[-- Attachment #2: 0001-Add-new-option-no-write-registry.patch --]
[-- Type: text/plain, Size: 3038 bytes --]

From 8a93babe4ef963de9fe1d2f5ba77ea9c89afa23c Mon Sep 17 00:00:00 2001
From: Christian Franke <christian.franke@t-online.de>
Date: Tue, 12 Jul 2022 18:04:25 +0200
Subject: [PATCH] Add new option --no-write-registry

If specified, the rootdir is not written to the registry and no
registry key is created.
---
 install.cc    | 6 ++++--
 res/en/res.rc | 1 +
 res/fr/res.rc | 1 +
 resource.h    | 1 +
 4 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/install.cc b/install.cc
index 1fdc699..fbd28b1 100644
--- a/install.cc
+++ b/install.cc
@@ -70,6 +70,7 @@ static long long int total_bytes_sofar = 0;
 static int package_bytes = 0;
 
 static BoolOption NoReplaceOnReboot (false, 'r', "no-replaceonreboot", IDS_HELPTEXT_NO_REPLACEONREBOOT);
+static BoolOption NoWriteRegistry (false, '\0', "no-write-registry", IDS_HELPTEXT_NO_WRITE_REGISTRY);
 
 struct std_dirs_t {
   const char *name;
@@ -833,8 +834,9 @@ do_install_thread (HINSTANCE h, HWND owner)
   int df = diskfull (get_root_dir ().c_str());
   Progress.SetBar3 (df);
 
-  /* Writes Cygwin/setup/rootdir registry value */
-  create_install_root ();
+  if (!NoWriteRegistry)
+    /* Writes Cygwin/setup/rootdir registry value */
+    create_install_root ();
 
   std::vector <packageversion> install_q, uninstall_q, sourceinstall_q;
 
diff --git a/res/en/res.rc b/res/en/res.rc
index 9683ab5..644b252 100644
--- a/res/en/res.rc
+++ b/res/en/res.rc
@@ -679,6 +679,7 @@ BEGIN
     IDS_HELPTEXT_NO_VERIFY "Don't verify setup.ini signatures"
     IDS_HELPTEXT_NO_VERSION_CHECK "Suppress checking if a newer version of setup is available"
     IDS_HELPTEXT_NO_WARN_DEPRECATED_WINDOWS "Don't warn about deprecated Windows versions"
+    IDS_HELPTEXT_NO_WRITE_REGISTRY "Don't write root installation directory to registry"
     IDS_HELPTEXT_OLD_KEYS "Enable old cygwin.com keys"
     IDS_HELPTEXT_ONLY_SITE "Do not download mirror list.  Only use sites specified with -s."
     IDS_HELPTEXT_PACKAGES "Specify packages to install"
diff --git a/res/fr/res.rc b/res/fr/res.rc
index 79f2371..a0a7909 100644
--- a/res/fr/res.rc
+++ b/res/fr/res.rc
@@ -665,6 +665,7 @@ BEGIN
     IDS_HELPTEXT_NO_VERIFY "Ne pas vérifier les signatures de setup.ini"
     IDS_HELPTEXT_NO_VERSION_CHECK "Ne pas vérifier si une version plus récente de l'assistant est disponible"
     IDS_HELPTEXT_NO_WARN_DEPRECATED_WINDOWS "Ne pas avertir pour les vieilles versions de Windows"
+    // IDS_HELPTEXT_NO_WRITE_REGISTRY "XXX: missing translation"
     IDS_HELPTEXT_OLD_KEYS "Utiliser les anciennes clés de cygwin.com"
     IDS_HELPTEXT_ONLY_SITE "Ignorer tous les sites sauf ceux spécifiés par -s"
     IDS_HELPTEXT_PACKAGES "Spécifie les paquets à installer"
diff --git a/resource.h b/resource.h
index e8ed0fa..2668dd9 100644
--- a/resource.h
+++ b/resource.h
@@ -154,6 +154,7 @@
 #define IDS_HELPTEXT_ERROR               1545
 #define IDS_HELPTEXT_HEADER              1546
 #define IDS_HELPTEXT_FOOTER              1547
+#define IDS_HELPTEXT_NO_WRITE_REGISTRY   1548
 
 // Dialogs
 
-- 
2.37.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH setup] Add new option --no-write-registry
  2022-07-12 17:04   ` Christian Franke
@ 2022-07-16 13:48     ` Jon Turney
  0 siblings, 0 replies; 4+ messages in thread
From: Jon Turney @ 2022-07-16 13:48 UTC (permalink / raw)
  To: cygwin-apps, Christian Franke

On 12/07/2022 18:04, Christian Franke wrote:
> Jon Turney wrote:
>> On 09/07/2022 16:59, Christian Franke wrote:
>>> IMO useful for temporary test installs or "portable" installs to USB 
>>> devices.
>>>
>>> The 0002-patch adds a related log message.
>>
>> These patches are ok.
>>
>> If you can provide a help-text for the new option, I will apply them.
> 
> Attached new version of 0001-... patch which includes a help text.

Thanks.  Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-16 13:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-09 15:59 [PATCH setup] Add new option --no-write-registry Christian Franke
2022-07-12 12:50 ` Jon Turney
2022-07-12 17:04   ` Christian Franke
2022-07-16 13:48     ` Jon Turney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).