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 105 106 107 108 109 110 111 112 113 114 115 116 117
|
int g_components;
string testRequest(string request, string key, int value)
{
int idx = strfind(request, key);
if (idx == -1)
return request;
int len = strlen(request);
string ret;
if (idx > 0)
ret = substr(request, 0, idx);
if (++idx < len)
ret += substr(request, idx, len);
g_components |= value;
return ret;
}
void install(string request, string dest)
{
string target;
list pathsplit;
string base;
base = "tmp/install/";
md(base);
if (request == "x")
{
g_components = 63;
request = "";
}
else
{
request = testRequest(request, "a", 1); // additional info
request = testRequest(request, "b", 2); // binary program
request = testRequest(request, "d", 4); // std documentation
request = testRequest(request, "m", 8); // man-pages
request = testRequest(request, "s", 16); // skeleton files
request = testRequest(request, "u", 32); // use guide
}
if (g_components == 0 || strlen(request) != 0)
{
printf("'build install selection ...': 'selection' must be x or "
"chars. of [abdsmu]\n");
exit(1);
}
chdir(g_cwd); // determine the destination path
if (dest == "")
dest = "/";
else
md(dest);
dest = cutEoln(backtick("readlink -f " + dest)[0]);
if (g_logPath != "")
exec(P_NOCHECK, "rm -f " + g_logPath);
if (g_components & 2)
{
target = base + "b/" BINARY;
pathsplit = path_file(target);
// copy srdir/src to destdir/dest, where destdir also contains
// the topic-icentifier (e.g., b in tmp/install/b)
logFile("tmp/bin", "binary", pathsplit[0], pathsplit[1]);
destInstall(dest, base + "b");
logInstalled(dest, "b");
}
if (g_components & (4 | 8))
{
target = base + "d/" DOC "/";
if (g_components & 4)
{
printf(" installing the changelog at `", target, "\n");
logZip("", "changelog", target );
destInstall(dest, base + "d");
}
if (g_components & 8)
{
printf(" installing the html-manual pages at `", target, "\n");
logInstall("tmp/manhtml", "", target);
destInstall(dest, base + "d");
}
logInstalled(dest, "d");
}
if (g_components & 8)
{
target = base + "m/" MAN;
printf(" installing the manual pages below `", target, "'\n");
target = base + "m/" MAN;
logZip("tmp/man", "oxref.1", target);
destInstall(dest, base + "m");
logInstalled(dest, "m");
}
printf("\n Installation completed\n");
exit(0);
}
|