2 * Copyright (c) 2001, Jan Nieuwenhuizen.
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.
9 * A copy of the GNU General Public License can be found at
12 * Written by Jan Nieuwenhuizen <janneke@gnu.org>
15 #ifndef SETUP_SCRIPT_H
16 #define SETUP_SCRIPT_H
18 /* Initialisation stuff for run_script: sh, cmd, CYGWINROOT and PATH */
19 void init_run_script ();
21 /* Run the script named dir/fname.ext
22 Returns the script exit status or negative error if any. */
23 int try_run_script (const std::string
& dir
,
24 const std::string
& fname
,
25 const std::string
& ext
);
27 /* Run a command and capture it's output to the log */
28 int run (const char *cmdline
);
32 static bool isAScript (const std::string
& file
);
33 bool is_p (const std::string
& stratum
);
34 bool not_p (const std::string
& stratum
);
35 Script (const std::string
& fileName
);
36 std::string
baseName() const;
37 std::string
fullName() const;
38 /* Run the script. If its suffix is .sh, and we have a Bourne shell, execute
39 it using sh. Otherwise, if the suffix is .bat, execute using cmd.exe (NT)
40 or command.com (9x). Returns the exit status of the process, or
41 negative error if any. */
43 bool operator == (const Script s
) const {
44 return scriptName
== s
.scriptName
;
46 bool operator < (const Script s
) const {
47 return scriptBaseName
< s
.scriptBaseName
;
50 bool match (const std::string
& stratum
, const std::string
& type
);
51 std::string scriptName
;
52 std::string scriptBaseName
;
53 std::string scriptExtension
;
54 std::string scriptStratum
;
55 std::string scriptType
;
56 static char const ETCPostinstall
[];
57 static char const allowedStrata
[];
58 static char const allowedTypes
[];
61 #endif /* SETUP_SCRIPT_H */