Landing patch for bug 292021 "Software Update self-contained executable" r+a=bsmedberg

This commit is contained in:
darin%meer.net 2005-06-08 18:04:25 +00:00
parent dcd9aa5bfe
commit b1e47d43a3
24 changed files with 2378 additions and 0 deletions

View File

@ -125,6 +125,11 @@ ifdef MOZ_INSTALLER
tier_1_dirs += modules/zlib/standalone
endif
ifdef MOZ_UPDATER
tier_1_dirs += modules/libbz2
tier_1_dirs += modules/libmar
endif
ifdef MOZ_SVG_RENDERER_LIBART
tier_1_dirs += other-licenses/libart_lgpl
endif

View File

@ -1203,6 +1203,15 @@ MAKEFILES_zlib="
modules/zlib/standalone/Makefile
"
MAKEFILES_libbz2="
modules/libbz2/Makefile
modules/libbz2/src/Makefile
"
MAKEFILES_libmar="
modules/libmar/Makefile
modules/libmar/src/Makefile
"
if [ ! "$SYSTEM_PNG" ]; then
MAKEFILES_libimg="$MAKEFILES_libimg modules/libimg/png/Makefile"
@ -1601,6 +1610,8 @@ $MAKEFILES_xpconnect
$MAKEFILES_xpinstall
$MAKEFILES_xpfe
$MAKEFILES_zlib
$MAKEFILES_libbz2
$MAKEFILES_libmar
"
if test -n "$MOZ_PSM"; then

View File

@ -1,3 +1,4 @@
# vim:set ts=8 sw=8 sts=8 noet:
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
@ -224,3 +225,12 @@ installers-%:
ifeq (WINNT,$(OS_ARCH))
@$(MAKE) repackage-win32-installer-$*
endif
ifdef MOZ_UPDATER
libs:: $(addprefix $(LOCALE_SRCDIR)/,updater/updater.ini)
ifeq ($(OS_ARCH),WINNT)
iconv -f UTF-8 -t $(WIN_INSTALLER_CHARSET) $< > $(FINAL_TARGET)/updater.ini
else
$(INSTALL) $^ $(FINAL_TARGET)
endif
endif

View File

@ -0,0 +1,4 @@
; This file is in the UTF-8 encoding
[Strings]
Title=Updating Firefox
Info=Applying updates to Firefox. Please do not interrupt this process.

View File

@ -65,6 +65,7 @@
#
# Other common MOZ_CO_MODULE options include the following:
# mozilla/other-licenses/libart_lgpl
# mozilla/other-licenses/bsdiff
# mozilla/tools/codesighs
#
# Other targets (gmake -f client.mk [targets...]),
@ -102,6 +103,8 @@ MODULES_core := \
SeaMonkeyAll \
mozilla/ipc/ipcd \
mozilla/modules/libpr0n \
mozilla/modules/libmar \
mozilla/modules/libbz2 \
mozilla/accessible \
mozilla/security/manager \
mozilla/toolkit \

View File

@ -123,6 +123,7 @@ XPCOM_USE_LEA = @XPCOM_USE_LEA@
JS_ULTRASPARC_OPTS = @JS_ULTRASPARC_OPTS@
MOZ_ENABLE_POSTSCRIPT = @MOZ_ENABLE_POSTSCRIPT@
MOZ_INSTALLER = @MOZ_INSTALLER@
MOZ_UPDATER = @MOZ_UPDATER@
MOZ_NO_ACTIVEX_SUPPORT = @MOZ_NO_ACTIVEX_SUPPORT@
MOZ_ACTIVEX_SCRIPTING_SUPPORT = @MOZ_ACTIVEX_SCRIPTING_SUPPORT@
XPC_IDISPATCH_SUPPORT = @MOZ_ACTIVEX_SCRIPTING_SUPPORT@

View File

@ -4834,6 +4834,19 @@ if test -z "$MOZ_XPINSTALL"; then
fi
AC_SUBST(MOZ_INSTALLER)
dnl ========================================================
dnl Updater
dnl ========================================================
if test "$MOZ_XUL_APP"; then
MOZ_UPDATER=1
fi
MOZ_ARG_DISABLE_BOOL(updater,
[ --disable-updater Disable building of updater],
MOZ_UPDATER=,
MOZ_UPDATER=1 )
AC_SUBST(MOZ_UPDATER)
dnl ========================================================
dnl ActiveX
dnl ========================================================

View File

@ -177,3 +177,12 @@ installers-%:
ifeq (WINNT,$(OS_ARCH))
@$(MAKE) repackage-win32-installer-$*
endif
ifdef MOZ_UPDATER
libs:: $(addprefix $(LOCALE_SRCDIR)/,updater/updater.ini)
ifeq ($(OS_ARCH),WINNT)
iconv -f UTF-8 -t $(WIN_INSTALLER_CHARSET) $< > $(FINAL_TARGET)/updater.ini
else
$(INSTALL) $^ $(FINAL_TARGET)
endif
endif

View File

@ -0,0 +1,4 @@
; This file is in the UTF-8 encoding
[Strings]
Title=Updating Thunderbird
Info=Applying updates to Thunderbird. Please do not interrupt this process.

View File

@ -44,6 +44,10 @@ include $(DEPTH)/config/autoconf.mk
MODULE = extensions
ifdef MOZ_UPDATER
DIRS = updater
endif
EXTRA_COMPONENTS = nsUpdateService.js
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,85 @@
# vim:set ts=8 sw=8 sts=8 noet:
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla Toolkit Application Update.
#
# The Initial Developer of the Original Code is
# Benjamin Smedberg <benjamin@smedbergs.us>
# Portions created by the Initial Developer are Copyright (C) 2005
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
CPPSRCS = \
updater.cpp \
bspatch.cpp \
archivereader.cpp \
$(NULL)
PROGRAM = updater$(BIN_SUFFIX)
REQUIRES = libmar libbz2
LIBS += \
$(DIST)/lib/$(LIB_PREFIX)mar.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)bz2.$(LIB_SUFFIX) \
$(NULL)
ifeq ($(OS_ARCH),WINNT)
HAVE_PROGRESSUI = 1
RCINCLUDE = updater.rc
CPPSRCS += progressui_win.cpp
OS_LIBS += $(call EXPAND_LIBNAME,comctl32 ws2_32)
ifndef GNU_CC
RCFLAGS += -I$(srcdir)
else
RCFLAGS += --include-dir $(srcdir)
endif
endif
ifneq ($(MOZ_ENABLE_GTK2),)
HAVE_PROGRESSUI = 1
CPPSRCS += progressui_gtk.cpp
OS_CXXFLAGS += $(TK_CFLAGS)
OS_LIBS += $(TK_LIBS)
endif
ifndef HAVE_PROGRESSUI
CPPSRCS += progressui_null.cpp
endif
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,146 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Darin Fisher <darin@meer.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <string.h>
#include <fcntl.h>
#include "bzlib.h"
#include "archivereader.h"
#include "errors.h"
#if defined(XP_UNIX)
# include <sys/types.h>
#elif defined(XP_WIN)
# include <io.h>
#endif
int
ArchiveReader::Open(const char *path)
{
if (mArchive)
Close();
mArchive = mar_open(path);
if (!mArchive)
return IO_ERROR;
return OK;
}
void
ArchiveReader::Close()
{
if (mArchive) {
mar_close(mArchive);
mArchive = NULL;
}
}
int
ArchiveReader::ExtractFile(const char *name, const char *dest)
{
const MarItem *item = mar_find_item(mArchive, name);
if (!item)
return IO_ERROR;
#ifdef XP_WIN
int fd = _open(dest, _O_BINARY|_O_CREAT|_O_TRUNC|_O_WRONLY, item->flags);
#else
int fd = creat(dest, item->flags);
#endif
if (fd == -1)
return IO_ERROR;
FILE *fp = fdopen(fd, "wb");
if (!fp)
return IO_ERROR;
int rv = ExtractItemToStream(item, fp);
fclose(fp);
return rv;
}
int
ArchiveReader::ExtractItemToStream(const MarItem *item, FILE *fp)
{
/* decompress the data chunk by chunk */
char inbuf[BUFSIZ], outbuf[BUFSIZ];
bz_stream strm;
int offset, inlen, ret = OK;
memset(&strm, 0, sizeof(strm));
if (BZ2_bzDecompressInit(&strm, 0, 0) != BZ_OK)
return UNEXPECTED_ERROR;
offset = 0;
for (;;) {
if (offset < (int) item->length && strm.avail_in == 0) {
inlen = mar_read(mArchive, item, offset, inbuf, BUFSIZ);
if (inlen <= 0)
return -1;
offset += inlen;
strm.next_in = inbuf;
strm.avail_in = inlen;
}
strm.next_out = outbuf;
strm.avail_out = BUFSIZ;
ret = BZ2_bzDecompress(&strm);
if (ret != BZ_OK && ret != BZ_STREAM_END) {
ret = IO_ERROR;
break;
}
if (strm.avail_out < BUFSIZ) {
if (fwrite(outbuf, BUFSIZ - strm.avail_out, 1, fp) != 1) {
ret = IO_ERROR;
break;
}
}
if (ret == BZ_STREAM_END) {
ret = OK;
break;
}
}
BZ2_bzDecompressEnd(&strm);
return ret;
}

View File

@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Darin Fisher <darin@meer.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef ArchiveReader_h__
#define ArchiveReader_h__
#include <stdio.h>
#include "mar.h"
// This class provides an API to extract files from an update archive.
class ArchiveReader
{
public:
ArchiveReader() : mArchive(NULL) {}
~ArchiveReader() { Close(); }
int Open(const char *path);
void Close();
int ExtractFile(const char *item, const char *destination);
private:
int ExtractItemToStream(const MarItem *item, FILE *fp);
MarFile *mArchive;
};
#endif // ArchiveReader_h__

View File

@ -0,0 +1,189 @@
/*-
* Copyright 2003,2004 Colin Percival
* All rights reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted providing that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* Changelog:
* 2005-04-26 - Define the header as a C structure, add a CRC32 checksum to
* the header, and make all the types 32-bit.
* --Benjamin Smedberg <benjamin@smedbergs.us>
*/
#include "bspatch.h"
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <limits.h>
#if defined(XP_UNIX)
# include <unistd.h>
#elif defined(XP_WIN)
# include <io.h>
#endif
#ifdef XP_WIN
#include <winsock2.h>
#else
#include <arpa/inet.h>
#endif
#ifndef SSIZE_MAX
# define SSIZE_MAX LONG_MAX
#endif
int
MBS_ReadHeader(int fd, MBSPatchHeader *header)
{
int s = read(fd, header, sizeof(MBSPatchHeader));
if (s != sizeof(MBSPatchHeader))
return BSP_ERROR_IO;
header->slen = ntohl(header->slen);
header->scrc32 = ntohl(header->scrc32);
header->dlen = ntohl(header->dlen);
header->cblen = ntohl(header->cblen);
header->difflen = ntohl(header->difflen);
header->extralen = ntohl(header->extralen);
struct stat hs;
s = fstat(fd, &hs);
if (s)
return BSP_ERROR_IO;
if (memcmp(header->tag, "MBDIFF10", 8) != 0)
return BSP_ERROR_CORRUPT;
if (sizeof(MBSPatchHeader) +
header->cblen +
header->difflen +
header->extralen != PRUint32(hs.st_size))
return BSP_ERROR_CORRUPT;
return BSP_OK;
}
int
MBS_ApplyPatch(const MBSPatchHeader *header, int patchfd,
unsigned char *fbuffer, int filefd)
{
unsigned char *fbufend = fbuffer + header->slen;
unsigned char *buf = (unsigned char*) malloc(header->cblen +
header->difflen +
header->extralen);
if (!buf)
return BSP_ERROR_NOMEM;
int rv = BSP_OK;
int r = header->cblen + header->difflen + header->extralen;
unsigned char *wb = buf;
while (r) {
int c = read(patchfd, wb, (r > SSIZE_MAX) ? SSIZE_MAX : r);
if (c < 0) {
rv = BSP_ERROR_IO;
goto end;
}
r -= c;
if (c == 0 && r) {
rv = BSP_ERROR_CORRUPT;
goto end;
}
}
{
MBSPatchTriple *ctrlsrc = (MBSPatchTriple*) buf;
unsigned char *diffsrc = buf + header->cblen;
unsigned char *extrasrc = diffsrc + header->difflen;
MBSPatchTriple *ctrlend = (MBSPatchTriple*) diffsrc;
unsigned char *diffend = extrasrc;
unsigned char *extraend = extrasrc + header->extralen;
do {
ctrlsrc->x = ntohl(ctrlsrc->x);
ctrlsrc->y = ntohl(ctrlsrc->y);
ctrlsrc->z = ntohl(ctrlsrc->z);
#ifdef DEBUG_bsmedberg
printf("Applying block:\n"
" x: %u\n"
" y: %u\n"
" z: %i\n",
ctrlsrc->x,
ctrlsrc->y,
ctrlsrc->z);
#endif
/* Add x bytes from oldfile to x bytes from the diff block */
if (fbuffer + ctrlsrc->x > fbufend ||
diffsrc + ctrlsrc->x > diffend) {
rv = BSP_ERROR_CORRUPT;
goto end;
}
for (PRUint32 i = 0; i < ctrlsrc->x; ++i) {
diffsrc[i] += fbuffer[i];
}
if ((PRUint32) write(filefd, diffsrc, ctrlsrc->x) != ctrlsrc->x) {
rv = BSP_ERROR_IO;
goto end;
}
fbuffer += ctrlsrc->x;
diffsrc += ctrlsrc->x;
/* Copy y bytes from the extra block */
if (extrasrc + ctrlsrc->y > extraend) {
rv = BSP_ERROR_CORRUPT;
goto end;
}
if ((PRUint32) write(filefd, extrasrc, ctrlsrc->y) != ctrlsrc->y) {
rv = BSP_ERROR_IO;
goto end;
}
extrasrc += ctrlsrc->y;
/* "seek" forwards in oldfile by z bytes */
if (fbuffer + ctrlsrc->z > fbufend) {
rv = BSP_ERROR_CORRUPT;
goto end;
}
fbuffer += ctrlsrc->z;
/* and on to the next control block */
++ctrlsrc;
} while (ctrlsrc < ctrlend);
}
end:
free(buf);
return rv;
}

View File

@ -0,0 +1,99 @@
/*-
* Copyright 2003,2004 Colin Percival
* All rights reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted providing that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* Changelog:
* 2005-04-26 - Define the header as a C structure, add a CRC32 checksum to
* the header, and make all the types 32-bit.
* --Benjamin Smedberg <benjamin@smedbergs.us>
*/
#ifndef bspatch_h__
#define bspatch_h__
// We use the NSPR types, but we don't link with NSPR
#include "prtypes.h"
/* return values for bspatch */
#define BSP_OK 0
#define BSP_ERROR_IO -1
#define BSP_ERROR_CORRUPT -2
#define BSP_ERROR_NOMEM -3
typedef struct MBSPatchHeader_ {
/* "MBDIFF10" */
char tag[8];
/* Length of the file to be patched */
PRUint32 slen;
/* CRC32 of the file to be patched */
PRUint32 scrc32;
/* Length of the result file */
PRUint32 dlen;
/* Length of the control block in bytes */
PRUint32 cblen;
/* Length of the diff block in bytes */
PRUint32 difflen;
/* Length of the extra block in bytes */
PRUint32 extralen;
/* Control block (MBSPatchTriple[]) */
/* Diff block (binary data) */
/* Extra block (binary data) */
} MBSPatchHeader;
/**
* Read the header of a patch file into the MBSPatchHeader structure.
*
* @param fd Must have been opened for reading, and be at the beginning
* of the file.
*/
int MBS_ReadHeader(int fd, MBSPatchHeader *header);
/**
* Apply a patch. This method does not validate the checksum of the original
* file: client code should validate the checksum before calling this method.
*
* @param patchfd Must have been processed by MBS_ReadHeader
* @param fbuffer The original file read into a memory buffer of length
* header->slen.
* @param filefd Must have been opened for writing. Should be truncated
* to header->dlen if it is an existing file. The offset
* should be at the beginning of the file.
*/
int MBS_ApplyPatch(const MBSPatchHeader *header, int patchfd,
unsigned char *fbuffer, int filefd);
typedef struct MBSPatchTriple_ {
PRUint32 x; /* add x bytes from oldfile to x bytes from the diff block */
PRUint32 y; /* copy y bytes from the extra block */
PRInt32 z; /* seek forwards in oldfile by z bytes */
} MBSPatchTriple;
#endif // bspatch_h__

View File

@ -0,0 +1,52 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Darin Fisher <darin@meer.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef Errors_h__
#define Errors_h__
#define OK 0
#define MEM_ERROR 1
#define IO_ERROR 2
#define USAGE_ERROR 3
#define CRC_ERROR 4
#define PARSE_ERROR 5
#define SOURCE_ERROR 6
#define TARGET_ERROR 7
#define UNEXPECTED_ERROR 8
#endif // Errors_h__

View File

@ -0,0 +1,54 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Darin Fisher <darin@meer.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef PROGRESSUI_H__
#define PROGRESSUI_H__
// Called to perform any initialization of the widget toolkit
int InitProgressUI(int *argc, char ***argv);
// Called on the main thread at startup
int ShowProgressUI();
// May be called from any thread
void QuitProgressUI();
// May be called from any thread: progress is a number between 0 and 100
void UpdateProgressUI(float progress);
#endif // PROGRESSUI_H__

View File

@ -0,0 +1,191 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Darin Fisher <darin@meer.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <stdio.h>
#include <gtk/gtk.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#define TIMER_INTERVAL 100
#define MAX_TEXT_LEN 200
static float sProgressVal; // between 0 and 100
static gboolean sQuit = FALSE;
static guint sTimerID;
static GtkWidget *sWin;
static GtkWidget *sLabel;
static GtkWidget *sProgressBar;
static const char *sProgramPath;
// stack based FILE wrapper to ensure that fclose is called.
class AutoFILE {
public:
AutoFILE(FILE *fp) : fp_(fp) {}
~AutoFILE() { if (fp_) fclose(fp_); }
operator FILE *() { return fp_; }
private:
FILE *fp_;
};
// very basic parser for updater.ini
static gboolean
ReadStrings(char title[MAX_TEXT_LEN], char info[MAX_TEXT_LEN])
{
char path[PATH_MAX];
snprintf(path, sizeof(path), "%s.ini", sProgramPath);
AutoFILE fp = fopen(path, "r");
if (!fp)
return FALSE;
if (!fgets(title, MAX_TEXT_LEN, fp))
return FALSE;
if (!fgets(title, MAX_TEXT_LEN, fp))
return FALSE;
if (!fgets(info, MAX_TEXT_LEN, fp))
return FALSE;
// trim trailing newline character and leading 'key='
char *strings[] = {
title, info, NULL
};
for (char **p = strings; *p; ++p) {
int len = strlen(*p);
if (len)
(*p)[len - 1] = '\0';
char *eq = strchr(*p, '=');
if (!eq)
return FALSE;
memmove(*p, eq + 1, len - (eq - *p + 1));
}
return TRUE;
}
static gboolean
UpdateDialog(gpointer data)
{
if (sQuit)
{
gtk_widget_hide(sWin);
gtk_main_quit();
}
float progress = sProgressVal;
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(sProgressBar),
progress / 100.0);
return TRUE;
}
static void
DoNothing()
{
}
int
InitProgressUI(int *pargc, char ***pargv)
{
sProgramPath = (*pargv)[0];
gtk_init(pargc, pargv);
return 0;
}
int
ShowProgressUI()
{
// Only show the Progress UI if the process is taking significant time.
// Here we measure significant time as taking more than one second.
usleep(500000);
if (sQuit || sProgressVal > 50.0f)
return 0;
char titleText[MAX_TEXT_LEN], infoText[MAX_TEXT_LEN];
if (!ReadStrings(titleText, infoText))
return -1;
sWin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
if (!sWin)
return -1;
gtk_window_set_title(GTK_WINDOW(sWin), titleText);
gtk_window_set_type_hint(GTK_WINDOW(sWin), GDK_WINDOW_TYPE_HINT_DIALOG);
gtk_window_set_position(GTK_WINDOW(sWin), GTK_WIN_POS_CENTER_ALWAYS);
gtk_window_set_resizable(GTK_WINDOW(sWin), FALSE);
gtk_window_set_decorated(GTK_WINDOW(sWin), FALSE);
gtk_signal_connect(GTK_OBJECT(sWin), "delete", DoNothing, NULL);
GtkWidget *vbox = gtk_vbox_new(TRUE, 6);
sLabel = gtk_label_new(infoText);
gtk_misc_set_alignment(GTK_MISC(sLabel), 0.0f, 0.0f);
sProgressBar = gtk_progress_bar_new();
gtk_box_pack_start(GTK_BOX(vbox), sLabel, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), sProgressBar, TRUE, TRUE, 0);
sTimerID = g_timeout_add(TIMER_INTERVAL, UpdateDialog, NULL);
gtk_container_set_border_width(GTK_CONTAINER(sWin), 10);
gtk_container_add(GTK_CONTAINER(sWin), vbox);
gtk_widget_show_all(sWin);
gtk_main();
return 0;
}
// Called on a background thread
void
QuitProgressUI()
{
sQuit = TRUE;
}
// Called on a background thread
void
UpdateProgressUI(float progress)
{
sProgressVal = progress; // 32-bit writes are atomic
}

View File

@ -0,0 +1,57 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Darin Fisher <darin@meer.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "progressui.h"
int InitProgressUI(int *argc, char ***argv)
{
return 0;
}
int ShowProgressUI()
{
return 0;
}
void QuitProgressUI()
{
}
void UpdateProgressUI(float progress)
{
}

View File

@ -0,0 +1,196 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Darin Fisher <darin@meer.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <stdio.h>
#include <windows.h>
#include <commctrl.h>
#include <process.h>
#include "resource.h"
#define TIMER_ID 1
#define TIMER_INTERVAL 100
static float sProgress; // between 0 and 100
static BOOL sQuit = FALSE;
static BOOL
GetStringsFile(char filename[MAX_PATH])
{
if (!GetModuleFileName(NULL, filename, MAX_PATH))
return FALSE;
char *dot = strrchr(filename, '.');
if (!dot || stricmp(dot + 1, "exe"))
return FALSE;
strcpy(dot + 1, "ini");
return TRUE;
}
static void
UpdateDialog(HWND hDlg)
{
int pos = int(sProgress + 0.5f);
SendMessage(GetDlgItem(hDlg, IDC_PROGRESS), PBM_SETPOS, pos, 0L);
}
// The code in this function is from MSDN:
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/usingdialogboxes.asp
static void
CenterDialog(HWND hDlg)
{
RECT rc, rcOwner, rcDlg;
// Get the owner window and dialog box rectangles.
HWND desktop = GetDesktopWindow();
GetWindowRect(desktop, &rcOwner);
GetWindowRect(hDlg, &rcDlg);
CopyRect(&rc, &rcOwner);
// Offset the owner and dialog box rectangles so that
// right and bottom values represent the width and
// height, and then offset the owner again to discard
// space taken up by the dialog box.
OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
OffsetRect(&rc, -rc.left, -rc.top);
OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
// The new position is the sum of half the remaining
// space and the owner's original position.
SetWindowPos(hDlg,
HWND_TOP,
rcOwner.left + (rc.right / 2),
rcOwner.top + (rc.bottom / 2),
0, 0, // ignores size arguments
SWP_NOSIZE);
}
static void
SetItemText(HWND hwnd, const char *key, const char *ini)
{
char text[512];
if (!GetPrivateProfileString("Strings", key, NULL, text, sizeof(text), ini))
return;
SetWindowText(hwnd, text);
}
static void
InitDialog(HWND hDlg)
{
char filename[MAX_PATH];
if (!GetStringsFile(filename))
return;
SetItemText(hDlg, "Title", filename);
SetItemText(GetDlgItem(hDlg, IDC_INFO), "Info", filename);
SendMessage(GetDlgItem(hDlg, IDC_PROGRESS), PBM_SETRANGE, 0,
MAKELPARAM(0, 100));
CenterDialog(hDlg); // make dialog appear in the center of the screen
SetTimer(hDlg, TIMER_ID, TIMER_INTERVAL, NULL);
}
// Message handler for about box.
static LRESULT CALLBACK
DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
InitDialog(hDlg);
return TRUE;
case WM_TIMER:
if (sQuit)
EndDialog(hDlg, 0);
else
UpdateDialog(hDlg);
return TRUE;
case WM_COMMAND:
return TRUE;
}
return FALSE;
}
int
InitProgressUI(int *argc, char ***argv)
{
return 0;
}
int
ShowProgressUI()
{
// Only show the Progress UI if the process is taking significant time.
// Here we measure significant time as taking more than one second.
Sleep(500);
if (sQuit || sProgress > 50.0f)
return 0;
INITCOMMONCONTROLSEX icc = {
sizeof(INITCOMMONCONTROLSEX),
ICC_PROGRESS_CLASS
};
InitCommonControlsEx(&icc);
DialogBox(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDD_DIALOG), NULL,
(DLGPROC) DialogProc);
return 0;
}
void
QuitProgressUI()
{
sQuit = TRUE;
}
void
UpdateProgressUI(float progress)
{
sProgress = progress; // 32-bit writes are atomic
}

View File

@ -0,0 +1,18 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by updater.rc
//
#define IDD_DIALOG 101
#define IDC_PROGRESS 1000
#define IDC_INFO 1002
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1003
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="Updater"
type="win32"
/>
<description>Updater</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>

View File

@ -0,0 +1,104 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// RT_MANIFEST
//
1 RT_MANIFEST "updater.exe.manifest"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DIALOG DIALOGEX 0, 0, 253, 46
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER,7,29,239,
10
LTEXT "",IDC_INFO,7,7,239,17
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 246
TOPMARGIN, 7
BOTTOMMARGIN, 39
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED