[Q] Add GApps to AOSP build - General Questions and Answers

Hi all,
I had a look at other threads but am still lost. I'm building AOSP for a variscite board and would like to include the gapps at build time. So I've downloaded the zip and in device/variscite/varsom/varsom.mk I added
PRODUCT_COPY_FILES += \
$(foreach f,$(wildcard vendor/google/addon.d/*),$(f):system/addon.d/$(notdir $(f))) \
$(foreach f,$(wildcard vendor/google/framework/*),$(f):system/framework/$(notdir $(f))) \
$(foreach f,$(wildcard vendor/google/lib/*),$(f):system/lib/$(notdir $(f))) \
vendor/google/etc/g.prop:system/etc/g.prop \
$(foreach f,$(wildcard vendor/google/etc/permissions/*),$(f):system/etc/permissions/$(notdir $(f))) \
$(foreach f,$(wildcard vendor/google/etc/preferred-apps/*),$(f):system/etc/preferred-apps/$(notdir $(f))) \
The thing is I'm stuck as to how I copy the apks in system/app. When I add them to PRODUCT_COPY_FILES it throws an error saying I should use BUILD_PREBUILT but I'm not sure what I means, thanks for any help!

Related

Opera Mini 4.2 and Write user data...

Firstly, I'm using an AT&T Fuze, stock ROM and I'd like to keep it stock.
I installed the signed version of Opera Mini 4.2 and, under permissions, it doesn't allow me to change the permission for "Write user data" as well as "Read user data". I've looked through the forums trying to find a solution that doesn't involve flashing the device.
I took a look at the selector.utf file and here's what it looked like after I installed OM (I haven't uninstalled any of the stock apps as yet):
Code:
nextroot=9
suite=Brain Challenge 2 DEMO, \
icon=/i.png, \
vendor=Gameloft SA, \
root=s0_, \
num=1, \
preinstalled=N, \
domain=cingular_preferred, \
removable=Y, \
rootCertHash=+sWuMjMvveQMkjVi4unVDQHNYnA=, \
signingInfo=Divertissement Gameloft\, CA, \
permissions=XXXXDXXXXXXXXXXXXXXXXXXXXXXXXX, \
install_time=1221210061499, \
drmProtected=N, \
drmRenewable=N
midlet=Brain Challenge 2 DEMO, \
icon=/i.png, \
class=GloftMBRC
suite=Bubble Bash DEMO, \
icon=/icon.png, \
vendor=Gameloft SA, \
root=s1_, \
num=1, \
preinstalled=N, \
domain=cingular_preferred, \
removable=Y, \
rootCertHash=+sWuMjMvveQMkjVi4unVDQHNYnA=, \
signingInfo=Divertissement Gameloft\, CA, \
permissions=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX, \
install_time=1221210096643, \
drmProtected=N, \
drmRenewable=N
midlet=Bubble Bash DEMO, \
icon=/icon.png, \
class=GloftBUBA
suite=My-Cast 5 Weather, \
icon=16_app.png, \
vendor=Digital Cyclone\, Inc., \
root=s2_, \
num=1, \
preinstalled=N, \
domain=cingular_preferred, \
removable=Y, \
rootCertHash=+sWuMjMvveQMkjVi4unVDQHNYnA=, \
signingInfo=Digital Cyclone Inc\, US, \
permissions=XXXXDXXXXXXXXXXXXXXXXXXXXXXXXX, \
install_time=1221210138627, \
drmProtected=N, \
drmRenewable=N
midlet=My-Cast 5 Weather, \
icon=16_app.png, \
class=phone.MyCastMidlet
suite=WikiMobile, \
icon=/allimages/icon15x15.png, \
vendor=BonfireMedia, \
root=s3_, \
num=1, \
preinstalled=N, \
domain=cingular_preferred, \
removable=Y, \
rootCertHash=+sWuMjMvveQMkjVi4unVDQHNYnA=, \
signingInfo=Bonfire Media Inc.\, US, \
permissions=XXXXDXXXXXXXXXXXXXXXXXXXXXXXXX, \
install_time=1221210177708, \
drmProtected=N, \
drmRenewable=N
midlet=WikiMobile, \
icon=/allimages/icon15x15.png, \
class=wikimobileMidlet
suite=Billboard, \
icon=icon.png, \
vendor=Hands-On Mobile\, Inc., \
root=s4_, \
num=1, \
preinstalled=N, \
domain=cingular_trusted, \
removable=Y, \
rootCertHash=2qeXj3fAwOWA4ZcvYdmTmJrCoxM=, \
signingInfo=Hands-On Mobile Inc.\, US, \
permissions=XXXXDXXXXXXXXXXXXXXXXXXXXXXXXX, \
install_time=1221210474866, \
drmProtected=N, \
drmRenewable=N
midlet=Billboard, \
icon=icon.png, \
class=Billboard
suite=Opera Mini, \
icon=/i.png, \
vendor=Opera Software ASA, \
root=s8_, \
num=1, \
preinstalled=N, \
domain=trusted, \
removable=Y, \
rootCertHash=dCwxkuYH5CTrRUlUK+G7xT5hdOI=, \
signingInfo=Opera Software ASA\, NO, \
permissions=XDDDDDXXXXXXXDDXXXXXXXXXDDDDDX, \
fg_permissions=DDDDDDDD, \
install_time=1246652430205, \
drmProtected=N, \
drmRenewable=N
midlet=Opera Mini, \
icon=/i.png, \
class=Browser
Initially, I thought I could just copy the permissions from, say, Wikimobile to the OM permissions line, but this makes no difference, the options to read and write data are still unchangeable and locked to 'Never Allow.' I also don't know what the fg_permissions is for, but removing that makes none of my applets show up in the manager.
I forgot to mention, on my Tornado (using Intent's java), I can install the unsigned version and, tho I get annoying confirmation messages, am able to save and read data from the phone. Is the esmertec manager on the Fuze just kinda broken and useless? Why do some apps have permission and others don't?
In looking through the s8_suite.utf (the one associated with Opera Mini on my device) I see a section for permissions and even listings for javax.microedition.io.Connector.file.write and read. Seeing these permissions listed would suggest (to me) they should show up under the permission list...
Sadly, I don't know enough about hex editing to tweak it. I looked at the wikimobile .utf file and it doesn't look much like the Opera one (obviously)...
I hate to bump my own thread, but I'd really like to know if anyone has gotten this to work. I really like using Opera Mini over Mobile and terribly miss the ability to save pages/images with it.
I've read through the Midlet Bible post and found nothing helpful (short of installing a different midlet manager).

[Q]

I'm building some common gnu/linux console utilities for my Android phone but so far I have only been able to build them statically, with quite a size penalty. Can someone walk me through the steps or point me to a howto for dynamic compiles using arm shared libraries?
Here's the script(s) I'm using for configuration:
Code:
./configure --host=arm-none-linux-gnueabi \
CC="arm-none-linux-gnueabi-gcc" \
CROSS_COMPILE="arm-none-linux-gnueabi-" \
CFLAGS=" -static $_XXFLAGS" \
for shared:
Code:
./configure --host=arm-none-linux-gnueabi \
CC="arm-none-linux-gnueabi-gcc" \
CROSS_COMPILE="arm-none-linux-gnueabi-" \
--enable-shared=yes --enable-static=no
Do I need to make the libs on my android phone avaiable to my cross-compiler? Google isn't helping me here.
Bump. Anyone?
Never mind on this. I learned that using the cross-compiler supplied by Google is the way to go.

[Q] makefile

Hi
my first jni app and run into those android.mk problems:
SDL_SRCS := \
$(LOCAL_PATH)/src/*.c \
$(LOCAL_PATH)/src/*.cpp \
1: How should that look to include all .c and cpp files in src?
#LOCAL_SRC_FILES := $(foreach files $(SDL_SRCS), $(wildcard *.c)$
(files))
LOCAL_SRC_FILES := $(foreach F, $(SDL_SRCS), $(dir $(F)),$(notdir $
(wildcard $(LOCAL_PATH)/$(F))))
2: what libs to include?
LOCAL_LDLIBS := -llog -lGLESv2 -lm
the original c++ makefile has those:
LDFLAGS = -lm -lGL -lGLU -lglut
LIBOBJS =
LIBS = -L/usr/X11R6/lib -L/usr/lib -L/usr/lib -lGL -lGLU -lglut -lSDL -
lSDLmain -lSDL_mixer
Many thanks indeed
Michael

ATRIX™ 2 ME865 Kernal downloads Maybe useful

This may be of use to some devs here. but I came across a few links that may be old news or maybe not...
here are the files and source
RAZR XT910 Developer Edition 698 MB
RAZR-XT910-DE_01.6.5.1-167_SPU-15-M2-1-DE .zip
http://developer.motorola.com/products/software/
kernel_omap4.tar.gz
http://sourceforge.net/projects/me865.motorola/
http://sourceforge.net/projects/me865.motorola/files/ME865/5.5.1-1_GC-109/
PHP:
1. Create a workspace containing "vanilla" gingerbread release from Google. You may need to apply the following change in build repo to prevent the build from aborting when unexpected user tag is found on some modules:
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 3c11673..ecf611d 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -99,7 +99,7 @@ ifneq ($(filter $(LOCAL_MODULE_TAGS),user),)
$(warning * PRODUCT_PACKAGES section of)
$(warning * build/target/product/core.mk)
$(warning * )
- $(error user tag detected on new module - user tags are only supported on legacy modules)
+ $(warning user tag detected on new module - user tags are only supported on legacy modules)
endif
endif
2. Overlay Motorola-provided published repos on top of original Google versions.
3. Build user space components:
cd <workspace>
. build/envsetup.sh
lunch generic-user
make BOARD_HAVE_BLUETOOTH=true TARGET_BOARD_PLATFORM=omap4 <target>
Where is something like out/target/product/generic/system/bin/bluetoothd
4. Building kernel and kernel modules.
# set this to the top of your android workspace
my_top_dir=....
# set this to where you want kernel intermediates written to
kernel_out_dir=...
# cross compiler
cross=$my_top_dir/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
make -j1 -C $my_top_dir/kernel/omap4 ARCH=arm \
CROSS_COMPILE=$cross \
O=$kernel_out_dir \
KBUILD_DEFCONFIG=mapphone_defconfig \
defconfig modules_prepare
make -C $my_top_dir/kernel/omap4 ARCH=arm \
CROSS_COMPILE=$cross \
O=$kernel_out_dir \
INSTALL_MOD_PATH=$kernel_out_dir \
modules 2>&1
make -C $my_top_dir/kernel/omap4 ARCH=arm \
CROSS_COMPILE=$cross \
O=$kernel_out_dir \
INSTALL_MOD_PATH=$kernel_out_dir \
modules_install
make -C $my_top_dir/kernel/omap4 ARCH=arm \
CROSS_COMPILE=$cross \
O=$kernel_out_dir zImage
make PREFIX=$kernel_out_dir CROSS=$cross CROSS_COMPILE=$cross \
PROCFAMILY=OMAP4430 PROJROOT= HOST_PLATFORM=sdc4430 \
KRNLSRC=$my_top_dir/kernel/omap4 KERNEL_DIR=$kernel_out_dir \
-C $my_top_dir/hardware/ti/wlan/wl1283/platforms/os/linux
# newly built module in $my_top_dir/hardware/ti/wlan/wl1283/platforms/os/linux/tiwlan_drv.ko
make PREFIX=$kernel_out_dir CROSS=$cross CROSS_COMPILE=$cross \
PROCFAMILY=OMAP4430 PROJROOT= HOST_PLATFORM=sdc4430 \
KRNLSRC=$my_top_dir/kernel/omap4 KERNEL_DIR=$kernel_out_dir \
-C $my_top_dir/hardware/ti/wlan/wl1283_softAP/platforms/os/linux
# newly built module in $my_top_dir/hardware/ti/wlan/wl1283_softAP/platforms/os/linux/tiap_drv.ko
make PREFIX=$kernel_out_dir CROSS=$cross CROSS_COMPILE=$cross \
PROCFAMILY=OMAP4430 PROJROOT= HOST_PLATFORM=sdc4430 \
KRNLSRC=$my_top_dir/kernel/omap4 KERNEL_DIR=$kernel_out_dir \
-C $my_top_dir/kernel/omap4 ARCH=arm \
O=$kernel_out_dir \
M=$my_top_dir/vendor/authentec/safenet/vpndriver modules
# newly built module in $my_top_dir/vendor/authentec/safenet/vpndriver/vpnclient.ko
5. Building lbl:
make -f motorola/external/lbl/Makefile all \
LBL_OUT=out/target/product/generic/obj/PARTITIONS/lbl_intermediates HOST_PREBUILT_TAG=linux-x86

[DEVS-ONLY] Compile Android SELinux binaries/libs using SELinux master

The master branch of SELinux doesn't include native android support,
and the external selinux repo from google is limited and only targets host for tools.
You can make a few edits to get some useful binaries to use on Android on master branch
even though libsepol and libselinux aren't patched for android compliance, the tools are still useful.
dispol for example allows you to dump sepolicy rules for everything, for example you could recreate the supersu.te if you wanted.
checkpolicy allows you to write out a new sepolicy with edits.
getfilecon and setfilecon are very useful for getting contexts and setting contexts.
I only enabled a few binaries, but there are many more you can add by following the examples in the Android.mk​by default it builds:
checkmodule
checkpolicy
chkcon
dismod
dispol
getfilecon
sefcontext_compile
setfilecon
I thought id share this here as folks often only use libsepol for sepolicy-inject and as security gets tighter it will be useful to know how to compile for target devices.
dispol is very useful, selecting a file to output to and then choosing option 1 dumps all rules.
also you can see specific rules, such as the filename_trans rule I implemented for Substratum's Interfacer,
allowing it to auto set the contexts on files it creates in /data/system/theme to "theme_data_file"​
Select a command:
1) display unconditional AVTAB
2) display conditional AVTAB (entirely)
3) display conditional AVTAB (only ENABLED rules)
4) display conditional AVTAB (only DISABLED rules)
5) display conditional bools
6) display conditional expressions
7) change a boolean value
8) display role transitions
c) display policy capabilities
p) display the list of permissive types
u) display unknown handling setting
F) display filename_trans rules
f) set output file
m) display menu
q) quit
Command ('m' for menu): F
filename_trans rules:
ueventd device :chr_file klog_device __kmsg__
wpa wifi_data_file :dir wpa_socket sockets
interfacer system_data_file :file theme_data_file theme
system_server system_data_file :sock_file system_ndebug_socket ndebugsocket
hostapd wifi_data_file :dir wpa_socket hostapd
hostapd wifi_data_file :dir wpa_socket sockets
Command ('m' for menu): p
permissive sids:
recovery
su
supersu
Command ('m' for menu):
similarly checkpolicy makes it easy to write out a new policy​
angler:/ $ checkpolicy /sepolicy -b -d -M -c 30 -o /sdcard/sepolicy.new
checkpolicy: loading policy configuration from /sepolicy
libsepol.policydb_index_others: security: 1 users, 2 roles, 801 types, 0 bools
libsepol.policydb_index_others: security: 1 sens, 1024 cats
libsepol.policydb_index_others: security: 63 classes, 13466 rules, 0 cond rules
checkpolicy: policy configuration loaded
checkpolicy: writing binary representation (version 30) to /sdcard/sepolicy.new
Theres quite a bit of trickery/makefile l33tness going on, so id encourage you to understand/look at this Sexy af Android.mk below, considering this is where most of the magic happens.​
Code:
LOCAL_PATH:= $(call my-dir)
libselinux_src_files := \
libselinux/src/audit2why.c \
libselinux/src/avc.c \
libselinux/src/avc_internal.c \
libselinux/src/avc_sidtab.c \
libselinux/src/booleans.c \
libselinux/src/callbacks.c \
libselinux/src/canonicalize_context.c \
libselinux/src/checkAccess.c \
libselinux/src/check_context.c \
libselinux/src/checkreqprot.c \
libselinux/src/compute_av.c \
libselinux/src/compute_create.c \
libselinux/src/compute_member.c \
libselinux/src/compute_relabel.c \
libselinux/src/compute_user.c \
libselinux/src/context.c \
libselinux/src/deny_unknown.c \
libselinux/src/disable.c \
libselinux/src/enabled.c \
libselinux/src/fgetfilecon.c \
libselinux/src/freecon.c \
libselinux/src/freeconary.c \
libselinux/src/fsetfilecon.c \
libselinux/src/get_context_list.c \
libselinux/src/get_default_type.c \
libselinux/src/get_initial_context.c \
libselinux/src/getenforce.c \
libselinux/src/getfilecon.c \
libselinux/src/getpeercon.c \
libselinux/src/init.c \
libselinux/src/is_customizable_type.c \
libselinux/src/label.c \
libselinux/src/label_backends_android.c \
libselinux/src/label_db.c \
libselinux/src/label_file.c \
libselinux/src/label_media.c \
libselinux/src/label_support.c \
libselinux/src/label_x.c \
libselinux/src/lgetfilecon.c \
libselinux/src/load_policy.c \
libselinux/src/lsetfilecon.c \
libselinux/src/mapping.c \
libselinux/src/matchmediacon.c \
libselinux/src/matchpathcon.c \
libselinux/src/policyvers.c \
libselinux/src/procattr.c \
libselinux/src/query_user_context.c \
libselinux/src/regex.c \
libselinux/src/selinux_check_securetty_context.c \
libselinux/src/selinux_config.c \
libselinux/src/selinux_restorecon.c \
libselinux/src/sestatus.c \
libselinux/src/setenforce.c \
libselinux/src/setexecfilecon.c \
libselinux/src/setfilecon.c \
libselinux/src/setrans_client.c \
libselinux/src/seusers.c \
libselinux/src/sha1.c \
libselinux/src/stringrep.c
libselinux_android_srcs := \
libselinux/src/android/android.c \
libselinux/src/android/android_host.c \
common_src_files := \
libsepol/src/assertion.c \
libsepol/src/avrule_block.c \
libsepol/src/avtab.c \
libsepol/src/boolean_record.c \
libsepol/src/booleans.c \
libsepol/src/conditional.c \
libsepol/src/constraint.c \
libsepol/src/context.c \
libsepol/src/context_record.c \
libsepol/src/debug.c \
libsepol/src/ebitmap.c \
libsepol/src/expand.c \
libsepol/src/genbools.c \
libsepol/src/genusers.c \
libsepol/src/handle.c \
libsepol/src/hashtab.c \
libsepol/src/hierarchy.c \
libsepol/src/ibendport_record.c \
libsepol/src/ibendports.c \
libsepol/src/ibpkey_record.c \
libsepol/src/ibpkeys.c \
libsepol/src/iface_record.c \
libsepol/src/interfaces.c \
libsepol/src/kernel_to_cil.c \
libsepol/src/kernel_to_common.c \
libsepol/src/kernel_to_conf.c \
libsepol/src/link.c \
libsepol/src/mls.c \
libsepol/src/module.c \
libsepol/src/module_to_cil.c \
libsepol/src/node_record.c \
libsepol/src/nodes.c \
libsepol/src/polcaps.c \
libsepol/src/policydb.c \
libsepol/src/policydb_convert.c \
libsepol/src/policydb_public.c \
libsepol/src/port_record.c \
libsepol/src/ports.c \
libsepol/src/roles.c \
libsepol/src/services.c \
libsepol/src/sidtab.c \
libsepol/src/symtab.c \
libsepol/src/user_record.c \
libsepol/src/users.c \
libsepol/src/util.c \
libsepol/src/write.c
cil_src_files := \
libsepol/cil/src/cil_binary.c \
libsepol/cil/src/cil_build_ast.c \
libsepol/cil/src/cil.c \
libsepol/cil/src/cil_copy_ast.c \
libsepol/cil/src/cil_find.c \
libsepol/cil/src/cil_fqn.c \
libsepol/cil/src/cil_list.c \
libsepol/cil/src/cil_log.c \
libsepol/cil/src/cil_mem.c \
libsepol/cil/src/cil_parser.c \
libsepol/cil/src/cil_policy.c \
libsepol/cil/src/cil_post.c \
libsepol/cil/src/cil_reset_ast.c \
libsepol/cil/src/cil_resolve_ast.c \
libsepol/cil/src/cil_stack.c \
libsepol/cil/src/cil_strpool.c \
libsepol/cil/src/cil_symtab.c \
libsepol/cil/src/cil_tree.c \
libsepol/cil/src/cil_verify.c
libpcre2_src_files := \
pcre/dist2/src/pcre2_auto_possess.c \
pcre/dist2/src/pcre2_compile.c \
pcre/dist2/src/pcre2_config.c \
pcre/dist2/src/pcre2_context.c \
pcre/dist2/src/pcre2_dfa_match.c \
pcre/dist2/src/pcre2_error.c \
pcre/dist2/src/pcre2_find_bracket.c \
pcre/dist2/src/pcre2_maketables.c \
pcre/dist2/src/pcre2_match.c \
pcre/dist2/src/pcre2_match_data.c \
pcre/dist2/src/pcre2_jit_compile.c \
pcre/dist2/src/pcre2_newline.c \
pcre/dist2/src/pcre2_ord2utf.c \
pcre/dist2/src/pcre2_pattern_info.c \
pcre/dist2/src/pcre2_serialize.c \
pcre/dist2/src/pcre2_string_utils.c \
pcre/dist2/src/pcre2_study.c \
pcre/dist2/src/pcre2_substitute.c \
pcre/dist2/src/pcre2_substring.c \
pcre/dist2/src/pcre2_tables.c \
pcre/dist2/src/pcre2_ucd.c \
pcre/dist2/src/pcre2_valid_utf.c \
pcre/dist2/src/pcre2_xclass.c \
pcre/dist2/src/pcre2_chartables.c
common_cflags := \
-Wall -W -Wundef \
-Wshadow -Wmissing-noreturn \
-Wmissing-format-attribute \
-std=gnu99 -O2 -fpic -fPIC \
-pipe -fno-strict-aliasing \
-D_GNU_SOURCE \
-D__BIONIC__ -DANDROID \
-D__ANDROID__
common_ldlibs := \
-lc
common_includes := \
include \
checkpolicy/ \
libsepol/include/ \
libsepol/src/ \
libsepol/cil/include/ \
libsepol/cil/src/ \
pcre/dist2 \
pcre/include_internal \
pcre/include \
libpcre/dist \
libselinux/src \
libsepol/include/sepol \
libselinux/include \
libselinux/include/selinux \
/usr/include/python2.7 \
/usr/include/python3.* \
/usr/local/include
yacc_flags := -x c -std=gnu89
FIND_HOSTOS := $(shell uname -s)
HOST_NAME := $(shell echo $(FIND_HOSTOS) |sed -e s/L/l/ |sed -e s/D/d/ |sed s/W/w/ )
mkdir-android := $(shell mkdir -vp $(addprefix $(LOCAL_PATH)/libselinux/src/, android))
mkdir-include := $(shell mkdir -vp $(addprefix $(LOCAL_PATH)/include/, openssl private packagelistparser))
get-openssl := $(shell wget -qO - "https://android.googlesource.com/platform/external/boringssl/+archive/master/src/include/openssl.tar.gz" -O - | tar -xz -C include/openssl)
get-private := $(shell wget -qO - "https://android.googlesource.com/platform/system/core/+archive/master/libcutils/include/private.tar.gz" -O - | tar -xz -C include/private)
get-log := $(shell wget -qO - "https://android.googlesource.com/platform/system/core/+archive/master/liblog/include.tar.gz" -O - | tar -xz -C include)
ifeq ($(HOST_NAME),darwin)
cmds := \
$(shell wget -qO - "https://android.googlesource.com/platform/external/selinux/+/master/libselinux/include/selinux/android.h?format=text" | \
base64 -D > libselinux/include/selinux/android.h) \
$(shell wget -qO - "https://android.googlesource.com/platform/external/selinux/+/master/libselinux/src/android/android.c?format=text" | \
base64 -D > libselinux/src/android/android.c) \
$(shell wget -qO - "https://android.googlesource.com/platform/external/selinux/+/master/libselinux/src/android/android_host.c?format=text" | \
base64 -D > libselinux/src/android/android_host.c) \
$(shell wget -qO - "https://android.googlesource.com/platform/system/core/+/master/libpackagelistparser/include/packagelistparser/packagelistparser.h?format=text" | \
base64 -D > include/packagelistparser/packagelistparser.h)
else
cmds := \
$(shell wget -qO - "https://android.googlesource.com/platform/external/selinux/+/master/libselinux/include/selinux/android.h?format=text" | \
base64 -d > libselinux/include/selinux/android.h) \
$(shell wget -qO - "https://android.googlesource.com/platform/external/selinux/+/master/libselinux/src/android/android.c?format=text" | \
base64 -d > libselinux/src/android/android.c) \
$(shell wget -qO - "https://android.googlesource.com/platform/external/selinux/+/master/libselinux/src/android/android_host.c?format=text" | \
base64 -d > libselinux/src/android/android_host.c) \
$(shell wget -qO - "https://android.googlesource.com/platform/system/core/+/master/libpackagelistparser/include/packagelistparser/packagelistparser.h?format=text" | \
base64 -d > include/packagelistparser/packagelistparser.h)
endif
libselinux_prepare := $(mkdir-android) $(mkdir-include) $(get-openssl) $(get-private) $(get-log) $(cmds)
checkpolicy_prepare := \
$(shell flex -o checkpolicy/lex.yy.c -l checkpolicy/policy_scan.l) \
$(shell yacc -vd checkpolicy/policy_parse.y -o checkpolicy/y.tab.c) \
$(shell bison -vd checkpolicy/policy_parse.y --defines=checkpolicy/policy_parse.h -o checkpolicy/policy_parse.c)
##
# libpcre2.a
#
include $(CLEAR_VARS)
LOCAL_MODULE := libpcre2
LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_SRC_FILES := $(libpcre2_src_files)
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
include $(BUILD_STATIC_LIBRARY)
##
# cil_lexer.a
#
include $(CLEAR_VARS)
LOCAL_MODULE := cil_lexer
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_CFLAGS := $(yacc_flags) $(common_cflags)
LOCAL_SRC_FILES := libsepol/cil/src/cil_lexer.l
include $(BUILD_STATIC_LIBRARY)
##
# libsepol.a
#
include $(CLEAR_VARS)
LOCAL_MODULE := libsepol
LOCAL_MODULE_TAGES := optional
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_CFLAGS := $(common_cflags)
LOCAL_SRC_FILES := $(common_src_files)
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
include $(BUILD_STATIC_LIBRARY)
##
# chkcon
#
include $(CLEAR_VARS)
LOCAL_MODULE := chkcon
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_CFLAGS := $(common_cflags)
LOCAL_SRC_FILES := libsepol/utils/chkcon.c
LOCAL_STATIC_LIBRARIES := libsepol
LOCAL_MODULE_CLASS := EXECUTABLES
include $(BUILD_EXECUTABLE)
##
# libselinux_static
#
include $(CLEAR_VARS)
LOCAL_MODULE := libselinux_static
LOCAL_MODULE_TAGS := optional
LOCAL_WHOLE_STATIC_LIBRARIES := libpcre2
LOCAL_CFLAGS := -std=gnu89 -DAUDITD_LOG_TAG=1003 -DUSE_PCRE2 $(common_cflags)
LOCAL_STATIC_LIBRARIES := libpcre2
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_SRC_FILES := $(libselinux_prepare) $(libselinux_src_files) $(libselinux_android_srcs)
include $(BUILD_STATIC_LIBRARY)
##
# sefcontext_compile
#
include $(CLEAR_VARS)
LOCAL_MODULE := sefcontext_compile
LOCAL_CFLAGS += -Wall -Werror -DUSE_PCRE2 -DNO_PERSISTENTLY_STORED_PATTERNS $(common_cflags)
LOCAL_STATIC_LIBRARIES := libselinux_static libpcre2 libsepol
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_SRC_FILES := libselinux/utils/sefcontext_compile.c
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
##
# getfilecon
#
include $(CLEAR_VARS)
LOCAL_MODULE := getfilecon
LOCAL_CFLAGS += -Wall -Werror -DUSE_PCRE2 -DNO_PERSISTENTLY_STORED_PATTERNS $(common_cflags)
LOCAL_STATIC_LIBRARIES := libselinux_static libpcre2 libsepol
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_SRC_FILES := libselinux/utils/getfilecon.c
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
##
# setfilecon
#
include $(CLEAR_VARS)
LOCAL_MODULE := setfilecon
LOCAL_CFLAGS += -Wall -Werror -DUSE_PCRE2 -DNO_PERSISTENTLY_STORED_PATTERNS $(common_cflags)
LOCAL_STATIC_LIBRARIES := libselinux_static libpcre2 libsepol
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_SRC_FILES := libselinux/utils/setfilecon.c
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
##
# checkpolicy
#
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(checkpolicy_prepare) \
checkpolicy/lex.yy.c \
checkpolicy/y.tab.c \
checkpolicy/checkpolicy.c \
checkpolicy/module_compiler.c \
checkpolicy/parse_util.c \
checkpolicy/policy_define.c \
checkpolicy/queue.c
LOCAL_MODULE := checkpolicy
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_CFLAGS := $(yacc_flags) $(common_cflags)
LOCAL_STATIC_LIBRARIES := libsepol
LOCAL_CFLAGS += -std=gnu99 -fpic -fPIC
LOCAL_YACCFLAGS := -v
include $(BUILD_EXECUTABLE)
##
# checkmodule
#
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(checkpolicy_prepare) \
checkpolicy/lex.yy.c \
checkpolicy/y.tab.c \
checkpolicy/checkmodule.c \
checkpolicy/module_compiler.c \
checkpolicy/parse_util.c \
checkpolicy/policy_define.c \
checkpolicy/queue.c
LOCAL_MODULE := checkmodule
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_CFLAGS := $(yacc_flags) $(common_cflags)
LOCAL_STATIC_LIBRARIES := libsepol
LOCAL_CFLAGS += -std=gnu99 -fpic -fPIC
LOCAL_YACCFLAGS := -v
include $(BUILD_EXECUTABLE)
##
# dispol
#
include $(CLEAR_VARS)
LOCAL_MODULE := dispol
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_SRC_FILES := checkpolicy/test/dispol.c
LOCAL_CFLAGS := $(yacc_flags) $(common_cflags)
LOCAL_STATIC_LIBRARIES := libsepol
LOCAL_CFLAGS += -std=gnu99 -fpic -fPIC
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
##
# dismod
#
include $(CLEAR_VARS)
LOCAL_MODULE := dismod
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(common_includes)
LOCAL_SRC_FILES := checkpolicy/test/dismod.c
LOCAL_CFLAGS := $(yacc_flags) $(common_cflags)
LOCAL_STATIC_LIBRARIES := libsepol
LOCAL_CFLAGS += -std=gnu99 -fpic -fPIC
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
theres a submodule for libpcre2 so you'll have to use git clone --recursive, AKA
git clone --recursive https://github.com/Surge1223/selinux.git selinux-master
or ideally, just clone SELinux master and cherry-pick the 3 commits that allow building for target devices
then building also depends on the NDK build system reading the jni/Application.mk first, before Android.mk so the NDK build command is
$NDK/ndk-build APP_PROJECT_PATH=. APPLICATION_BULID_SCRIPT=Application.mk
Click to expand...
Click to collapse
The main purpose of me posting this here is so that in the future, if it becomes necessary to create/build tools to deal with the additional restrictions on Android, this can serve as a starting point on building.
​
No I dont plan on posting binaries. If you're in this thread and you can't use the NDK, then you need to up your game son.
Good job @Surge1223!
Sent from my Samsung Galaxy S8+ using XDA Labs
Great work! @Surge1223
This is an interesting thread
Kudos Surge, subscribed

Categories

Resources