Created
December 4, 2017 13:22
-
-
Save shakalaca/1387496714b04cc6edb46359a82ce246 to your computer and use it in GitHub Desktop.
make_ext4fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BIN_DIR=$(pwd)/bin/$(uname) | |
CC=gcc | |
if [ ! -d $BIN_DIR ]; then | |
mkdir -p $BIN_DIR | |
fi | |
if [ ! -d src ]; then | |
mkdir src | |
fi | |
cd src | |
# if you do not want to fetch source again .. | |
DO_NOT_FETCH=1 | |
if [ -z "$DO_NOT_FETCH" ]; then | |
BRANCH=android-8.0.0_r34 | |
git clone https://android.googlesource.com/platform/external/selinux | |
git clone https://android.googlesource.com/platform/external/pcre | |
git clone https://android.googlesource.com/platform/system/core | |
git clone https://android.googlesource.com/platform/external/zlib | |
git clone https://android.googlesource.com/platform/system/extras | |
cd selinux; git checkout -b $BRANCH $BRANCH; cd .. | |
cd pcre; git checkout -b $BRANCH $BRANCH; cd .. | |
cd core; git checkout -b $BRANCH $BRANCH; patch -p1 < ../../patch_core.diff; cd .. | |
cd zlib; git checkout -b $BRANCH $BRANCH; cd .. | |
cd extras; git checkout -b $BRANCH $BRANCH; cd .. | |
fi | |
# build for make_ext4fs | |
echo building pcre | |
cd pcre/dist2 | |
$CC $CPPFLAGS \ | |
-DHAVE_CONFIG_H \ | |
-I../include_internal -I../include \ | |
-c src/pcre2_auto_possess.c src/pcre2_compile.c src/pcre2_config.c \ | |
src/pcre2_context.c src/pcre2_dfa_match.c src/pcre2_error.c \ | |
src/pcre2_find_bracket.c src/pcre2_maketables.c src/pcre2_match.c \ | |
src/pcre2_match_data.c src/pcre2_jit_compile.c src/pcre2_newline.c \ | |
src/pcre2_ord2utf.c src/pcre2_pattern_info.c src/pcre2_serialize.c \ | |
src/pcre2_string_utils.c src/pcre2_study.c src/pcre2_substitute.c \ | |
src/pcre2_substring.c src/pcre2_tables.c src/pcre2_ucd.c \ | |
src/pcre2_valid_utf.c src/pcre2_xclass.c src/pcre2_chartables.c | |
cd ../.. | |
echo building libselinux | |
cd selinux/libselinux | |
$CC $CPPFLAGS \ | |
-DNO_PERSISTENTLY_STORED_PATTERNS -DDISABLE_SETRANS -DDISABLE_BOOL \ | |
-D_GNU_SOURCE -DNO_MEDIA_BACKEND -DNO_X_BACKEND -DNO_DB_BACKEND -DUSE_PCRE2 \ | |
-DBUILD_HOST \ | |
-Iinclude -I../libsepol/include -I../../core/include -I../../pcre/include \ | |
-c src/booleans.c src/callbacks.c src/freecon.c src/label_backends_android.c \ | |
src/label.c src/label_support.c src/label_file.c src/matchpathcon.c \ | |
src/setrans_client.c src/sha1.c \ | |
src/regex.c \ | |
src/android/android_host.c src/avc.c src/avc_internal.c src/avc_sidtab.c src/compute_av.c \ | |
src/compute_create.c src/compute_member.c src/context.c src/enabled.c src/getenforce.c \ | |
src/getfilecon.c src/get_initial_context.c src/init.c src/load_policy.c src/mapping.c \ | |
src/procattr.c src/setexecfilecon.c src/stringrep.c | |
ar rcs libselinux.a *.o ../../pcre/dist2/*.o | |
cd ../.. | |
echo building libz | |
cd zlib/src | |
$CC $CPPFLAGS -O3 \ | |
-DUSE_MMAP -DZLIB_CONST \ | |
-I.. \ | |
-c adler32.c compress.c crc32.c deflate.c gzclose.c gzlib.c gzread.c \ | |
gzwrite.c infback.c inflate.c inftrees.c inffast.c trees.c uncompr.c \ | |
zutil.c | |
ar rcs libz.a *.o | |
cd ../.. | |
echo building libbase | |
cd core/base | |
$CC $CPPFLAGS -std=c++11 \ | |
-Iinclude \ | |
-c file.cpp logging.cpp parsenetaddress.cpp quick_exit.cpp \ | |
stringprintf.cpp strings.cpp test_utils.cpp chrono_utils.cpp errors_unix.cpp | |
ar rcs libbase.a *.o | |
cd ../.. | |
echo building libsparse | |
cd core/libsparse | |
$CC $CPPFLAGS \ | |
-Iinclude -I../../zlib \ | |
-c backed_block.c output_file.c sparse.c sparse_crc32.c sparse_err.c | |
$CC $CPPFLAGS -std=c++11 \ | |
-Iinclude -I../base/include \ | |
-c sparse_read.cpp | |
ar rcs libsparse.a *.o | |
$CC $CPPFLAGS \ | |
-Iinclude \ | |
-o simg2img \ | |
simg2img.c \ | |
libsparse.a ../../zlib/src/libz.a ../base/libbase.a -lstdc++ | |
cp simg2img $BIN_DIR | |
$CC $CPPFLAGS \ | |
-Iinclude \ | |
-o simg2simg \ | |
simg2simg.c \ | |
libsparse.a ../../zlib/src/libz.a ../base/libbase.a -lstdc++ | |
cp simg2simg $BIN_DIR | |
$CC $CPPFLAGS \ | |
-Iinclude \ | |
-o append2simg \ | |
append2simg.c \ | |
libsparse.a ../../zlib/src/libz.a ../base/libbase.a -lstdc++ | |
cp append2simg $BIN_DIR | |
cd ../.. | |
echo building liblog | |
cd core/liblog | |
$CC $CPPFLAGS \ | |
-DFAKE_LOG_DEVICE=1 \ | |
-Werror -fvisibility=hidden \ | |
-I../include \ | |
-c config_read.c config_write.c local_logger.c log_event_list.c log_event_write.c \ | |
log_ratelimit.cpp logger_lock.c logger_name.c logger_read.c logger_write.c \ | |
logprint.c stderr_write.c fake_log_device.c fake_writer.c uio.c | |
ar rcs liblog.a *.o | |
cd ../.. | |
echo building make_ext4fs | |
cd extras/ext4_utils | |
$CC $CPPFLAGS \ | |
-DHOST -DANDROID -DFAKE_LOG_DEVICE=1 -D__ANDROID_VNDK__ \ | |
-I../../selinux/libselinux/include -I../../core/libsparse/include \ | |
-I../../core/include -I../../core/libcutils/include -Iinclude \ | |
-o make_ext4fs \ | |
make_ext4fs_main.c make_ext4fs.c ext4fixup.c ext4_utils.c \ | |
allocate.c contents.c extent.c indirect.c sha1.c wipe.c crc16.c \ | |
ext4_sb.c \ | |
../../core/libcutils/canned_fs_config.c \ | |
../../core/libcutils/fs_config.cpp \ | |
../../core/libsparse/libsparse.a \ | |
../../core/base/libbase.a \ | |
../../zlib/src/libz.a \ | |
../../core/liblog/liblog.a \ | |
../../selinux/libselinux/libselinux.a \ | |
-lpthread -lrt | |
cp make_ext4fs $BIN_DIR | |
cd ../.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/base/errors_unix.cpp b/base/errors_unix.cpp | |
index 296995e..3b983d3 100644 | |
--- a/base/errors_unix.cpp | |
+++ b/base/errors_unix.cpp | |
@@ -17,6 +17,7 @@ | |
#include "android-base/errors.h" | |
#include <errno.h> | |
+#include <cstring> | |
namespace android { | |
namespace base { | |
diff --git a/base/file.cpp b/base/file.cpp | |
index a2f2887..2dc2550 100644 | |
--- a/base/file.cpp | |
+++ b/base/file.cpp | |
@@ -42,6 +42,8 @@ | |
#define O_NOFOLLOW 0 | |
#endif | |
+#include <cstring> | |
+ | |
namespace android { | |
namespace base { | |
diff --git a/base/logging.cpp b/base/logging.cpp | |
index 6357b4b..cc275a3 100644 | |
--- a/base/logging.cpp | |
+++ b/base/logging.cpp | |
@@ -70,6 +70,8 @@ | |
#include <windows.h> | |
#endif | |
+#include <cstring> | |
+ | |
#if defined(_WIN32) | |
typedef uint32_t thread_id; | |
#else | |
diff --git a/liblog/logprint.c b/liblog/logprint.c | |
index b62f8b4..ca74902 100644 | |
--- a/liblog/logprint.c | |
+++ b/liblog/logprint.c | |
@@ -926,8 +926,8 @@ static int android_log_printBinaryEvent(const unsigned char** pEventData, | |
break; | |
case TYPE_MONOTONIC: { | |
static const uint64_t minute = 60; | |
- static const uint64_t hour = 60 * minute; | |
- static const uint64_t day = 24 * hour; | |
+ uint64_t hour = 60 * minute; | |
+ uint64_t day = 24 * hour; | |
/* Repaint as unsigned seconds, minutes, hours ... */ | |
outBuf -= outCount; | |
diff --git a/libsparse/sparse_read.cpp b/libsparse/sparse_read.cpp | |
index bd66873..4c437d6 100644 | |
--- a/libsparse/sparse_read.cpp | |
+++ b/libsparse/sparse_read.cpp | |
@@ -37,6 +37,7 @@ | |
#include "sparse_file.h" | |
#include "sparse_format.h" | |
+#include <cstring> | |
#if defined(__APPLE__) && defined(__MACH__) | |
#define lseek64 lseek |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment