]> cygwin.com Git - cygwin-apps/setup.git/blob - postinstall.cc
77636ce900539df7770793be790c453cf7f264ab
[cygwin-apps/setup.git] / postinstall.cc
1 /*
2 * Copyright (c) 2000, 2001 Red Hat, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 * Written by DJ Delorie <dj@cygnus.com>
13 *
14 */
15
16 /* The purpose of this file is to run all the post-install scripts
17 in their various forms. */
18
19 #if 0
20 static const char *cvsid =
21 "\n%%% $Id$\n";
22 #endif
23
24 #include "dialog.h"
25 #include "find.h"
26 #include "mount.h"
27 #include "script.h"
28 #include "FindVisitor.h"
29 #include "FilterVisitor.h"
30 #include "package_db.h"
31 #include "package_meta.h"
32
33 class RunFindVisitor : public FindVisitor
34 {
35 public:
36 RunFindVisitor (){}
37 virtual void visitFile(String const &basePath, const WIN32_FIND_DATA *theFile)
38 {
39 run_script ("/etc/postinstall/", theFile->cFileName, TRUE);
40 }
41 virtual ~ RunFindVisitor () {}
42 protected:
43 RunFindVisitor (RunFindVisitor const &);
44 RunFindVisitor & operator= (RunFindVisitor const &);
45 };
46
47 void
48 do_postinstall (HINSTANCE h, HWND owner)
49 {
50 next_dialog = 0;
51 init_run_script ();
52 SetCurrentDirectory (get_root_dir ().cstr_oneuse());
53 packagedb db;
54 PackageDBConnectedIterator i = db.connectedBegin ();
55 while (i != db.connectedEnd ())
56 {
57 packagemeta & pkg = **i;
58 if (pkg.installed)
59 for (std::vector<Script>::iterator script=pkg.installed.scripts().begin(); script != pkg.installed.scripts().end(); ++script)
60 run_script ("/etc/postinstall/", script->baseName(), TRUE);
61 ++i;
62 }
63 RunFindVisitor myVisitor;
64 ExcludeNameFilter notDone("*.done");
65 FilterVisitor excludeDoneVisitor(&myVisitor, &notDone);
66 String postinst = cygpath ("/etc/postinstall");
67 Find (postinst).accept (excludeDoneVisitor);
68 }
This page took 0.038702 seconds and 4 git commands to generate.