-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstallscript.qs.in
More file actions
104 lines (88 loc) · 5.18 KB
/
installscript.qs.in
File metadata and controls
104 lines (88 loc) · 5.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
function Component() {}
function ensureDir(path) {
component.addOperation("Mkdir", path);
}
function copyDesktopForUser() {
if (installer.value("os") !== "x11")
return;
var targetDir = installer.value("TargetDir");
var home = QDir.homePath();
var appsDir = home + "/.local/share/applications";
var iconsDir = home + "/.local/share/icons/hicolor/256x256/apps";
ensureDir(appsDir);
ensureDir(home + "/.local/share/icons");
ensureDir(home + "/.local/share/icons/hicolor");
ensureDir(home + "/.local/share/icons/hicolor/256x256");
ensureDir(iconsDir);
var srcTemplate = targetDir + "/@PROJECT_PACKAGE_NAME@.desktop.ifw";
var dstDesktop = appsDir + "/@PROJECT_PACKAGE_NAME@.desktop";
var iconSrc = targetDir + "/@PROJECT_TARGET_NAME@/pixmaps/@PROJECT_PACKAGE_NAME@.png";
var iconDst = iconsDir + "/@PROJECT_PACKAGE_NAME@.png";
// Copy the icon to user's icon theme
component.addOperation("Copy", iconSrc, iconDst);
// Copy template and replace placeholders with real paths
component.addOperation("Copy", srcTemplate, dstDesktop);
component.addOperation("Replace", dstDesktop, "@EXEC_PATH@", targetDir + "/bin/@IFW_QS_TARGET_FILE_BASE@");
component.addOperation("Replace", dstDesktop, "@ICON_PATH@", iconDst);
// Try to refresh desktop/icon caches (best-effort)
component.addOperation("Execute", "update-desktop-database", appsDir, "||", "true");
component.addOperation("Execute", "xdg-desktop-menu", "forceupdate", "||", "true");
component.addOperation("Execute", "gtk-update-icon-cache", "-q", home + "/.local/share/icons/hicolor", "||", "true");
}
Component.prototype.createOperations = function() {
component.createOperations();
var targetFileBase = "@IFW_QS_TARGET_FILE_BASE@";
var targetNameBase = "@IFW_QS_TARGET_NAME_BASE@";
var targetDir = installer.value("TargetDir");
if (installer.value("os") === "win") {
var userProfile = installer.environmentVariable("USERPROFILE");
var startMenuDir = installer.value("StartMenuDir");
component.addOperation("CreateShortcut",
targetDir + "/bin/" + targetFileBase,
startMenuDir + "/" + targetNameBase + ".lnk",
"workingDirectory=" + targetDir,
"description=" + targetNameBase);
component.addOperation("CreateShortcut",
targetDir + "/bin/" + targetFileBase,
userProfile + "/Desktop/" + targetNameBase + ".lnk",
"workingDirectory=" + targetDir,
"description=" + targetNameBase);
component.addOperation("CreateShortcut",
targetDir + "/maintenancetool.exe",
startMenuDir + "/" + targetNameBase + " maintenance tool.lnk",
"workingDirectory=" + targetDir,
"description=" + targetNameBase + " Maintenance tool");
// Register in Add/Remove Programs
var regKey = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\@PROJECT_PACKAGE_NAME@";
component.addOperation("Execute",
"reg", "add", regKey, "/v", "DisplayName", "/d", "@PROJECT_HUMAN_NAME@", "/f",
"UNDOEXECUTE",
"reg", "delete", regKey, "/f");
component.addOperation("Execute",
"reg", "add", regKey, "/v", "UninstallString", "/d",
targetDir + "/maintenancetool.exe", "/f");
component.addOperation("Execute",
"reg", "add", regKey, "/v", "DisplayIcon", "/d",
targetDir + "/bin/" + targetFileBase, "/f");
component.addOperation("Execute",
"reg", "add", regKey, "/v", "DisplayVersion", "/d", "@PROJECT_VERSION@", "/f");
component.addOperation("Execute",
"reg", "add", regKey, "/v", "Publisher", "/d", "@PROJECT_AUTHOR@", "/f");
component.addOperation("Execute",
"reg", "add", regKey, "/v", "URLInfoAbout", "/d", "@PROJECT_WWW@", "/f");
}
if (installer.value("os") === "x11") {
component.addOperation("CreateDesktopEntry",
targetFileBase + ".desktop",
"Type=Application\nName=" + targetNameBase + "\nExec=" + targetDir + "/bin/" + targetFileBase + "\nPath=" + targetDir + "/bin\nTerminal=false\nIcon=range-" + targetFileBase);
component.addOperation("InstallIcons", targetDir + "/icons");
component.addOperation("Execute", "chmod", "+x", targetDir + "/bin/" + targetFileBase);
}
if (installer.value("os") === "mac") {
component.addOperation("Execute",
"ln", "-s", "-v", targetDir + "/" + targetFileBase + ".app", "/Applications/" + targetFileBase + ".app",
"UNDOEXECUTE",
"rm", "-vf", "/Applications/" + targetFileBase + ".app");
}
copyDesktopForUser();
}