On 27/08/2010 19:33, Christopher Faylor wrote:
On Fri, Aug 27, 2010 at 06:15:38PM +0100, Jon TURNEY wrote:
On 29/07/2010 17:28, Jon TURNEY wrote:
On 28/07/2010 15:58, Christopher Faylor wrote:
On Wed, Jul 28, 2010 at 03:25:17PM +0100, Jon TURNEY wrote:
Anyhow, here's another attempt, which unfortunately changes rather more than I
wanted to. It adds a new page, which is displayed if any script failed, and
reports which packages and scripts failed.
That is great. Please check in (with a ChangeLog of course).
Due to the way I tested this change, I'd failed to notice that when a package
is installed with a failing postinstall script, this will list the failing
script twice, once with the package name and once as 'no package'.
Attached is a patch to remedy that.
Do we realy need a separate for loop for this? Couldn't we just piggy
back on the previous for loop?
Sure. I'm not sure if it's any more elegant, though :-)
Index: postinstall.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/postinstall.cc,v
retrieving revision 2.25
diff -u -r2.25 postinstall.cc
--- postinstall.cc 30 Jul 2010 20:53:42 -0000 2.25
+++ postinstall.cc 28 Aug 2010 12:25:34 -0000
@@ -74,7 +74,7 @@
class RunScript
{
public:
- RunScript(const std::string& name, const vector<Script> &scripts) :
_name(name), _scripts(scripts), _cnt(0)
+ RunScript(const std::string& name, const vector<Script> &scripts,
vector<Script> *script_list) : _name(name), _scripts(scripts),
_script_list(script_list), _cnt(0)
{
Progress.SetText2 (name.c_str());
Progress.SetBar1 (0, _scripts.size());
@@ -114,11 +114,22 @@
fs << "\t" << j->baseName() << " exit code " << retval << "\r\n";
s = s + fs.str();
}
+
+ // Remove each script we try to run from the list of scripts
+ if (_script_list)
+ {
+ std::vector<Script>::iterator p = find(_script_list->begin(),
_script_list->end(), *j);
+ if (p != _script_list->end())
+ {
+ _script_list->erase(p);
+ }
+ }
}
}
private:
std::string _name;
const vector<Script> &_scripts;
+ vector<Script> *_script_list;
int _cnt;
};
@@ -146,6 +157,12 @@
std::string s = "";
+ // Build a list of the scripts in /etc/postinstall
+ std::string postinst = cygpath ("/etc/postinstall");
+ vector<Script> script_list;
+ RunFindVisitor myVisitor (&script_list);
+ Find (postinst).accept (myVisitor);
+
// For each package we installed, we noted anything installed into
/etc/postinstall.
// run those scripts now
int numpkg = packages.size() + 1;
@@ -154,22 +171,16 @@
{
packagemeta & pkg = **i;
- RunScript scriptRunner(pkg.name, pkg.installed.scripts());
+ RunScript scriptRunner(pkg.name, pkg.installed.scripts(), &script_list);
scriptRunner.run_all(s);
++k;
Progress.SetBar2 (k, numpkg);
}
- // Look for any scripts in /etc/postinstall which haven't been renamed .done,
- // and try to run them...
- std::string postinst = cygpath ("/etc/postinstall");
- vector<Script> scripts;
- RunFindVisitor myVisitor (&scripts);
- Find (postinst).accept (myVisitor);
-
+ // Run any scripts left in the list, which haven't been claimed by any
package
{
- RunScript scriptRunner("No package", scripts);
+ RunScript scriptRunner("No package", script_list, NULL);
scriptRunner.run_all(s);
}
Index: script.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/script.h,v
retrieving revision 2.13
diff -u -r2.13 script.h
--- script.h 16 Apr 2006 15:37:49 -0000 2.13
+++ script.h 28 Aug 2010 12:25:34 -0000
@@ -35,6 +35,7 @@
or command.com (9x). Returns the exit status of the process, or
negative error if any. */
int run() const;
+ bool operator == (const Script s) { return s.scriptName == scriptName; } ;
private:
std::string scriptName;
static char const ETCPostinstall[];