aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/sisfileheader.cpp16
-rw-r--r--sisinstall/Makefile.am2
-rw-r--r--sisinstall/fakepsion.cpp6
-rw-r--r--sisinstall/fakepsion.h2
-rw-r--r--sisinstall/psion.cpp6
-rw-r--r--sisinstall/psion.h2
-rw-r--r--sisinstall/sisfilelink.cpp9
-rw-r--r--sisinstall/sisfilelink.h16
-rw-r--r--sisinstall/sisinstaller.cpp178
-rw-r--r--sisinstall/sisinstaller.h14
10 files changed, 177 insertions, 74 deletions
diff --git a/lib/sisfileheader.cpp b/lib/sisfileheader.cpp
index a6535c8..c816c00 100644
--- a/lib/sisfileheader.cpp
+++ b/lib/sisfileheader.cpp
@@ -127,24 +127,24 @@ SISFileHeader::fillFrom(uint8_t* buf, int* base, off_t len)
m_languagePtr = read32(start + 48);
if (logLevel >= 2)
printf(_("Languages begin at %d\n"), m_languagePtr);
- if (m_languagePtr >= len)
- return SIS_TRUNCATED;
+// if (m_languagePtr >= len)
+// return SIS_TRUNCATED;
m_filesPtr = read32(start + 52);
if (logLevel >= 2)
printf(_("Files begin at %d\n"), m_filesPtr);
- if (m_filesPtr >= len)
- return SIS_TRUNCATED;
+// if (m_filesPtr >= len)
+// return SIS_TRUNCATED;
m_reqPtr = read32(start + 56);
if (logLevel >= 2)
printf(_("Requisites begin at %d\n"), m_reqPtr);
- if (m_reqPtr >= len)
- return SIS_TRUNCATED;
+// if (m_reqPtr >= len)
+// return SIS_TRUNCATED;
m_unknown = read32(start + 60);
m_componentPtr = read32(start + 64);
if (logLevel >= 2)
printf(_("Components begin at %d\n"), m_componentPtr);
- if (m_componentPtr >= len)
- return SIS_TRUNCATED;
+// if (m_componentPtr >= len)
+// return SIS_TRUNCATED;
*base += 68;
return SIS_OK;
}
diff --git a/sisinstall/Makefile.am b/sisinstall/Makefile.am
index 04e7ca4..a02fb20 100644
--- a/sisinstall/Makefile.am
+++ b/sisinstall/Makefile.am
@@ -5,7 +5,7 @@ INCLUDES=-I$(top_srcdir)/lib
bin_PROGRAMS = sisinstall
sisinstall_LDADD = $(top_srcdir)/lib/libplp.la
sisinstall_SOURCES = psion.cpp sisinstaller.cpp sismain.cpp \
- fakepsion.cpp
+ fakepsion.cpp sisfilelink.cpp sisfilelink.h
EXTRA_DIST = psion.h sisinstaller.h fakepsion.h
maintainer-clean-local:
diff --git a/sisinstall/fakepsion.cpp b/sisinstall/fakepsion.cpp
index 49defca..3de2967 100644
--- a/sisinstall/fakepsion.cpp
+++ b/sisinstall/fakepsion.cpp
@@ -33,6 +33,12 @@ FakePsion::devlist(u_int32_t& devbits)
return rfsv::E_PSI_GEN_FAIL;
}
+Enum<rfsv::errs>
+FakePsion::dir(const char* dir, PlpDir& files)
+{
+ return rfsv::E_PSI_GEN_NONE;
+}
+
bool
FakePsion::dirExists(const char* name)
{
diff --git a/sisinstall/fakepsion.h b/sisinstall/fakepsion.h
index d53dafd..f1b965c 100644
--- a/sisinstall/fakepsion.h
+++ b/sisinstall/fakepsion.h
@@ -22,6 +22,8 @@ public:
virtual Enum<rfsv::errs> devlist(u_int32_t& devbits);
+ virtual Enum<rfsv::errs> dir(const char* dir, PlpDir& files);
+
virtual bool dirExists(const char* name);
virtual void disconnect();
diff --git a/sisinstall/psion.cpp b/sisinstall/psion.cpp
index c068b1c..d3abdf4 100644
--- a/sisinstall/psion.cpp
+++ b/sisinstall/psion.cpp
@@ -90,6 +90,12 @@ Psion::devlist(u_int32_t& devbits)
return res;
}
+Enum<rfsv::errs>
+Psion::dir(const char* dir, PlpDir& files)
+{
+ return m_rfsv->dir(dir, files);
+}
+
bool
Psion::dirExists(const char* name)
{
diff --git a/sisinstall/psion.h b/sisinstall/psion.h
index d01c70b..c305173 100644
--- a/sisinstall/psion.h
+++ b/sisinstall/psion.h
@@ -31,6 +31,8 @@ public:
virtual Enum<rfsv::errs> devlist(u_int32_t& devbits);
+ virtual Enum<rfsv::errs> dir(const char* dir, PlpDir& files);
+
virtual bool dirExists(const char* name);
virtual void disconnect();
diff --git a/sisinstall/sisfilelink.cpp b/sisinstall/sisfilelink.cpp
new file mode 100644
index 0000000..b1cc78b
--- /dev/null
+++ b/sisinstall/sisfilelink.cpp
@@ -0,0 +1,9 @@
+
+#include "sisfilelink.h"
+
+SISFileLink::SISFileLink(SISFile* file)
+{
+ m_file = file;
+ m_next = 0;
+}
+
diff --git a/sisinstall/sisfilelink.h b/sisinstall/sisfilelink.h
new file mode 100644
index 0000000..66a0ad1
--- /dev/null
+++ b/sisinstall/sisfilelink.h
@@ -0,0 +1,16 @@
+#ifndef _SISFILELINK_H
+#define _SISFILELINK_H
+
+class SISFile;
+
+class SISFileLink
+{
+public:
+ SISFileLink(SISFile* file);
+
+ SISFileLink* m_next;
+ SISFile* m_file;
+};
+
+#endif
+
diff --git a/sisinstall/sisinstaller.cpp b/sisinstall/sisinstaller.cpp
index 263b2ea..80d2ce2 100644
--- a/sisinstall/sisinstaller.cpp
+++ b/sisinstall/sisinstaller.cpp
@@ -2,6 +2,7 @@
#include "sisinstaller.h"
#include "sisfile.h"
+#include "sisfilelink.h"
#include "sisfilerecord.h"
#include "sisreqrecord.h"
#include "psion.h"
@@ -23,6 +24,11 @@ checkAbortHash(void *, u_int32_t)
return continueRunning;
}
+SISInstaller::SISInstaller()
+{
+ m_installed = 0;
+}
+
void
SISInstaller::createDirs(char* filename)
{
@@ -161,6 +167,7 @@ SISInstaller::installFile(SISFileRecord* fileRecord)
}
SISInstaller installer;
installer.setPsion(m_psion);
+ installer.setInstalled(m_installed);
rc = installer.run(&sisFile, buf2, len, m_file);
if (0 == m_drive)
{
@@ -186,10 +193,72 @@ SISInstaller::installFile(SISFileRecord* fileRecord)
return FILE_OK;
}
+#define SYSTEMINSTALL "c:\\system\\install\\"
+
+SisRC
+SISInstaller::loadInstalled()
+{
+ PlpDir files;
+ Enum<rfsv::errs> res;
+
+ if ((res = m_psion->dir(SYSTEMINSTALL, files)) != rfsv::E_PSI_GEN_NONE)
+ {
+ return SIS_FAILED;
+ }
+ else
+ {
+ while (!files.empty())
+ {
+ PlpDirent file = files[0];
+ printf("Loading sis file `%s'\n", file.getName());
+ char sisname[256];
+ sprintf(sisname, "%s%s", SYSTEMINSTALL, file.getName());
+ loadPsionSis(sisname);
+ files.pop_front();
+ }
+ }
+}
+
void
-SISInstaller::setPsion(Psion* psion)
+SISInstaller::loadPsionSis(const char* name)
{
- m_psion = psion;
+ char srcName[32];
+ strcpy(srcName, "/tmp/plptools-sis-XXXXXX");
+ int fd = mkstemp(srcName);
+ if (-1 == fd)
+ {
+ printf("Couldn't create temp file: %s\n", strerror(errno));
+ return;
+ }
+ Enum<rfsv::errs> res;
+ continueRunning = 1;
+ if (logLevel >= 2)
+ printf("Copying from %s to temp file %s\n", name, srcName);
+ res = m_psion->copyFromPsion(name, fd, checkAbortHash);
+ if (res == rfsv::E_PSI_GEN_NONE)
+ {
+ off_t fileLen = lseek(fd, 0, SEEK_END);
+ if (logLevel >= 2)
+ printf("Read %d bytes from the Psion file %s\n",
+ (int)fileLen, name);
+ lseek(fd, SEEK_SET, 0);
+ uint8_t* sisbuf = new uint8_t[fileLen];
+ int rc = read(fd, sisbuf, fileLen);
+ if (rc == fileLen)
+ {
+ SISFile* sisFile = new SISFile();
+ SisRC rc2 = sisFile->fillFrom(sisbuf, fileLen);
+ if (rc2 == SIS_OK)
+ {
+ if (logLevel >= 1)
+ printf(" Ok.\n");
+ SISFileLink* link = new SISFileLink(sisFile);
+ link->m_next = m_installed;
+ m_installed = link;
+ }
+ }
+ }
+ close(fd);
}
SisRC
@@ -240,6 +309,8 @@ SISInstaller::run(SISFile* file, uint8_t* buf, off_t len, SISFile* parent)
// library has been loaded, since the sis file names could be just
// about anything.
//
+ if (m_installed == 0)
+ loadInstalled();
// Check Requisites.
//
@@ -262,76 +333,38 @@ SISInstaller::run(SISFile* file, uint8_t* buf, off_t len, SISFile* parent)
m_file->m_header.m_uid1,
m_file->m_header.m_major,
m_file->m_header.m_minor);
- char* resname = new char[256];
- int namelen = 0;
- while (compName[namelen] != 0)
- {
- if (compName[namelen] == ' ')
- break;
- namelen++;
- }
- sprintf(resname, "C:\\System\\Install\\%.*s.sis", namelen, compName);
-#if 0
- char srcName[32];
- strcpy(srcName, "/tmp/plptools-sis-XXXXXX");
- int fd = mkstemp(srcName);
- if (-1 == fd)
- {
- printf("Couldn't create temp file: %s\n", strerror(errno));
- return SIS_FAILED;
- }
- Enum<rfsv::errs> res;
- continueRunning = 1;
- printf("Copying from %s to temp file %s\n", resname, srcName);
- res = m_psion->copyFromPsion(resname, fd, checkAbortHash);
- if (res == rfsv::E_PSI_GEN_NONE)
+ bool uninstallFirst;
+ SISFileLink* curr = m_installed;
+ while (curr)
{
- off_t fileLen = lseek(fd, SEEK_END, 0);
- if (logLevel >= 2)
- printf("Read %d bytes from the Psion file %s\n",
- fileLen, resname);
- lseek(fd, SEEK_SET, 0);
- uint8_t* sisbuf = new uint8_t[fileLen];
- int rc = read(fd, sisbuf, fileLen);
- if (rc == fileLen)
+ SISFile* sisFile = curr->m_file;
+ switch (sisFile->compareApp(m_file))
{
- bool uninstallFirst = false;
- SISFile sisFile;
- SisRC rc2 = sisFile.fillFrom(sisbuf, fileLen);
- if (rc2 == SIS_OK)
- {
- switch (sisFile.compareApp(m_file))
- {
- case SIS_DIFFERENT_APP:
- // NOW WHAT?
- return SIS_DIFFERENT_APP;
-
- case SIS_VER_EARLIER:
- uninstallFirst = true;
- break;
-
- case SIS_SAME_OR_LATER:
- // Ask for confirmation.
- uninstallFirst = true;
- break;
+ case SIS_VER_EARLIER:
+ uninstallFirst = true;
+ break;
- case SIS_OTHER_VARIANT:
- // Ask for confirmation.
- uninstallFirst = true;
- break;
+ case SIS_SAME_OR_LATER:
+ // Ask for confirmation.
+ uninstallFirst = true;
+ break;
- }
- if (uninstallFirst)
- {
- // Not yet...
- // uninstall(&sisFile);
- }
- }
+ case SIS_OTHER_VARIANT:
+ // Ask for confirmation.
+ uninstallFirst = true;
+ break;
}
+ curr = curr->m_next;
+ }
+
+ if (uninstallFirst)
+ {
+ printf("You should uninstall the previous version first.\n");
+ return SIS_ABORTED;
+ // Not yet...
+ // uninstall(&sisFile);
}
- close(fd);
-#endif
// Install file components.
//
@@ -398,6 +431,15 @@ SISInstaller::run(SISFile* file, uint8_t* buf, off_t len, SISFile* parent)
// Copy the updated sis file to the epoc machine.
//
+ char* resname = new char[256];
+ int namelen = 0;
+ while (compName[namelen] != 0)
+ {
+ if (compName[namelen] == ' ')
+ break;
+ namelen++;
+ }
+ sprintf(resname, "C:\\System\\Install\\%.*s.sis", namelen, compName);
printf("Creating residual sis file %s\n", resname);
copyBuf(buf, firstFile, resname);
delete[] resname;
@@ -467,3 +509,9 @@ SISInstaller::selectDrive()
}
}
+void
+SISInstaller::setPsion(Psion* psion)
+{
+ m_psion = psion;
+}
+
diff --git a/sisinstall/sisinstaller.h b/sisinstall/sisinstaller.h
index bca7117..ff9845e 100644
--- a/sisinstall/sisinstaller.h
+++ b/sisinstall/sisinstaller.h
@@ -7,6 +7,7 @@
class Psion;
class SISFile;
+class SISFileLink;
class SISFileRecord;
/**
@@ -17,6 +18,8 @@ class SISInstaller
{
public:
+ SISInstaller();
+
SisRC run(SISFile* file, uint8_t* buf, off_t len);
SisRC run(SISFile* file, uint8_t* buf, off_t len, SISFile* parent);
@@ -26,6 +29,11 @@ public:
*/
void selectDrive();
+ void setInstalled(SISFileLink* installed)
+ {
+ m_installed = installed;
+ }
+
/**
* Set the Psion manager.
*/
@@ -43,6 +51,8 @@ private:
SISFile* m_file;
+ SISFileLink* m_installed;
+
enum {
FILE_OK,
FILE_SKIP,
@@ -63,6 +73,10 @@ private:
int installFile(SISFileRecord* fileRecord);
+ SisRC loadInstalled();
+
+ void loadPsionSis(const char* name);
+
void uninstall(SISFile* sisFile);
};