From 161fb9be8edf37cf52c3d223214d81e4cbb7a787 Mon Sep 17 00:00:00 2001
From: Efraim Flashner <efraim@flashner.co.il>
Date: Thu, 1 Dec 2016 10:47:29 +0200
Subject: gnu: nasm: Switch patch to phase.

* gnu/packages/assembly.scm (nasm)[source]: Remove patch.
[arguments]: Disable ps and pdf doc outputs in new phase.
* gnu/packages/patches/nasm-no-ps-pdf.patch: Remove file.
* gnu/local.mk (dist_patch_DATA): Remove it.
---
 gnu/packages/patches/nasm-no-ps-pdf.patch | 20 --------------------
 1 file changed, 20 deletions(-)
 delete mode 100644 gnu/packages/patches/nasm-no-ps-pdf.patch

(limited to 'gnu/packages/patches')

diff --git a/gnu/packages/patches/nasm-no-ps-pdf.patch b/gnu/packages/patches/nasm-no-ps-pdf.patch
deleted file mode 100644
index b03b57a6ed..0000000000
--- a/gnu/packages/patches/nasm-no-ps-pdf.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-Avoid building PS and PDF docs, which do not build bit-reproducible.  NASM
-already installs doc in info and html.
-
---- nasm-2.12.01/doc/Makefile.in.orig	2016-06-21 18:02:59.483484829 +0200
-+++ nasm-2.12.01/doc/Makefile.in	2016-06-21 18:03:46.700151410 +0200
-@@ -27,7 +27,7 @@
- PS2PDF          = @PS2PDF@		# Part of GhostScript
- 
- SRCS		= nasmdoc.src inslist.src changes.src
--OUT		= info html nasmdoc.txt nasmdoc.ps nasmdoc.pdf
-+OUT		= info html nasmdoc.txt
- 
- # exports
- export srcdir
-@@ -100,4 +100,4 @@
- 	$(INSTALL_DATA) info/* $(INSTALLROOT)$(infodir)
- 	mkdir -p $(INSTALLROOT)$(docdir)/html
- 	$(INSTALL_DATA) html/* $(INSTALLROOT)$(docdir)/html
--	$(INSTALL_DATA) nasmdoc.ps nasmdoc.pdf nasmdoc.txt $(INSTALLROOT)$(docdir)
-+	$(INSTALL_DATA) nasmdoc.txt $(INSTALLROOT)$(docdir)
-- 
cgit 1.4.1


From 1742132fb1bed2b9b97d4f25a3819a243845ce3a Mon Sep 17 00:00:00 2001
From: Efraim Flashner <efraim@flashner.co.il>
Date: Thu, 1 Dec 2016 12:53:30 +0200
Subject: gnu: gst-plugins-good: Update to 1.10.2.

* gnu/packages/gstreamer.scm (gst-plugins-good): Update to 1.10.2.
[source]: Remove patches.
* gnu/packages/patches/gst-plugins-good-fix-crashes.patch,
gnu/packages/patches/gst-plugins-good-fix-invalid-read.patch,
gnu/packages/patches/gst-plugins-good-fix-signedness.patch,
gnu/packages/patches/gst-plugins-good-flic-bounds-check.patch: Remove files.
* gnu/local.mk (dist_patch_DATA): Remove them.
---
 gnu/local.mk                                       |    4 -
 gnu/packages/gstreamer.scm                         |    8 +-
 .../patches/gst-plugins-good-fix-crashes.patch     | 1047 --------------------
 .../gst-plugins-good-fix-invalid-read.patch        |   37 -
 .../patches/gst-plugins-good-fix-signedness.patch  |   58 --
 .../gst-plugins-good-flic-bounds-check.patch       |  319 ------
 6 files changed, 2 insertions(+), 1471 deletions(-)
 delete mode 100644 gnu/packages/patches/gst-plugins-good-fix-crashes.patch
 delete mode 100644 gnu/packages/patches/gst-plugins-good-fix-invalid-read.patch
 delete mode 100644 gnu/packages/patches/gst-plugins-good-fix-signedness.patch
 delete mode 100644 gnu/packages/patches/gst-plugins-good-flic-bounds-check.patch

(limited to 'gnu/packages/patches')

diff --git a/gnu/local.mk b/gnu/local.mk
index 0f70a083b2..0d019f73db 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -593,10 +593,6 @@ dist_patch_DATA =						\
   %D%/packages/patches/grub-gets-undeclared.patch		\
   %D%/packages/patches/grub-freetype.patch			\
   %D%/packages/patches/gsl-test-i686.patch			\
-  %D%/packages/patches/gst-plugins-good-fix-crashes.patch	\
-  %D%/packages/patches/gst-plugins-good-fix-invalid-read.patch	\
-  %D%/packages/patches/gst-plugins-good-fix-signedness.patch	\
-  %D%/packages/patches/gst-plugins-good-flic-bounds-check.patch	\
   %D%/packages/patches/guile-1.8-cpp-4.5.patch			\
   %D%/packages/patches/guile-arm-fixes.patch			\
   %D%/packages/patches/guile-default-utf8.patch			\
diff --git a/gnu/packages/gstreamer.scm b/gnu/packages/gstreamer.scm
index 2b6f0e246a..faccf44956 100644
--- a/gnu/packages/gstreamer.scm
+++ b/gnu/packages/gstreamer.scm
@@ -201,20 +201,16 @@ for the GStreamer multimedia library.")
 (define-public gst-plugins-good
   (package
     (name "gst-plugins-good")
-    (version "1.10.1")
+    (version "1.10.2")
     (source
      (origin
       (method url-fetch)
       (uri (string-append
             "https://gstreamer.freedesktop.org/src/" name "/"
             name "-" version ".tar.xz"))
-      (patches (search-patches "gst-plugins-good-flic-bounds-check.patch"
-                               "gst-plugins-good-fix-signedness.patch"
-                               "gst-plugins-good-fix-invalid-read.patch"
-                               "gst-plugins-good-fix-crashes.patch"))
       (sha256
        (base32
-        "1hkcap9l2603266gyi6jgvx7frbvfmb7xhfhjizbczy1wykjwr57"))))
+        "04rksbhjj2yz32g523cfabwqn2s3byd94dpbxghxr0p9ridk53qr"))))
     (build-system gnu-build-system)
     (inputs
      `(("aalib" ,aalib)
diff --git a/gnu/packages/patches/gst-plugins-good-fix-crashes.patch b/gnu/packages/patches/gst-plugins-good-fix-crashes.patch
deleted file mode 100644
index c36a595608..0000000000
--- a/gnu/packages/patches/gst-plugins-good-fix-crashes.patch
+++ /dev/null
@@ -1,1047 +0,0 @@
-Fixes upstream bug #774859 (flic decoder: Invalid memory read in
-flx_decode_chunks):
-
-https://bugzilla.gnome.org/show_bug.cgi?id=774859
-
-Patch copied from upstream source repository:
-
-https://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=be670f0daf67304fb92c76aa09c30cae0bfd1fe4
-
-From be670f0daf67304fb92c76aa09c30cae0bfd1fe4 Mon Sep 17 00:00:00 2001
-From: Matthew Waters <matthew@centricular.com>
-Date: Wed, 23 Nov 2016 07:09:06 +1100
-Subject: [PATCH] flxdec: rewrite logic based on GstByteReader/Writer
-
-Solves overreading/writing the given arrays and will error out if the
-streams asks to do that.
-
-Also does more error checking that the stream is valid and won't
-overrun any allocated arrays.  Also mitigate integer overflow errors
-calculating allocation sizes.
-
-https://bugzilla.gnome.org/show_bug.cgi?id=774859
----
- gst/flx/flx_color.c |   1 -
- gst/flx/flx_fmt.h   |  72 -------
- gst/flx/gstflxdec.c | 610 ++++++++++++++++++++++++++++++++++++----------------
- gst/flx/gstflxdec.h |   4 +-
- 4 files changed, 427 insertions(+), 260 deletions(-)
-
-diff --git a/gst/flx/flx_color.c b/gst/flx/flx_color.c
-index 047bfdf..3a58135 100644
---- a/gst/flx/flx_color.c
-+++ b/gst/flx/flx_color.c
-@@ -101,7 +101,6 @@ flx_set_palette_vector (FlxColorSpaceConverter * flxpal, guint start, guint num,
-   } else {
-     memcpy (&flxpal->palvec[start * 3], newpal, grab * 3);
-   }
--
- }
- 
- void
-diff --git a/gst/flx/flx_fmt.h b/gst/flx/flx_fmt.h
-index 9ab31ba..abff200 100644
---- a/gst/flx/flx_fmt.h
-+++ b/gst/flx/flx_fmt.h
-@@ -123,78 +123,6 @@ typedef struct _FlxFrameType
- } FlxFrameType;
- #define FlxFrameTypeSize 10
- 
--#if G_BYTE_ORDER == G_BIG_ENDIAN 
--#define LE_TO_BE_16(i16) ((guint16) (((i16) << 8) | ((i16) >> 8)))
--#define LE_TO_BE_32(i32) \
--    (((guint32) (LE_TO_BE_16((guint16) (i32))) << 16) | (LE_TO_BE_16((i32) >> 16)))
--
--#define FLX_FRAME_TYPE_FIX_ENDIANNESS(frm_type_p) \
--    do { \
--     (frm_type_p)->chunks = LE_TO_BE_16((frm_type_p)->chunks); \
--     (frm_type_p)->delay = LE_TO_BE_16((frm_type_p)->delay); \
--    } while(0)
--
--#define FLX_HUFFMAN_TABLE_FIX_ENDIANNESS(hffmn_table_p) \
--    do { \
--     (hffmn_table_p)->codelength = \
--	LE_TO_BE_16((hffmn_table_p)->codelength); \
--     (hffmn_table_p)->numcodes = LE_TO_BE_16((hffmn_table_p)->numcodes); \
--    } while(0)
--
--#define FLX_SEGMENT_TABLE_FIX_ENDIANNESS(sgmnt_table_p) \
--     ((sgmnt_table_p)->segments = LE_TO_BE_16((sgmnt_table_p)->segments))
--
--#define FLX_PREFIX_CHUNK_FIX_ENDIANNESS(prfx_chnk_p) \
--    do { \
--     (prfx_chnk_p)->chunks = LE_TO_BE_16((prfx_chnk_p)->chunks); \
--    } while(0)
--
--#define FLX_FRAME_CHUNK_FIX_ENDIANNESS(frm_chnk_p) \
--    do { \
--     (frm_chnk_p)->size = LE_TO_BE_32((frm_chnk_p)->size); \
--     (frm_chnk_p)->id = LE_TO_BE_16((frm_chnk_p)->id); \
--    } while(0)
--
--#define FLX_HDR_FIX_ENDIANNESS(hdr_p) \
--    do { \
--     (hdr_p)->size = LE_TO_BE_32((hdr_p)->size); \
--     (hdr_p)->type = LE_TO_BE_16((hdr_p)->type); \
--     (hdr_p)->frames = LE_TO_BE_16((hdr_p)->frames); \
--     (hdr_p)->width = LE_TO_BE_16((hdr_p)->width); \
--     (hdr_p)->height = LE_TO_BE_16((hdr_p)->height); \
--     (hdr_p)->depth = LE_TO_BE_16((hdr_p)->depth); \
--     (hdr_p)->flags = LE_TO_BE_16((hdr_p)->flags); \
--     (hdr_p)->speed = LE_TO_BE_32((hdr_p)->speed); \
--     (hdr_p)->reserved1 = LE_TO_BE_16((hdr_p)->reserved1); \
--     (hdr_p)->created = LE_TO_BE_32((hdr_p)->created); \
--     (hdr_p)->creator = LE_TO_BE_32((hdr_p)->creator); \
--     (hdr_p)->updated = LE_TO_BE_32((hdr_p)->updated); \
--     (hdr_p)->updater = LE_TO_BE_32((hdr_p)->updater); \
--     (hdr_p)->aspect_dx = LE_TO_BE_16((hdr_p)->aspect_dx); \
--     (hdr_p)->aspect_dy = LE_TO_BE_16((hdr_p)->aspect_dy); \
--     (hdr_p)->ext_flags = LE_TO_BE_16((hdr_p)->ext_flags); \
--     (hdr_p)->keyframes = LE_TO_BE_16((hdr_p)->keyframes); \
--     (hdr_p)->totalframes = LE_TO_BE_16((hdr_p)->totalframes); \
--     (hdr_p)->req_memory = LE_TO_BE_32((hdr_p)->req_memory); \
--     (hdr_p)->max_regions = LE_TO_BE_16((hdr_p)->max_regions); \
--     (hdr_p)->transp_num = LE_TO_BE_16((hdr_p)->transp_num); \
--     (hdr_p)->oframe1 = LE_TO_BE_32((hdr_p)->oframe1); \
--     (hdr_p)->oframe2 = LE_TO_BE_32((hdr_p)->oframe2); \
--    } while(0)
--#else
--
--#define LE_TO_BE_16(i16) ((i16))
--#define LE_TO_BE_32(i32) ((i32))
--
--#define FLX_FRAME_TYPE_FIX_ENDIANNESS(frm_type_p)
--#define FLX_HUFFMAN_TABLE_FIX_ENDIANNESS(hffmn_table_p)
--#define FLX_SEGMENT_TABLE_FIX_ENDIANNESS(sgmnt_table_p)
--#define FLX_PREFIX_CHUNK_FIX_ENDIANNESS(prfx_chnk_p)
--#define FLX_FRAME_CHUNK_FIX_ENDIANNESS(frm_chnk_p)
--#define FLX_HDR_FIX_ENDIANNESS(hdr_p)
--
--#endif /* G_BYTE_ORDER == G_BIG_ENDIAN */
--
- G_END_DECLS
- 
- #endif /* __GST_FLX_FMT_H__ */
-diff --git a/gst/flx/gstflxdec.c b/gst/flx/gstflxdec.c
-index a237976..aa1bed5 100644
---- a/gst/flx/gstflxdec.c
-+++ b/gst/flx/gstflxdec.c
-@@ -1,5 +1,6 @@
- /* GStreamer
-  * Copyright (C) <1999> Erik Walthinsen <omega@temple-baptist.com>
-+ * Copyright (C) <2016> Matthew Waters <matthew@centricular.com>
-  *
-  * This library is free software; you can redistribute it and/or
-  * modify it under the terms of the GNU Library General Public
-@@ -24,6 +25,7 @@
- /*
-  * http://www.coolutils.com/Formats/FLI
-  * http://woodshole.er.usgs.gov/operations/modeling/flc.html
-+ * http://www.compuphase.com/flic.htm
-  */
- 
- #ifdef HAVE_CONFIG_H
-@@ -73,10 +75,14 @@ static GstStateChangeReturn gst_flxdec_change_state (GstElement * element,
- static gboolean gst_flxdec_src_query_handler (GstPad * pad, GstObject * parent,
-     GstQuery * query);
- 
--static void flx_decode_color (GstFlxDec *, guchar *, guchar *, gint);
--static gboolean flx_decode_brun (GstFlxDec *, guchar *, guchar *);
--static gboolean flx_decode_delta_fli (GstFlxDec *, guchar *, guchar *);
--static gboolean flx_decode_delta_flc (GstFlxDec *, guchar *, guchar *);
-+static gboolean flx_decode_color (GstFlxDec * flxdec, GstByteReader * reader,
-+    GstByteWriter * writer, gint scale);
-+static gboolean flx_decode_brun (GstFlxDec * flxdec,
-+    GstByteReader * reader, GstByteWriter * writer);
-+static gboolean flx_decode_delta_fli (GstFlxDec * flxdec,
-+    GstByteReader * reader, GstByteWriter * writer);
-+static gboolean flx_decode_delta_flc (GstFlxDec * flxdec,
-+    GstByteReader * reader, GstByteWriter * writer);
- 
- #define rndalign(off) ((off) + ((off) & 1))
- 
-@@ -204,57 +210,59 @@ gst_flxdec_sink_event_handler (GstPad * pad, GstObject * parent,
- }
- 
- static gboolean
--flx_decode_chunks (GstFlxDec * flxdec, gulong count, guchar * data,
--    guchar * dest)
-+flx_decode_chunks (GstFlxDec * flxdec, gulong n_chunks, GstByteReader * reader,
-+    GstByteWriter * writer)
- {
--  FlxFrameChunk *hdr;
-   gboolean ret = TRUE;
- 
--  g_return_val_if_fail (data != NULL, FALSE);
--
--  while (count--) {
--    hdr = (FlxFrameChunk *) data;
--    FLX_FRAME_CHUNK_FIX_ENDIANNESS (hdr);
--    data += FlxFrameChunkSize;
-+  while (n_chunks--) {
-+    GstByteReader chunk;
-+    guint32 size;
-+    guint16 type;
-+
-+    if (!gst_byte_reader_get_uint32_le (reader, &size))
-+      goto parse_error;
-+    if (!gst_byte_reader_get_uint16_le (reader, &type))
-+      goto parse_error;
-+    GST_LOG_OBJECT (flxdec, "chunk has type 0x%02x size %d", type, size);
-+
-+    if (!gst_byte_reader_get_sub_reader (reader, &chunk,
-+            size - FlxFrameChunkSize)) {
-+      GST_ERROR_OBJECT (flxdec, "Incorrect size in the chunk header");
-+      goto error;
-+    }
- 
--    switch (hdr->id) {
-+    switch (type) {
-       case FLX_COLOR64:
--        flx_decode_color (flxdec, data, dest, 2);
--        data += rndalign (hdr->size) - FlxFrameChunkSize;
-+        ret = flx_decode_color (flxdec, &chunk, writer, 2);
-         break;
- 
-       case FLX_COLOR256:
--        flx_decode_color (flxdec, data, dest, 0);
--        data += rndalign (hdr->size) - FlxFrameChunkSize;
-+        ret = flx_decode_color (flxdec, &chunk, writer, 0);
-         break;
- 
-       case FLX_BRUN:
--        ret = flx_decode_brun (flxdec, data, dest);
--        data += rndalign (hdr->size) - FlxFrameChunkSize;
-+        ret = flx_decode_brun (flxdec, &chunk, writer);
-         break;
- 
-       case FLX_LC:
--        ret = flx_decode_delta_fli (flxdec, data, dest);
--        data += rndalign (hdr->size) - FlxFrameChunkSize;
-+        ret = flx_decode_delta_fli (flxdec, &chunk, writer);
-         break;
- 
-       case FLX_SS2:
--        ret = flx_decode_delta_flc (flxdec, data, dest);
--        data += rndalign (hdr->size) - FlxFrameChunkSize;
-+        ret = flx_decode_delta_flc (flxdec, &chunk, writer);
-         break;
- 
-       case FLX_BLACK:
--        memset (dest, 0, flxdec->size);
-+        ret = gst_byte_writer_fill (writer, 0, flxdec->size);
-         break;
- 
-       case FLX_MINI:
--        data += rndalign (hdr->size) - FlxFrameChunkSize;
-         break;
- 
-       default:
--        GST_WARNING ("Unimplented chunk type: 0x%02x size: %d - skipping",
--            hdr->id, hdr->size);
--        data += rndalign (hdr->size) - FlxFrameChunkSize;
-+        GST_WARNING ("Unimplemented chunk type: 0x%02x size: %d - skipping",
-+            type, size);
-         break;
-     }
- 
-@@ -263,43 +271,60 @@ flx_decode_chunks (GstFlxDec * flxdec, gulong count, guchar * data,
-   }
- 
-   return ret;
-+
-+parse_error:
-+  GST_ERROR_OBJECT (flxdec, "Failed to decode chunk");
-+error:
-+  return FALSE;
- }
- 
- 
--static void
--flx_decode_color (GstFlxDec * flxdec, guchar * data, guchar * dest, gint scale)
-+static gboolean
-+flx_decode_color (GstFlxDec * flxdec, GstByteReader * reader,
-+    GstByteWriter * writer, gint scale)
- {
--  guint packs, count, indx;
-+  guint8 count, indx;
-+  guint16 packs;
- 
--  g_return_if_fail (flxdec != NULL);
--
--  packs = (data[0] + (data[1] << 8));
--
--  data += 2;
-+  if (!gst_byte_reader_get_uint16_le (reader, &packs))
-+    goto error;
-   indx = 0;
- 
--  GST_LOG ("GstFlxDec: cmap packs: %d", packs);
-+  GST_LOG ("GstFlxDec: cmap packs: %d", (guint) packs);
-   while (packs--) {
-+    const guint8 *data;
-+    guint16 actual_count;
-+
-     /* color map index + skip count */
--    indx += *data++;
-+    if (!gst_byte_reader_get_uint8 (reader, &indx))
-+      goto error;
- 
-     /* number of rgb triplets */
--    count = *data++ & 0xff;
--    if (count == 0)
--      count = 256;
-+    if (!gst_byte_reader_get_uint8 (reader, &count))
-+      goto error;
- 
--    GST_LOG ("GstFlxDec: cmap count: %d (indx: %d)", count, indx);
--    flx_set_palette_vector (flxdec->converter, indx, count, data, scale);
-+    actual_count = count == 0 ? 256 : count;
- 
--    data += (count * 3);
-+    if (!gst_byte_reader_get_data (reader, count * 3, &data))
-+      goto error;
-+
-+    GST_LOG_OBJECT (flxdec, "cmap count: %d (indx: %d)", actual_count, indx);
-+    flx_set_palette_vector (flxdec->converter, indx, actual_count,
-+        (guchar *) data, scale);
-   }
-+
-+  return TRUE;
-+
-+error:
-+  GST_ERROR_OBJECT (flxdec, "Error decoding color palette");
-+  return FALSE;
- }
- 
- static gboolean
--flx_decode_brun (GstFlxDec * flxdec, guchar * data, guchar * dest)
-+flx_decode_brun (GstFlxDec * flxdec, GstByteReader * reader,
-+    GstByteWriter * writer)
- {
--  gulong count, lines, row;
--  guchar x;
-+  gulong lines, row;
- 
-   g_return_val_if_fail (flxdec != NULL, FALSE);
- 
-@@ -310,82 +335,125 @@ flx_decode_brun (GstFlxDec * flxdec, guchar * data, guchar * dest)
-      * contain more then 255 RLE packets. we use the frame 
-      * width instead. 
-      */
--    data++;
-+    if (!gst_byte_reader_skip (reader, 1))
-+      goto error;
- 
-     row = flxdec->hdr.width;
-     while (row) {
--      count = *data++;
-+      gint8 count;
-+
-+      if (!gst_byte_reader_get_int8 (reader, &count))
-+        goto error;
-+
-+      if (count <= 0) {
-+        const guint8 *data;
- 
--      if (count > 0x7f) {
-         /* literal run */
--        count = 0x100 - count;
--        if ((glong) row - (glong) count < 0) {
--          GST_ERROR_OBJECT (flxdec, "Invalid BRUN packet detected.");
-+        count = ABS (count);
-+
-+        GST_LOG_OBJECT (flxdec, "have literal run of size %d", count);
-+
-+        if (count > row) {
-+          GST_ERROR_OBJECT (flxdec, "Invalid BRUN line detected. "
-+              "bytes to write exceeds the end of the row");
-           return FALSE;
-         }
-         row -= count;
- 
--        while (count--)
--          *dest++ = *data++;
--
-+        if (!gst_byte_reader_get_data (reader, count, &data))
-+          goto error;
-+        if (!gst_byte_writer_put_data (writer, data, count))
-+          goto error;
-       } else {
--        if ((glong) row - (glong) count < 0) {
--          GST_ERROR_OBJECT (flxdec, "Invalid BRUN packet detected.");
-+        guint8 x;
-+
-+        GST_LOG_OBJECT (flxdec, "have replicate run of size %d", count);
-+
-+        if (count > row) {
-+          GST_ERROR_OBJECT (flxdec, "Invalid BRUN packet detected."
-+              "bytes to write exceeds the end of the row");
-           return FALSE;
-         }
- 
-         /* replicate run */
-         row -= count;
--        x = *data++;
- 
--        while (count--)
--          *dest++ = x;
-+        if (!gst_byte_reader_get_uint8 (reader, &x))
-+          goto error;
-+        if (!gst_byte_writer_fill (writer, x, count))
-+          goto error;
-       }
-     }
-   }
- 
-   return TRUE;
-+
-+error:
-+  GST_ERROR_OBJECT (flxdec, "Failed to decode BRUN packet");
-+  return FALSE;
- }
- 
- static gboolean
--flx_decode_delta_fli (GstFlxDec * flxdec, guchar * data, guchar * dest)
-+flx_decode_delta_fli (GstFlxDec * flxdec, GstByteReader * reader,
-+    GstByteWriter * writer)
- {
--  gulong count, packets, lines, start_line;
--  guchar *start_p, x;
-+  guint16 start_line, lines;
-+  guint line_start_i;
- 
-   g_return_val_if_fail (flxdec != NULL, FALSE);
-   g_return_val_if_fail (flxdec->delta_data != NULL, FALSE);
- 
-   /* use last frame for delta */
--  memcpy (dest, flxdec->delta_data, flxdec->size);
-+  if (!gst_byte_writer_put_data (writer, flxdec->delta_data, flxdec->size))
-+    goto error;
-+
-+  if (!gst_byte_reader_get_uint16_le (reader, &start_line))
-+    goto error;
-+  if (!gst_byte_reader_get_uint16_le (reader, &lines))
-+    goto error;
-+  GST_LOG_OBJECT (flxdec, "height %d start line %d line count %d",
-+      flxdec->hdr.height, start_line, lines);
- 
--  start_line = (data[0] + (data[1] << 8));
--  lines = (data[2] + (data[3] << 8));
-   if (start_line + lines > flxdec->hdr.height) {
-     GST_ERROR_OBJECT (flxdec, "Invalid FLI packet detected. too many lines.");
-     return FALSE;
-   }
--  data += 4;
- 
--  /* start position of delta */
--  dest += (flxdec->hdr.width * start_line);
--  start_p = dest;
-+  line_start_i = flxdec->hdr.width * start_line;
-+  if (!gst_byte_writer_set_pos (writer, line_start_i))
-+    goto error;
- 
-   while (lines--) {
-+    guint8 packets;
-+
-     /* packet count */
--    packets = *data++;
-+    if (!gst_byte_reader_get_uint8 (reader, &packets))
-+      goto error;
-+    GST_LOG_OBJECT (flxdec, "have %d packets", packets);
- 
-     while (packets--) {
-       /* skip count */
--      guchar skip = *data++;
--      dest += skip;
-+      guint8 skip;
-+      gint8 count;
-+      if (!gst_byte_reader_get_uint8 (reader, &skip))
-+        goto error;
-+
-+      /* skip bytes */
-+      if (!gst_byte_writer_set_pos (writer,
-+              gst_byte_writer_get_pos (writer) + skip))
-+        goto error;
- 
-       /* RLE count */
--      count = *data++;
-+      if (!gst_byte_reader_get_int8 (reader, &count))
-+        goto error;
-+
-+      if (count < 0) {
-+        guint8 x;
- 
--      if (count > 0x7f) {
-         /* literal run */
--        count = 0x100 - count;
-+        count = ABS (count);
-+        GST_LOG_OBJECT (flxdec, "have literal run of size %d at offset %d",
-+            count, skip);
- 
-         if (skip + count > flxdec->hdr.width) {
-           GST_ERROR_OBJECT (flxdec, "Invalid FLI packet detected. "
-@@ -393,11 +461,16 @@ flx_decode_delta_fli (GstFlxDec * flxdec, guchar * data, guchar * dest)
-           return FALSE;
-         }
- 
--        x = *data++;
--        while (count--)
--          *dest++ = x;
--
-+        if (!gst_byte_reader_get_uint8 (reader, &x))
-+          goto error;
-+        if (!gst_byte_writer_fill (writer, x, count))
-+          goto error;
-       } else {
-+        const guint8 *data;
-+
-+        GST_LOG_OBJECT (flxdec, "have replicate run of size %d at offset %d",
-+            count, skip);
-+
-         if (skip + count > flxdec->hdr.width) {
-           GST_ERROR_OBJECT (flxdec, "Invalid FLI packet detected. "
-               "line too long.");
-@@ -405,45 +478,60 @@ flx_decode_delta_fli (GstFlxDec * flxdec, guchar * data, guchar * dest)
-         }
- 
-         /* replicate run */
--        while (count--)
--          *dest++ = *data++;
-+        if (!gst_byte_reader_get_data (reader, count, &data))
-+          goto error;
-+        if (!gst_byte_writer_put_data (writer, data, count))
-+          goto error;
-       }
-     }
--    start_p += flxdec->hdr.width;
--    dest = start_p;
-+    line_start_i += flxdec->hdr.width;
-+    if (!gst_byte_writer_set_pos (writer, line_start_i))
-+      goto error;
-   }
- 
-   return TRUE;
-+
-+error:
-+  GST_ERROR_OBJECT (flxdec, "Failed to decode FLI packet");
-+  return FALSE;
- }
- 
- static gboolean
--flx_decode_delta_flc (GstFlxDec * flxdec, guchar * data, guchar * dest)
-+flx_decode_delta_flc (GstFlxDec * flxdec, GstByteReader * reader,
-+    GstByteWriter * writer)
- {
--  gulong count, lines, start_l, opcode;
--  guchar *start_p;
-+  guint16 lines, start_l;
- 
-   g_return_val_if_fail (flxdec != NULL, FALSE);
-   g_return_val_if_fail (flxdec->delta_data != NULL, FALSE);
- 
-   /* use last frame for delta */
--  memcpy (dest, flxdec->delta_data, flxdec->size);
-+  if (!gst_byte_writer_put_data (writer, flxdec->delta_data, flxdec->size))
-+    goto error;
-+  if (!gst_byte_reader_get_uint16_le (reader, &lines))
-+    goto error;
- 
--  lines = (data[0] + (data[1] << 8));
-   if (lines > flxdec->hdr.height) {
-     GST_ERROR_OBJECT (flxdec, "Invalid FLC packet detected. too many lines.");
-     return FALSE;
-   }
--  data += 2;
- 
--  start_p = dest;
-   start_l = lines;
- 
-   while (lines) {
--    dest = start_p + (flxdec->hdr.width * (start_l - lines));
-+    guint16 opcode;
-+
-+    if (!gst_byte_writer_set_pos (writer,
-+            flxdec->hdr.width * (start_l - lines)))
-+      goto error;
- 
-     /* process opcode(s) */
--    while ((opcode = (data[0] + (data[1] << 8))) & 0xc000) {
--      data += 2;
-+    while (TRUE) {
-+      if (!gst_byte_reader_get_uint16_le (reader, &opcode))
-+        goto error;
-+      if ((opcode & 0xc000) == 0)
-+        break;
-+
-       if ((opcode & 0xc000) == 0xc000) {
-         /* line skip count */
-         gulong skip = (0x10000 - opcode);
-@@ -453,27 +541,44 @@ flx_decode_delta_flc (GstFlxDec * flxdec, guchar * data, guchar * dest)
-           return FALSE;
-         }
-         start_l += skip;
--        dest += flxdec->hdr.width * skip;
-+        if (!gst_byte_writer_set_pos (writer,
-+                gst_byte_writer_get_pos (writer) + flxdec->hdr.width * skip))
-+          goto error;
-       } else {
-         /* last pixel */
--        dest += flxdec->hdr.width;
--        *dest++ = (opcode & 0xff);
-+        if (!gst_byte_writer_set_pos (writer,
-+                gst_byte_writer_get_pos (writer) + flxdec->hdr.width))
-+          goto error;
-+        if (!gst_byte_writer_put_uint8 (writer, opcode & 0xff))
-+          goto error;
-       }
-     }
--    data += 2;
- 
-     /* last opcode is the packet count */
-+    GST_LOG_OBJECT (flxdec, "have %d packets", opcode);
-     while (opcode--) {
-       /* skip count */
--      guchar skip = *data++;
--      dest += skip;
-+      guint8 skip;
-+      gint8 count;
-+
-+      if (!gst_byte_reader_get_uint8 (reader, &skip))
-+        goto error;
-+      if (!gst_byte_writer_set_pos (writer,
-+              gst_byte_writer_get_pos (writer) + skip))
-+        goto error;
- 
-       /* RLE count */
--      count = *data++;
-+      if (!gst_byte_reader_get_int8 (reader, &count))
-+        goto error;
-+
-+      if (count < 0) {
-+        guint16 x;
- 
--      if (count > 0x7f) {
-         /* replicate word run */
--        count = 0x100 - count;
-+        count = ABS (count);
-+
-+        GST_LOG_OBJECT (flxdec, "have replicate run of size %d at offset %d",
-+            count, skip);
- 
-         if (skip + count > flxdec->hdr.width) {
-           GST_ERROR_OBJECT (flxdec, "Invalid FLC packet detected. "
-@@ -481,22 +586,31 @@ flx_decode_delta_flc (GstFlxDec * flxdec, guchar * data, guchar * dest)
-           return FALSE;
-         }
- 
-+        if (!gst_byte_reader_get_uint16_le (reader, &x))
-+          goto error;
-+
-         while (count--) {
--          *dest++ = data[0];
--          *dest++ = data[1];
-+          if (!gst_byte_writer_put_uint16_le (writer, x)) {
-+            goto error;
-+          }
-         }
--        data += 2;
-       } else {
-+        GST_LOG_OBJECT (flxdec, "have literal run of size %d at offset %d",
-+            count, skip);
-+
-         if (skip + count > flxdec->hdr.width) {
-           GST_ERROR_OBJECT (flxdec, "Invalid FLC packet detected. "
-               "line too long.");
-           return FALSE;
-         }
- 
--        /* literal word run */
-         while (count--) {
--          *dest++ = *data++;
--          *dest++ = *data++;
-+          guint16 x;
-+
-+          if (!gst_byte_reader_get_uint16_le (reader, &x))
-+            goto error;
-+          if (!gst_byte_writer_put_uint16_le (writer, x))
-+            goto error;
-         }
-       }
-     }
-@@ -504,13 +618,91 @@ flx_decode_delta_flc (GstFlxDec * flxdec, guchar * data, guchar * dest)
-   }
- 
-   return TRUE;
-+
-+error:
-+  GST_ERROR_OBJECT (flxdec, "Failed to decode FLI packet");
-+  return FALSE;
-+}
-+
-+static gboolean
-+_read_flx_header (GstFlxDec * flxdec, GstByteReader * reader, FlxHeader * flxh)
-+{
-+  memset (flxh, 0, sizeof (*flxh));
-+
-+  if (!gst_byte_reader_get_uint32_le (reader, &flxh->size))
-+    goto error;
-+  if (flxh->size < FlxHeaderSize) {
-+    GST_ERROR_OBJECT (flxdec, "Invalid file size in the header");
-+    return FALSE;
-+  }
-+
-+  if (!gst_byte_reader_get_uint16_le (reader, &flxh->type))
-+    goto error;
-+  if (!gst_byte_reader_get_uint16_le (reader, &flxh->frames))
-+    goto error;
-+  if (!gst_byte_reader_get_uint16_le (reader, &flxh->width))
-+    goto error;
-+  if (!gst_byte_reader_get_uint16_le (reader, &flxh->height))
-+    goto error;
-+  if (!gst_byte_reader_get_uint16_le (reader, &flxh->depth))
-+    goto error;
-+  if (!gst_byte_reader_get_uint16_le (reader, &flxh->flags))
-+    goto error;
-+  if (!gst_byte_reader_get_uint32_le (reader, &flxh->speed))
-+    goto error;
-+  if (!gst_byte_reader_skip (reader, 2))        /* reserved */
-+    goto error;
-+  /* FLC */
-+  if (!gst_byte_reader_get_uint32_le (reader, &flxh->created))
-+    goto error;
-+  if (!gst_byte_reader_get_uint32_le (reader, &flxh->creator))
-+    goto error;
-+  if (!gst_byte_reader_get_uint32_le (reader, &flxh->updated))
-+    goto error;
-+  if (!gst_byte_reader_get_uint32_le (reader, &flxh->updater))
-+    goto error;
-+  if (!gst_byte_reader_get_uint16_le (reader, &flxh->aspect_dx))
-+    goto error;
-+  if (!gst_byte_reader_get_uint16_le (reader, &flxh->aspect_dy))
-+    goto error;
-+  /* EGI */
-+  if (!gst_byte_reader_get_uint16_le (reader, &flxh->ext_flags))
-+    goto error;
-+  if (!gst_byte_reader_get_uint16_le (reader, &flxh->keyframes))
-+    goto error;
-+  if (!gst_byte_reader_get_uint16_le (reader, &flxh->totalframes))
-+    goto error;
-+  if (!gst_byte_reader_get_uint32_le (reader, &flxh->req_memory))
-+    goto error;
-+  if (!gst_byte_reader_get_uint16_le (reader, &flxh->max_regions))
-+    goto error;
-+  if (!gst_byte_reader_get_uint16_le (reader, &flxh->transp_num))
-+    goto error;
-+  if (!gst_byte_reader_skip (reader, 24))       /* reserved */
-+    goto error;
-+  /* FLC */
-+  if (!gst_byte_reader_get_uint32_le (reader, &flxh->oframe1))
-+    goto error;
-+  if (!gst_byte_reader_get_uint32_le (reader, &flxh->oframe2))
-+    goto error;
-+  if (!gst_byte_reader_skip (reader, 40))       /* reserved */
-+    goto error;
-+
-+  return TRUE;
-+
-+error:
-+  GST_ERROR_OBJECT (flxdec, "Error reading file header");
-+  return FALSE;
- }
- 
- static GstFlowReturn
- gst_flxdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
- {
-+  GstByteReader reader;
-+  GstBuffer *input;
-+  GstMapInfo map_info;
-   GstCaps *caps;
--  guint avail;
-+  guint available;
-   GstFlowReturn res = GST_FLOW_OK;
- 
-   GstFlxDec *flxdec;
-@@ -521,31 +713,50 @@ gst_flxdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
-   g_return_val_if_fail (flxdec != NULL, GST_FLOW_ERROR);
- 
-   gst_adapter_push (flxdec->adapter, buf);
--  avail = gst_adapter_available (flxdec->adapter);
-+  available = gst_adapter_available (flxdec->adapter);
-+  input = gst_adapter_get_buffer (flxdec->adapter, available);
-+  if (!gst_buffer_map (input, &map_info, GST_MAP_READ)) {
-+    GST_ELEMENT_ERROR (flxdec, STREAM, DECODE,
-+        ("%s", "Failed to map buffer"), (NULL));
-+    goto error;
-+  }
-+  gst_byte_reader_init (&reader, map_info.data, map_info.size);
- 
-   if (flxdec->state == GST_FLXDEC_READ_HEADER) {
--    if (avail >= FlxHeaderSize) {
--      const guint8 *data = gst_adapter_map (flxdec->adapter, FlxHeaderSize);
-+    if (available >= FlxHeaderSize) {
-+      GstByteReader header;
-       GstCaps *templ;
- 
--      memcpy ((gchar *) & flxdec->hdr, data, FlxHeaderSize);
--      FLX_HDR_FIX_ENDIANNESS (&(flxdec->hdr));
--      gst_adapter_unmap (flxdec->adapter);
-+      if (!gst_byte_reader_get_sub_reader (&reader, &header, FlxHeaderSize)) {
-+        GST_ELEMENT_ERROR (flxdec, STREAM, DECODE,
-+            ("%s", "Could not read header"), (NULL));
-+        goto unmap_input_error;
-+      }
-       gst_adapter_flush (flxdec->adapter, FlxHeaderSize);
-+      available -= FlxHeaderSize;
-+
-+      if (!_read_flx_header (flxdec, &header, &flxdec->hdr)) {
-+        GST_ELEMENT_ERROR (flxdec, STREAM, DECODE,
-+            ("%s", "Failed to parse header"), (NULL));
-+        goto unmap_input_error;
-+      }
- 
-       flxh = &flxdec->hdr;
- 
-       /* check header */
-       if (flxh->type != FLX_MAGICHDR_FLI &&
--          flxh->type != FLX_MAGICHDR_FLC && flxh->type != FLX_MAGICHDR_FLX)
--        goto wrong_type;
-+          flxh->type != FLX_MAGICHDR_FLC && flxh->type != FLX_MAGICHDR_FLX) {
-+        GST_ELEMENT_ERROR (flxdec, STREAM, WRONG_TYPE, (NULL),
-+            ("not a flx file (type %x)", flxh->type));
-+        goto unmap_input_error;
-+      }
- 
--      GST_LOG ("size      :  %d", flxh->size);
--      GST_LOG ("frames    :  %d", flxh->frames);
--      GST_LOG ("width     :  %d", flxh->width);
--      GST_LOG ("height    :  %d", flxh->height);
--      GST_LOG ("depth     :  %d", flxh->depth);
--      GST_LOG ("speed     :  %d", flxh->speed);
-+      GST_INFO_OBJECT (flxdec, "size      :  %d", flxh->size);
-+      GST_INFO_OBJECT (flxdec, "frames    :  %d", flxh->frames);
-+      GST_INFO_OBJECT (flxdec, "width     :  %d", flxh->width);
-+      GST_INFO_OBJECT (flxdec, "height    :  %d", flxh->height);
-+      GST_INFO_OBJECT (flxdec, "depth     :  %d", flxh->depth);
-+      GST_INFO_OBJECT (flxdec, "speed     :  %d", flxh->speed);
- 
-       flxdec->next_time = 0;
- 
-@@ -573,18 +784,32 @@ gst_flxdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
-       gst_pad_set_caps (flxdec->srcpad, caps);
-       gst_caps_unref (caps);
- 
--      if (flxh->depth <= 8)
--        flxdec->converter =
--            flx_colorspace_converter_new (flxh->width, flxh->height);
-+      /* zero means 8 */
-+      if (flxh->depth == 0)
-+        flxh->depth = 8;
-+
-+      if (flxh->depth != 8) {
-+        GST_ELEMENT_ERROR (flxdec, STREAM, WRONG_TYPE,
-+            ("%s", "Don't know how to decode non 8 bit depth streams"), (NULL));
-+        goto unmap_input_error;
-+      }
-+
-+      flxdec->converter =
-+          flx_colorspace_converter_new (flxh->width, flxh->height);
- 
-       if (flxh->type == FLX_MAGICHDR_FLC || flxh->type == FLX_MAGICHDR_FLX) {
--        GST_LOG ("(FLC) aspect_dx :  %d", flxh->aspect_dx);
--        GST_LOG ("(FLC) aspect_dy :  %d", flxh->aspect_dy);
--        GST_LOG ("(FLC) oframe1   :  0x%08x", flxh->oframe1);
--        GST_LOG ("(FLC) oframe2   :  0x%08x", flxh->oframe2);
-+        GST_INFO_OBJECT (flxdec, "(FLC) aspect_dx :  %d", flxh->aspect_dx);
-+        GST_INFO_OBJECT (flxdec, "(FLC) aspect_dy :  %d", flxh->aspect_dy);
-+        GST_INFO_OBJECT (flxdec, "(FLC) oframe1   :  0x%08x", flxh->oframe1);
-+        GST_INFO_OBJECT (flxdec, "(FLC) oframe2   :  0x%08x", flxh->oframe2);
-       }
- 
-       flxdec->size = ((guint) flxh->width * (guint) flxh->height);
-+      if (flxdec->size >= G_MAXSIZE / 4) {
-+        GST_ELEMENT_ERROR (flxdec, STREAM, DECODE,
-+            ("%s", "Cannot allocate required memory"), (NULL));
-+        goto unmap_input_error;
-+      }
- 
-       /* create delta and output frame */
-       flxdec->frame_data = g_malloc (flxdec->size);
-@@ -596,55 +821,66 @@ gst_flxdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
-     GstBuffer *out;
- 
-     /* while we have enough data in the adapter */
--    while (avail >= FlxFrameChunkSize && res == GST_FLOW_OK) {
--      FlxFrameChunk flxfh;
--      guchar *chunk;
--      const guint8 *data;
--      GstMapInfo map;
--
--      chunk = NULL;
--      data = gst_adapter_map (flxdec->adapter, FlxFrameChunkSize);
--      memcpy (&flxfh, data, FlxFrameChunkSize);
--      FLX_FRAME_CHUNK_FIX_ENDIANNESS (&flxfh);
--      gst_adapter_unmap (flxdec->adapter);
--
--      switch (flxfh.id) {
--        case FLX_FRAME_TYPE:
--          /* check if we have the complete frame */
--          if (avail < flxfh.size)
--            goto need_more_data;
--
--          /* flush header */
--          gst_adapter_flush (flxdec->adapter, FlxFrameChunkSize);
--
--          chunk = gst_adapter_take (flxdec->adapter,
--              flxfh.size - FlxFrameChunkSize);
--          FLX_FRAME_TYPE_FIX_ENDIANNESS ((FlxFrameType *) chunk);
--          if (((FlxFrameType *) chunk)->chunks == 0)
--            break;
-+    while (available >= FlxFrameChunkSize && res == GST_FLOW_OK) {
-+      guint32 size;
-+      guint16 type;
- 
--          /* create 32 bits output frame */
--//          res = gst_pad_alloc_buffer_and_set_caps (flxdec->srcpad,
--//              GST_BUFFER_OFFSET_NONE,
--//              flxdec->size * 4, GST_PAD_CAPS (flxdec->srcpad), &out);
--//          if (res != GST_FLOW_OK)
--//            break;
-+      if (!gst_byte_reader_get_uint32_le (&reader, &size))
-+        goto parse_error;
-+      if (available < size)
-+        goto need_more_data;
- 
--          out = gst_buffer_new_and_alloc (flxdec->size * 4);
-+      available -= size;
-+      gst_adapter_flush (flxdec->adapter, size);
-+
-+      if (!gst_byte_reader_get_uint16_le (&reader, &type))
-+        goto parse_error;
-+
-+      switch (type) {
-+        case FLX_FRAME_TYPE:{
-+          GstByteReader chunks;
-+          GstByteWriter writer;
-+          guint16 n_chunks;
-+          GstMapInfo map;
-+
-+          GST_LOG_OBJECT (flxdec, "Have frame type 0x%02x of size %d", type,
-+              size);
-+
-+          if (!gst_byte_reader_get_sub_reader (&reader, &chunks,
-+                  size - FlxFrameChunkSize))
-+            goto parse_error;
-+
-+          if (!gst_byte_reader_get_uint16_le (&chunks, &n_chunks))
-+            goto parse_error;
-+          GST_LOG_OBJECT (flxdec, "Have %d chunks", n_chunks);
-+
-+          if (n_chunks == 0)
-+            break;
-+          if (!gst_byte_reader_skip (&chunks, 8))       /* reserved */
-+            goto parse_error;
-+
-+          gst_byte_writer_init_with_data (&writer, flxdec->frame_data,
-+              flxdec->size, TRUE);
- 
-           /* decode chunks */
--          if (!flx_decode_chunks (flxdec,
--                  ((FlxFrameType *) chunk)->chunks,
--                  chunk + FlxFrameTypeSize, flxdec->frame_data)) {
-+          if (!flx_decode_chunks (flxdec, n_chunks, &chunks, &writer)) {
-             GST_ELEMENT_ERROR (flxdec, STREAM, DECODE,
-                 ("%s", "Could not decode chunk"), NULL);
--            return GST_FLOW_ERROR;
-+            goto unmap_input_error;
-           }
-+          gst_byte_writer_reset (&writer);
- 
-           /* save copy of the current frame for possible delta. */
-           memcpy (flxdec->delta_data, flxdec->frame_data, flxdec->size);
- 
--          gst_buffer_map (out, &map, GST_MAP_WRITE);
-+          out = gst_buffer_new_and_alloc (flxdec->size * 4);
-+          if (!gst_buffer_map (out, &map, GST_MAP_WRITE)) {
-+            GST_ELEMENT_ERROR (flxdec, STREAM, DECODE,
-+                ("%s", "Could not map output buffer"), NULL);
-+            gst_buffer_unref (out);
-+            goto unmap_input_error;
-+          }
-+
-           /* convert current frame. */
-           flx_colorspace_convert (flxdec->converter, flxdec->frame_data,
-               map.data);
-@@ -655,30 +891,32 @@ gst_flxdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
- 
-           res = gst_pad_push (flxdec->srcpad, out);
-           break;
-+        }
-         default:
--          /* check if we have the complete frame */
--          if (avail < flxfh.size)
--            goto need_more_data;
--
--          gst_adapter_flush (flxdec->adapter, flxfh.size);
-+          GST_DEBUG_OBJECT (flxdec, "Unknown frame type 0x%02x, skipping %d",
-+              type, size);
-+          if (!gst_byte_reader_skip (&reader, size - FlxFrameChunkSize))
-+            goto parse_error;
-           break;
-       }
--
--      g_free (chunk);
--
--      avail = gst_adapter_available (flxdec->adapter);
-     }
-   }
-+
-+  gst_buffer_unmap (input, &map_info);
-+  gst_buffer_unref (input);
-+
- need_more_data:
-   return res;
- 
-   /* ERRORS */
--wrong_type:
--  {
--    GST_ELEMENT_ERROR (flxdec, STREAM, WRONG_TYPE, (NULL),
--        ("not a flx file (type %x)", flxh->type));
--    return GST_FLOW_ERROR;
--  }
-+parse_error:
-+  GST_ELEMENT_ERROR (flxdec, STREAM, DECODE,
-+      ("%s", "Failed to parse stream"), (NULL));
-+unmap_input_error:
-+  gst_buffer_unmap (input, &map_info);
-+  gst_buffer_unref (input);
-+error:
-+  return GST_FLOW_ERROR;
- }
- 
- static GstStateChangeReturn
-diff --git a/gst/flx/gstflxdec.h b/gst/flx/gstflxdec.h
-index 3f9a0aa..4fd8dfd 100644
---- a/gst/flx/gstflxdec.h
-+++ b/gst/flx/gstflxdec.h
-@@ -23,6 +23,8 @@
- #include <gst/gst.h>
- 
- #include <gst/base/gstadapter.h>
-+#include <gst/base/gstbytereader.h>
-+#include <gst/base/gstbytewriter.h>
- #include "flx_color.h"
- 
- G_BEGIN_DECLS
-@@ -45,7 +47,7 @@ struct _GstFlxDec {
- 
-   guint8 *delta_data, *frame_data;
-   GstAdapter *adapter;
--  gulong size;
-+  gsize size;
-   GstFlxDecState state;
-   gint64 frame_time;
-   gint64 next_time;
--- 
-2.10.2
-
diff --git a/gnu/packages/patches/gst-plugins-good-fix-invalid-read.patch b/gnu/packages/patches/gst-plugins-good-fix-invalid-read.patch
deleted file mode 100644
index 1daaa2ae15..0000000000
--- a/gnu/packages/patches/gst-plugins-good-fix-invalid-read.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-Fixes upstream bug #774897 (flxdec: Unreferences itself one time too many on
-invalid files):
-
-https://bugzilla.gnome.org/show_bug.cgi?id=774897
-
-Patch copied from upstream source repository:
-
-https://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=b31c504645a814c59d91d49e4fe218acaf93f4ca
-
-From b31c504645a814c59d91d49e4fe218acaf93f4ca Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com>
-Date: Wed, 23 Nov 2016 11:20:49 +0200
-Subject: [PATCH] flxdec: Don't unref() parent in the chain function
-
-We don't own the reference here, it is owned by the caller and given to
-us for the scope of this function. Leftover mistake from 0.10 porting.
-
-https://bugzilla.gnome.org/show_bug.cgi?id=774897
----
- gst/flx/gstflxdec.c | 1 -
- 1 file changed, 1 deletion(-)
-
-diff --git a/gst/flx/gstflxdec.c b/gst/flx/gstflxdec.c
-index e675c99..a237976 100644
---- a/gst/flx/gstflxdec.c
-+++ b/gst/flx/gstflxdec.c
-@@ -677,7 +677,6 @@ wrong_type:
-   {
-     GST_ELEMENT_ERROR (flxdec, STREAM, WRONG_TYPE, (NULL),
-         ("not a flx file (type %x)", flxh->type));
--    gst_object_unref (flxdec);
-     return GST_FLOW_ERROR;
-   }
- }
--- 
-2.10.2
-
diff --git a/gnu/packages/patches/gst-plugins-good-fix-signedness.patch b/gnu/packages/patches/gst-plugins-good-fix-signedness.patch
deleted file mode 100644
index a3e20e19dd..0000000000
--- a/gnu/packages/patches/gst-plugins-good-fix-signedness.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-This is a followup fix for upstream bug #774834 (flic decoder: Buffer overflow
-in flx_decode_delta_fli):
-
-https://bugzilla.gnome.org/show_bug.cgi?id=774834#c2
-
-Patch copied from upstream source repository:
-
-https://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=1ab2b26193861b124426e2f8eb62b75b59ec5488
-
-From 1ab2b26193861b124426e2f8eb62b75b59ec5488 Mon Sep 17 00:00:00 2001
-From: Matthew Waters <matthew@centricular.com>
-Date: Tue, 22 Nov 2016 23:46:00 +1100
-Subject: [PATCH] flxdec: fix some warnings comparing unsigned < 0
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-bf43f44fcfada5ec4a3ce60cb374340486fe9fac was comparing an unsigned
-expression to be < 0 which was always false.
-
-gstflxdec.c: In function ‘flx_decode_brun’:
-gstflxdec.c:322:33: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
-         if ((glong) row - count < 0) {
-                                 ^
-gstflxdec.c:332:33: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
-         if ((glong) row - count < 0) {
-                                 ^
-
-https://bugzilla.gnome.org/show_bug.cgi?id=774834
----
- gst/flx/gstflxdec.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/gst/flx/gstflxdec.c b/gst/flx/gstflxdec.c
-index d51a8e6..e675c99 100644
---- a/gst/flx/gstflxdec.c
-+++ b/gst/flx/gstflxdec.c
-@@ -319,7 +319,7 @@ flx_decode_brun (GstFlxDec * flxdec, guchar * data, guchar * dest)
-       if (count > 0x7f) {
-         /* literal run */
-         count = 0x100 - count;
--        if ((glong) row - count < 0) {
-+        if ((glong) row - (glong) count < 0) {
-           GST_ERROR_OBJECT (flxdec, "Invalid BRUN packet detected.");
-           return FALSE;
-         }
-@@ -329,7 +329,7 @@ flx_decode_brun (GstFlxDec * flxdec, guchar * data, guchar * dest)
-           *dest++ = *data++;
- 
-       } else {
--        if ((glong) row - count < 0) {
-+        if ((glong) row - (glong) count < 0) {
-           GST_ERROR_OBJECT (flxdec, "Invalid BRUN packet detected.");
-           return FALSE;
-         }
--- 
-2.10.2
-
diff --git a/gnu/packages/patches/gst-plugins-good-flic-bounds-check.patch b/gnu/packages/patches/gst-plugins-good-flic-bounds-check.patch
deleted file mode 100644
index f77dca2cd6..0000000000
--- a/gnu/packages/patches/gst-plugins-good-flic-bounds-check.patch
+++ /dev/null
@@ -1,319 +0,0 @@
-Fix CVE-2016-{9634,9635,9636}.
-
-https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-9634
-https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-9635
-https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-9636
-
-This fixes upstream bug #774834 (flic decoder: Buffer overflow in
-flx_decode_delta_fli):
-
-https://bugzilla.gnome.org/show_bug.cgi?id=774834
-
-Patch copied from upstream source repository:
-
-https://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=2e203a79b7d9af4029307c1a845b3c148d5f5e62
-
-From 2e203a79b7d9af4029307c1a845b3c148d5f5e62 Mon Sep 17 00:00:00 2001
-From: Matthew Waters <matthew@centricular.com>
-Date: Tue, 22 Nov 2016 19:05:00 +1100
-Subject: [PATCH] flxdec: add some write bounds checking
-
-Without checking the bounds of the frame we are writing into, we can
-write off the end of the destination buffer.
-
-https://scarybeastsecurity.blogspot.dk/2016/11/0day-exploit-advancing-exploitation.html
-
-https://bugzilla.gnome.org/show_bug.cgi?id=774834
----
- gst/flx/gstflxdec.c | 116 +++++++++++++++++++++++++++++++++++++++++-----------
- 1 file changed, 91 insertions(+), 25 deletions(-)
-
-diff --git a/gst/flx/gstflxdec.c b/gst/flx/gstflxdec.c
-index 604be2f..d51a8e6 100644
---- a/gst/flx/gstflxdec.c
-+++ b/gst/flx/gstflxdec.c
-@@ -74,9 +74,9 @@ static gboolean gst_flxdec_src_query_handler (GstPad * pad, GstObject * parent,
-     GstQuery * query);
- 
- static void flx_decode_color (GstFlxDec *, guchar *, guchar *, gint);
--static void flx_decode_brun (GstFlxDec *, guchar *, guchar *);
--static void flx_decode_delta_fli (GstFlxDec *, guchar *, guchar *);
--static void flx_decode_delta_flc (GstFlxDec *, guchar *, guchar *);
-+static gboolean flx_decode_brun (GstFlxDec *, guchar *, guchar *);
-+static gboolean flx_decode_delta_fli (GstFlxDec *, guchar *, guchar *);
-+static gboolean flx_decode_delta_flc (GstFlxDec *, guchar *, guchar *);
- 
- #define rndalign(off) ((off) + ((off) & 1))
- 
-@@ -203,13 +203,14 @@ gst_flxdec_sink_event_handler (GstPad * pad, GstObject * parent,
-   return ret;
- }
- 
--static void
-+static gboolean
- flx_decode_chunks (GstFlxDec * flxdec, gulong count, guchar * data,
-     guchar * dest)
- {
-   FlxFrameChunk *hdr;
-+  gboolean ret = TRUE;
- 
--  g_return_if_fail (data != NULL);
-+  g_return_val_if_fail (data != NULL, FALSE);
- 
-   while (count--) {
-     hdr = (FlxFrameChunk *) data;
-@@ -228,17 +229,17 @@ flx_decode_chunks (GstFlxDec * flxdec, gulong count, guchar * data,
-         break;
- 
-       case FLX_BRUN:
--        flx_decode_brun (flxdec, data, dest);
-+        ret = flx_decode_brun (flxdec, data, dest);
-         data += rndalign (hdr->size) - FlxFrameChunkSize;
-         break;
- 
-       case FLX_LC:
--        flx_decode_delta_fli (flxdec, data, dest);
-+        ret = flx_decode_delta_fli (flxdec, data, dest);
-         data += rndalign (hdr->size) - FlxFrameChunkSize;
-         break;
- 
-       case FLX_SS2:
--        flx_decode_delta_flc (flxdec, data, dest);
-+        ret = flx_decode_delta_flc (flxdec, data, dest);
-         data += rndalign (hdr->size) - FlxFrameChunkSize;
-         break;
- 
-@@ -256,7 +257,12 @@ flx_decode_chunks (GstFlxDec * flxdec, gulong count, guchar * data,
-         data += rndalign (hdr->size) - FlxFrameChunkSize;
-         break;
-     }
-+
-+    if (!ret)
-+      break;
-   }
-+
-+  return ret;
- }
- 
- 
-@@ -289,13 +295,13 @@ flx_decode_color (GstFlxDec * flxdec, guchar * data, guchar * dest, gint scale)
-   }
- }
- 
--static void
-+static gboolean
- flx_decode_brun (GstFlxDec * flxdec, guchar * data, guchar * dest)
- {
-   gulong count, lines, row;
-   guchar x;
- 
--  g_return_if_fail (flxdec != NULL);
-+  g_return_val_if_fail (flxdec != NULL, FALSE);
- 
-   lines = flxdec->hdr.height;
-   while (lines--) {
-@@ -313,12 +319,21 @@ flx_decode_brun (GstFlxDec * flxdec, guchar * data, guchar * dest)
-       if (count > 0x7f) {
-         /* literal run */
-         count = 0x100 - count;
-+        if ((glong) row - count < 0) {
-+          GST_ERROR_OBJECT (flxdec, "Invalid BRUN packet detected.");
-+          return FALSE;
-+        }
-         row -= count;
- 
-         while (count--)
-           *dest++ = *data++;
- 
-       } else {
-+        if ((glong) row - count < 0) {
-+          GST_ERROR_OBJECT (flxdec, "Invalid BRUN packet detected.");
-+          return FALSE;
-+        }
-+
-         /* replicate run */
-         row -= count;
-         x = *data++;
-@@ -328,22 +343,28 @@ flx_decode_brun (GstFlxDec * flxdec, guchar * data, guchar * dest)
-       }
-     }
-   }
-+
-+  return TRUE;
- }
- 
--static void
-+static gboolean
- flx_decode_delta_fli (GstFlxDec * flxdec, guchar * data, guchar * dest)
- {
-   gulong count, packets, lines, start_line;
-   guchar *start_p, x;
- 
--  g_return_if_fail (flxdec != NULL);
--  g_return_if_fail (flxdec->delta_data != NULL);
-+  g_return_val_if_fail (flxdec != NULL, FALSE);
-+  g_return_val_if_fail (flxdec->delta_data != NULL, FALSE);
- 
-   /* use last frame for delta */
-   memcpy (dest, flxdec->delta_data, flxdec->size);
- 
-   start_line = (data[0] + (data[1] << 8));
-   lines = (data[2] + (data[3] << 8));
-+  if (start_line + lines > flxdec->hdr.height) {
-+    GST_ERROR_OBJECT (flxdec, "Invalid FLI packet detected. too many lines.");
-+    return FALSE;
-+  }
-   data += 4;
- 
-   /* start position of delta */
-@@ -356,7 +377,8 @@ flx_decode_delta_fli (GstFlxDec * flxdec, guchar * data, guchar * dest)
- 
-     while (packets--) {
-       /* skip count */
--      dest += *data++;
-+      guchar skip = *data++;
-+      dest += skip;
- 
-       /* RLE count */
-       count = *data++;
-@@ -364,12 +386,24 @@ flx_decode_delta_fli (GstFlxDec * flxdec, guchar * data, guchar * dest)
-       if (count > 0x7f) {
-         /* literal run */
-         count = 0x100 - count;
--        x = *data++;
- 
-+        if (skip + count > flxdec->hdr.width) {
-+          GST_ERROR_OBJECT (flxdec, "Invalid FLI packet detected. "
-+              "line too long.");
-+          return FALSE;
-+        }
-+
-+        x = *data++;
-         while (count--)
-           *dest++ = x;
- 
-       } else {
-+        if (skip + count > flxdec->hdr.width) {
-+          GST_ERROR_OBJECT (flxdec, "Invalid FLI packet detected. "
-+              "line too long.");
-+          return FALSE;
-+        }
-+
-         /* replicate run */
-         while (count--)
-           *dest++ = *data++;
-@@ -378,21 +412,27 @@ flx_decode_delta_fli (GstFlxDec * flxdec, guchar * data, guchar * dest)
-     start_p += flxdec->hdr.width;
-     dest = start_p;
-   }
-+
-+  return TRUE;
- }
- 
--static void
-+static gboolean
- flx_decode_delta_flc (GstFlxDec * flxdec, guchar * data, guchar * dest)
- {
-   gulong count, lines, start_l, opcode;
-   guchar *start_p;
- 
--  g_return_if_fail (flxdec != NULL);
--  g_return_if_fail (flxdec->delta_data != NULL);
-+  g_return_val_if_fail (flxdec != NULL, FALSE);
-+  g_return_val_if_fail (flxdec->delta_data != NULL, FALSE);
- 
-   /* use last frame for delta */
-   memcpy (dest, flxdec->delta_data, flxdec->size);
- 
-   lines = (data[0] + (data[1] << 8));
-+  if (lines > flxdec->hdr.height) {
-+    GST_ERROR_OBJECT (flxdec, "Invalid FLC packet detected. too many lines.");
-+    return FALSE;
-+  }
-   data += 2;
- 
-   start_p = dest;
-@@ -405,9 +445,15 @@ flx_decode_delta_flc (GstFlxDec * flxdec, guchar * data, guchar * dest)
-     while ((opcode = (data[0] + (data[1] << 8))) & 0xc000) {
-       data += 2;
-       if ((opcode & 0xc000) == 0xc000) {
--        /* skip count */
--        start_l += (0x10000 - opcode);
--        dest += flxdec->hdr.width * (0x10000 - opcode);
-+        /* line skip count */
-+        gulong skip = (0x10000 - opcode);
-+        if (skip > flxdec->hdr.height) {
-+          GST_ERROR_OBJECT (flxdec, "Invalid FLC packet detected. "
-+              "skip line count too big.");
-+          return FALSE;
-+        }
-+        start_l += skip;
-+        dest += flxdec->hdr.width * skip;
-       } else {
-         /* last pixel */
-         dest += flxdec->hdr.width;
-@@ -419,7 +465,8 @@ flx_decode_delta_flc (GstFlxDec * flxdec, guchar * data, guchar * dest)
-     /* last opcode is the packet count */
-     while (opcode--) {
-       /* skip count */
--      dest += *data++;
-+      guchar skip = *data++;
-+      dest += skip;
- 
-       /* RLE count */
-       count = *data++;
-@@ -427,12 +474,25 @@ flx_decode_delta_flc (GstFlxDec * flxdec, guchar * data, guchar * dest)
-       if (count > 0x7f) {
-         /* replicate word run */
-         count = 0x100 - count;
-+
-+        if (skip + count > flxdec->hdr.width) {
-+          GST_ERROR_OBJECT (flxdec, "Invalid FLC packet detected. "
-+              "line too long.");
-+          return FALSE;
-+        }
-+
-         while (count--) {
-           *dest++ = data[0];
-           *dest++ = data[1];
-         }
-         data += 2;
-       } else {
-+        if (skip + count > flxdec->hdr.width) {
-+          GST_ERROR_OBJECT (flxdec, "Invalid FLC packet detected. "
-+              "line too long.");
-+          return FALSE;
-+        }
-+
-         /* literal word run */
-         while (count--) {
-           *dest++ = *data++;
-@@ -442,6 +502,8 @@ flx_decode_delta_flc (GstFlxDec * flxdec, guchar * data, guchar * dest)
-     }
-     lines--;
-   }
-+
-+  return TRUE;
- }
- 
- static GstFlowReturn
-@@ -571,9 +633,13 @@ gst_flxdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
-           out = gst_buffer_new_and_alloc (flxdec->size * 4);
- 
-           /* decode chunks */
--          flx_decode_chunks (flxdec,
--              ((FlxFrameType *) chunk)->chunks,
--              chunk + FlxFrameTypeSize, flxdec->frame_data);
-+          if (!flx_decode_chunks (flxdec,
-+                  ((FlxFrameType *) chunk)->chunks,
-+                  chunk + FlxFrameTypeSize, flxdec->frame_data)) {
-+            GST_ELEMENT_ERROR (flxdec, STREAM, DECODE,
-+                ("%s", "Could not decode chunk"), NULL);
-+            return GST_FLOW_ERROR;
-+          }
- 
-           /* save copy of the current frame for possible delta. */
-           memcpy (flxdec->delta_data, flxdec->frame_data, flxdec->size);
--- 
-2.10.2
-
-- 
cgit 1.4.1


From a4b0bfb1952a33b04cf2f2282633e7b342c16fb8 Mon Sep 17 00:00:00 2001
From: Eric Bavier <bavier@member.fsf.org>
Date: Wed, 30 Nov 2016 21:26:01 -0600
Subject: gnu: netcdf: Upgrade to 4.4.1.1.

* gnu/packages/maths.scm (netcdf, netcdf-parallel-openmpi): Upgrade to
4.4.1.1.
[source]: Adjust patch name, add netcdf-tst_h_par.patch
* gnu/packages/patches/netcdf-config.date.patch: Rename to...
* gnu/packages/patches/netcdf-date-time.patch: ...this.  Adjust for
latest source.
* gnu/packages/patches/netcdf-tst_h_par.patch: New patch.
* gnu/local.mk (dist_patch_DATA): Adjust patches.
---
 gnu/local.mk                                  |  3 +-
 gnu/packages/maths.scm                        |  7 ++--
 gnu/packages/patches/netcdf-config-date.patch | 47 ---------------------------
 gnu/packages/patches/netcdf-date-time.patch   | 11 +++++++
 gnu/packages/patches/netcdf-tst_h_par.patch   | 21 ++++++++++++
 5 files changed, 38 insertions(+), 51 deletions(-)
 delete mode 100644 gnu/packages/patches/netcdf-config-date.patch
 create mode 100644 gnu/packages/patches/netcdf-date-time.patch
 create mode 100644 gnu/packages/patches/netcdf-tst_h_par.patch

(limited to 'gnu/packages/patches')

diff --git a/gnu/local.mk b/gnu/local.mk
index 0d019f73db..6f128ed913 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -745,7 +745,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/musl-CVE-2016-8859.patch			\
   %D%/packages/patches/mutt-store-references.patch		\
   %D%/packages/patches/net-tools-bitrot.patch			\
-  %D%/packages/patches/netcdf-config-date.patch			\
+  %D%/packages/patches/netcdf-date-time.patch			\
+  %D%/packages/patches/netcdf-tst_h_par.patch			\
   %D%/packages/patches/netsurf-about.patch			\
   %D%/packages/patches/ngircd-handle-zombies.patch		\
   %D%/packages/patches/ngircd-no-dns-in-tests.patch		\
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 0ee573527a..fc98eae4f7 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -714,7 +714,7 @@ HDF5 file is encoded according to the HDF File Format Specification.")
 (define-public netcdf
   (package
     (name "netcdf")
-    (version "4.4.0")
+    (version "4.4.1.1")
     (source
      (origin
        (method url-fetch)
@@ -722,8 +722,9 @@ HDF5 file is encoded according to the HDF File Format Specification.")
                            "netcdf-" version ".tar.gz"))
        (sha256
         (base32
-         "0y6gdcplarwqqnrav2xg1xd6ih732rzzbmdw78v3rl5b8mwcnh0d"))
-       (patches (list (search-patch "netcdf-config-date.patch")))))
+         "1blc7ik5yin7i0ls2kag0a9xjk12m0dzx6v1x88az3ras3scci2d"))
+       (patches (search-patches "netcdf-date-time.patch"
+                                "netcdf-tst_h_par.patch"))))
     (build-system gnu-build-system)
     (native-inputs
      `(("m4" ,m4)
diff --git a/gnu/packages/patches/netcdf-config-date.patch b/gnu/packages/patches/netcdf-config-date.patch
deleted file mode 100644
index 5054612e95..0000000000
--- a/gnu/packages/patches/netcdf-config-date.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-Honor SOURCE_DATE_EPOCH when exporting configuration date.
-Autoconf-level patch submitted upstream on Fri Apr 15 23:07:42 UTC 2016
-
---- a/configure
-+++ b/configure
-@@ -2866,7 +2866,17 @@
- 
- 
- # Configuration Date
-- CONFIG_DATE="`date`"
-+ CONFIG_DATE="`date -u`"
-+if test -n "$SOURCE_DATE_EPOCH"; then
-+  CONFIG_DATE=`date -u -d "@$SOURCE_DATE_EPOCH" 2>/dev/null \
-+               || date -u -r "$SOURCE_DATE_EPOCH" 2>/dev/null`
-+  if test -z "$CONFIG_DATE"; then
-+    as_fn_error $? "malformed SOURCE_DATE_EPOCH" "$LINENO" 5
-+  fi
-+fi
-+cat >>confdefs.h <<_ACEOF
-+#define CONFIG_DATE "$CONFIG_DATE"
-+_ACEOF
- 
- # Find out about the host we're building on.
- ac_aux_dir=
---- a/libdispatch/derror.c
-+++ b/libdispatch/derror.c
-@@ -13,7 +13,7 @@
- #endif
- 
- /* Tell the user the version of netCDF. */
--static const char nc_libvers[] = PACKAGE_VERSION " of "__DATE__" "__TIME__" $";
-+static const char nc_libvers[] = PACKAGE_VERSION " of "CONFIG_DATE" $";
- 
- /**
- \defgroup lib_version Library Version
---- a/config.h.in
-+++ b/config.h.in
-@@ -393,6 +393,9 @@
- /* Define to the version of this package. */
- #undef PACKAGE_VERSION
- 
-+/* Define to the configuration date */
-+#undef CONFIG_DATE
-+
- /* The size of `double', as computed by sizeof. */
- #undef SIZEOF_DOUBLE
- 
diff --git a/gnu/packages/patches/netcdf-date-time.patch b/gnu/packages/patches/netcdf-date-time.patch
new file mode 100644
index 0000000000..a4e7925aa1
--- /dev/null
+++ b/gnu/packages/patches/netcdf-date-time.patch
@@ -0,0 +1,11 @@
+--- a/libdispatch/derror.c
++++ b/libdispatch/derror.c
+@@ -13,7 +13,7 @@
+ #endif
+ 
+ /* Tell the user the version of netCDF. */
+-static const char nc_libvers[] = PACKAGE_VERSION " of "__DATE__" "__TIME__" $";
++static const char nc_libvers[] = PACKAGE_VERSION" $";
+ 
+ /**
+ \defgroup lib_version Library Version
diff --git a/gnu/packages/patches/netcdf-tst_h_par.patch b/gnu/packages/patches/netcdf-tst_h_par.patch
new file mode 100644
index 0000000000..ac14a4c0a2
--- /dev/null
+++ b/gnu/packages/patches/netcdf-tst_h_par.patch
@@ -0,0 +1,21 @@
+From a83702834938b23cc2e843589aa223e2024a7e6f Mon Sep 17 00:00:00 2001
+From: Orion Poplawski <orion@cora.nwra.com>
+Date: Tue, 29 Nov 2016 11:48:01 -0700
+Subject: [PATCH] Add missing #include "err_macros.h" to tst_h_par.c
+
+---
+ h5_test/tst_h_par.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/h5_test/tst_h_par.c b/h5_test/tst_h_par.c
+index c3da7f4..a419d55 100644
+--- a/h5_test/tst_h_par.c
++++ b/h5_test/tst_h_par.c
+@@ -11,6 +11,7 @@
+    $Id: tst_h_par.c,v 1.15 2010/05/25 13:53:04 ed Exp $
+ */
+ #include <nc_tests.h>
++#include "err_macros.h"
+ #include <hdf5.h>
+ 
+ /* Defining USE_MPE causes the MPE trace library to be used (and you
-- 
cgit 1.4.1


From 0e988a8483de93a5f3f2e09193cadf285f37dea1 Mon Sep 17 00:00:00 2001
From: Eric Bavier <bavier@member.fsf.org>
Date: Fri, 15 Jul 2016 20:24:25 -0500
Subject: gnu: vtk: Upgrade to 7.1.0.

* gnu/packages/vtk.scm (vtk): Upgrade to 7.1.0.
[source]: Remove patches.  Use version-major+minor.
* gnu/packages/patches/vtk-mesa-10.patch: Delete patch.
* gnu/local.mk (dist_patch_DATA): Remove it.
---
 gnu/local.mk                           |  1 -
 gnu/packages/patches/vtk-mesa-10.patch | 36 ----------------------------------
 gnu/packages/vtk.scm                   |  9 ++++-----
 3 files changed, 4 insertions(+), 42 deletions(-)
 delete mode 100644 gnu/packages/patches/vtk-mesa-10.patch

(limited to 'gnu/packages/patches')

diff --git a/gnu/local.mk b/gnu/local.mk
index 6f128ed913..f6f2db6df9 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -912,7 +912,6 @@ dist_patch_DATA =						\
   %D%/packages/patches/vpnc-script.patch			\
   %D%/packages/patches/vte-CVE-2012-2738-pt1.patch			\
   %D%/packages/patches/vte-CVE-2012-2738-pt2.patch			\
-  %D%/packages/patches/vtk-mesa-10.patch			\
   %D%/packages/patches/weechat-python.patch			\
   %D%/packages/patches/wicd-bitrate-none-fix.patch		\
   %D%/packages/patches/wicd-get-selected-profile-fix.patch	\
diff --git a/gnu/packages/patches/vtk-mesa-10.patch b/gnu/packages/patches/vtk-mesa-10.patch
deleted file mode 100644
index bc60af68c4..0000000000
--- a/gnu/packages/patches/vtk-mesa-10.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-Fix build against new mesa.  See:
-
-  https://bugs.freedesktop.org/show_bug.cgi?id=83631
-  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=765938
-
-Description: fixes FTBFS against new libjpeg-turbo
-Author: Ondřej Surý <ondrej@debian.org>
-Bug-Debian: https://bugs.debian.org/765938
-Reviewed-By: Anton Gladky <gladk@debian.org>
-Last-Update: 2014-10-22
-
-Index: vtk6-6.1.0+dfsg2/Rendering/OpenGL/vtkOpenGL.h
-===================================================================
---- vtk6-6.1.0+dfsg2.orig/Rendering/OpenGL/vtkOpenGL.h
-+++ vtk6-6.1.0+dfsg2/Rendering/OpenGL/vtkOpenGL.h
-@@ -20,6 +20,7 @@
- 
- // To prevent gl.h to include glext.h provided by the system
- #define GL_GLEXT_LEGACY
-+#define GLX_GLEXT_LEGACY
- #if defined(__APPLE__) && (defined(VTK_USE_CARBON) || defined(VTK_USE_COCOA))
- # include <OpenGL/gl.h> // Include OpenGL API.
- #else
-Index: vtk6-6.1.0+dfsg2/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx
-===================================================================
---- vtk6-6.1.0+dfsg2.orig/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx
-+++ vtk6-6.1.0+dfsg2/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx
-@@ -27,7 +27,7 @@
- 
- // define GLX_GLXEXT_LEGACY to prevent glx.h to include glxext.h provided by
- // the system
--//#define GLX_GLXEXT_LEGACY
-+#define GLX_GLXEXT_LEGACY
- #include "GL/glx.h"
- 
- #include "vtkgl.h"
diff --git a/gnu/packages/vtk.scm b/gnu/packages/vtk.scm
index 13ce2e2ac0..eef982a8b3 100644
--- a/gnu/packages/vtk.scm
+++ b/gnu/packages/vtk.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -29,17 +30,15 @@
 (define-public vtk
   (package
     (name "vtk")
-    (version "6.1.0")
+    (version "7.1.0")
     (source (origin
               (method url-fetch)
               (uri (string-append "http://www.vtk.org/files/release/"
-                                  (substring version 0
-                                             (string-rindex version #\.))
+                                  (version-major+minor version)
                                   "/VTK-" version ".tar.gz"))
               (sha256
                (base32
-                "0d7shccdkyj4mbh2riilslgx3gd28in4c7xpm0lxa1ln8w5g2zdx"))
-              (patches (search-patches "vtk-mesa-10.patch"))))
+                "0yj96z58haan77gzilnqp7xpf8hg5jk11a3jx55p2ksd400s0gjz"))))
     (build-system cmake-build-system)
     (arguments
      ;; Build without '-g' to save space.
-- 
cgit 1.4.1


From ab519cfa3db289303eb2e640d959340b3f66e738 Mon Sep 17 00:00:00 2001
From: Ricardo Wurmus <rekado@elephly.net>
Date: Wed, 30 Nov 2016 17:04:34 +0100
Subject: gnu: Add fcgi.

* gnu/packages/patches/fcgi-2.4.0-gcc44-fixes.patch: New file.
* gnu/packages/patches/fcgi-2.4.0-poll.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register patches.
* gnu/packages/web.scm (fcgi): New variable.
---
 gnu/local.mk                                      |  2 +
 gnu/packages/patches/fcgi-2.4.0-gcc44-fixes.patch | 14 ++++
 gnu/packages/patches/fcgi-2.4.0-poll.patch        | 89 +++++++++++++++++++++++
 gnu/packages/web.scm                              | 25 +++++++
 4 files changed, 130 insertions(+)
 create mode 100644 gnu/packages/patches/fcgi-2.4.0-gcc44-fixes.patch
 create mode 100644 gnu/packages/patches/fcgi-2.4.0-poll.patch

(limited to 'gnu/packages/patches')

diff --git a/gnu/local.mk b/gnu/local.mk
index f6f2db6df9..2fc4b6cf5b 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -540,6 +540,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/fasthenry-spUtils.patch			\
   %D%/packages/patches/fasthenry-spSolve.patch			\
   %D%/packages/patches/fasthenry-spFactor.patch			\
+  %D%/packages/patches/fcgi-2.4.0-gcc44-fixes.patch		\
+  %D%/packages/patches/fcgi-2.4.0-poll.patch			\
   %D%/packages/patches/findutils-localstatedir.patch		\
   %D%/packages/patches/findutils-test-xargs.patch		\
   %D%/packages/patches/flex-CVE-2016-6354.patch			\
diff --git a/gnu/packages/patches/fcgi-2.4.0-gcc44-fixes.patch b/gnu/packages/patches/fcgi-2.4.0-gcc44-fixes.patch
new file mode 100644
index 0000000000..0f921b120b
--- /dev/null
+++ b/gnu/packages/patches/fcgi-2.4.0-gcc44-fixes.patch
@@ -0,0 +1,14 @@
+Taken from http://pkgs.fedoraproject.org/cgit/rpms/fcgi.git/plain/fcgi-2.4.0-gcc44_fixes.patch.
+Fixes compilation with GCC 4.4 and later.
+
+diff -up fcgi-2.4.0/libfcgi/fcgio.cpp.gcc44_fixes fcgi-2.4.0/libfcgi/fcgio.cpp
+--- fcgi-2.4.0/libfcgi/fcgio.cpp.gcc44_fixes	2002-02-24 21:12:22.000000000 +0100
++++ fcgi-2.4.0/libfcgi/fcgio.cpp	2009-02-15 11:35:18.000000000 +0100
+@@ -23,6 +23,7 @@
+ #endif
+ 
+ #include <limits.h>
++#include <cstdio>
+ #include "fcgio.h"
+ 
+ using std::streambuf;
diff --git a/gnu/packages/patches/fcgi-2.4.0-poll.patch b/gnu/packages/patches/fcgi-2.4.0-poll.patch
new file mode 100644
index 0000000000..73be6a0a08
--- /dev/null
+++ b/gnu/packages/patches/fcgi-2.4.0-poll.patch
@@ -0,0 +1,89 @@
+Taken from http://pkgs.fedoraproject.org/cgit/rpms/fcgi.git/plain/fcgi-2.4.0-poll.patch
+Fixes CVE-2012-6687.
+
+Author: Anton Kortunov <toshic.toshic@gmail.com>
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libfcgi/+bug/933417
+Description: use poll in os_unix.c instead of select to avoid problem with > 1024 connections
+Forwarded: yes, fastcgi-developers@mailman.fastcgi.com
+
+diff --git a/libfcgi/os_unix.c b/libfcgi/os_unix.c
+index 73e6a7f..af35aee 100755
+--- a/libfcgi/os_unix.c
++++ b/libfcgi/os_unix.c
+@@ -42,6 +42,7 @@ static const char rcsid[] = "$Id: os_unix.c,v 1.37 2002/03/05 19:14:49 robs Exp
+ #include <sys/time.h>
+ #include <sys/un.h>
+ #include <signal.h>
++#include <poll.h>
+ 
+ #ifdef HAVE_NETDB_H
+ #include <netdb.h>
+@@ -103,6 +104,9 @@ static int volatile maxFd = -1;
+ static int shutdownPending = FALSE;
+ static int shutdownNow = FALSE;
+ 
++static int libfcgiOsClosePollTimeout = 2000;
++static int libfcgiIsAfUnixKeeperPollTimeout = 2000;
++
+ void OS_ShutdownPending()
+ {
+     shutdownPending = TRUE;
+@@ -168,6 +172,16 @@ int OS_LibInit(int stdioFds[3])
+     if(libInitialized)
+         return 0;
+ 
++    char *libfcgiOsClosePollTimeoutStr = getenv( "LIBFCGI_OS_CLOSE_POLL_TIMEOUT" );
++    if(libfcgiOsClosePollTimeoutStr) {
++        libfcgiOsClosePollTimeout = atoi(libfcgiOsClosePollTimeoutStr);
++    }
++
++    char *libfcgiIsAfUnixKeeperPollTimeoutStr = getenv( "LIBFCGI_IS_AF_UNIX_KEEPER_POLL_TIMEOUT" );
++    if(libfcgiIsAfUnixKeeperPollTimeoutStr) {
++        libfcgiIsAfUnixKeeperPollTimeout = atoi(libfcgiIsAfUnixKeeperPollTimeoutStr);
++    }
++
+     asyncIoTable = (AioInfo *)malloc(asyncIoTableSize * sizeof(AioInfo));
+     if(asyncIoTable == NULL) {
+         errno = ENOMEM;
+@@ -755,19 +769,16 @@ int OS_Close(int fd)
+ 
+     if (shutdown(fd, 1) == 0)
+     {
+-        struct timeval tv;
+-        fd_set rfds;
++        struct pollfd pfd;
+         int rv;
+         char trash[1024];
+ 
+-        FD_ZERO(&rfds);
++        pfd.fd = fd;
++        pfd.events = POLLIN;
+ 
+         do 
+         {
+-            FD_SET(fd, &rfds);
+-            tv.tv_sec = 2;
+-            tv.tv_usec = 0;
+-            rv = select(fd + 1, &rfds, NULL, NULL, &tv);
++            rv = poll(&pfd, 1, libfcgiOsClosePollTimeout);
+         }
+         while (rv > 0 && read(fd, trash, sizeof(trash)) > 0);
+     }
+@@ -1116,13 +1127,11 @@ static int is_reasonable_accept_errno (const int error)
+  */
+ static int is_af_unix_keeper(const int fd)
+ {
+-    struct timeval tval = { READABLE_UNIX_FD_DROP_DEAD_TIMEVAL };
+-    fd_set read_fds;
+-
+-    FD_ZERO(&read_fds);
+-    FD_SET(fd, &read_fds);
++    struct pollfd pfd;
++    pfd.fd = fd;
++    pfd.events = POLLIN;
+ 
+-    return select(fd + 1, &read_fds, NULL, NULL, &tval) >= 0 && FD_ISSET(fd, &read_fds);
++    return poll(&pfd, 1, libfcgiIsAfUnixKeeperPollTimeout) >= 0 && (pfd.revents & POLLIN);
+ }
+ 
+ /*
diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index 593b0ab41a..7c869c0b11 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -201,6 +201,31 @@ and as a proxy to reduce the load on back-end HTTP or mail servers.")
     ;;     except for two source files which are bsd-4 licensed.
     (license (list l:bsd-2 l:expat l:bsd-3 l:bsd-4))))
 
+(define-public fcgi
+  (package
+    (name "fcgi")
+    (version "2.4.0")
+    (source
+     (origin
+       (method url-fetch)
+       ;; Upstream has disappeared
+       (uri (string-append "https://sources.archlinux.org/other/packages/fcgi/"
+                           "fcgi-" version ".tar.gz"))
+       (sha256
+        (base32
+         "1f857wnl1d6jfrgfgfpz3zdaj8fch3vr13mnpcpvy8bang34bz36"))
+       (patches (search-patches "fcgi-2.4.0-poll.patch"
+                                "fcgi-2.4.0-gcc44-fixes.patch"))))
+    (build-system gnu-build-system)
+    (home-page "http://www.fastcgi.com")
+    (synopsis "Language-independent, high-performant extension to CGI")
+    (description "FastCGI is a language independent, scalable extension to CGI
+that provides high performance without the limitations of server specific
+APIs.")
+    ;; This package is released under the Open Market License, a variant of
+    ;; the Expat license, incompatible with the GPL.
+    (license (l:non-copyleft "file://LICENSE.TERMS"))))
+
 (define-public starman
   (package
     (name "starman")
-- 
cgit 1.4.1


From 5bdec7d634ce0058801cd212e9e4ea56e914ca0c Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw@netris.org>
Date: Sat, 3 Dec 2016 12:19:17 -0500
Subject: gnu: icecat: Update to 45.5.1-gnu1.

* gnu/packages/gnuzilla.scm (icecat): Update to 45.5.1-gnu1.
[source]: Remove temporary URI for 45.3 beta.  Fix URI computation.  Remove
outdated patches.  Add more cherry-picked bug fixes from upstream
mozilla-esr45.  Use 'list' instead of quasiquote in 'patches' field.
---
 gnu/local.mk                                    |   1 -
 gnu/packages/gnuzilla.scm                       | 106 +--
 gnu/packages/patches/icecat-CVE-2016-9064.patch | 996 ------------------------
 3 files changed, 32 insertions(+), 1071 deletions(-)
 delete mode 100644 gnu/packages/patches/icecat-CVE-2016-9064.patch

(limited to 'gnu/packages/patches')

diff --git a/gnu/local.mk b/gnu/local.mk
index 2fc4b6cf5b..e5755ec968 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -628,7 +628,6 @@ dist_patch_DATA =						\
   %D%/packages/patches/hypre-ldflags.patch			\
   %D%/packages/patches/icecat-avoid-bundled-libraries.patch	\
   %D%/packages/patches/icecat-binutils.patch			\
-  %D%/packages/patches/icecat-CVE-2016-9064.patch		\
   %D%/packages/patches/icu4c-CVE-2014-6585.patch		\
   %D%/packages/patches/icu4c-CVE-2015-1270.patch		\
   %D%/packages/patches/icu4c-CVE-2015-4760.patch		\
diff --git a/gnu/packages/gnuzilla.scm b/gnu/packages/gnuzilla.scm
index 3342a39122..f63e950f29 100644
--- a/gnu/packages/gnuzilla.scm
+++ b/gnu/packages/gnuzilla.scm
@@ -303,82 +303,41 @@ standards.")
 (define-public icecat
   (package
     (name "icecat")
-    (version "45.3.0-gnu1-beta")
+    (version "45.5.1-gnu1")
     (source
      (origin
       (method url-fetch)
-      (uri (list (string-append "mirror://gnu/gnuzilla/" version "/"
-                                name "-" version ".tar.bz2")
-                 ;; XXX Temporary URI for 45.3 beta release.
-                 ;;     Remove when no longer needed.
-                 (string-append "http://jenkins.trisquel.info/icecat/binaries/"
-                                "icecat-45.3.0-gnu1.tar.bz2")))
+      (uri (string-append "mirror://gnu/gnuzilla/"
+                          (first (string-split version #\-))
+                          "/" name "-" version ".tar.bz2"))
       (sha256
        (base32
-        "1hk5lwaqm8nkfm43sq521mzyrx0x3iiwvlcy62m7cq7grz9wixp6"))
+        "1sbfgsibmb8wfmb2g40gmqwq3nikmrgzksf51ydrz7gnafyfaqw1"))
       (patches
-       `(,(search-patch "icecat-avoid-bundled-libraries.patch")
-         ,(search-patch "icecat-binutils.patch")
-         ,(mozilla-patch "icecat-CVE-2016-5250.patch"     "6711ccb0184e" "1p0s91rw1j7ib6hy9gh5p0l33rja32rfgygh29jw4wq1hxfql8rk")
-         ,(mozilla-patch "icecat-CVE-2016-5257-pt1.patch" "b08f28db372e" "0fmifimavawbff700rzjibsnr16am6902gp965scvi1iy78754ia")
-         ,(mozilla-patch "icecat-CVE-2016-5257-pt2.patch" "a49fd7eb57ba" "1dyh0pjdmf64sjbj1x0mdjwfispacx9yny1kx9nzpf85myryr640")
-         ,(mozilla-patch "icecat-CVE-2016-5257-pt3.patch" "9707c3423a1e" "12nn8av0akza4ml1is9mfy8f7368mrkxsl32ly97r4irzh0iryh1")
-         ,(mozilla-patch "icecat-CVE-2016-5257-pt4.patch" "9d632865560a" "1msp1wqv0c317wqkm82hd9ajbg4a5mcr8pld5j8cx37ccv7f21g3")
-         ,(mozilla-patch "icecat-CVE-2016-5257-pt5.patch" "90697781ec9f" "1h6gcrw5ykf7r59phxqkhpfs7jsgzqn509qm43sj7mbpcvqvk5mg")
-         ,(mozilla-patch "icecat-CVE-2016-5257-pt6.patch" "dd9eb81853b9" "1lyqnn40sayziych8gqd5aj7il3zajf318y8ddj8dzz3c8id5dzc")
-         ,(mozilla-patch "icecat-CVE-2016-5257-pt7.patch" "d91fc76079e0" "022lhixa8dxa6ny9a4bh2di282i0lhyq0glqr9n4q3r8msfmf0ba")
-         ,(mozilla-patch "icecat-CVE-2016-5257-pt8.patch" "3e37ba5e0867" "1w8lncxaayq4xndhyp1hwlv00zggbayljq6rlypb8kdwgzfpi77w")
-         ,(mozilla-patch "icecat-CVE-2016-5257-pt9.patch" "3c4958a98908" "16bc6ai5qddnpm3yw24lry5s7i05xs0ycixzxiir4wmcgwcaayiy")
-         ,(mozilla-patch "icecat-CVE-2016-5261.patch"     "bc2f5467b33d" "0i4b8ydmqg4blx541f56g9qrlm7gp6ih4cs7ixbds724cwk83b9f")
-         ,(mozilla-patch "icecat-CVE-2016-5270.patch"     "7cd50d56bb61" "15nbp5axr59mczxgf37nli37jbw0jdknmxz7z71772pzjd2z07r9")
-         ,(mozilla-patch "icecat-CVE-2016-5272.patch"     "6e43a01fee3c" "025xp1wdnz1gc5l2rsgbrwsh1pbysjiyfgz0g6rvr390r7ag1n74")
-         ,(mozilla-patch "icecat-CVE-2016-5274.patch"     "10c9453407de" "1wqh6hj0dpa7r3hhlyrflcv3r3cg0xq4rb0zvhysi6l7lwb8q51r")
-         ,(mozilla-patch "icecat-CVE-2016-5276.patch"     "fc818ab03f15" "1q64ipl172dcmyy9p8p3l3ljpdh1q1jg48lai0qn2xgknl7sdpks")
-         ,(mozilla-patch "icecat-CVE-2016-5277.patch"     "7b668c5cec92" "1qmchn6qifgjakzac6i4hgnivy062pzgz9p1l11c1m3an1rh0isg")
-         ,(mozilla-patch "icecat-CVE-2016-5278.patch"     "fd5052e343df" "1nzmzlnsz61w9aw4mjvgmlkz88aqv1w858rr0mbv07hwyrljfi84")
-         ,(mozilla-patch "icecat-CVE-2016-5280.patch"     "30673bc9730b" "1qz1684v1rp86ngadcaqd68iqf472flnrnk971ryg4fbsyy8g1za")
-         ,(mozilla-patch "icecat-CVE-2016-5281-pt1.patch" "61405f1fd1df" "1fgmq67arwsl1nrl133fcb5cz6jbbcfjvbv8cd8cadhapin971a7")
-         ,(mozilla-patch "icecat-CVE-2016-5281-pt2.patch" "7776b6ec7b92" "1f7k8f4lk7nyghwajsxf6nb7yvzsaw3jwpa3316znsva12m548mn")
-         ,(mozilla-patch "icecat-CVE-2016-5284-pt1.patch" "55e768767416" "1gg7m12njbkn1jqf2gp2y7zd9ik3xhqkjb7znczna4l438h7ki83")
-         ,(mozilla-patch "icecat-CVE-2016-5284-pt2.patch" "3c42249975a5" "0gnanndkmhsp49rldv4kh0smkdcs7616v46hn567kfw8yfwqvnli")
-         ,(mozilla-patch "icecat-CVE-2016-5284-pt3.patch" "126e5d574811" "13gr08bzqy23adz0ciihb7cy9wdnkcn71i77a3y5b5apm6k54mwi")
-         ,(mozilla-patch "icecat-CVE-2016-5284-pt4.patch" "7b8bd7aae1a8" "0mq5gpq6ni8czfcs1rif4is0igh0054aw41ga0jqkq58g7lavkrf")
-         ,(mozilla-patch "icecat-CVE-2016-5284-pt5.patch" "0799490f4e6f" "1ypv6i48nabbhcqbach8fbgz9bmnhm7q5z9dnfid44z8g54l3f33")
-         ,(mozilla-patch "icecat-CVE-2016-5284-pt6.patch" "fc990e4ae8bc" "1s2cj505ajwwiy4xvn5zlmyzqpgahxmqqvis0a6xm6mjbjh02gm4")
-         ,(mozilla-patch "icecat-bug-1251088.patch"       "5ffa912ed83e" "0v5lpv3c89c2d4y5acn0kyijv096axdnrvaj5ya5yypzfcaqxv24")
-         ,(mozilla-patch "icecat-CVE-2016-5290-pt1.patch" "d4b5b8f3e373" "0w8cxn6ryhgxryy8k8i06yw4mknv509ns9ff1avd0hmgxa83mcdp")
-         ,(mozilla-patch "icecat-CVE-2016-5290-pt2.patch" "adce603ae36d" "0mgs85cwx61bk17r7npl311l4m8yn4667wyhgjmm2ajiys6nn0yl")
-         ,(mozilla-patch "icecat-CVE-2016-5290-pt3.patch" "97268426bb6f" "1z7hg796cgag025gm9pp2szz7w870s7naagdri1dlsilj797v8hr")
-         ,(mozilla-patch "icecat-CVE-2016-5290-pt4.patch" "fc055950b6b8" "05iml5k3rzc653jk4imd111sh18625jxfxkcj12kjdihl0gdr4x4")
-         ,(mozilla-patch "icecat-CVE-2016-5290-pt5.patch" "6f845c23565b" "01dlbnmpsnwr448fajs276y62gl03r74k1hxnwsg6ihwhnfdvn5a")
-         ,(mozilla-patch "icecat-CVE-2016-5290-pt6.patch" "e5d51ca7a3c0" "0hshcz24hc6pkz5pcqxhajm17ibwrlfn1s00frfnpjjy56vacfz0")
-         ,(mozilla-patch "icecat-CVE-2016-5290-pt7.patch" "61d1463acd04" "1iig4a79dxmfcr6w82mdhyl88wy7d36g5n4p24632kbabgl9j9sz")
-         ,(mozilla-patch "icecat-CVE-2016-5290-pt8.patch" "8e0bab4216de" "1knq8h5ni8crfndi3p78b2pyj5lzchqw67vk0yx061r76mq4wp4r")
-         ,(mozilla-patch "icecat-CVE-2016-5290-pt9.patch" "bb10104dc89e" "1flvagckrzfk7hs2xzb5j3s5i0ck57ygyskh5494xmpa2a1nnsqj")
-         ,(mozilla-patch "icecat-CVE-2016-5290-pt10.patch" "7006b275b829" "0sqagm247wx94mf51fyhdkn0vf1a1qy9i829shjnhssd79srxmnn")
-         ,(mozilla-patch "icecat-CVE-2016-5290-pt11.patch" "32ce7be98543" "1y2r9i4p1qpqi75mlwmibr51whz5h1vj28c6mh6ik57dxkqxbclb")
-         ,(mozilla-patch "icecat-CVE-2016-5291.patch"     "3ff0c89f3b26" "1prn74aglshaj27jfrpd2s2i4slpljw4rbzjxc1qgwjvkq4m6j6f")
-         ,(mozilla-patch "icecat-CVE-2016-5297.patch"     "46b07bdbf8b2" "1n8y1c5l0ms81dra7jsx8mp633ak5qvx105drvlg9hn3m0fwv1lj")
-         ,(search-patch  "icecat-CVE-2016-9064.patch") ; adapted for icecat based on:
-                                        ;                 "00c2b7baaa0b" "0y02yb7r62656nq9dji9dnwils2lxqasjz5byv62j1xa87r7f9hp"
-         ,(mozilla-patch "icecat-CVE-2016-9066.patch"     "576f1725a57e" "1lic9d3r8r1vcniw1g3ca71390lw3dmwjsw55dp6z96hyjbcq3fd")
-         ,(mozilla-patch "icecat-CVE-2016-9079.patch"     "e6eb0a3a3c76" "1gfcl58cm255sn3f5fwfhw21c2msbghg9i1b3nc9pp4gafaj2p9i")
-         ,(mozilla-patch "icecat-bug-1212939.patch"       "4a0e851f83e4" "182vx1qxrr7r2175jjf0bcixwwm1khdj4sq0c8wnsyry7p9waq5q")
-         ,(mozilla-patch "icecat-bug-1168743.patch"       "a1e06af61ab3" "07llk1ba6axjasiv30vicz96k55ff4mybxy21vjxk6j0asgyjz23")
-         ,(mozilla-patch "icecat-bug-1287176.patch"       "0569d5dce9db" "1d41sqbq6jc3af73dz9w19win7v7c12kw1mp7j7b1gkadq46c4y7")
-         ,(mozilla-patch "icecat-bug-1263665.patch"       "a79cafee93f4" "0bn7hpm8mh8qmkpz5wiridr792irrs5sjxyvryazy2i0p4pjh62p")
-         ,(mozilla-patch "icecat-bug-1304962.patch"       "f61049d5f373" "04d1na31qqq7yq4jjvhq6vzqq3f23rwac8c6fw4h5fx1pdb3l997")
-         ,(mozilla-patch "icecat-bug-1314574.patch"       "46b2558ca469" "00q8676xg4wb7p371wgi04nl05j7idkb2kna9a0l08k6lks9wdhh")
-         ,(mozilla-patch "icecat-bug-1301381.patch"       "2e5438a92617" "0pyjbzyy04759ldpcar8q8cccv67j1jkxsg46rkq7a3rbhmwmw4p")
-         ,(mozilla-patch "icecat-bug-1317409.patch"       "7391f60fb790" "1hydggpmmm2cs9lb15micnkxn4wl4cda9g74hkn3zmks805vjz3h")
-         ,(mozilla-patch "icecat-bug-1309834.patch"       "744e01001e6e" "0z2fq765kap3ll9as5rvjpnbj3pw26074alw7df0zi215qz47nxr")
-         ,(mozilla-patch "icecat-bug-1317936-pt1.patch"   "8ae673f34a5b" "1rlbihckl9afa0y91lqs7gpnv6a7zxzrmxjv95y3yrl03kibqp76")
-         ,(mozilla-patch "icecat-bug-1317936-pt2.patch"   "409c23c144fe" "05kgs16y8s5pxmg2dxp93247zagnj6zgj3209qpm5hz3an7gr13h")
-         ,(mozilla-patch "icecat-bug-1319122.patch"       "994d9bd0e28d" "007wifyx3b2ln4fwv1i8n24yz5ngjf4mkzd7sqr5bpd3q88ff293")
-         ,(mozilla-patch "icecat-bug-1312609.patch"       "0fc43af8982e" "0pc8q9knzq2knj723mwkay1lnzbzysb07ygxnc16mcb6f7vl2mw8")
-         ,(mozilla-patch "icecat-bug-1319524.patch"       "19f9a4643d77" "0w5yxj1l0hvs66q9agjp4m5sfby7fj05lx33gaqf899bw4hn4vcf")
-         ,(mozilla-patch "icecat-bug-1312548.patch"       "c58442c414f5" "1z1w1v8xagkhrwgp51ij1k2gx0ripslia09vm78812n7gcwddaas")
-         ,(mozilla-patch "icecat-bug-1314442.patch"       "5054047b7328" "0xlw8irymfp3bcaa5jpf7clf7bq6qxp3i8zapp8jya8lzr1nf868")))
+       (list
+        (search-patch "icecat-avoid-bundled-libraries.patch")
+        (search-patch "icecat-binutils.patch")
+        (mozilla-patch "icecat-bug-1301381.patch"       "2e5438a92617" "0pyjbzyy04759ldpcar8q8cccv67j1jkxsg46rkq7a3rbhmwmw4p")
+        (mozilla-patch "icecat-bug-1317409.patch"       "7391f60fb790" "1hydggpmmm2cs9lb15micnkxn4wl4cda9g74hkn3zmks805vjz3h")
+        (mozilla-patch "icecat-bug-1309834.patch"       "744e01001e6e" "0z2fq765kap3ll9as5rvjpnbj3pw26074alw7df0zi215qz47nxr")
+        (mozilla-patch "icecat-bug-1317936-pt1.patch"   "8ae673f34a5b" "1rlbihckl9afa0y91lqs7gpnv6a7zxzrmxjv95y3yrl03kibqp76")
+        (mozilla-patch "icecat-bug-1317936-pt2.patch"   "409c23c144fe" "05kgs16y8s5pxmg2dxp93247zagnj6zgj3209qpm5hz3an7gr13h")
+        (mozilla-patch "icecat-bug-1319122.patch"       "994d9bd0e28d" "007wifyx3b2ln4fwv1i8n24yz5ngjf4mkzd7sqr5bpd3q88ff293")
+        (mozilla-patch "icecat-bug-1312609.patch"       "0fc43af8982e" "0pc8q9knzq2knj723mwkay1lnzbzysb07ygxnc16mcb6f7vl2mw8")
+        (mozilla-patch "icecat-bug-1319524.patch"       "19f9a4643d77" "0w5yxj1l0hvs66q9agjp4m5sfby7fj05lx33gaqf899bw4hn4vcf")
+        (mozilla-patch "icecat-bug-1312548.patch"       "c58442c414f5" "1z1w1v8xagkhrwgp51ij1k2gx0ripslia09vm78812n7gcwddaas")
+        (mozilla-patch "icecat-bug-1314442.patch"       "5054047b7328" "0xlw8irymfp3bcaa5jpf7clf7bq6qxp3i8zapp8jya8lzr1nf868")
+        (mozilla-patch "icecat-bug-881832-pt1.patch"    "1123263318a3" "1qkxwva3zrcs1zhga8ncmndq03988dx75i896g53gbvpskj06915")
+        (mozilla-patch "icecat-bug-881832-pt2.patch"    "dc87c0a39adf" "01rapf14f3r2wk0cjd16dn1rll4ipgs33cnjmjck48nvk67ikz6h")
+        (mozilla-patch "icecat-bug-881832-pt3.patch"    "f20e5f488368" "15ql9ywifb3gm2g1057k63f821dbs3wqsh3zhndprzf3dn6aha4i")
+        (mozilla-patch "icecat-bug-881832-pt4.patch"    "7950c4d5bd7c" "0jhkg5hq5yfy7rh21k1mpbsbr81ql85aazym30zy3n2cf28xxhd7")
+        (mozilla-patch "icecat-bug-881832-pt5.patch"    "972734ec21b6" "073i4v1f1ydy49i57pvzscz95sjr5bbk9s5sajxvmmcsmwhpjdfy")
+        (mozilla-patch "icecat-bug-1293985-pt1.patch"   "aebd3687e05e" "1qz6hdgflcrqyg7fv66cbg23v4b7q5bc2yxzrgjxs4j1d7jy1s0s")
+        (mozilla-patch "icecat-bug-1293985-pt2.patch"   "63d8e5cd27cb" "11fsgyngy7v59ma30xdbmycwf4izwikzvaljngm3ks4534inpl4a")
+        (mozilla-patch "icecat-bug-1279202.patch"       "e560997291af" "1hn35slasfcj3ryka4fsarx4l9r99z0iwj67fmbv6zxz4z133kks")
+        (mozilla-patch "icecat-bug-1320039.patch"       "21c615b65048" "0ibgsxa36x9ajn2jqbhxxvrfvj6x6iyspsmzzn4brdz11n93skhr")
+        (mozilla-patch "icecat-bug-1320057.patch"       "c15e5afc0430" "17gj32agqs94548z8lvz0l6zz3kbwajn8as0y4iw5nb6jsll4c66")
+        (mozilla-patch "icecat-bug-1163212.patch"       "46163fb1cb34" "1yikayczfgfla3aka0159apq3149d52sgvlca0sivx4myd0lvjm7")))
       (modules '((guix build utils)))
       (snippet
        '(begin
@@ -422,7 +381,7 @@ standards.")
                       "db/sqlite3"))
           ;; Delete .pyc files, typically present in icecat source tarballs
           (for-each delete-file (find-files "." "\\.pyc$"))
-          ;; Delete obj-* directories, found in icecat-45.3.0-gnu1-beta
+          ;; Delete obj-* directories, sometimes present in icecat tarballs
           (for-each delete-file-recursively
                     (scandir "." (lambda (name)
                                    (string-prefix? "obj-" name))))
@@ -502,9 +461,8 @@ standards.")
                            "--disable-debug"
                            "--disable-debug-symbols"
 
-                           ;; Temporary hack to work around missing
-                           ;; "unofficial" branding in
-                           ;; icecat-45.3.0-gnu1-beta.
+                           ;; Hack to work around missing
+                           ;; "unofficial" branding in icecat.
                            "--enable-official-branding"
 
                            ;; Avoid bundled libraries.
diff --git a/gnu/packages/patches/icecat-CVE-2016-9064.patch b/gnu/packages/patches/icecat-CVE-2016-9064.patch
deleted file mode 100644
index a5393815e0..0000000000
--- a/gnu/packages/patches/icecat-CVE-2016-9064.patch
+++ /dev/null
@@ -1,996 +0,0 @@
-Copied from
-<https://hg.mozilla.org/releases/mozilla-esr45/raw-rev/00c2b7baaa0b>
-but with one hunk omitted: the git binary patch for
-toolkit/mozapps/extensions/test/addons/test_update_multi2/addon.xpi
-which is not present in the IceCat sources.
-
-# HG changeset patch
-# User Andrew Swan <aswan@mozilla.com>
-# Date 1474063218 25200
-# Node ID 00c2b7baaa0b4bfb7d5f1aac31c094ea6b255e1f
-# Parent  46b07bdbf8b20cf3fdc28104add57ff58a55832b
-Bug 1303418 - Don't allow upgrades that change the addon ID. r=mossop, a=lizzard
-
-MozReview-Commit-ID: JHINo8ShmeI
-
-diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm
---- a/toolkit/mozapps/extensions/AddonManager.jsm
-+++ b/toolkit/mozapps/extensions/AddonManager.jsm
-@@ -2956,16 +2956,18 @@ this.AddonManager = {
-   // The downloaded file seems to be corrupted in some way.
-   ERROR_CORRUPT_FILE: -3,
-   // An error occured trying to write to the filesystem.
-   ERROR_FILE_ACCESS: -4,
-   // The add-on must be signed and isn't.
-   ERROR_SIGNEDSTATE_REQUIRED: -5,
-   // The downloaded add-on had a different type than expected.
-   ERROR_UNEXPECTED_ADDON_TYPE: -6,
-+  // The addon did not have the expected ID
-+  ERROR_INCORRECT_ID: -7,
- 
-   // These must be kept in sync with AddonUpdateChecker.
-   // No error was encountered.
-   UPDATE_STATUS_NO_ERROR: 0,
-   // The update check timed out
-   UPDATE_STATUS_TIMEOUT: -1,
-   // There was an error while downloading the update information.
-   UPDATE_STATUS_DOWNLOAD_ERROR: -2,
-diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
---- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
-+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
-@@ -5473,16 +5473,37 @@ AddonInstall.prototype = {
-       // loadManifestFromZipReader performs the certificate verification for us
-       this.addon = yield loadManifestFromZipReader(zipreader, this.installLocation);
-     }
-     catch (e) {
-       zipreader.close();
-       return Promise.reject([AddonManager.ERROR_CORRUPT_FILE, e]);
-     }
- 
-+    if (this.existingAddon) {
-+      // Check various conditions related to upgrades
-+      if (this.addon.id != this.existingAddon.id) {
-+        zipreader.close();
-+        return Promise.reject([AddonManager.ERROR_INCORRECT_ID,
-+                               `Refusing to upgrade addon ${this.existingAddon.id} to different ID ${this.addon.id}`]);
-+      }
-+
-+      if (this.addon.type == "multipackage") {
-+        zipreader.close();
-+        return Promise.reject([AddonManager.ERROR_UNEXPECTED_ADDON_TYPE,
-+                               `Refusing to upgrade addon ${this.existingAddon.id} to a multi-package xpi`]);
-+      }
-+
-+      if (this.existingAddon.type == "webextension" && this.addon.type != "webextension") {
-+        zipreader.close();
-+        return Promise.reject([AddonManager.ERROR_UNEXPECTED_ADDON_TYPE,
-+                               "Webextensions may not be updated to other extension types"]);
-+      }
-+    }
-+
-     if (mustSign(this.addon.type)) {
-       if (this.addon.signedState <= AddonManager.SIGNEDSTATE_MISSING) {
-         // This add-on isn't properly signed by a signature that chains to the
-         // trusted root.
-         let state = this.addon.signedState;
-         this.addon = null;
-         zipreader.close();
- 
-@@ -5510,23 +5531,16 @@ AddonInstall.prototype = {
-         } else {
-           zipreader.close();
-           return Promise.reject([AddonManager.ERROR_CORRUPT_FILE,
-                                  "XPI is incorrectly signed"]);
-         }
-       }
-     }
- 
--    if (this.existingAddon && this.existingAddon.type == "webextension" &&
--        this.addon.type != "webextension") {
--      zipreader.close();
--      return Promise.reject([AddonManager.ERROR_UNEXPECTED_ADDON_TYPE,
--                             "WebExtensions may not be upated to other extension types"]);
--    }
--
-     if (this.addon.type == "multipackage")
-       return this._loadMultipackageManifests(zipreader);
- 
-     zipreader.close();
- 
-     this.updateAddonURIs();
- 
-     this.addon._install = this;
-@@ -5791,16 +5805,17 @@ AddonInstall.prototype = {
-           else {
-             // TODO Should we send some event here (bug 557716)?
-             this.state = AddonManager.STATE_CHECKING;
-             new UpdateChecker(this.addon, {
-               onUpdateFinished: aAddon => this.downloadCompleted(),
-             }, AddonManager.UPDATE_WHEN_ADDON_INSTALLED);
-           }
-         }, ([error, message]) => {
-+          this.removeTemporaryFile();
-           this.downloadFailed(error, message);
-         });
-       }
-       else {
-         if (aRequest instanceof Ci.nsIHttpChannel)
-           this.downloadFailed(AddonManager.ERROR_NETWORK_FAILURE,
-                               aRequest.responseStatus + " " +
-                               aRequest.responseStatusText);
-diff --git a/toolkit/mozapps/extensions/test/addons/test_update_multi1/bootstrap.js b/toolkit/mozapps/extensions/test/addons/test_update_multi1/bootstrap.js
-new file mode 100644
---- /dev/null
-+++ b/toolkit/mozapps/extensions/test/addons/test_update_multi1/bootstrap.js
-@@ -0,0 +1,5 @@
-+
-+function install(data, reason) {}
-+function startup(data, reason) {}
-+function shutdown(data, reason) {}
-+function uninstall(data, reason) {}
-diff --git a/toolkit/mozapps/extensions/test/addons/test_update_multi1/install.rdf b/toolkit/mozapps/extensions/test/addons/test_update_multi1/install.rdf
-new file mode 100644
---- /dev/null
-+++ b/toolkit/mozapps/extensions/test/addons/test_update_multi1/install.rdf
-@@ -0,0 +1,16 @@
-+<?xml version="1.0"?>
-+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-+<Description about="urn:mozilla:install-manifest">
-+  <em:id>updatemulti@tests.mozilla.org</em:id>
-+  <em:version>1.0</em:version>
-+  <em:updateURL>http://localhost:4444/data/test_update_multi.rdf</em:updateURL>
-+  <em:bootstrap>true</em:bootstrap>
-+  <em:name>Test Addon 1</em:name>
-+<em:targetApplication><Description>
-+  <em:id>xpcshell@tests.mozilla.org</em:id>
-+  <em:minVersion>1</em:minVersion>
-+  <em:maxVersion>1</em:maxVersion>
-+</Description></em:targetApplication>
-+</Description>
-+</RDF>
-diff --git a/toolkit/mozapps/extensions/test/addons/test_update_multi2/install.rdf b/toolkit/mozapps/extensions/test/addons/test_update_multi2/install.rdf
-new file mode 100644
---- /dev/null
-+++ b/toolkit/mozapps/extensions/test/addons/test_update_multi2/install.rdf
-@@ -0,0 +1,9 @@
-+<?xml version="1.0"?>
-+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-+<Description about="urn:mozilla:install-manifest">
-+  <em:id>updatemulti@tests.mozilla.org</em:id>
-+  <em:type>32</em:type>
-+  <em:version>2.0</em:version>
-+</Description>
-+</RDF>
-diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid1/bootstrap.js b/toolkit/mozapps/extensions/test/addons/test_updateid1/bootstrap.js
-new file mode 100644
---- /dev/null
-+++ b/toolkit/mozapps/extensions/test/addons/test_updateid1/bootstrap.js
-@@ -0,0 +1,5 @@
-+
-+function install(data, reason) {}
-+function startup(data, reason) {}
-+function shutdown(data, reason) {}
-+function uninstall(data, reason) {}
-diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid1/install.rdf b/toolkit/mozapps/extensions/test/addons/test_updateid1/install.rdf
-new file mode 100644
---- /dev/null
-+++ b/toolkit/mozapps/extensions/test/addons/test_updateid1/install.rdf
-@@ -0,0 +1,16 @@
-+<?xml version="1.0"?>
-+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-+<Description about="urn:mozilla:install-manifest">
-+  <em:id>addon1@tests.mozilla.org</em:id>
-+  <em:version>1.0</em:version>
-+  <em:updateURL>http://localhost:4444/data/test_updateid.rdf</em:updateURL>
-+  <em:bootstrap>true</em:bootstrap>
-+  <em:name>Test Addon 1</em:name>
-+<em:targetApplication><Description>
-+  <em:id>xpcshell@tests.mozilla.org</em:id>
-+  <em:minVersion>1</em:minVersion>
-+  <em:maxVersion>1</em:maxVersion>
-+</Description></em:targetApplication>
-+</Description>
-+</RDF>
-diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid2/bootstrap.js b/toolkit/mozapps/extensions/test/addons/test_updateid2/bootstrap.js
-new file mode 100644
---- /dev/null
-+++ b/toolkit/mozapps/extensions/test/addons/test_updateid2/bootstrap.js
-@@ -0,0 +1,5 @@
-+
-+function install(data, reason) {}
-+function startup(data, reason) {}
-+function shutdown(data, reason) {}
-+function uninstall(data, reason) {}
-diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid2/install.rdf b/toolkit/mozapps/extensions/test/addons/test_updateid2/install.rdf
-new file mode 100644
---- /dev/null
-+++ b/toolkit/mozapps/extensions/test/addons/test_updateid2/install.rdf
-@@ -0,0 +1,16 @@
-+<?xml version="1.0"?>
-+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-+<Description about="urn:mozilla:install-manifest">
-+  <em:id>addon1.changed@tests.mozilla.org</em:id>
-+  <em:version>2.0</em:version>
-+  <em:updateURL>http://localhost:4444/data/test_updateid.rdf</em:updateURL>
-+  <em:bootstrap>true</em:bootstrap>
-+  <em:name>Test Addon 1</em:name>
-+<em:targetApplication><Description>
-+  <em:id>xpcshell@tests.mozilla.org</em:id>
-+  <em:minVersion>1</em:minVersion>
-+  <em:maxVersion>1</em:maxVersion>
-+</Description></em:targetApplication>
-+</Description>
-+</RDF>
-diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid2_2/install.rdf b/toolkit/mozapps/extensions/test/addons/test_updateid2_2/install.rdf
-deleted file mode 100644
---- a/toolkit/mozapps/extensions/test/addons/test_updateid2_2/install.rdf
-+++ /dev/null
-@@ -1,24 +0,0 @@
--<?xml version="1.0"?>
--
--<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
--     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
--
--  <Description about="urn:mozilla:install-manifest">
--    <em:id>addon2@tests.mozilla.org</em:id>
--    <em:version>2.0</em:version>
--    <em:updateURL>http://localhost:4444/data/test_updateid.rdf</em:updateURL>
--
--    <!-- Front End MetaData -->
--    <em:name>Test 2</em:name>
--    <em:description>Test Description</em:description>
--
--    <em:targetApplication>
--      <Description>
--        <em:id>xpcshell@tests.mozilla.org</em:id>
--        <em:minVersion>1</em:minVersion>
--        <em:maxVersion>1</em:maxVersion>
--      </Description>
--    </em:targetApplication>
--
--  </Description>
--</RDF>
-diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid2_5/install.rdf b/toolkit/mozapps/extensions/test/addons/test_updateid2_5/install.rdf
-deleted file mode 100644
---- a/toolkit/mozapps/extensions/test/addons/test_updateid2_5/install.rdf
-+++ /dev/null
-@@ -1,24 +0,0 @@
--<?xml version="1.0"?>
--
--<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
--     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
--
--  <Description about="urn:mozilla:install-manifest">
--    <em:id>addon2@tests.mozilla.org</em:id>
--    <em:version>5.0</em:version>
--    <em:updateURL>http://localhost:4444/data/test_updateid.rdf</em:updateURL>
--
--    <!-- Front End MetaData -->
--    <em:name>Test 2</em:name>
--    <em:description>Test Description</em:description>
--
--    <em:targetApplication>
--      <Description>
--        <em:id>xpcshell@tests.mozilla.org</em:id>
--        <em:minVersion>1</em:minVersion>
--        <em:maxVersion>1</em:maxVersion>
--      </Description>
--    </em:targetApplication>
--
--  </Description>
--</RDF>
-diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid3_3/bootstrap.js b/toolkit/mozapps/extensions/test/addons/test_updateid3_3/bootstrap.js
-deleted file mode 100644
---- a/toolkit/mozapps/extensions/test/addons/test_updateid3_3/bootstrap.js
-+++ /dev/null
-@@ -1,21 +0,0 @@
--Components.utils.import("resource://gre/modules/Services.jsm");
--
--function install(data, reason) {
--  Services.prefs.setIntPref("bootstraptest.installed_version", 3);
--  Services.prefs.setIntPref("bootstraptest.install_reason", reason);
--}
--
--function startup(data, reason) {
--  Services.prefs.setIntPref("bootstraptest.active_version", 3);
--  Services.prefs.setIntPref("bootstraptest.startup_reason", reason);
--}
--
--function shutdown(data, reason) {
--  Services.prefs.setIntPref("bootstraptest.active_version", 0);
--  Services.prefs.setIntPref("bootstraptest.shutdown_reason", reason);
--}
--
--function uninstall(data, reason) {
--  Services.prefs.setIntPref("bootstraptest.installed_version", 0);
--  Services.prefs.setIntPref("bootstraptest.uninstall_reason", reason);
--}
-diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid3_3/install.rdf b/toolkit/mozapps/extensions/test/addons/test_updateid3_3/install.rdf
-deleted file mode 100644
---- a/toolkit/mozapps/extensions/test/addons/test_updateid3_3/install.rdf
-+++ /dev/null
-@@ -1,25 +0,0 @@
--<?xml version="1.0"?>
--
--<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
--     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
--
--  <Description about="urn:mozilla:install-manifest">
--    <em:id>addon3@tests.mozilla.org</em:id>
--    <em:version>3.0</em:version>
--    <em:updateURL>http://localhost:4444/data/test_updateid.rdf</em:updateURL>
--    <em:bootstrap>true</em:bootstrap>
--
--    <!-- Front End MetaData -->
--    <em:name>Test 3</em:name>
--    <em:description>Test Description</em:description>
--
--    <em:targetApplication>
--      <Description>
--        <em:id>xpcshell@tests.mozilla.org</em:id>
--        <em:minVersion>1</em:minVersion>
--        <em:maxVersion>1</em:maxVersion>
--      </Description>
--    </em:targetApplication>
--
--  </Description>
--</RDF>
-diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid4_4/bootstrap.js b/toolkit/mozapps/extensions/test/addons/test_updateid4_4/bootstrap.js
-deleted file mode 100644
---- a/toolkit/mozapps/extensions/test/addons/test_updateid4_4/bootstrap.js
-+++ /dev/null
-@@ -1,21 +0,0 @@
--Components.utils.import("resource://gre/modules/Services.jsm");
--
--function install(data, reason) {
--  Services.prefs.setIntPref("bootstraptest.installed_version", 4);
--  Services.prefs.setIntPref("bootstraptest.install_reason", reason);
--}
--
--function startup(data, reason) {
--  Services.prefs.setIntPref("bootstraptest.active_version", 4);
--  Services.prefs.setIntPref("bootstraptest.startup_reason", reason);
--}
--
--function shutdown(data, reason) {
--  Services.prefs.setIntPref("bootstraptest.active_version", 0);
--  Services.prefs.setIntPref("bootstraptest.shutdown_reason", reason);
--}
--
--function uninstall(data, reason) {
--  Services.prefs.setIntPref("bootstraptest.installed_version", 0);
--  Services.prefs.setIntPref("bootstraptest.uninstall_reason", reason);
--}
-diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid4_4/install.rdf b/toolkit/mozapps/extensions/test/addons/test_updateid4_4/install.rdf
-deleted file mode 100644
---- a/toolkit/mozapps/extensions/test/addons/test_updateid4_4/install.rdf
-+++ /dev/null
-@@ -1,25 +0,0 @@
--<?xml version="1.0"?>
--
--<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
--     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
--
--  <Description about="urn:mozilla:install-manifest">
--    <em:id>addon4@tests.mozilla.org</em:id>
--    <em:version>4.0</em:version>
--    <em:updateURL>http://localhost:4444/data/test_updateid.rdf</em:updateURL>
--    <em:bootstrap>true</em:bootstrap>
--
--    <!-- Front End MetaData -->
--    <em:name>Test 4</em:name>
--    <em:description>Test Description</em:description>
--
--    <em:targetApplication>
--      <Description>
--        <em:id>xpcshell@tests.mozilla.org</em:id>
--        <em:minVersion>1</em:minVersion>
--        <em:maxVersion>1</em:maxVersion>
--      </Description>
--    </em:targetApplication>
--
--  </Description>
--</RDF>
-diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_update_multi.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_update_multi.rdf
-new file mode 100644
---- /dev/null
-+++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_update_multi.rdf
-@@ -0,0 +1,26 @@
-+<?xml version="1.0" encoding="UTF-8"?>
-+
-+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-+
-+  <Description about="urn:mozilla:extension:updatemulti@tests.mozilla.org">
-+    <em:updates>
-+      <Seq>
-+        <li>
-+          <Description>
-+            <em:version>2.0</em:version>
-+            <em:targetApplication>
-+              <Description>
-+                <em:id>xpcshell@tests.mozilla.org</em:id>
-+                <em:minVersion>1</em:minVersion>
-+                <em:maxVersion>1</em:maxVersion>
-+                <em:updateLink>http://localhost:4444/addons/test_update_multi2.xpi</em:updateLink>
-+              </Description>
-+            </em:targetApplication>
-+          </Description>
-+        </li>
-+      </Seq>
-+    </em:updates>
-+  </Description>
-+
-+</RDF>
-diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_updateid.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_updateid.rdf
---- a/toolkit/mozapps/extensions/test/xpcshell/data/test_updateid.rdf
-+++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_updateid.rdf
-@@ -9,77 +9,17 @@
-         <li>
-           <Description>
-             <em:version>2.0</em:version>
-             <em:targetApplication>
-               <Description>
-                 <em:id>xpcshell@tests.mozilla.org</em:id>
-                 <em:minVersion>1</em:minVersion>
-                 <em:maxVersion>1</em:maxVersion>
--                <em:updateLink>http://localhost:4444/addons/test_updateid2_2.xpi</em:updateLink>
--              </Description>
--            </em:targetApplication>
--          </Description>
--        </li>
--      </Seq>
--    </em:updates>
--  </Description>
--
--  <Description about="urn:mozilla:extension:addon2@tests.mozilla.org">
--    <em:updates>
--      <Seq>
--        <li>
--          <Description>
--            <em:version>3.0</em:version>
--            <em:targetApplication>
--              <Description>
--                <em:id>xpcshell@tests.mozilla.org</em:id>
--                <em:minVersion>1</em:minVersion>
--                <em:maxVersion>1</em:maxVersion>
--                <em:updateLink>http://localhost:4444/addons/test_updateid3_3.xpi</em:updateLink>
--              </Description>
--            </em:targetApplication>
--          </Description>
--        </li>
--      </Seq>
--    </em:updates>
--  </Description>
--
--  <Description about="urn:mozilla:extension:addon3@tests.mozilla.org">
--    <em:updates>
--      <Seq>
--        <li>
--          <Description>
--            <em:version>4.0</em:version>
--            <em:targetApplication>
--              <Description>
--                <em:id>xpcshell@tests.mozilla.org</em:id>
--                <em:minVersion>1</em:minVersion>
--                <em:maxVersion>1</em:maxVersion>
--                <em:updateLink>http://localhost:4444/addons/test_updateid4_4.xpi</em:updateLink>
--              </Description>
--            </em:targetApplication>
--          </Description>
--        </li>
--      </Seq>
--    </em:updates>
--  </Description>
--
--  <Description about="urn:mozilla:extension:addon4@tests.mozilla.org">
--    <em:updates>
--      <Seq>
--        <li>
--          <Description>
--            <em:version>5.0</em:version>
--            <em:targetApplication>
--              <Description>
--                <em:id>xpcshell@tests.mozilla.org</em:id>
--                <em:minVersion>1</em:minVersion>
--                <em:maxVersion>1</em:maxVersion>
--                <em:updateLink>http://localhost:4444/addons/test_updateid2_5.xpi</em:updateLink>
-+                <em:updateLink>http://localhost:4444/addons/test_updateid2.xpi</em:updateLink>
-               </Description>
-             </em:targetApplication>
-           </Description>
-         </li>
-       </Seq>
-     </em:updates>
-   </Description>
- 
-diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js b/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js
---- a/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js
-+++ b/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js
-@@ -2,421 +2,85 @@
-  * http://creativecommons.org/publicdomain/zero/1.0/
-  */
- 
- // This verifies that updating an add-on to a new ID works
- 
- // The test extension uses an insecure update url.
- Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
- 
--Components.utils.import("resource://testing-common/httpd.js");
--var testserver;
- const profileDir = gProfD.clone();
- profileDir.append("extensions");
- 
--function resetPrefs() {
--  Services.prefs.setIntPref("bootstraptest.active_version", -1);
--  Services.prefs.setIntPref("bootstraptest.installed_version", -1);
--  Services.prefs.setIntPref("bootstraptest.startup_reason", -1);
--  Services.prefs.setIntPref("bootstraptest.shutdown_reason", -1);
--  Services.prefs.setIntPref("bootstraptest.install_reason", -1);
--  Services.prefs.setIntPref("bootstraptest.uninstall_reason", -1);
--}
--
--function getActiveVersion() {
--  return Services.prefs.getIntPref("bootstraptest.active_version");
--}
--
--function getInstalledVersion() {
--  return Services.prefs.getIntPref("bootstraptest.installed_version");
--}
--
--function run_test() {
--  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
--
--  // Create and configure the HTTP server.
--  testserver = new HttpServer();
--  testserver.registerDirectory("/data/", do_get_file("data"));
--  testserver.registerDirectory("/addons/", do_get_file("addons"));
--  testserver.start(4444);
--
--  do_test_pending();
--  run_test_1();
--}
--
--function end_test() {
--  testserver.stop(do_test_finished);
--}
--
--function installUpdate(aInstall, aCallback) {
--  aInstall.addListener({
--    onInstallEnded: function(aInstall) {
--      // give the startup time to run
--      do_execute_soon(function() {
--        aCallback(aInstall);
--      });
--    }
--  });
--
--  aInstall.install();
--}
--
--// Verify that an update to an add-on with a new ID uninstalls the old add-on
--function run_test_1() {
--  writeInstallRDFForExtension({
--    id: "addon1@tests.mozilla.org",
--    version: "1.0",
--    updateURL: "http://localhost:4444/data/test_updateid.rdf",
--    targetApplications: [{
--      id: "xpcshell@tests.mozilla.org",
--      minVersion: "1",
--      maxVersion: "1"
--    }],
--    name: "Test Addon 1",
--  }, profileDir);
--
--  startupManager();
--
--  AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
--    do_check_neq(a1, null);
--    do_check_eq(a1.version, "1.0");
-+function promiseInstallUpdate(install) {
-+  return new Promise((resolve, reject) => {
-+    install.addListener({
-+      onDownloadFailed: () => {
-+        let err = new Error("download error");
-+        err.code = install.error;
-+        reject(err);
-+      },
-+      onInstallFailed: () => {
-+        let err = new Error("install error");
-+        err.code = install.error;
-+        reject(err);
-+      },
-+      onInstallEnded: resolve,
-+    });
- 
--    a1.findUpdates({
--      onUpdateAvailable: function(addon, install) {
--        do_check_eq(install.name, addon.name);
--        do_check_eq(install.version, "2.0");
--        do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
--        do_check_eq(install.existingAddon, a1);
--
--        installUpdate(install, check_test_1);
--      }
--    }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
--  });
--}
--
--function check_test_1(install) {
--  AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1) {
--    // Existing add-on should have a pending upgrade
--    do_check_neq(a1.pendingUpgrade, null);
--    do_check_eq(a1.pendingUpgrade.id, "addon2@tests.mozilla.org");
--    do_check_eq(a1.pendingUpgrade.install.existingAddon, a1);
--    do_check_neq(a1.syncGUID);
--
--    let a1SyncGUID = a1.syncGUID;
--
--    restartManager();
--
--    AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
--                                 "addon2@tests.mozilla.org"], function([a1, a2]) {
--      // Should have uninstalled the old and installed the new
--      do_check_eq(a1, null);
--      do_check_neq(a2, null);
--      do_check_neq(a2.syncGUID, null);
--
--      // The Sync GUID should change when the ID changes
--      do_check_neq(a1SyncGUID, a2.syncGUID);
--
--      a2.uninstall();
--
--      do_execute_soon(run_test_2);
--    });
--  }));
--}
--
--// Test that when the new add-on already exists we just upgrade that
--function run_test_2() {
--  restartManager();
--  shutdownManager();
--
--  writeInstallRDFForExtension({
--    id: "addon1@tests.mozilla.org",
--    version: "1.0",
--    updateURL: "http://localhost:4444/data/test_updateid.rdf",
--    targetApplications: [{
--      id: "xpcshell@tests.mozilla.org",
--      minVersion: "1",
--      maxVersion: "1"
--    }],
--    name: "Test Addon 1",
--  }, profileDir);
--  writeInstallRDFForExtension({
--    id: "addon2@tests.mozilla.org",
--    version: "1.0",
--    targetApplications: [{
--      id: "xpcshell@tests.mozilla.org",
--      minVersion: "1",
--      maxVersion: "1"
--    }],
--    name: "Test Addon 2",
--  }, profileDir);
--
--  startupManager();
--
--  AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
--    do_check_neq(a1, null);
--    do_check_eq(a1.version, "1.0");
--
--    a1.findUpdates({
--      onUpdateAvailable: function(addon, install) {
--        installUpdate(install, check_test_2);
--      }
--    }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
-+    install.install();
-   });
- }
- 
--function check_test_2(install) {
--  AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
--                               "addon2@tests.mozilla.org"],
--                               callback_soon(function([a1, a2]) {
--    do_check_eq(a1.pendingUpgrade, null);
--    // Existing add-on should have a pending upgrade
--    do_check_neq(a2.pendingUpgrade, null);
--    do_check_eq(a2.pendingUpgrade.id, "addon2@tests.mozilla.org");
--    do_check_eq(a2.pendingUpgrade.install.existingAddon, a2);
--
--    restartManager();
--
--    AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
--                                 "addon2@tests.mozilla.org"], function([a1, a2]) {
--      // Should have uninstalled the old and installed the new
--      do_check_neq(a1, null);
--      do_check_neq(a2, null);
--
--      a1.uninstall();
--      a2.uninstall();
--
--      do_execute_soon(run_test_3);
--    });
--  }));
--}
--
--// Test that we rollback correctly when removing the old add-on fails
--function run_test_3() {
--  restartManager();
--  shutdownManager();
--
--  // This test only works on Windows
--  if (!("nsIWindowsRegKey" in AM_Ci)) {
--    run_test_4();
--    return;
--  }
--
--  writeInstallRDFForExtension({
--    id: "addon1@tests.mozilla.org",
--    version: "1.0",
--    updateURL: "http://localhost:4444/data/test_updateid.rdf",
--    targetApplications: [{
--      id: "xpcshell@tests.mozilla.org",
--      minVersion: "1",
--      maxVersion: "1"
--    }],
--    name: "Test Addon 1",
--  }, profileDir);
--
--  startupManager();
-+// Create and configure the HTTP server.
-+let testserver = createHttpServer(4444);
-+testserver.registerDirectory("/data/", do_get_file("data"));
-+testserver.registerDirectory("/addons/", do_get_file("addons"));
- 
--  AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
--    do_check_neq(a1, null);
--    do_check_eq(a1.version, "1.0");
--
--    a1.findUpdates({
--      onUpdateAvailable: function(addon, install) {
--        installUpdate(install, check_test_3);
--      }
--    }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
--  });
--}
--
--function check_test_3(install) {
--  AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1) {
--    // Existing add-on should have a pending upgrade
--    do_check_neq(a1.pendingUpgrade, null);
--    do_check_eq(a1.pendingUpgrade.id, "addon2@tests.mozilla.org");
--    do_check_eq(a1.pendingUpgrade.install.existingAddon, a1);
--
--    // Lock the old add-on open so it can't be uninstalled
--    var file = profileDir.clone();
--    file.append("addon1@tests.mozilla.org");
--    if (!file.exists())
--      file.leafName += ".xpi";
--    else
--      file.append("install.rdf");
--
--    var fstream = AM_Cc["@mozilla.org/network/file-output-stream;1"].
--                  createInstance(AM_Ci.nsIFileOutputStream);
--    fstream.init(file, FileUtils.MODE_APPEND | FileUtils.MODE_WRONLY, FileUtils.PERMS_FILE, 0);
--
--    restartManager();
--
--    fstream.close();
--
--    AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
--                                 "addon2@tests.mozilla.org"],
--                                 callback_soon(function([a1, a2]) {
--      // Should not have installed the new add-on but it should still be
--      // pending install
--      do_check_neq(a1, null);
--      do_check_eq(a2, null);
--
--      restartManager();
--
--      AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
--                                   "addon2@tests.mozilla.org"], function([a1, a2]) {
--        // Should have installed the new add-on
--        do_check_eq(a1, null);
--        do_check_neq(a2, null);
--
--        a2.uninstall();
--
--        do_execute_soon(run_test_4);
--      });
--    }));
--  }));
-+function run_test() {
-+  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-+  startupManager();
-+  run_next_test();
- }
- 
--// Tests that upgrading to a bootstrapped add-on works but requires a restart
--function run_test_4() {
--  restartManager();
--  shutdownManager();
--
--  writeInstallRDFForExtension({
--    id: "addon2@tests.mozilla.org",
--    version: "2.0",
--    updateURL: "http://localhost:4444/data/test_updateid.rdf",
--    targetApplications: [{
--      id: "xpcshell@tests.mozilla.org",
--      minVersion: "1",
--      maxVersion: "1"
--    }],
--    name: "Test Addon 2",
--  }, profileDir);
--
--  startupManager();
--
--  resetPrefs();
--
--  AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
--    do_check_neq(a2, null);
--    do_check_neq(a2.syncGUID, null);
--    do_check_eq(a2.version, "2.0");
--
--    a2.findUpdates({
--      onUpdateAvailable: function(addon, install) {
--        installUpdate(install, check_test_4);
--      }
--    }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
--  });
--}
--
--function check_test_4() {
--  AddonManager.getAddonsByIDs(["addon2@tests.mozilla.org",
--                               "addon3@tests.mozilla.org"],
--                               callback_soon(function([a2, a3]) {
--    // Should still be pending install even though the new add-on is restartless
--    do_check_neq(a2, null);
--    do_check_eq(a3, null);
--
--    do_check_neq(a2.pendingUpgrade, null);
--    do_check_eq(a2.pendingUpgrade.id, "addon3@tests.mozilla.org");
--
--    do_check_eq(getInstalledVersion(), -1);
--    do_check_eq(getActiveVersion(), -1);
--
--    restartManager();
--
--    AddonManager.getAddonsByIDs(["addon2@tests.mozilla.org",
--                                 "addon3@tests.mozilla.org"], function([a2, a3]) {
--      // Should have updated
--      do_check_eq(a2, null);
--      do_check_neq(a3, null);
--
--      do_check_eq(getInstalledVersion(), 3);
--      do_check_eq(getActiveVersion(), 3);
--
--      do_execute_soon(run_test_5);
--    });
--  }));
--}
--
--// Tests that upgrading to another bootstrapped add-on works without a restart
--function run_test_5() {
--  AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) {
--    do_check_neq(a3, null);
--    do_check_eq(a3.version, "3.0");
-+// Verify that an update to an add-on with a new ID fails
-+add_task(function* test_update_new_id() {
-+  yield promiseInstallAllFiles([do_get_addon("test_updateid1")]);
- 
--    a3.findUpdates({
--      onUpdateAvailable: function(addon, install) {
--        installUpdate(install, check_test_5);
--      }
--    }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
--  });
--}
--
--function check_test_5() {
--  AddonManager.getAddonsByIDs(["addon3@tests.mozilla.org",
--                               "addon4@tests.mozilla.org"],
--                               callback_soon(function([a3, a4]) {
--    // Should have updated
--    do_check_eq(a3, null);
--    do_check_neq(a4, null);
--
--    do_check_eq(getInstalledVersion(), 4);
--    do_check_eq(getActiveVersion(), 4);
--
--    restartManager();
--
--    AddonManager.getAddonsByIDs(["addon3@tests.mozilla.org",
--                                 "addon4@tests.mozilla.org"], function([a3, a4]) {
--      // Should still be gone
--      do_check_eq(a3, null);
--      do_check_neq(a4, null);
--
--      do_check_eq(getInstalledVersion(), 4);
--      do_check_eq(getActiveVersion(), 4);
--
--      run_test_6();
--    });
--  }));
--}
-+  let addon = yield promiseAddonByID("addon1@tests.mozilla.org");
-+  do_check_neq(addon, null);
-+  do_check_eq(addon.version, "1.0");
- 
--// Tests that upgrading to a non-bootstrapped add-on works but requires a restart
--function run_test_6() {
--  AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) {
--    do_check_neq(a4, null);
--    do_check_eq(a4.version, "4.0");
--
--    a4.findUpdates({
--      onUpdateAvailable: function(addon, install) {
--        installUpdate(install, check_test_6);
--      }
--    }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
--  });
--}
-+  let update = yield promiseFindAddonUpdates(addon, AddonManager.UPDATE_WHEN_USER_REQUESTED);
-+  let install = update.updateAvailable;
-+  do_check_eq(install.name, addon.name);
-+  do_check_eq(install.version, "2.0");
-+  do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
-+  do_check_eq(install.existingAddon, addon);
- 
--function check_test_6() {
--  AddonManager.getAddonsByIDs(["addon4@tests.mozilla.org",
--                               "addon2@tests.mozilla.org"],
--                               callback_soon(function([a4, a2]) {
--    // Should still be pending install even though the old add-on is restartless
--    do_check_neq(a4, null);
--    do_check_eq(a2, null);
--
--    do_check_neq(a4.pendingUpgrade, null);
--    do_check_eq(a4.pendingUpgrade.id, "addon2@tests.mozilla.org");
--
--    do_check_eq(getInstalledVersion(), 4);
--    do_check_eq(getActiveVersion(), 4);
-+  yield Assert.rejects(promiseInstallUpdate(install),
-+                       function(err) { return err.code == AddonManager.ERROR_INCORRECT_ID },
-+                       "Upgrade to a different ID fails");
- 
--    restartManager();
-+  addon.uninstall();
-+});
- 
--    AddonManager.getAddonsByIDs(["addon4@tests.mozilla.org",
--                                 "addon2@tests.mozilla.org"], function([a4, a2]) {
--      // Should have updated
--      do_check_eq(a4, null);
--      do_check_neq(a2, null);
-+// Verify that an update to a multi-package xpi fails
-+add_task(function* test_update_new_id() {
-+  yield promiseInstallAllFiles([do_get_addon("test_update_multi1")]);
- 
--      do_check_eq(getInstalledVersion(), 0);
--      do_check_eq(getActiveVersion(), 0);
-+  let addon = yield promiseAddonByID("updatemulti@tests.mozilla.org");
-+  do_check_neq(addon, null);
-+  do_check_eq(addon.version, "1.0");
- 
--      end_test();
--    });
--  }));
--}
-+  let update = yield promiseFindAddonUpdates(addon, AddonManager.UPDATE_WHEN_USER_REQUESTED);
-+  let install = update.updateAvailable;
-+  do_check_eq(install.name, addon.name);
-+  do_check_eq(install.version, "2.0");
-+  do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
-+  do_check_eq(install.existingAddon, addon);
-+
-+  yield Assert.rejects(promiseInstallUpdate(install),
-+                       function(err) { return err.code == AddonManager.ERROR_UNEXPECTED_ADDON_TYPE },
-+                       "Upgrade to a multipackage xpi fails");
-+
-+  addon.uninstall();
-+});
-
-- 
cgit 1.4.1