Merge "applypatch: Add a Makefile to build imgdiff in Chrome OS."
This commit is contained in:
@@ -0,0 +1,32 @@
|
|||||||
|
# Copyright (C) 2016 The Android Open Source Project
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# This file is for building imgdiff in Chrome OS.
|
||||||
|
|
||||||
|
CPPFLAGS += -iquote..
|
||||||
|
CXXFLAGS += -std=c++11 -O3 -Wall -Werror
|
||||||
|
LDLIBS += -lbz2 -lz
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
|
|
||||||
|
all: imgdiff libimgpatch.a
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o imgdiff libimgpatch.a
|
||||||
|
|
||||||
|
imgdiff: imgdiff.o bsdiff.o utils.o
|
||||||
|
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDLIBS) -o $@ $^
|
||||||
|
|
||||||
|
libimgpatch.a: imgpatch.o bspatch.o utils.o
|
||||||
|
${AR} rcs $@ $^
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
#ifndef _APPLYPATCH_H
|
#ifndef _APPLYPATCH_H
|
||||||
#define _APPLYPATCH_H
|
#define _APPLYPATCH_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|||||||
@@ -224,7 +224,6 @@ static void offtout(off_t x,u_char *buf)
|
|||||||
int bsdiff(u_char* old, off_t oldsize, off_t** IP, u_char* newdata, off_t newsize,
|
int bsdiff(u_char* old, off_t oldsize, off_t** IP, u_char* newdata, off_t newsize,
|
||||||
const char* patch_filename)
|
const char* patch_filename)
|
||||||
{
|
{
|
||||||
int fd;
|
|
||||||
off_t *I;
|
off_t *I;
|
||||||
off_t scan,pos,len;
|
off_t scan,pos,len;
|
||||||
off_t lastscan,lastpos,lastoffset;
|
off_t lastscan,lastpos,lastoffset;
|
||||||
|
|||||||
@@ -182,7 +182,6 @@ int ApplyBSDiffPatchMem(const unsigned char* old_data, ssize_t old_size,
|
|||||||
|
|
||||||
off_t oldpos = 0, newpos = 0;
|
off_t oldpos = 0, newpos = 0;
|
||||||
off_t ctrl[3];
|
off_t ctrl[3];
|
||||||
off_t len_read;
|
|
||||||
int i;
|
int i;
|
||||||
unsigned char buf[24];
|
unsigned char buf[24];
|
||||||
while (newpos < new_size) {
|
while (newpos < new_size) {
|
||||||
|
|||||||
@@ -598,7 +598,6 @@ int ReconstructDeflateChunk(ImageChunk* chunk) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t p = 0;
|
|
||||||
unsigned char* out = reinterpret_cast<unsigned char*>(malloc(BUFFER_SIZE));
|
unsigned char* out = reinterpret_cast<unsigned char*>(malloc(BUFFER_SIZE));
|
||||||
|
|
||||||
// We only check two combinations of encoder parameters: level 6
|
// We only check two combinations of encoder parameters: level 6
|
||||||
@@ -844,7 +843,6 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (argc != 4) {
|
if (argc != 4) {
|
||||||
usage:
|
|
||||||
printf("usage: %s [-z] [-b <bonus-file>] <src-img> <tgt-img> <patch-file>\n",
|
printf("usage: %s [-z] [-b <bonus-file>] <src-img> <tgt-img> <patch-file>\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
return 2;
|
return 2;
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size,
|
|||||||
size_t src_len = Read8(deflate_header+8);
|
size_t src_len = Read8(deflate_header+8);
|
||||||
size_t patch_offset = Read8(deflate_header+16);
|
size_t patch_offset = Read8(deflate_header+16);
|
||||||
size_t expanded_len = Read8(deflate_header+24);
|
size_t expanded_len = Read8(deflate_header+24);
|
||||||
|
size_t target_len = Read8(deflate_header+32);
|
||||||
int level = Read4(deflate_header+40);
|
int level = Read4(deflate_header+40);
|
||||||
int method = Read4(deflate_header+44);
|
int method = Read4(deflate_header+44);
|
||||||
int windowBits = Read4(deflate_header+48);
|
int windowBits = Read4(deflate_header+48);
|
||||||
@@ -195,6 +196,11 @@ int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size,
|
|||||||
&uncompressed_target_data) != 0) {
|
&uncompressed_target_data) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (uncompressed_target_data.size() != target_len) {
|
||||||
|
printf("expected target len to be %zu, but it's %zu\n",
|
||||||
|
target_len, uncompressed_target_data.size());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// Now compress the target data and append it to the output.
|
// Now compress the target data and append it to the output.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user