Skip to content

Commit

Permalink
Added support for arbitrary archive formats on self-extracting instal…
Browse files Browse the repository at this point in the history
…lers.
  • Loading branch information
icculus committed Jan 24, 2011
1 parent c29f8bf commit dbd8269
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Expand Up @@ -835,6 +835,8 @@ GET_TARGET_PROPERTY(MOJOSETUP_BINARY_LOCATION mojosetup LOCATION)
TARGET_LINK_LIBRARIES(mojosetup ${OPTIONAL_LIBS})
SET(MOJOSETUP_TARGETS "${MOJOSETUP_TARGETS};mojosetup")

ADD_EXECUTABLE(make_self_extracting misc/make_self_extracting.c)

# For cobbling together a skeleton installer...

# !!! FIXME: all of these custom .cmake files are built-in commands in CMake 2.6.(4?) ...!
Expand Down
2 changes: 1 addition & 1 deletion docs.txt
Expand Up @@ -1046,7 +1046,7 @@ Now you have a MojoSetup binary and a directory tree containing your data, GUI
self-extracting, zip your directory tree up and append it to the binary:

zip -9r mydata.zip data guis scripts
cat mydata.zip >> mojosetup
./make_self_extracting ./mojosetup mydata.zip

Now rename "mojosetup" to something meaningful (mygame-1.0-linux-x86.bin or
whatever), and you've got an installer.
Expand Down
2 changes: 1 addition & 1 deletion examples/aquaria/make.sh
Expand Up @@ -181,7 +181,7 @@ else
cd ..
rm -rf image
# Append the .zip archive to the mojosetup binary, so it's "self-extracting."
cat pdata.zip >> ./aquaria-installer
../../cmake-build/make_self_extracting pdata.zip ./aquaria-installer
rm -f pdata.zip
fi

Expand Down
2 changes: 1 addition & 1 deletion examples/braid/make.sh
Expand Up @@ -181,7 +181,7 @@ else
cd ..
rm -rf image
# Append the .zip archive to the mojosetup binary, so it's "self-extracting."
cat pdata.zip >> ./braid-installer
../../cmake-build/make_self_extracting pdata.zip ./braid-installer
rm -f pdata.zip
fi

Expand Down
2 changes: 1 addition & 1 deletion examples/duke3d/make.sh
Expand Up @@ -147,7 +147,7 @@ else
cd ..
rm -rf image
# Append the .zip archive to the mojosetup binary, so it's "self-extracting."
cat pdata.zip >> ./duke3d-installer
../../cmake-build/make_self_extracting pdata.zip ./duke3d-installer
rm -f pdata.zip
fi

Expand Down
2 changes: 1 addition & 1 deletion examples/lugaru/make.sh
Expand Up @@ -181,7 +181,7 @@ else
cd ..
rm -rf image
# Append the .zip archive to the mojosetup binary, so it's "self-extracting."
cat pdata.zip >> ./lugaru-installer
../../cmake-build/make_self_extracting pdata.zip ./lugaru-installer
rm -f pdata.zip
fi

Expand Down
2 changes: 1 addition & 1 deletion examples/postal1/make.sh
Expand Up @@ -181,7 +181,7 @@ else
cd ..
rm -rf image
# Append the .zip archive to the mojosetup binary, so it's "self-extracting."
cat pdata.zip >> ./postal1-installer
../../cmake-build/make_self_extracting pdata.zip ./postal1-installer
rm -f pdata.zip
fi

Expand Down
2 changes: 1 addition & 1 deletion examples/postal2/make.sh
Expand Up @@ -181,7 +181,7 @@ else
cd ..
rm -rf image
# Append the .zip archive to the mojosetup binary, so it's "self-extracting."
cat pdata.zip >> ./postal2-installer
../../cmake-build/make_self_extracting pdata.zip ./postal2-installer
rm -f pdata.zip
fi

Expand Down
2 changes: 1 addition & 1 deletion examples/postal2aw/make.sh
Expand Up @@ -181,7 +181,7 @@ else
cd ..
rm -rf image
# Append the .zip archive to the mojosetup binary, so it's "self-extracting."
cat pdata.zip >> ./postal2aw-installer
../../cmake-build/make_self_extracting pdata.zip ./postal2aw-installer
rm -f pdata.zip
fi

Expand Down
2 changes: 1 addition & 1 deletion examples/prey-demo/make.sh
Expand Up @@ -180,7 +180,7 @@ cd ..
rm -rf image

# Append the .zip archive to the mojosetup binary, so it's "self-extracting."
cat pdata.zip >> ./$pkgbin
../../cmake-build/make_self_extracting pdata.zip ./$pkgbin
rm -f pdata.zip

# ...and that's that.
Expand Down
2 changes: 1 addition & 1 deletion examples/prey/make.sh
Expand Up @@ -183,7 +183,7 @@ cd ..
rm -rf image

# Append the .zip archive to the mojosetup binary, so it's "self-extracting."
cat pdata.zip >> ./$pkgbin
../../cmake-build/make_self_extracting pdata.zip ./$pkgbin
rm -f pdata.zip

# ...and that's that.
Expand Down
2 changes: 1 addition & 1 deletion examples/ut3-dedicated-patches/make.sh
Expand Up @@ -140,7 +140,7 @@ cd ..
rm -rf image

# Append the .zip archive to the mojosetup binary, so it's "self-extracting."
cat pdata.zip >> ./mojosetup
../../cmake-build/make_self_extracting pdata.zip ./mojosetup
rm -f pdata.zip

# Rename it, and we're good to go.
Expand Down
2 changes: 1 addition & 1 deletion examples/ut3-dedicated/make.sh
Expand Up @@ -130,7 +130,7 @@ cd ..
rm -rf image

# Append the .zip archive to the mojosetup binary, so it's "self-extracting."
cat pdata.zip >> ./mojosetup
../../cmake-build/make_self_extracting pdata.zip ./mojosetup
rm -f pdata.zip

# Rename it, and we're good to go.
Expand Down
22 changes: 22 additions & 0 deletions fileio.c
Expand Up @@ -1469,7 +1469,29 @@ MojoArchive *MojoArchive_initBaseArchive(void)
io = MojoInput_newFromFile(basepath);

if (io != NULL)
{
// See if there's a MOJOBASE signature at the end of the
// file. This means we appended an archive to the executable,
// for a self-extracting installer. This method works with
// any archive type, even if it wasn't specifically designed
// to be appended.
uint8 buf[8];
uint64 size = 0;
const int64 flen = io->length(io) - 16;
if ( (flen > 0) && (io->seek(io, flen)) &&
(io->read(io, buf, 8) == 8) &&
(memcmp(buf, "MOJOBASE", 8) == 0) &&
(MojoInput_readui64(io, &size)) &&
(size < flen) )
{
MojoInput *newio;
newio = MojoInput_newFromSubset(io, flen - size, flen);
if (newio != NULL)
io = newio;
} // if

GBaseArchive = MojoArchive_newFromInput(io, basepath);
} // if

if (GBaseArchive == NULL)
{
Expand Down

0 comments on commit dbd8269

Please sign in to comment.