This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
Patch for unattended setup (updated)
- From: "Dr. Frank Lee" <rl201 at cam dot ac dot uk>
- To: cygwin-apps at cygwin dot com
- Date: Wed, 9 Apr 2008 17:15:50 +0100 (BST)
- Subject: Patch for unattended setup (updated)
I attach a re-working of my previous patch to setup.exe to support the '-p
package1[,package2[...]]' command line option. This patch also intercepts
all
message boxes and returns some default values to the calling function for
unattended installations. A patched setup.exe will return
IDS_REBOOT_REQUIRED
(=118) if a reboot seems desirable.
This patch applies to setup version 2.578 (the most recent I could
compile).
(http://www.sp.phy.cam.ac.uk/~rl201/cygwin-setup-unattended-patch.diff
contains
this patch and http://www.sp.phy.cam.ac.uk/~rl201/setup-patched.exe the
resulting executable - usual caveats about running such binaries apply!)
Yours,
Frank
Common subdirectories: setup-2.578/.deps and setup-2.578RFL/.deps
Common subdirectories: setup-2.578/cfgaux and setup-2.578RFL/cfgaux
Common subdirectories: setup-2.578/csu_util and setup-2.578RFL/csu_util
diff -u setup-2.578/install.cc setup-2.578RFL/install.cc
--- setup-2.578/install.cc 2008-04-09 16:46:25.718797700 +0100
+++ setup-2.578RFL/install.cc 2008-04-09 16:48:01.739933100 +0100
@@ -135,7 +135,7 @@
static int num_installs, num_uninstalls;
static void md5_one (const packagesource& source);
-static bool rebootneeded;
+// RFL static bool rebootneeded;
void
Installer::preremoveOne (packagemeta & pkg)
@@ -624,7 +624,11 @@
if (myInstaller.errors)
exit_msg = IDS_INSTALL_INCOMPLETE;
else if (!unattended_mode)
- exit_msg = IDS_INSTALL_COMPLETE;
+ exit_msg = IDS_INSTALL_COMPLETE;
+
+ if (rebootneeded)
+ exit_msg = IDS_REBOOT_REQUIRED;
+
}
static DWORD WINAPI
Common subdirectories: setup-2.578/libgetopt++ and setup-2.578RFL/libgetopt++
Common subdirectories: setup-2.578/libmd5-rfc and setup-2.578RFL/libmd5-rfc
diff -u setup-2.578/main.cc setup-2.578RFL/main.cc
--- setup-2.578/main.cc 2008-04-09 16:48:32.321998100 +0100
+++ setup-2.578RFL/main.cc 2008-04-09 16:23:15.845822300 +0100
@@ -200,8 +200,11 @@
// Clean exit.. save user options.
UserSettings::Instance().saveAllSettings();
-
- theLog->exit (0);
+ if (rebootneeded) {
+ theLog->exit (IDS_REBOOT_REQUIRED);
+ } else {
+ theLog->exit (0);
+ }
}
TOPLEVEL_CATCH("main");
diff -u setup-2.578/msg.cc setup-2.578RFL/msg.cc
--- setup-2.578/msg.cc 2008-04-09 16:48:50.170661100 +0100
+++ setup-2.578RFL/msg.cc 2008-04-09 15:54:06.363639500 +0100
@@ -30,6 +30,9 @@
#include <stdarg.h>
#include "dialog.h"
+// RFL
+#include "state.h"
+
void
msg (const char *fmt, ...)
{
@@ -50,6 +53,35 @@
vsnprintf (buf, 1000, fmt, args);
log (LOG_PLAIN) << "mbox " << name << ": " << buf << endLog;
+ // RFL suspects this code should really be in the _custom_MessageBox routine but code
+ // placed there doesn't get executed (for the 'Files in-use have been replaced' message,
+ // at least.
+ if (unattended_mode) {
+ // Return some default values.
+ log (LOG_PLAIN) << "Unattended_mode is set at mbox" << endLog;
+ switch (type & MB_TYPEMASK)
+ {
+ case MB_OK | MB_OKCANCEL:
+ return IDOK;
+ break;
+ case MB_YESNO | MB_YESNOCANCEL:
+ return IDYES;
+ break;
+ case MB_ABORTRETRYIGNORE:
+ return IDIGNORE;
+ break;
+ case MB_RETRYCANCEL: // Retry -> infinite loop perchance
+ return IDCANCEL;
+ break;
+ //case MB_CANCELTRYCONTINUE:
+ // return IDCONTINUE;
+ // break;
+ default:
+ return 0;
+ }
+ }
+ // Back to previous code
+
return MessageBox (owner, buf, "Cygwin Setup", type);
}
diff -u setup-2.578/package_db.cc setup-2.578RFL/package_db.cc
--- setup-2.578/package_db.cc 2008-04-09 16:49:14.479883100 +0100
+++ setup-2.578RFL/package_db.cc 2008-04-09 15:40:01.339239500 +0100
@@ -398,8 +398,15 @@
}
void
+packagedb::addFromCmdLine()
+{
+ for_each(packages.begin(), packages.end(), mem_fun(&packagemeta::addToCategoryBase));
+}
+
+void
packagedb::fillMissingCategory ()
{
+ for_each(packages.begin(), packages.end(), visit_if(mem_fun(&packagemeta::addToCategoryBase), mem_fun(&packagemeta::isManuallyWanted)));
for_each(packages.begin(), packages.end(), visit_if(mem_fun(&packagemeta::setDefaultCategories), mem_fun(&packagemeta::hasNoCategories)));
for_each(packages.begin(), packages.end(), mem_fun(&packagemeta::addToCategoryAll));
}
diff -u setup-2.578/package_db.h setup-2.578RFL/package_db.h
--- setup-2.578/package_db.h 2008-04-09 16:49:27.526145100 +0100
+++ setup-2.578RFL/package_db.h 2008-04-09 15:37:58.356892100 +0100
@@ -46,6 +46,7 @@
PackageDBConnectedIterator connectedEnd();
void fillMissingCategory();
void markUnVisited();
+ void addFromCmdLine();
void setExistence();
/* all seen binary packages */
static std::vector < packagemeta *> packages;
diff -u setup-2.578/package_meta.cc setup-2.578RFL/package_meta.cc
--- setup-2.578/package_meta.cc 2008-04-09 16:50:17.677603100 +0100
+++ setup-2.578RFL/package_meta.cc 2008-04-09 15:42:15.103472300 +0100
@@ -42,6 +42,7 @@
#include "script.h"
#include "package_version.h"
+#include "getopt++/StringOption.h"
#include "cygpackage.h"
#include "package_db.h"
@@ -242,6 +243,26 @@
return pkg.SDesc().size();
}
+static StringOption PackageOption ("", 'p', "package", "Packages to include");
+
+bool packagemeta::isManuallyWanted() const
+{
+ string packages_option = PackageOption;
+ string tname;
+ /* Split the packages listed in the option up */
+ string::size_type loc = packages_option.find(",",0);
+ bool bReturn=false;
+ while ( loc != string::npos) {
+ tname=packages_option.substr(0,loc);
+ packages_option=packages_option.substr(loc+1);
+ bReturn=bReturn || (name.compare(tname)==0);
+ loc = packages_option.find(",",0);
+ }
+ /* At this point, no "," exists in packages_option */
+ bReturn=bReturn || (name.compare(packages_option)==0);
+ return bReturn;
+}
+
const std::string
packagemeta::SDesc () const
{
@@ -664,3 +685,9 @@
{
add_category ("All");
}
+
+void
+packagemeta::addToCategoryBase()
+{
+ add_category ("Base");
+}
diff -u setup-2.578/package_meta.h setup-2.578RFL/package_meta.h
--- setup-2.578/package_meta.h 2008-04-09 16:49:48.519051100 +0100
+++ setup-2.578RFL/package_meta.h 2008-04-09 15:30:06.535953500 +0100
@@ -54,8 +54,10 @@
void visited(bool const &);
bool visited() const;
bool hasNoCategories() const;
+ bool isManuallyWanted() const;
void setDefaultCategories();
void addToCategoryAll();
+ void addToCategoryBase();
class _actions
{
Only in setup-2.578RFL: state.bak
diff -u setup-2.578/state.cc setup-2.578RFL/state.cc
--- setup-2.578/state.cc 2006-04-15 22:21:25.000000000 +0100
+++ setup-2.578RFL/state.cc 2008-04-09 16:32:11.076677500 +0100
@@ -23,6 +23,7 @@
#include "state.h"
bool unattended_mode;
+bool rebootneeded;
int source;
diff -u setup-2.578/state.h setup-2.578RFL/state.h
--- setup-2.578/state.h 2008-04-09 16:50:45.694216100 +0100
+++ setup-2.578RFL/state.h 2008-04-09 16:22:36.223567100 +0100
@@ -32,10 +32,12 @@
#include <string>
extern bool unattended_mode;
+extern bool rebootneeded;
extern int source;
extern std::string local_dir;
+extern std::string packages_option;
extern int root_text;
extern int root_scope;
Common subdirectories: setup-2.578/tests and setup-2.578RFL/tests