3554d02004-11-03Henrik Grubbström (Grubba) /*
0917d32013-03-04Anders Johansson  * $Id$
3554d02004-11-03Henrik Grubbström (Grubba)  * * Make a Windows Installer XML Source file (wxs) suitable * for a Roxen installer. * * 2004-11-03 Henrik Grubbström */ import Standards.XML.Wix;
a1316a2004-11-16Henrik Grubbström (Grubba) #ifdef ROXEN_VERSION
bb1fc42008-06-24Martin Stjernholm constant roxen_ver = "5.0"; constant roxen_build = "0";
b359942009-05-04Henrik Grubbström (Grubba) #define __roxen_version__ roxen_ver #define __roxen_build__ roxen_build
a1316a2004-11-16Henrik Grubbström (Grubba) #else
3554d02004-11-03Henrik Grubbström (Grubba) #include "../etc/include/version.h"
af38572004-11-16Henrik Grubbström (Grubba) #endif
3554d02004-11-03Henrik Grubbström (Grubba)  int main(int argc, array(string) argv) { string base_guid = "e0eb949e-2d84-11d9-8482-77582478aab0"; // WebServer.
b359942009-05-04Henrik Grubbström (Grubba)  string version_str = __roxen_version__+"."+__roxen_build__;
3554d02004-11-03Henrik Grubbström (Grubba)  string title = "Roxen Webserver"; string manufacturer = "Roxen Internet Software"; string pike_module = "Pike_module.msm"; foreach(Getopt.find_all_options(argv, ({ ({"--guid", Getopt.HAS_ARG, ({"-g", "--guid"})}), ({"--version", Getopt.MAY_HAVE_ARG, ({"-v", "--version"})}), ({"--title", Getopt.HAS_ARG, ({"-t", "--title", "--name"})}), ({"--manufacturer", Getopt.HAS_ARG, ({"-m", "--manufacturer"})}), ({"--pike-module", Getopt.HAS_ARG, ({"-p", "--pike", "--pike-module"})}), })), array(string) opt) { switch(opt[0]) { case "--guid": base_guid = Standards.UUID.UUID(opt[1])->str(); break; case "--version": if (stringp(opt[1])) { version_str = opt[1]; } else {
0917d32013-03-04Anders Johansson  werror("$Id$\n");
3554d02004-11-03Henrik Grubbström (Grubba)  exit(0); } break; case "--title": title = opt[1]; break; case "--manufacturer": manufacturer = opt[1]; break; case "--pike-module": pike_module = opt[1]; break; } } argv = Getopt.get_args(argv); string version_guid =
b359942009-05-04Henrik Grubbström (Grubba)  Standards.UUID.make_version3(version_str, base_guid)->str();
3554d02004-11-03Henrik Grubbström (Grubba)  Directory root = Directory("SourceDir", Standards.UUID.UUID(version_guid)->encode(), "TARGETDIR"); string server_dir = "server-"+version_str;
382b6c2004-11-16Henrik Grubbström (Grubba) #if defined(UNIX_PREFIX) && defined(NT_PREFIX) if (has_prefix(pike_module, UNIX_PREFIX)) { pike_module = NT_PREFIX + pike_module[sizeof(UNIX_PREFIX)..]; } #endif
3554d02004-11-03Henrik Grubbström (Grubba)  // First make sure we have a pike binary in the appropriate place.
382b6c2004-11-16Henrik Grubbström (Grubba)  root->merge_module(server_dir+"/pike", replace(pike_module, "/", "\\"), "Pike", "PIKE_TARGETDIR");
3554d02004-11-03Henrik Grubbström (Grubba)  Parser.XML.Tree.SimpleTextNode line_feed = Parser.XML.Tree.SimpleTextNode("\n"); WixNode feature_node = WixNode("Feature", ([ "ConfigurableDirectory":"TARGETDIR", "Title":title, "Level":"1", "Id":"F_ROXEN", ]))-> add_child(line_feed)-> add_child(WixNode("MergeRef", ([ "Id":"Pike" ])))-> add_child(line_feed); // Then populate with the other modules. foreach(argv[1..]; int number; string module_name) { string id = "M_"+number;
382b6c2004-11-16Henrik Grubbström (Grubba) #if defined(UNIX_PREFIX) && defined(NT_PREFIX) if (has_prefix(module_name, UNIX_PREFIX)) { module_name = NT_PREFIX + module_name[sizeof(UNIX_PREFIX)..]; } #endif module_name = replace(module_name, "/", "\\");
3554d02004-11-03Henrik Grubbström (Grubba)  if (has_suffix(module_name, "_server.msm")) {
7f0c3f2004-11-09Henrik Grubbström (Grubba)  root->merge_module(server_dir, module_name, id, "SERVERDIR");
3554d02004-11-03Henrik Grubbström (Grubba)  } else {
7f0c3f2004-11-09Henrik Grubbström (Grubba)  root->merge_module(".", module_name, id, "ROXEN_ROOT");
3554d02004-11-03Henrik Grubbström (Grubba)  } feature_node->add_child(WixNode("MergeRef", ([ "Id":id ])))-> add_child(line_feed); }
ab7b372009-05-04Henrik Grubbström (Grubba)  // configurations/server_version Stdio.write_file("server_version", server_dir); Directory d = root->low_add_path(({ "configurations" })); d->low_install_file("server_version", "server_version");
ff0df22009-05-04Henrik Grubbström (Grubba)  feature_node->add_child(WixNode("ComponentRef", ([ "Id":"C_" + d->id, ])))-> add_child(line_feed);
ab7b372009-05-04Henrik Grubbström (Grubba) 
a1aa742004-11-16Henrik Grubbström (Grubba)  // Add cleanup. root->uninstall_file(combine_path(server_dir, "bin/roxen*.exe"));
9b6e3e2004-11-22Henrik Grubbström (Grubba)  feature_node->add_child(WixNode("ComponentRef", ([
3eb21c2004-11-22Henrik Grubbström (Grubba)  "Id":"C_" + root->sub_dirs[server_dir]-> sub_dirs["bin"]->id,
9b6e3e2004-11-22Henrik Grubbström (Grubba)  ])))-> add_child(line_feed);
a1aa742004-11-16Henrik Grubbström (Grubba)  root->uninstall_file(combine_path(server_dir, "pikelo*.txt"));
b359942009-05-04Henrik Grubbström (Grubba)  root->uninstall_file(combine_path(server_dir, "mysql*.txt"));
9b6e3e2004-11-22Henrik Grubbström (Grubba)  feature_node->add_child(WixNode("ComponentRef", ([
3eb21c2004-11-22Henrik Grubbström (Grubba)  "Id":"C_" + root->sub_dirs[server_dir]->id,
9b6e3e2004-11-22Henrik Grubbström (Grubba)  ])))-> add_child(line_feed);
a1aa742004-11-16Henrik Grubbström (Grubba) 
55afb22004-11-23Henrik Grubbström (Grubba)  // Start menu. Directory start_menu =
b359942009-05-04Henrik Grubbström (Grubba)  root->low_add_path(({"Program Menu"}), "ProgramMenuFolder");
55afb22004-11-23Henrik Grubbström (Grubba) 
b359942009-05-04Henrik Grubbström (Grubba)  Directory sub_menu = start_menu->low_add_path(({title}), "ProductMenuFolder"); sub_menu->low_add_shortcut("Roxen Administration", "ProductMenuFolder", 0,
15a4982004-11-24Henrik Grubbström (Grubba)  "[BROWSER]",
55afb22004-11-23Henrik Grubbström (Grubba)  "[SERVER_PROTOCOL]://localhost:[SERVER_PORT]/");
b359942009-05-04Henrik Grubbström (Grubba)  sub_menu->low_add_shortcut("Roxen Documentation", "ProductMenuFolder", 0,
15a4982004-11-24Henrik Grubbström (Grubba)  "[BROWSER]",
8ae3332004-11-23Henrik Grubbström (Grubba)  "[SERVER_PROTOCOL]://localhost:[SERVER_PORT]/docs/");
b359942009-05-04Henrik Grubbström (Grubba)  sub_menu->low_add_shortcut("Start Roxen (log to file)", "ProductMenuFolder", 0,
8ae3332004-11-23Henrik Grubbström (Grubba)  "[TARGETDIR]ntstart", "\"[TARGETDIR]ntstart.exe\" --quiet",
27f5372009-05-04Henrik Grubbström (Grubba)  "TARGETDIR", "minimized");
b359942009-05-04Henrik Grubbström (Grubba)  sub_menu->low_add_shortcut("Start Roxen (log to window)", "ProductMenuFolder", 0,
8ae3332004-11-23Henrik Grubbström (Grubba)  "[TARGETDIR]ntstart", "\"[TARGETDIR]ntstart.exe\"",
27f5372009-05-04Henrik Grubbström (Grubba)  "TARGETDIR");
55afb22004-11-23Henrik Grubbström (Grubba)  feature_node->add_child(WixNode("ComponentRef", ([ "Id":"C_" + sub_menu->id, ])))->
0137ac2004-11-23Henrik Grubbström (Grubba)  add_child(line_feed);
55afb22004-11-23Henrik Grubbström (Grubba) 
3554d02004-11-03Henrik Grubbström (Grubba)  // Generate the XML. Parser.XML.Tree.SimpleRootNode root_node = Parser.XML.Tree.SimpleRootNode()-> add_child(Parser.XML.Tree.SimpleHeaderNode((["version": "1.0", "encoding": "utf-8"])))-> add_child(WixNode("Wix", (["xmlns":wix_ns]))-> add_child(line_feed)-> add_child(WixNode("Product", ([ "Manufacturer":manufacturer,
8395112009-02-18Henrik Grubbström (Grubba)  "Name":title + " " + version_str,
3554d02004-11-03Henrik Grubbström (Grubba)  "Language":"1033", "UpgradeCode":base_guid, "Id":version_guid, "Version":version_str, ]))-> add_child(line_feed)->
afce352004-11-23Henrik Grubbström (Grubba) #if 0
092db32004-11-22Henrik Grubbström (Grubba)  add_child(WixNode("Upgrade", ([ "Id":base_guid, ]))->
6fdb2d2004-11-22Henrik Grubbström (Grubba)  add_child(line_feed)->
092db32004-11-22Henrik Grubbström (Grubba)  add_child(WixNode("UpgradeVersion", ([ "IgnoreRemoveFailure":"yes", "IncludeMaximum":"no", "Maximum":version_str, "OnlyDetect":"yes", ])))-> add_child(line_feed))->
afce352004-11-23Henrik Grubbström (Grubba) #endif /* 0 */
092db32004-11-22Henrik Grubbström (Grubba)  add_child(line_feed)->
3554d02004-11-03Henrik Grubbström (Grubba)  add_child(WixNode("Package", ([ "Manufacturer":manufacturer, "Languages":"1033", "Compressed":"yes", "InstallerVersion":"200", "Platforms":"Intel", "SummaryCodepage":"1252", "Id":version_guid, ])))-> add_child(line_feed)-> add_child(WixNode("Media", ([ "Cabinet":"Roxen.cab", "EmbedCab":"yes", "Id":"1", ])))-> add_child(line_feed)->
b359942009-05-04Henrik Grubbström (Grubba)  // Same as [ProductName], but without // the version number. add_child(WixNode("Property", ([ "Id":"ROXEN_TITLE", "Value":title, ])))-> add_child(line_feed)->
7885642009-05-06Henrik Grubbström (Grubba)  add_child(root->gen_xml(UNDEFINED, "1"))->
3554d02004-11-03Henrik Grubbström (Grubba)  add_child(line_feed)-> add_child(feature_node)-> add_child(line_feed)-> add_child(WixNode("FragmentRef", ([ "Id":"RoxenUI", ])))))-> add_child(line_feed); write(root_node->render_xml());
7f0c3f2004-11-09Henrik Grubbström (Grubba) }