Skip to content

Commit

Permalink
[samba4] Build more like OpenWrt
Browse files Browse the repository at this point in the history
Also fix 2 GB limit due to previously broken waf-answer-files
  • Loading branch information
Schimmelreiter committed Dec 2, 2019
1 parent 51d8032 commit 0ebae8c
Show file tree
Hide file tree
Showing 11 changed files with 776 additions and 589 deletions.
95 changes: 95 additions & 0 deletions meta-oe/recipes-connectivity/samba/asn1compile-native.bb
@@ -0,0 +1,95 @@
require samba-source.inc

S = "${WORKDIR}/samba-${PV}"

inherit cpan-base perlnative pythonnative native

#DEPENDS += "libxslt-native docbook-xsl-stylesheets-native e2fsprogs readline virtual/libiconv zlib popt
#DEPENDS += "python-native"

DEPENDS += "e2fsprogs-native zlib-native readline-native"

DEPENDS_append_libc-musl = " libtirpc"
CFLAGS_append_libc-musl = " -I${STAGING_INCDIR}/tirpc"
LDFLAGS_append_libc-musl = " -ltirpc"

EXTRA_OECONF += "--disable-cups \
--disable-iprint \
--disable-cephfs \
--disable-fault-handling \
--disable-glusterfs \
--disable-rpath \
--disable-rpath-install \
--disable-rpath-private-install \
--enable-fhs \
--without-automount \
--without-iconv \
--without-lttng \
--without-ntvfs-fileserver \
--without-pam \
--without-systemd \
--without-utmp \
--without-dmapi \
--without-fam \
--without-gettext \
--without-regedit \
--without-gpgme \
--disable-avahi \
--without-quotas \
--without-acl-support \
--without-winbind \
--without-ad-dc \
--without-json \
--without-libarchive \
--disable-python --nopyc --nopyo \
--disable-gnutls \
--without-dnsupdate \
--without-ads \
--without-ldap \
--nonshared-binary=asn1_compile \
--builtin-libraries=replace \
--with-static-modules=!DEFAULT,!FORCED \
--with-shared-modules=!DEFAULT,!FORCED \
"

LDFLAGS += "-Wl,-z,relro,-z,now ${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd ', '', d)}"

# avoids build breaks when using no-static-libs.inc
DISABLE_STATIC = ""

CONFIGUREOPTS = " --prefix=${prefix} \
--bindir=${bindir} \
--sbindir=${sbindir} \
--libexecdir=${libexecdir} \
--datadir=${datadir} \
--sysconfdir=${sysconfdir} \
--sharedstatedir=${sharedstatedir} \
--localstatedir=${localstatedir} \
--libdir=${libdir} \
--includedir=${includedir} \
--oldincludedir=${oldincludedir} \
--infodir=${infodir} \
--mandir=${mandir} \
${PACKAGECONFIG_CONFARGS} \
"

do_configure() {
export STAGING_LIBDIR=${STAGING_DIR_HOST}${libdir}
export STAGING_INCDIR=${STAGING_DIR_HOST}${incdir}
export PYTHONPATH=${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR}

export python_LDFLAGS=""
export python_LIBDIR=""

CONFIG_CMD="./configure ${CONFIGUREOPTS} ${EXTRA_OECONF}"
${CONFIG_CMD}
}

do_compile () {
./buildtools/bin/waf build --targets=asn1_compile
}

do_install() {
install -d ${D}${bindir}
install -m 0755 ${S}/bin/default/source4/heimdal_build/asn1_compile ${D}${bindir}
}
217 changes: 217 additions & 0 deletions meta-oe/recipes-connectivity/samba/samba-pkgs.inc
@@ -0,0 +1,217 @@
inherit systemd update-rc.d update-alternatives

PACKAGES =+ "smbclient ${PN}-common \
${PN}-admin ${PN}-utils \
${PN}-ldb-tools ${PN}-tdb-tools ${PN}-pdb-tools registry-tools \
winbind ${PN}-ad-dc ${PN}-ctdb-tests \
${PN}-python ${PN}-pidl ${PN}-dsdb-modules ${PN}-testsuite \
"

# remove default added RDEPENDS on perl
RDEPENDS_${PN}_remove = "perl"

INITSCRIPT_PACKAGES = "${PN}"
INITSCRIPT_NAME_${PN} = "samba"
INITSCRIPT_PARAMS_${PN} = "defaults"

SYSTEMD_PACKAGES = "${PN} ${PN}-ad-dc winbind"
SYSTEMD_SERVICE_${PN} = "${@bb.utils.contains('DISTRO_FEATURES_BACKFILL_CONSIDERED', 'sysvinit', 'nmb.service smb.service', '', d)}"
SYSTEMD_SERVICE_${PN}-ad-dc = "${@bb.utils.contains('PACKAGECONFIG', 'ad-dc', 'samba.service', '', d)}"
SYSTEMD_SERVICE_winbind = "winbind.service"

# There are prerequisite settings to enable ad-dc, so disable the service by default.
# Reference:
# https://wiki.samba.org/index.php/Setting_up_Samba_as_an_Active_Directory_Domain_Controller
SYSTEMD_AUTO_ENABLE_${PN}-ad-dc = "disable"

RDEPENDS_${PN}-ctdb-tests += "bash util-linux-getopt"

python samba_populate_packages() {
def module_hook(file, pkg, pattern, format, basename):
pn = d.getVar('PN')

mlprefix = d.getVar('MLPREFIX') or ''
pam_libdir = d.expand('${base_libdir}/security')
pam_pkgname = mlprefix + 'pam-plugin%s'
do_split_packages(d, pam_libdir, '^pam_(.*)\.so$', pam_pkgname, 'PAM plugin for %s', extra_depends='', prepend=False)

pkglibdir = d.getVar('libdir')
do_split_packages(d, pkglibdir, '^lib(.*)\.so\..*$', 'lib%s', 'Samba %s library', allow_links=True, extra_depends='${PN}-common', prepend=True)
do_split_packages(d, pkglibdir, '^lib(.*)\.so$', 'lib%s', 'Samba %s library', allow_links=True, extra_depends='${PN}-common', prepend=True)
moduledir = '%s/samba/auth' % pkglibdir
do_split_packages(d, moduledir, '^(.*)\.so$', 'samba-auth-%s', 'Samba %s authentication backend', hook=module_hook, extra_depends='', prepend=False)
moduledir = '%s/samba/pdb' % pkglibdir
do_split_packages(d, moduledir, '^(.*)\.so$', 'samba-pdb-%s', 'Samba %s password backend', hook=module_hook, extra_depends='', prepend=False)
}

PACKAGESPLITFUNCS_prepend = "samba_populate_packages "
PACKAGES_DYNAMIC = "samba-auth-.* samba-pdb-.*"

# Common to client and server installation
FILES_${BPN}-common = "${sysconfdir}/default \
${sysconfdir}/pam.d/samba \
${sysconfdir}/samba \
${sysconfdir}/tmpfiles.d \
${localstatedir}/lib/samba \
${localstatedir}/spool/samba \
\
/lib/security/pam_smbpass.so \
"

CONFFILES_${BPN}-common = "${sysconfdir}/pam.d/samba \
${sysconfdir}/samba/smb-user.conf \
${sysconfdir}/samba/private/users.map \
${sysconfdir}/samba/private/smbpasswd \
"
INSANE_SKIP_${BPN}-common += "dev-so"

# The Samba client
FILES_smbclient = "${bindir}/smbclient"
RDEPENDS_smbclient += "${BPN}-common"

# The Samba server
FILES_${PN} = " \
${sbindir}/smbd \
${sbindir}/nmbd \
${bindir}/smbcontrol \
${bindir}/smbstatus \
${sysconfdir}/init.d \
${systemd_system_unitdir}/nmb.service \
${systemd_system_unitdir}/smb.service \
${libdir}/charset/*.so \
${libdir}/*.dat \
${libdir}/auth/*.so \
${bindir}/smbpasswd \
${bindir}/testparm \
\
"
RDEPENDS_${PN} += "${BPN}-common wsdd"
INSANE_SKIP_${PN} += "dev-so"

# Server admin tools that are not needed in our image
FILES_${PN}-admin = "${bindir}/net \
${bindir}/profiles \
${bindir}/rpcclient \
${bindir}/sharesec \
${bindir}/smbcacls \
${bindir}/smbcquotas \
${sbindir}/eventlogadm \
"

# Advanced utilities, generally not needed in our image
FILES_${PN}-utils = "${bindir}/cifsdd \
${bindir}/smbtree \
${bindir}/smbget \
${bindir}/smbspool \
${bindir}/smbtar \
${bindir}/mvxattr \
${bindir}/nmblookup \
"

FILES_${PN}-ad-dc = "${sbindir}/samba \
${systemd_system_unitdir}/samba.service \
${libdir}/krb5/plugins/kdb/samba.so \
"
RDEPENDS_${PN}-ad-dc += "samba krb5-kdc"

FILES_registry-tools = "${bindir}/regdiff \
${bindir}/regpatch \
${bindir}/regshell \
${bindir}/regtree"

FILES_${PN}-ldb-tools = "${bindir}/ldbadd \
${bindir}/ldbdel \
${bindir}/ldbedit \
${bindir}/ldbmodify \
${bindir}/ldbrename \
${bindir}/ldbsearch \
${bindir}/oLschema2ldif \
"

FILES_${PN}-pdb-tools = "${bindir}/pdbedit"

FILES_winbind = "${sbindir}/winbindd \
${bindir}/wbinfo \
${bindir}/ntlm_auth \
${libdir}/samba/idmap \
${libdir}/samba/nss_info \
${libdir}/samba/krb5/winbind_krb5_locator.so \
${libdir}/samba/krb5/winbind_krb5_localauth.so \
${sysconfdir}/init.d/winbind \
${systemd_system_unitdir}/winbind.service \
"

FILES_${PN}-ctdb-tests = "${bindir}/ctdb_run_tests \
${bindir}/ctdb_run_cluster_tests \
${sysconfdir}/ctdb/nodes \
${datadir}/ctdb-tests \
${datadir}/ctdb/tests \
${localstatedir}/lib/ctdb \
"

FILES_${PN}-dsdb-modules = "${libdir}/samba/ldb"

FILES_${PN}-testsuite = "${bindir}/gentest \
${bindir}/locktest \
${bindir}/masktest \
${bindir}/ndrdump \
${bindir}/smbtorture"

FILES_${PN}-python = "${PYTHON_SITEPACKAGES_DIR}"

RDEPENDS_${PN}-pidl_append = " perl"
FILES_${PN}-pidl = "${bindir}/pidl ${datadir}/perl5/Parse"

pkg_postinst_${BPN}-common_append() {
#!/bin/sh

set +e
grep -v 'pam_smbpass.so' $D/etc/pam.d/common-password > $D/tmp/common-password
mv $D/tmp/common-password $D/etc/pam.d/common-password
echo -e "password\toptional\t\t\tpam_smbpass.so use_authtok use_first_pass" >> $D/etc/pam.d/common-password

grep -qE '^kids:' $D/etc/passwd
if [[ $? -ne 0 ]] ; then
echo 'kids:x:500:500:Linux User,,,:/media:/bin/false' >> $D/etc/passwd
echo 'kids:!:16560:0:99999:7:::' >> $D/etc/shadow
fi

if [ -e $D/etc/samba/distro/smb-vmc.vmc ]; then
rm $D/etc/samba/distro/smb-vmc.conf 2>/dev/null || true
ln -s smb-vmc.vmc $D/etc/samba/distro/smb-vmc.conf
else
rm $D/etc/samba/distro/smb-vmc.conf 2>/dev/null || true
ln -s smb-vmc.samba $D/etc/samba/distro/smb-vmc.conf
fi

if [ -z "$D" ]; then
set +e
[ -e /etc/samba/private/smbpasswd ] || touch /etc/samba/private/smbpasswd

grep -qE '^root:' /etc/samba/private/smbpasswd
if [[ $? -ne 0 ]] ; then
smbpasswd -Ln root >/dev/null
fi

grep -qE '^kids:' /etc/passwd
if [[ $? -ne 0 ]] ; then
adduser -h /media -s /bin/false -H -D -u 500 kids 2>/dev/null || adduser -h /media -s /bin/false -H -D kids
fi

grep -qE '^kids:' /etc/samba/private/smbpasswd
if [[ $? -ne 0 ]] ; then
smbpasswd -Ln kids >/dev/null
fi
fi
}

pkg_prerm_${BPN}-common_prepend() {
#!/bin/sh
grep -v 'pam_smbpass.so' $D/etc/pam.d/common-password > $D/tmp/common-password
mv $D/tmp/common-password $D/etc/pam.d/common-password
}

pkg_postrm_${BPN}-common_prepend() {
#!/bin/sh
rm $D/etc/samba/distro/smb-vmc.conf 2>/dev/null || true
}
62 changes: 62 additions & 0 deletions meta-oe/recipes-connectivity/samba/samba-source.inc
@@ -0,0 +1,62 @@
PV="4.9.15"
HOMEPAGE = "https://www.samba.org/"
SECTION = "console/network"

LICENSE = "GPL-3.0+ & LGPL-3.0+ & GPL-2.0+"
LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504 \
file://${COREBASE}/meta/files/common-licenses/LGPL-3.0;md5=bfccfe952269fff2b407dd11f2f3083b \
file://${COREBASE}/meta/files/common-licenses/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6 "

SAMBA_MIRROR = "http://samba.org/samba/ftp"
MIRRORS += "\
${SAMBA_MIRROR} http://mirror.internode.on.net/pub/samba \n \
${SAMBA_MIRROR} http://www.mirrorservice.org/sites/ftp.samba.org \n \
"

FILESEXTRAPATHS_prepend := "${THISDIR}/samba:"

SRC_URI = "${SAMBA_MIRROR}/stable/samba-${PV}.tar.gz \
file://001-samba-4.9.15-pam.patch \
file://002-dnsserver-4.9.15.patch \
file://010-source3-msgsock-nvram-fix.patch \
file://011-source4-msgsock-nvram-fix.patch \
file://101-do-not-check-xsltproc-manpages.patch \
file://102-samba-4.9.15-unbundle-libbsd.patch \
file://103-tmsize-overflow-fix.patch \
file://201-add-config-option-without-valgrind.patch \
file://202-iconv-4.9.15.patch \
file://203-netdb_defines.patch \
file://206-lib-replace-wscript-Avoid-generating-nested-main-fun.patch \
file://207-glibc_only.patch \
file://208-talloc_old_kernel_fix.patch \
file://210-skip-faulty-ldb_match_test.patch \
file://300-Revert-pam_smbpass-REMOVE-this-PAM-module.patch \
file://301-Revert-source3-wscript-remove-pam_smbpass-option-as-it-was-removed.patch \
file://302-dynamically-create-a-samba-account-if-needed.patch \
file://heimdal_build_fix.patch \
file://smb.conf \
file://smb-user.conf \
file://smb-branding.conf \
file://smb-global.conf \
file://smb-shares.conf \
file://smb-vmc.samba \
file://init.samba \
file://pam.samba \
file://users.map \
file://smbpasswd \
file://volatiles.03_samba \
"
SRC_URI_append_libc-musl = " \
file://400-samba-4.10.10-remove-getpwent_r.patch \
file://401-cmocka-uintptr_t.patch \
file://402-samba-fix-musl-lib-without-innetgr.patch \
"

SRC_URI_append_sh4 = " \
file://209-strtoull.patch \
"

SRC_URI[md5sum] = "57510c96714fa8ad0dc9f25fa458c7d1"
SRC_URI[sha256sum] = "377102b80b97941bf0d131b828cae8415190e5bdd2928c2e2c954e29f1904496"

UPSTREAM_CHECK_REGEX = "samba\-(?P<pver>4\.9(\.\d+)+).tar.gz"

16 comments on commit 0ebae8c

@jetzzze
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there,
I learned that this commit is in the context of a correction to remove file size limitation of 2.1GigaByte. I still experience the file size limitation on Open ATV 6.3 latest build on my VU+ receiver ... could there still be a bug or does this mean that my image does not contain the fix yet?

@Schimmelreiter
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenATV 6.3 doesn't even get built from this branch, so this commit (and the previous commits to Samba in this branch) do not have any effect on Samba on OpenATV 6.3.

@jetzzze
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your quick response!!! (How) can I find out if this bug correction has made it into the OpenATV built? Or the other way round: if the OpenATV has still the file size limitation? I mean, obviously I suffer from it. But I would like/need to draw the attention of the OpenATV developers to it ... Any idea? ... and thanks again!

@nickersk
Copy link
Member

@nickersk nickersk commented on 0ebae8c Feb 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is bug in system bootloader. we cant do nothing about it as its sources are closed. you can ask manufacturer to provide bootloader upgrade, but im afraid it will be pointless...many of them doesnt even respond to users questions afaik.

@nickersk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still you can try to flash it to openmultiboot from other image.

@jetzzze
Copy link

@jetzzze jetzzze commented on 0ebae8c Feb 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nickersk,
you mean that the Samba server problem is in the closed source from VU+ in this case and that only they can fix it (which I understand is futile)?
And what exactly do you mean by "try to flash it to openmultiboot from other image" (sorry for my bad understanding)? Do you mean that I shoul install an additional image (like OpenPLi) on my box and run the other image when I want to copy files > 2.1GB?

@nickersk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah you meant large files support...well it has nothing to do with bootloader. i understood that you cant flash openatv at first time :-) so your problem ist largefiles support of samba yes?

@jetzzze
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - when I copy/stream files > 2.1GB from my receiver via a SMB mount to Windows, Mac or Linux it aborts at 2.1GB

@nickersk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which machine, atv version and samba version do you use ?

@jetzzze
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use VU+ Solo 4K and Vu+ Solo SE v2 with OpenATV 6.3 both latest version (update yesterday). "opkg -list-installed" shows samba version 4.8.4-r2

@nickersk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have vusolose se v2 too :-) is there any reason why dont you switch to 6.4?

@jetzzze
Copy link

@jetzzze jetzzze commented on 0ebae8c Feb 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a) I thought the vusolo se v2 was not yet listed in the supported devices for 6.4
b) I heavily use some extensions for skins, streaming "mediatheken" and watching blu ray isos and very often the extension are not available for the beta ...
c) The se v2 is my testing box where I have only little recordings. The Solo 4K is the main box and there have been problems reported on 6.4 that is why I wait.
d) I could consider upgrading the SE if the bug is fixed there ... and my extensions are available :-)

@jetzzze
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But shouldn't the Samba bug be fixed in openatv 6.3 also (if it is fixed in 6.4 at all)?

@nickersk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahm ok, i'll take a look on that.

@jetzzze
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that I made the openatv forum people mad with my research. I DID NOT INTEND THAT !!! I apologize and hope you are not mad at me as well. I will be quiet now and wait for the solution!

@jetzzze
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nickersk, I read through the OpenATV 6.4 beta topic closer and saw that vusolose is tested (Sorry for my mistake!) I flashed it to the 202002228 build and now the mounting behaviour is coherent and you need to mount the receivers harddisk as network drive in Windows with "root" + passwort credentials ... Now large file support via SMB works with 6.4 beta (and fortunately all my used extensions).
Maybe this is giving a hint how to fix it in 6.3 ... Thanks for your support and your advice to upgrade to 6.4 ... works well for me!!! THANK YOU

Please sign in to comment.