# HG changeset patch # User Pascal Bellard # Date 1509533408 -3600 # Node ID 5b64ca8fb7e18020777834007855324e8dd10490 # Parent 4673755e4f1499b9cf67642371bb5d3c0be4cc21 Up qemu-light (2.0.2) diff -r 4673755e4f14 -r 5b64ca8fb7e1 postgresql/receipt --- a/postgresql/receipt Wed Nov 01 11:33:53 2017 +0100 +++ b/postgresql/receipt Wed Nov 01 11:50:08 2017 +0100 @@ -13,7 +13,7 @@ WGET_URL="http://ftp.postgresql.org/pub/source/v$VERSION/$TARBALL" DEPENDS="postgresql-client slitaz-base-files" -BUILD_DEPENDS="readline-dev zlib-dev perl python-dev" +BUILD_DEPENDS="readline-dev zlib-dev perl-dev python-dev" SPLIT="libpostgresqlclient postgresql-client postgresql-dev postgresql-doc" # Rules to configure and make the package. diff -r 4673755e4f14 -r 5b64ca8fb7e1 qemu-light/receipt --- a/qemu-light/receipt Wed Nov 01 11:33:53 2017 +0100 +++ b/qemu-light/receipt Wed Nov 01 11:50:08 2017 +0100 @@ -1,7 +1,7 @@ # SliTaz package receipt. PACKAGE="qemu-light" -VERSION="1.2.0" +VERSION="2.0.2" CATEGORY="misc" SHORT_DESC="Light Qemu i386-softmmu target (without xen, vde, bluez, blobs, tls)." MAINTAINER="pankso@slitaz.org" @@ -14,16 +14,27 @@ CONFLICT="qemu" DEPENDS="alsa-lib libsdl util-linux-uuid" -BUILD_DEPENDS="perl alsa-lib-dev libsdl-dev util-linux-uuid-dev python \ -glib-dev zlib-dev" +BUILD_DEPENDS="gettext perl alsa-lib-dev libsdl-dev util-linux-uuid-dev python \ +glib-dev zlib-dev autoconf automake libtool bison flex" # Rules to configure and make the package. compile_rules() { - cd $src + mkdir -p $DESTIDR/usr/share/qemu/ia32 + + [ -s $SOURCES_REPOSITORY/$UEFIZIP ] || wget -P $SOURCES_REPOSITORY \ + http://netassist.dl.sourceforge.net/project/edk2/OVMF/$UEFIZIP + unzip $SOURCES_REPOSITORY/$UEFIZIP OVMF.fd -d $DESTIDR/usr/share/qemu/ia32 + + patch -p0 < $stuff/cloop.u + TARGET="i386-softmmu" + + export LDFLAGS="$LDFLAGS -Wl,--copy-dt-needed-entries" + #--cross-prefix= --host-cc= ./configure \ --prefix=/usr \ + --sysconfdir=/etc \ --disable-xen \ --disable-vnc-sasl \ --disable-vnc-tls \ diff -r 4673755e4f14 -r 5b64ca8fb7e1 qemu-light/stuff/cloop.u --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/qemu-light/stuff/cloop.u Wed Nov 01 11:50:08 2017 +0100 @@ -0,0 +1,284 @@ +--- block/cloop.c ++++ block/cloop.c +@@ -29,11 +29,90 @@ + /* Maximum compressed block size */ + #define MAX_BLOCK_SIZE (64 * 1024 * 1024) + ++typedef struct cloop_tail { ++ uint32_t table_size; ++ uint32_t index_size; ++ uint32_t num_blocks; ++} cloop_tail; ++ ++typedef struct block_info { ++ uint64_t offset; /* 64-bit offsets of compressed block */ ++ uint32_t size; /* 32-bit compressed block size */ ++ uint32_t optidx; /* 32-bit index number */ ++} block_info; ++ ++static inline int build_index(block_info *offsets, unsigned long n) ++{ ++ uint32_t *ofs32 = (uint32_t *) offsets; ++ uint64_t *ofs64 = (uint64_t *) offsets; ++ ++ if (ofs32[0] == 0) { ++ if (ofs32[2]) { /* ACCELERATED KNOPPIX V1.0 */ ++ while (n--) { ++ offsets[n].offset = be64_to_cpu(offsets[n].offset); ++ offsets[n].size = ntohl(offsets[n].size); ++ if (offsets[n].size > 2 * MAX_BLOCK_SIZE) ++ return n+1; ++ } ++ } ++ else { /* V2.0 */ ++ uint64_t last = be64_to_cpu(ofs64[n - 1]); ++ while (n--) { ++ offsets[n].size = last - ++ (offsets[n].offset = be64_to_cpu(ofs64[n])); ++ if (offsets[n].size > 2 * MAX_BLOCK_SIZE) ++ return n+1; ++ last = offsets[n].offset; ++ } ++ } ++ } ++ else if (ofs32[1] == 0) { /* V1.0 */ ++ uint64_t last = le64_to_cpu(ofs64[n - 1]); ++ while (n--) { ++ offsets[n].size = last - ++ (offsets[n].offset = le64_to_cpu(ofs64[n])); ++ if (offsets[n].size > 2 * MAX_BLOCK_SIZE) ++ return n+1; ++ last = offsets[n].offset; ++ } ++ } ++ else if (ntohl(ofs32[0]) == (4*n) + 0x8C) { /* V0.68 */ ++ uint64_t last = ntohl(ofs32[n - 1]); ++ while (n--) { ++ offsets[n].size = last - ++ (offsets[n].offset = ntohl(ofs32[n])); ++ if (offsets[n].size > 2 * MAX_BLOCK_SIZE) ++ return n+1; ++ last = offsets[n].offset; ++ } ++ } ++ else { /* V3.0 */ ++ unsigned long i; ++ uint64_t j; ++ ++ for (i = n; i-- > 0; ) { ++ offsets[i].size = ntohl(ofs32[i]); ++ if (offsets[i].size > 2 * MAX_BLOCK_SIZE) ++ return i+1; ++ } ++ for (i = 0, j = 128 + 4 + 4; i < n; i++) { ++ offsets[i].offset = j; ++ if (offsets[i].size & 0x80000000) { ++ unsigned long k = offsets[i].size & 0x7FFFFFFF; ++ offsets[i].offset = offsets[k].offset; ++ offsets[i].size = offsets[k].size; ++ } ++ else j += offsets[i].size; ++ } ++ } ++ return 0; ++} ++ + typedef struct BDRVCloopState { + CoMutex lock; + uint32_t block_size; + uint32_t n_blocks; +- uint64_t *offsets; ++ block_info *offsets; + uint32_t sectors_per_block; + uint32_t current_block; + uint8_t *compressed_block; +@@ -43,17 +117,21 @@ + + static int cloop_probe(const uint8_t *buf, int buf_size, const char *filename) + { +- const char *magic_version_2_0 = "#!/bin/sh\n" +- "#V2.0 Format\n" ++ static const uint8_t magic[] = + "modprobe cloop file=$0 && mount -r -t iso9660 /dev/cloop $1\n"; +- int length = strlen(magic_version_2_0); +- if (length > buf_size) { +- length = buf_size; ++ int i, ret = 0, length = buf_size; ++ uint8_t c; ++ ++ if (length > 127) { ++ length = 127; + } +- if (!memcmp(magic_version_2_0, buf, length)) { +- return 2; ++ for (i = 0; i < length - sizeof(magic) + 1; i++) { ++ if (buf[i] != magic[0]) continue; ++ if (strncmp(buf + i, magic, sizeof(magic) - 1)) continue; ++ ret = 2; ++ break; + } +- return 0; ++ return ret; + } + + static int cloop_open(BlockDriverState *bs, QDict *options, int flags, +@@ -91,79 +169,97 @@ + MAX_BLOCK_SIZE / (1024 * 1024)); + return -EINVAL; + } +- + ret = bdrv_pread(bs->file, 128 + 4, &s->n_blocks, 4); + if (ret < 0) { + return ret; + } + s->n_blocks = be32_to_cpu(s->n_blocks); + +- /* read offsets */ +- if (s->n_blocks > (UINT32_MAX - 1) / sizeof(uint64_t)) { +- /* Prevent integer overflow */ +- error_setg(errp, "n_blocks %u must be %zu or less", +- s->n_blocks, +- (UINT32_MAX - 1) / sizeof(uint64_t)); +- return -EINVAL; +- } +- offsets_size = (s->n_blocks + 1) * sizeof(uint64_t); +- if (offsets_size > 512 * 1024 * 1024) { +- /* Prevent ridiculous offsets_size which causes memory allocation to +- * fail or overflows bdrv_pread() size. In practice the 512 MB +- * offsets[] limit supports 16 TB images at 256 KB block size. +- */ +- error_setg(errp, "image requires too many offsets, " +- "try increasing block size"); +- return -EINVAL; +- } +- s->offsets = g_malloc(offsets_size); ++ /* initialize zlib engine */ ++ max_compressed_block_size = s->block_size + s->block_size/1000 + 12 + 4; ++ s->compressed_block = g_malloc(max_compressed_block_size + 1); ++ s->uncompressed_block = g_malloc(s->block_size); + +- ret = bdrv_pread(bs->file, 128 + 4 + 4, s->offsets, offsets_size); +- if (ret < 0) { ++ if (inflateInit(&s->zstream) != Z_OK) { ++ ret = -EINVAL; + goto fail; + } + +- for (i = 0; i < s->n_blocks + 1; i++) { +- uint64_t size; ++ /* read offsets */ ++ if (s->n_blocks + 1 == 0) { ++ cloop_tail tail; ++ int64_t end = bdrv_getlength(bs->file); ++ void *p; ++ uint32_t toclen, len; + +- s->offsets[i] = be64_to_cpu(s->offsets[i]); +- if (i == 0) { +- continue; ++ ret = bdrv_pread(bs->file, end - sizeof(tail), &tail, sizeof(tail)); ++ if (ret < 0) { ++ goto fail; + } + +- if (s->offsets[i] < s->offsets[i - 1]) { +- error_setg(errp, "offsets not monotonically increasing at " +- "index %u, image file is corrupt", i); +- ret = -EINVAL; +- goto fail; ++ s->n_blocks = be32_to_cpu(tail.num_blocks); ++ offsets_size = s->n_blocks * sizeof(block_info); ++ if (offsets_size > 512 * 1024 * 1024) { ++ /* Prevent ridiculous offsets_size which causes memory allocation to ++ * fail or overflows bdrv_pread() size. In practice the 512 MB ++ * offsets[] limit supports 16 TB images at 256 KB block size. ++ */ ++ error_setg(errp, "image requires too many offsets, " ++ "try increasing block size"); ++ return -EINVAL; + } ++ len = be32_to_cpu(tail.table_size); ++ toclen = (be32_to_cpu(tail.index_size) & 255) * s->n_blocks; + +- size = s->offsets[i] - s->offsets[i - 1]; ++ s->offsets = g_malloc(offsets_size); ++ p = g_malloc(len); + +- /* Compressed blocks should be smaller than the uncompressed block size +- * but maybe compression performed poorly so the compressed block is +- * actually bigger. Clamp down on unrealistic values to prevent +- * ridiculous s->compressed_block allocation. +- */ +- if (size > 2 * MAX_BLOCK_SIZE) { +- error_setg(errp, "invalid compressed block size at index %u, " +- "image file is corrupt", i); ++ ret = bdrv_pread(bs->file, end - sizeof(tail) - len, p, len); ++ if (ret < 0) { ++ goto fail; ++ } ++ s->zstream.next_in = p; ++ s->zstream.avail_in = len; ++ s->zstream.next_out = s->offsets; ++ s->zstream.avail_out = toclen; ++ ret = inflateReset(&s->zstream); ++ if (ret != Z_OK) { + ret = -EINVAL; + goto fail; + } +- +- if (size > max_compressed_block_size) { +- max_compressed_block_size = size; ++ ret = inflate(&s->zstream, Z_FINISH); ++ if (ret != Z_STREAM_END || s->zstream.total_out != toclen) { ++ ret = -EINVAL; ++ goto fail; + } ++ g_free(p); + } ++ else { ++ offsets_size = s->n_blocks * sizeof(block_info); ++ if (offsets_size > 512 * 1024 * 1024) { ++ /* Prevent ridiculous offsets_size which causes memory allocation to ++ * fail or overflows bdrv_pread() size. In practice the 512 MB ++ * offsets[] limit supports 16 TB images at 256 KB block size. ++ */ ++ error_setg(errp, "image requires too many offsets, " ++ "try increasing block size"); ++ return -EINVAL; ++ } ++ s->offsets = g_malloc(offsets_size); + +- /* initialize zlib engine */ +- s->compressed_block = g_malloc(max_compressed_block_size + 1); +- s->uncompressed_block = g_malloc(s->block_size); +- if (inflateInit(&s->zstream) != Z_OK) { ++ ret = bdrv_pread(bs->file, 128 + 4 + 4, s->offsets, offsets_size); ++ if (ret < 0) { ++ goto fail; ++ } ++ } ++ ret = build_index(s->offsets, s->n_blocks); ++ if (ret) { ++ error_setg(errp, "invalid compressed block size at index %u, " ++ "image file is corrupt", ret-1); + ret = -EINVAL; + goto fail; + } ++ + s->current_block = s->n_blocks; + + s->sectors_per_block = s->block_size/512; +@@ -184,10 +280,10 @@ + + if (s->current_block != block_num) { + int ret; +- uint32_t bytes = s->offsets[block_num + 1] - s->offsets[block_num]; ++ uint32_t bytes = s->offsets[block_num].size; + +- ret = bdrv_pread(bs->file, s->offsets[block_num], s->compressed_block, +- bytes); ++ ret = bdrv_pread(bs->file, s->offsets[block_num].offset, ++ s->compressed_block, bytes); + if (ret != bytes) { + return -1; + }