Android: final cleanup of new build system

Rename hidden config files to busybox-<profile>.config

Set also KBUILD_OUTPUT to prevent generation of files in src dir,
if local make without O= is made (which create host code)

That do not force the rebuild of config files, except with mm -B

With the help of Chih-Wei Huang <cwhuang@linux.org.tw>

Change-Id: Ic6bc2bc7177b1f266b9c0d1ccdfb925c1aa00d46
Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Makefile: remove warnings on initial version check

Android.mk is using a SUBMAKE variable which is only
used to get busybox version as a CFLAG. This one has
the -s (--silent) makeflag. So ignore the KBUILD_OUTPUT
default value if this flag is present.

Change-Id: Ifcc11d148d6707a8c301b3d2ba0370b91215647e
android: backport pty implementation from aosp/master

This is not (yet) in l-preview branch but on master
The only way to prevent duplicated includes was to
test the existence of a new constant added after
l-preview bionic source release.

Also use compatible hasmntopt() return type
(swapon/off compilation warnings)

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>

Change-Id: I4ee6e7752eab84de4566ae86a90171b8241fcaea
Fix remaining bionic warnings

Tested on arm and x86 (kitkat),
aosp/master has some other ones

Also update the readme and android.h

Change-Id: I170b16f2e091b99f971fb518bf0106c0e92adfdd
android: on prepare, clean all intermediates

This was requested to me to prevent no clobbered builds failures
on busybox config changes.

Change-Id: I1bdf2948e0669b1de567381eb809f576e8f1eef5
mktemp: include libc mktemp, safe in busybox

This commit remove the last warning in busybox,
and prevent users to try to use mkstemp which has not
the right behavior.

Change-Id: I5aaae8044769bb1893f2430287d72b3abbee796c
Android.mk: prevent warnings on make prepare

Add "+" to allow a new job

touch import_includes to prevent problems with -jN

Change-Id: Iea3cd527842a8bd770ff56fce01bcd0ff2d0db83
selinux: implement missing selinux functions

checkPasswdAccess() is deprecated
http://linux.die.net/man/3/selinux_check_passwd_access

also, ensure context is initialized in run_shell()

Note: these stubs are just compatible with busybox source code
Should be enhanced, or implemented in libselinux...

Change-Id: I22ea2679191d5c0887b6ef8c77f09a032c226876
Android: update busybox def PATH and cron folder

remove /usr/bin, add /vendor/bin, like official path

config folder was badly set to debian style cron.d
but busybox variant is a bit different :

  mkdir /etc/crontabs
  echo "* * * * * log CRON!" > /etc/crontabs/`whoami`
  crond -f

Change-Id: I0b9af08a557a952b5074da3231f32433f447f558
android: clearenv should not set environ to NULL

Remove the old internal clearenv() function which is
no more required (exported in libc)

Change-Id: I357f6a3b057c366761b481c09b471d7c53d7a419
mktemp: warning fix for x86 and l-preview

mktemp is almost not used in busybox, so rename
the function in the mktemp applet to prevent bionic
warning on include.

Change-Id: I4332d3b957aafd6174eb7fe098b099eae779d3c9
Bionic changes for tty related applets

Tested (but applets not included/enabled)
getty, login, su, passwd, mkpasswd, cryptpw

Sample /etc/passwd required before 'passwd' :
root:x:0:0:root:/:/system/xbin/bash

busybox su allow to change current user, if you are root
Example: "busybox su shell -c /system/xbin/bash"

busybox login allow also to do that :
Example: "busybox login shell"

getpwnam() returns now an empty string in passwd member
instead of null, busybox often check directly pw->pw_passwd[0]

Update also selinux related stubs after tests on x86 4.4.2,
l-preview and aosp/master

If you want to include these applets, here is the required
source list to add in busybox-full.sources :

 libbb/correct_password.c libbb/pw_encrypt.c libbb/update_passwd.c
 loginutils/getty.c loginutils/login.c loginutils/su.c
 loginutils/passwd.c loginutils/chpasswd.c loginutils/cryptpw.c

And the config flags to add :

 CONFIG_GETTY=y
 CONFIG_LOGIN=y
 CONFIG_FEATURE_NOLOGIN=y
 CONFIG_PASSWD=y
 CONFIG_CRYPTPW=y
 CONFIG_CHPASSWD=y
 CONFIG_SU=y
 CONFIG_FEATURE_SU_CHECKS_SHELLS=y

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>

Change-Id: I96ee64f0872856fad6b3ff299faafad6451da556
android: fix building errors with Android L

Tested OK with Android L PDK LRW17D.

The asm files are regenerated by Android L gensyscalls.py.

syscalls: restore compatibilty with current branch

on arm __NR_stime constant is undefined in asm/unistd.h

add also BIONIC_L define for assembly files (syscalls)
tested on arm and x86 (not on mips)

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>

Change-Id: If5b6a6d3f8b4c10339f8e7b0bf340d02c1cf26cb
android: remove syscalls implemented in libbb

We missed the addition of libbb/missing_syscalls.c in 1.21

This also fix 'busybox date -s "2014-08-06 14:15:15"'
(tested in recovery too)

Change-Id: I2a1297e894638f000734b15757100c2d48984ed3
Android: clean only objects, not the folders

Some users building with a high number of threads
reported to me problems regarding the import_includes folder.

So, only delete objects files (.o) and keep import_includes

Change-Id: Ibf3ac818ff2bcf00bdf4f5243112001e2b2e15ef
Android: typo in busybox folder

That was a remains of a test when the folder doesnt exists

Change-Id: If1989dc774ae7c6a8a94692ada6c321f67b5f4d9
dmesg: rework color feature, compat. with more

when used with less or more, the colors were not in
the same buffer, resulting blocs of colors.

Also, reset color numbers to the 16 ANSI ones.

Reduce the diff with busybox to be able to send the patch.
This is the first full busybox aosp feature with the new build system

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>

Change-Id: Ia0239a0bea02da01cae15736150dfee4fe66dcdb
[x86] Android 4.4.4 for x86 needs new implementation of "security_compute_relabel"

Change-Id: I2e15f58f11c9ee74ed8e1b7bf731efd881b890d9
New BIONIC_L(Android-L) has own support for STPCPY

The new BIONIC for android L preview has own support for STPCPY for all
arches. This patch removes inbuilt STPCPY support from busybox when BIONIC_L
is defined.

Change-Id: I189a4489450ca11eddd5b3f49a29f1fe46d0157a
Merge "[x86] Android 4.4.4 for x86 needs new implementation of "security_compute_relabel"" into cm-11.0