Skip to content

Commit

Permalink
Apply patch from samba-document-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricelam committed Dec 14, 2021
1 parent 548e16c commit c6eb10b
Show file tree
Hide file tree
Showing 27 changed files with 509 additions and 43 deletions.
39 changes: 39 additions & 0 deletions build_answers
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Checking uname sysname type: "Linux"
Checking uname machine type: "arm"
Checking uname release type: "Linux"
Checking uname version type: "Linux"
Checking simple C program: OK
rpath library support: FAIL
-Wl,--version-script support: FAIL
Checking getconf LFS_CFLAGS: FAIL
Checking for large file support without additional flags: FAIL
Checking for -D_FILE_OFFSET_BITS=64: OK
Checking for -D_LARGE_FILES: FAIL
Checking correct behavior of strtoll: OK
Checking for working strptime: OK
Checking for C99 vsnprintf: OK
Checking for HAVE_SHARED_MMAP: FAIL
Checking for HAVE_MREMAP: FAIL
Checking for HAVE_INCOHERENT_MMAP: FAIL
Checking for HAVE_SECURE_MKSTEMP: FAIL
Checking for HAVE_IFACE_GETIFADDRS: OK
Checking value of NSIG: "65"
Checking value of _NSIG: "65"
Checking value of SIGRTMAX: "64"
Checking value of SIGRTMIN: "35"
Checking for kernel change notify support: FAIL
Checking for Linux kernel oplocks: FAIL
Checking for kernel share modes: OK
vfs_fileid checking for statfs() and struct statfs.f_fsid: OK
Checking whether we can use Linux thread-specific credentials with 32-bit system calls: OK
Checking whether seteuid is available: OK
Checking whether setreuid is available: OK
Checking whether setresuid is available: OK
Checking whether fcntl locking is available: OK
Checking for the maximum value of the 'time_t' type: FAIL
Checking whether the realpath function allows a NULL argument: FAIL
Checking for ftruncate extend: FAIL
getcwd takes a NULL argument: OK
Checking for HAVE_IFACE_IFCONF: FAIL
Checking whether we can use Linux thread-specific credentials: FAIL
Checking whether fcntl lock supports open file description locks: FAIL
20 changes: 20 additions & 0 deletions buildtools/wafsamba/wafsamba.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ def SAMBA_LIBRARY(bld, libname, source,
enabled=True):
'''define a Samba library'''

if pyembed or pyext:
return

if pyembed and bld.env['IS_EXTRA_PYTHON']:
public_headers = pc_files = None

Expand Down Expand Up @@ -294,6 +297,14 @@ def SAMBA_LIBRARY(bld, libname, source,
bld.add_manual_dependency(bld.path.find_or_declare(instname), bld.path.find_or_declare(vscript))
vscript = os.path.join(bld.path.abspath(bld.env), vscript)

if soname is not None:
segs = soname.split(".");
idxso = segs.index("so");
soname = ".".join(segs[:idxso])
else:
vnum=None
soname="lib" + bundled_name + ".so"

bld.SET_BUILD_GROUP(group)
t = bld(
features = features,
Expand Down Expand Up @@ -365,6 +376,9 @@ def SAMBA_BINARY(bld, binname, source,
enabled=True):
'''define a Samba binary'''

if pyembed:
return

if not enabled:
SET_TARGET_TYPE(bld, binname, 'DISABLED')
return
Expand Down Expand Up @@ -466,6 +480,9 @@ def SAMBA_MODULE(bld, modname, source,
):
'''define a Samba module.'''

if pyembed:
return

bld.ASSERT(subsystem, "You must specify a subsystem for SAMBA_MODULE(%s)" % modname)

source = bld.EXPAND_VARIABLES(source, vars=vars)
Expand Down Expand Up @@ -570,6 +587,9 @@ def SAMBA_SUBSYSTEM(bld, modname, source,
pyembed=False):
'''define a Samba subsystem'''

if pyembed or pyext:
return

if not enabled:
SET_TARGET_TYPE(bld, modname, 'DISABLED')
return
Expand Down
39 changes: 39 additions & 0 deletions cc_shim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/python

import re
import sys
from subprocess import call

is_host=False

armv7_flags=["-march=armv7-a", "-mfloat-abi=softfp", "-mfpu=vfpv3-d16", "-Wl,--fix-cortex-a8"]

match_pattern=[r'.*asn1/gen_template.*\.o', r'.*compile_et.*\.o', r'.*print_version.*\.o', r'.*version_128\.o']

match_pattern=[re.compile(pattern) for pattern in match_pattern]

for i in sys.argv:
if i == '-D_SAMBA_HOSTCC_':
is_host=True

for pattern in match_pattern:
if pattern.match(i):
is_host=True

if is_host:
cmd=['gcc'];
for arg in sys.argv[2:]:
append=True
if arg.startswith('--sysroot'):
append=False

for flag in armv7_flags:
if arg == flag:
append=False

if append:
cmd.append(arg)

call(cmd, stdout=sys.stdout, stderr=sys.stderr)
else:
call(sys.argv[1:], stdout=sys.stdout, stderr=sys.stderr)
4 changes: 4 additions & 0 deletions compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
CWD=$(pwd)

WAF_MAKE=1 python $CWD/buildtools/bin/waf build --targets=smbclient $*
54 changes: 54 additions & 0 deletions configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
CWD=$(pwd)

NDK=$ANDROID_SDK/ndk-bundle

HOST=linux-x86_64

ANDROID_VER=23
TOOLCHAIN_VER=4.9

TOOLCHAIN=$CWD/bin/ndk/toolchain

# Flags for 32-bit ARM
#ABI=arm-linux-androideabi
#PLATFORM_ARCH=arm
#TRIPLE=arm-linux-androideabi

# Flags for ARM v7 used with flags for 32-bit ARM to compile for ARMv7
#COMPILER_FLAG="-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16"
#LINKER_FLAG="-march=armv7-a -Wl,--fix-cortex-a8"

# Flags for 64-bit ARM v8
ABI=aarch64-linux-android
PLATFORM_ARCH=arm64
TRIPLE=aarch64-linux-android

# Flags for x86
#ABI=x86
#PLATFORM_ARCH=x86
#TRIPLE=i686-linux-android

# Flags for x86_64
#ABI=x86_64
#PLATFORM_ARCH=x86_64
#TRIPLE=x86_64-linux-android

export CC="$CWD/cc_shim.py $TOOLCHAIN/bin/clang"
export AR=$TOOLCHAIN/$TRIPLE-ar
export RANLIB=$TOOLCHAIN/$TRIPLE-ranlib

COMPILE_SYSROOT=$TOOLCHAIN/sysroot
export CFLAGS="--sysroot=$COMPILE_SYSROOT $COMPILER_FLAG -O2 -D_FORTIFY_SOURCE=2 -D__ANDROID_API__=$ANDROID_VER -D__USE_FILE_OFFSET64=1 -fstack-protector-all -fPIE -Wa,--noexecstack -Wformat -Wformat-security"

LINK_SYSROOT=$NDK/platforms/android-$ANDROID_VER/arch-$PLATFORM_ARCH
export LDFLAGS="--sysroot=$LINK_SYSROOT $LINKER_FLAG -Wl,-z,relro,-z,now"

# Create standalone tool chain
rm -rf $TOOLCHAIN
echo "Creating standalone toolchain..."
$NDK/build/tools/make_standalone_toolchain.py --arch $PLATFORM_ARCH --api $ANDROID_VER --install-dir $TOOLCHAIN --unified-headers

# Configure Samba build
echo "Configuring Samba..."
$CWD/configure --hostcc=$(which gcc) --without-ads --without-ldap --without-acl-support --without-ad-dc --cross-compile --cross-answers=build_answers --prefix=$CWD/out
16 changes: 16 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

if [[ $1 == '' ]]; then
echo "Usage: $0 <install_location>"
exit 1
fi

DEST_DIR=$1
mkdir -p $DEST_DIR
find bin/default/ -name *.so -exec \
cp -vuni '{}' "$DEST_DIR" ";"

if [ ! -d $DEST_DIR/includes ]; then
mkdir $DEST_DIR/includes
fi
cp -r bin/default/include/public/* $DEST_DIR/includes
1 change: 1 addition & 0 deletions lib/param/loadparm.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#define _LOADPARM_H

#include <talloc.h>
#include "system/time.h"

struct parmlist_entry {
struct parmlist_entry *prev, *next;
Expand Down
8 changes: 8 additions & 0 deletions lib/replace/getifaddrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#define _FOUND_IFACE_ANY
#else

#ifndef __ANDROID__
void rep_freeifaddrs(struct ifaddrs *ifp)
{
if (ifp != NULL) {
Expand All @@ -55,6 +56,7 @@ void rep_freeifaddrs(struct ifaddrs *ifp)
free(ifp);
}
}
#endif // __ANDROID__

static struct sockaddr *sockaddr_dup(struct sockaddr *sa)
{
Expand Down Expand Up @@ -374,6 +376,12 @@ int rep_getifaddrs(struct ifaddrs **ifap)

#define _FOUND_IFACE_ANY
#endif /* HAVE_IFACE_AIX */

#ifdef __ANDROID__
#include "netlink_ifaddrs.c"
#define _FOUND_IFACE_ANY
#endif /* __ANDROID__ */

#ifndef _FOUND_IFACE_ANY
int rep_getifaddrs(struct ifaddrs **ifap)
{
Expand Down
Loading

0 comments on commit c6eb10b

Please sign in to comment.