Fix ipadiff [skip ci]

This commit is contained in:
Ali 2019-11-21 14:22:33 +04:00
parent 94b880c4dc
commit 144df3cc33
2 changed files with 59 additions and 9 deletions

View File

@ -181,11 +181,6 @@ def diff_plists(file1, file2):
if data1 == data2:
return 'equal'
else:
with open('lhs.plist', 'wb') as f:
f.write(str.encode(data1))
with open('rhs.plist', 'wb') as f:
f.write(str.encode(data2))
sys.exit(1)
return 'not_equal'

View File

@ -175,16 +175,54 @@ static void writeDataToFile(std::vector<uint8_t> const &data, std::string const
static std::vector<uint8_t> stripSwiftSymbols(std::string const &file) {
std::string command;
command += "xcrun strip -ST -o /dev/stdout \"";
command += "xcrun bitcode_strip \"";
command += file;
command += "\" 2> /dev/null";
command += "\" -r -o \"";
command += file;
command += ".stripped\"";
uint8_t buffer[128];
std::vector<uint8_t> result;
FILE *pipe = popen(command.c_str(), "r");
if (!pipe) {
throw std::runtime_error("popen() failed!");
}
while (true) {
size_t readBytes = fread(buffer, 1, 128, pipe);
if (readBytes <= 0) {
break;
}
}
pclose(pipe);
command = "";
command += "codesign --remove-signature \"";
command += file;
command += ".stripped\"";
pipe = popen(command.c_str(), "r");
if (!pipe) {
throw std::runtime_error("popen() failed!");
}
while (true) {
size_t readBytes = fread(buffer, 1, 128, pipe);
if (readBytes <= 0) {
break;
}
}
pclose(pipe);
command = "";
command += "xcrun strip -ST -o /dev/stdout \"";
command += file;
command += ".stripped\" 2> /dev/null";
std::vector<uint8_t> result;
pipe = popen(command.c_str(), "r");
if (!pipe) {
throw std::runtime_error("popen() failed!");
}
while (true) {
size_t readBytes = fread(buffer, 1, 128, pipe);
if (readBytes <= 0) {
@ -193,6 +231,23 @@ static std::vector<uint8_t> stripSwiftSymbols(std::string const &file) {
result.insert(result.end(), buffer, buffer + readBytes);
}
pclose(pipe);
command = "";
command += "rm \"";
command += file;
command += ".stripped\"";
pipe = popen(command.c_str(), "r");
if (!pipe) {
throw std::runtime_error("popen() failed!");
}
while (true) {
size_t readBytes = fread(buffer, 1, 128, pipe);
if (readBytes <= 0) {
break;
}
}
pclose(pipe);
return result;
}