Continue OS X installer work.
This commit is contained in:
@@ -17,7 +17,7 @@ using namespace std;
|
||||
#include <stack>
|
||||
#include <map>
|
||||
|
||||
void HandleFile(const char *file, const char *archivePath, bool overwrite)
|
||||
void HandleFile(const CString& file, const CString& archivePath, bool overwrite)
|
||||
{
|
||||
static bool archiveMade = false;
|
||||
CString command;
|
||||
@@ -29,14 +29,11 @@ void HandleFile(const char *file, const char *archivePath, bool overwrite)
|
||||
archiveMade = true;
|
||||
command = "tar cfP '";
|
||||
}
|
||||
command += archivePath;
|
||||
command += "' '";
|
||||
command += file;
|
||||
command += "'";
|
||||
command += archivePath + "' '" + file + "'";
|
||||
|
||||
system(command);
|
||||
|
||||
printf("%s\n", file);
|
||||
printf("%s\n", file.c_str());
|
||||
}
|
||||
|
||||
void PrintUsage(int err)
|
||||
@@ -75,6 +72,7 @@ int main(int argc, char *argv[])
|
||||
if (inFile == "help" || inFile == "-h" || inFile == "--help")
|
||||
PrintUsage(0);
|
||||
|
||||
outDir += "/files";
|
||||
|
||||
InstallerFile config(inFile);
|
||||
unsigned nextLine = 0;
|
||||
@@ -96,11 +94,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
CString archivePath = outDir + "/archive.tar";
|
||||
|
||||
Processor p(archivePath, HandleFile, NULL, false);
|
||||
Processor p(archivePath, HandleFile, NULL, NULL, false);
|
||||
|
||||
while (nextLine < config.GetNumLines())
|
||||
p.ProcessLine(config.GetLine(nextLine), nextLine);
|
||||
|
||||
/* Compress the archive after it is created */
|
||||
command = "gzip '" + archivePath + "'";
|
||||
system(command);
|
||||
|
||||
if (!config.WriteFile(outDir + "/config"))
|
||||
{
|
||||
printf("%s\n", strerror(errno));
|
||||
|
||||
@@ -10,9 +10,12 @@
|
||||
#ifndef INSTALLER_FILE_H
|
||||
#define INSTALLER_FILE_H
|
||||
|
||||
#include "StdString.h"
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class InstallerFile {
|
||||
private:
|
||||
CString mPath;
|
||||
|
||||
@@ -209,6 +209,13 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine)
|
||||
return;
|
||||
}
|
||||
|
||||
if (parts[0] == "ASK")
|
||||
{
|
||||
if (parts.size() != 3)
|
||||
goto error;
|
||||
mVars[parts[1]] = (*mAsk)(parts[2]);
|
||||
}
|
||||
|
||||
error:
|
||||
(*mError)("%s is an invalid command", line.c_str());
|
||||
++nextLine;
|
||||
|
||||
@@ -18,9 +18,10 @@ using namespace std;
|
||||
class Processor
|
||||
{
|
||||
private:
|
||||
typedef void (*handleFileFunc)(const char *file, const char *archivePath, bool overwrite);
|
||||
typedef const char *(*getPathFunc)(const char *id);
|
||||
typedef void (*handleFileFunc)(const CString& file, const CString& archivePath, bool overwrite);
|
||||
typedef const CString (*getPathFunc)(const CString& ID);
|
||||
typedef void (*errorFunc)(const char *fmt, ...);
|
||||
typedef bool (*askFunc)(const CString& question);
|
||||
|
||||
stack<unsigned> mReturnStack;
|
||||
bool mDoGoto;
|
||||
@@ -32,6 +33,7 @@ private:
|
||||
CString mCWD;
|
||||
handleFileFunc mHandleFile;
|
||||
getPathFunc mGetPath;
|
||||
askFunc mAsk;
|
||||
errorFunc mError;
|
||||
bool mInstalling;
|
||||
|
||||
@@ -39,8 +41,8 @@ private:
|
||||
bool ResolveConditional(const CString& cond);
|
||||
static void DefaultError(const char *fmt, ...);
|
||||
public:
|
||||
Processor(CString& path, handleFileFunc f, getPathFunc p, bool i)
|
||||
: mDoGoto(false), mPath(path), mCWD("."), mHandleFile(f), mGetPath(p),
|
||||
Processor(CString& path, handleFileFunc f, getPathFunc p, askFunc a, bool i)
|
||||
: mDoGoto(false), mPath(path), mCWD("."), mHandleFile(f), mGetPath(p), mAsk(a),
|
||||
mError(Processor::DefaultError), mInstalling(i) { }
|
||||
void ProcessLine(const CString& line, unsigned& nextLine);
|
||||
void SetErrorFunc(errorFunc f) { mError = f; }
|
||||
|
||||
Reference in New Issue
Block a user