#!/bin/sh -e
export AR="arm-poky-linux-gnueabi-gcc-ar"
export AS="arm-poky-linux-gnueabi-as "
export BUILD_AR="ar"
export BUILD_AS="as "
export BUILD_CC="gcc "
export BUILD_CCLD="gcc "
export BUILD_CFLAGS="-isystemFIXMESTAGINGDIRHOST/usr/include -O2 -pipe"
export BUILD_CPP="gcc  -E"
export BUILD_CPPFLAGS="-isystemFIXMESTAGINGDIRHOST/usr/include"
export BUILD_CXX="g++ "
export BUILD_CXXFLAGS="-isystemFIXMESTAGINGDIRHOST/usr/include -O2 -pipe"
export BUILD_FC="gfortran "
export BUILD_LD="ld "
export BUILD_LDFLAGS="-LFIXMESTAGINGDIRHOST/usr/lib                         -LFIXMESTAGINGDIRHOST/lib                         -Wl,--enable-new-dtags                         -Wl,-rpath-link,FIXMESTAGINGDIRHOST/usr/lib                         -Wl,-rpath-link,FIXMESTAGINGDIRHOST/lib                         -Wl,-rpath,FIXMESTAGINGDIRHOST/usr/lib                         -Wl,-rpath,FIXMESTAGINGDIRHOST/lib                         -Wl,-O1 -Wl,--allow-shlib-undefined -Wl,--dynamic-linker=/srv/pokybuild/yocto-worker/beaglebone-alt/build/build/tmp/sysroots-uninative/x86_64-linux/lib/ld-linux-x86-64.so.2 -pthread"
export BUILD_NM="nm"
export BUILD_RANLIB="ranlib -D"
export BUILD_STRIP="strip"
export CC="arm-poky-linux-gnueabi-gcc  -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a8 -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=FIXMESTAGINGDIRTARGET"
export CCLD="arm-poky-linux-gnueabi-gcc  -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a8 -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=FIXMESTAGINGDIRTARGET"
export CFLAGS=" -O2 -g -fcanon-prefix-map  -ffile-prefix-map=/srv/pokybuild/yocto-worker/beaglebone-alt/build/build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/systemd/259.5/sources/systemd-259.5=/usr/src/debug/systemd/259.5  -ffile-prefix-map=/srv/pokybuild/yocto-worker/beaglebone-alt/build/build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/systemd/259.5/build=/usr/src/debug/systemd/259.5  -ffile-prefix-map=FIXMESTAGINGDIRTARGET=  -ffile-prefix-map=FIXMESTAGINGDIRHOST=  -pipe --sysroot=FIXMESTAGINGDIRTARGET"
export CPP="arm-poky-linux-gnueabi-gcc -E --sysroot=FIXMESTAGINGDIRTARGET  -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a8 -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security"
export CPPFLAGS=""
export CXX="arm-poky-linux-gnueabi-g++  -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a8 -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=FIXMESTAGINGDIRTARGET"
export CXXFLAGS=" -O2 -g -fcanon-prefix-map  -ffile-prefix-map=/srv/pokybuild/yocto-worker/beaglebone-alt/build/build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/systemd/259.5/sources/systemd-259.5=/usr/src/debug/systemd/259.5  -ffile-prefix-map=/srv/pokybuild/yocto-worker/beaglebone-alt/build/build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/systemd/259.5/build=/usr/src/debug/systemd/259.5  -ffile-prefix-map=FIXMESTAGINGDIRTARGET=  -ffile-prefix-map=FIXMESTAGINGDIRHOST=  -pipe -fvisibility-inlines-hidden"
export FC="arm-poky-linux-gnueabi-gfortran  -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a8 -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=FIXMESTAGINGDIRTARGET"
export GETTEXTDATADIRS=":FIXMESTAGINGDIRTARGET/usr/share/gettext"
export GIT_CEILING_DIRECTORIES="/srv/pokybuild/yocto-worker/beaglebone-alt/build/build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/systemd/259.5:/srv/pokybuild/yocto-worker/beaglebone-alt/build/build/tmp"
export HOME="/srv/pokybuild"
export LC_ALL="en_US.UTF-8"
export LD="arm-poky-linux-gnueabi-ld --sysroot=FIXMESTAGINGDIRTARGET "
export LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now"
export LOGNAME="pokybuild"
export MAKE="make"
export NM="arm-poky-linux-gnueabi-gcc-nm"
export OBJCOPY="arm-poky-linux-gnueabi-objcopy"
export OBJDUMP="arm-poky-linux-gnueabi-objdump"
export OMP_NUM_THREADS="16"
export PATH="/srv/pokybuild/yocto-worker/beaglebone-alt/build/build/tmp/sysroots-uninative/x86_64-linux/usr/bin:FIXMESTAGINGDIRHOST/usr/bin/python3-native:FIXMESTAGINGDIRHOST/usr/bin/perl-native:/srv/pokybuild/yocto-worker/beaglebone-alt/build/layers/openembedded-core/scripts:FIXMESTAGINGDIRHOST/usr/bin/arm-poky-linux-gnueabi:FIXMESTAGINGDIRTARGET/usr/bin/crossscripts:FIXMESTAGINGDIRHOST/usr/sbin:FIXMESTAGINGDIRHOST/usr/bin:FIXMESTAGINGDIRHOST/sbin:FIXMESTAGINGDIRHOST/bin:/srv/pokybuild/yocto-worker/beaglebone-alt/build/layers/bitbake/bin:FIXME_HOSTTOOLS_DIR"
export PERL_HASH_SEED="0"
export PKG_CONFIG_DISABLE_UNINSTALLED="yes"
export PKG_CONFIG_LIBDIR="FIXMESTAGINGDIRTARGET/usr/lib/pkgconfig:FIXMESTAGINGDIRTARGET/usr/share/pkgconfig"
export PKG_CONFIG_PATH=""
export PKG_CONFIG_SYSROOT_DIR="FIXMESTAGINGDIRTARGET"
export PKG_CONFIG_SYSTEM_INCLUDE_PATH="FIXMESTAGINGDIRTARGET/usr/include"
export PKG_CONFIG_SYSTEM_LIBRARY_PATH="FIXMESTAGINGDIRTARGET/usr/lib:FIXMESTAGINGDIRTARGET/usr/lib"
export PSEUDO_DISABLED="1"
export PSEUDO_UNLOAD="1"
export PYTHON="FIXMESTAGINGDIRHOST/usr/bin/python3-native/python3"
export PYTHONHASHSEED="0"
export PYTHONNOUSERSITE="1"
export PYTHON_INCLUDE_DIR="FIXMESTAGINGDIRTARGET/usr/include/python3.14"
export PYTHON_LIBRARY="FIXMESTAGINGDIRTARGET/usr/lib/libpython3.14.so"
export RANLIB="arm-poky-linux-gnueabi-gcc-ranlib"
export READELF="arm-poky-linux-gnueabi-readelf"
unset SHELL
export SOURCE_DATE_EPOCH="1773416108"
export STAGING_INCDIR="FIXMESTAGINGDIRTARGET/usr/include"
export STAGING_LIBDIR="FIXMESTAGINGDIRTARGET/usr/lib"
export STRINGS="arm-poky-linux-gnueabi-strings"
export STRIP="arm-poky-linux-gnueabi-strip"
export TZ="UTC"
export USER="pokybuild"
export base_bindir="/usr/bin"
export base_libdir="/usr/lib"
export base_prefix=""
export base_sbindir="/usr/sbin"
export bindir="/usr/bin"
export datadir="/usr/share"
export docdir="/usr/share/doc"
export exec_prefix="/usr"
export includedir="/usr/include"
export infodir="/usr/share/info"
export libdir="/usr/lib"
export libexecdir="/usr/libexec"
export localstatedir="/var"
export mandir="/usr/share/man"
export nonarch_base_libdir="/usr/lib"
export nonarch_libdir="/usr/lib"
export prefix="/usr"
export sbindir="/usr/sbin"
export servicedir="/srv"
export sharedstatedir="/com"
export sysconfdir="/etc"
export systemd_system_unitdir="/usr/lib/systemd/system"
export systemd_unitdir="/usr/lib/systemd"
export systemd_user_unitdir="/usr/lib/systemd/user"

# line: 122, file: /srv/pokybuild/yocto-worker/beaglebone-alt/build/layers/openembedded-core/meta/classes/useradd.bbclass
groupadd_sysroot() {
	common_useradd_sysroot groupadd
}

# line: 138, file: /srv/pokybuild/yocto-worker/beaglebone-alt/build/layers/openembedded-core/meta/classes/useradd.bbclass
common_useradd_sysroot() {
	# Pseudo may (do_prepare_recipe_sysroot) or may not (do_populate_sysroot_setscene) be running
	# at this point so we're explicit about the environment so pseudo can load if
	# not already present.
	# PSEUDO_SYSROOT can contain references to the build architecture and COMPONENT_DIR
	# so needs the STAGING_FIXME below
	export PSEUDO="PSEUDO_PREFIX=FIXME_PSEUDO_SYSROOT/usr PSEUDO_LOCALSTATEDIR=FIXME_PSEUDO_LOCALSTATEDIR PSEUDO_PASSWD=FIXMESTAGINGDIRTARGET:FIXME_PSEUDO_SYSROOT PSEUDO_NOSYMLINKEXP=1 PSEUDO_INCLUDE_PATHS=/proc,/srv/pokybuild/yocto-worker/beaglebone-alt/build/build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/systemd/259.5/image,/srv/pokybuild/yocto-worker/beaglebone-alt/build/build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/systemd/259.5/package,/srv/pokybuild/yocto-worker/beaglebone-alt/build/build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/systemd/259.5/rootfs,/srv/pokybuild/yocto-worker/beaglebone-alt/build/build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/systemd/259.5/sstate-build-package/,/srv/pokybuild/yocto-worker/beaglebone-alt/build/build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/systemd/259.5/sstate-install-package/,/srv/pokybuild/yocto-worker/beaglebone-alt/build/build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/systemd/259.5/pkgdata,/srv/pokybuild/yocto-worker/beaglebone-alt/build/build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/systemd/259.5/minidebuginfo,/srv/pokybuild/yocto-worker/beaglebone-alt/build/build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/systemd/259.5/devtool-deploy-target-stripped PSEUDO_DISABLED=0 FIXME_PSEUDO_SYSROOT/usr/bin/pseudo"

	# Explicitly set $D since it isn't set to anything
	# before do_prepare_recipe_sysroot
	D=FIXMESTAGINGDIRTARGET

	# base-passwd's postinst may not have run yet in which case we'll get called later, just exit.
	# Beware that in some cases we might see the fake pseudo passwd here, in which case we also must
	# exit.
	if [ ! -f $D/etc/passwd ] ||
	   grep -q this-is-the-pseudo-passwd $D/etc/passwd; then
		exit 0
	fi

	# It is also possible we may be in a recipe which doesn't have useradd dependencies and hence the
	# useradd/groupadd tools are unavailable. If there is no dependency, we assume we don't want to
	# create users in the sysroot
	if ! command -v "$1"; then
		bbwarn "The $1 command could not be found!"
		exit 0
	fi

	# Add groups and users defined for all recipe packages
	case "$1" in
		groupadd) GROUPADD_PARAM="-r systemd-journal; -r empower; -r render";;
		useradd) USERADD_PARAM="   --system -d / -M --shell /sbin/nologin systemd-resolve; --system -d / -M --shell /sbin/nologin systemd-timesync; --system -d / -M --shell /sbin/nologin systemd-network";;
		usermod) USERMOD_PARAM="";;
		groupmems) GROUPMEMS_PARAM="";;
	esac

	# Tell the system to use the environment vars
	UA_SYSROOT=1

	useradd_preinst
}

# line: 48, file: /srv/pokybuild/yocto-worker/beaglebone-alt/build/layers/openembedded-core/meta/classes-global/logging.bbclass
bbwarn() {
	if [ -p FIXME_LOGFIFO ] ; then
		printf "%b\0" "bbwarn $*" > FIXME_LOGFIFO
	else
		echo "WARNING: $*"
	fi
}

# line: 22, file: /srv/pokybuild/yocto-worker/beaglebone-alt/build/layers/openembedded-core/meta/classes/useradd.bbclass
useradd_preinst() {
OPT=""
SYSROOT=""

if test "x$D" != "x"; then
	# Installing into a sysroot
	SYSROOT="$D"
	OPT="--prefix $D"

	# Make sure login.defs is there, this is to make debian package backend work
	# correctly while doing rootfs.
	# The problem here is that if /etc/login.defs is treated as a config file for
	# shadow package, then while performing preinsts for packages that depend on
	# shadow, there might only be /etc/login.def.dpkg-new there in root filesystem.
	if [ ! -e $D/etc/login.defs -a -e $D/etc/login.defs.dpkg-new ]; then
		cp $D/etc/login.defs.dpkg-new $D/etc/login.defs
	fi

	# user/group lookups should match useradd/groupadd --prefix
	export PSEUDO_PASSWD="$SYSROOT"
fi

# If we're not doing a special SSTATE/SYSROOT install
# then set the values, otherwise use the environment
if test "x$UA_SYSROOT" = "x"; then
	# Installing onto a target
	# Add groups and users defined only for this package
	GROUPADD_PARAM="${GROUPADD_PARAM}"
	USERADD_PARAM="${USERADD_PARAM}"
	USERMOD_PARAM="${USERMOD_PARAM}"
	GROUPMEMS_PARAM="${GROUPMEMS_PARAM}"
fi

# Perform group additions first, since user additions may depend
# on these groups existing
if test "x`echo $GROUPADD_PARAM | tr -d '[:space:]'`" != "x"; then
	echo "Running groupadd commands..."
	# Invoke multiple instances of groupadd for parameter lists
	# separated by ';'
	opts=`echo "$GROUPADD_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
	remaining=`echo "$GROUPADD_PARAM" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
	while test "x$opts" != "x"; do
		perform_groupadd "$SYSROOT" "$OPT $opts"
		if test "x$opts" = "x$remaining"; then
			break
		fi
		opts=`echo "$remaining" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
		remaining=`echo "$remaining" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
	done
fi

if test "x`echo $USERADD_PARAM | tr -d '[:space:]'`" != "x"; then
	echo "Running useradd commands..."
	# Invoke multiple instances of useradd for parameter lists
	# separated by ';'
	opts=`echo "$USERADD_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
	remaining=`echo "$USERADD_PARAM" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
	while test "x$opts" != "x"; do
		perform_useradd "$SYSROOT" "$OPT $opts"
		if test "x$opts" = "x$remaining"; then
			break
		fi
		opts=`echo "$remaining" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
		remaining=`echo "$remaining" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
	done
fi

if test "x`echo $USERMOD_PARAM | tr -d '[:space:]'`" != "x"; then
	echo "Running usermod commands..."
	# Invoke multiple instances of usermod for parameter lists
	# separated by ';'
	opts=`echo "$USERMOD_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
	remaining=`echo "$USERMOD_PARAM" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
	while test "x$opts" != "x"; do
		perform_usermod "$SYSROOT" "$OPT $opts"
		if test "x$opts" = "x$remaining"; then
			break
		fi
		opts=`echo "$remaining" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
		remaining=`echo "$remaining" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
	done
fi

if test "x`echo $GROUPMEMS_PARAM | tr -d '[:space:]'`" != "x"; then
	echo "Running groupmems commands..."
	# Invoke multiple instances of groupmems for parameter lists
	# separated by ';'
	opts=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
	remaining=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
	while test "x$opts" != "x"; do
		perform_groupmems "$SYSROOT" "$OPT $opts"
		if test "x$opts" = "x$remaining"; then
			break
		fi
		opts=`echo "$remaining" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
		remaining=`echo "$remaining" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
	done
fi
}

# line: 19, file: /srv/pokybuild/yocto-worker/beaglebone-alt/build/layers/openembedded-core/meta/classes/useradd_base.bbclass
perform_groupadd() {
	local rootdir="$1"
	local opts="$2"
	bbnote "systemd: Performing groupadd with [$opts]"
	local groupname=`echo "$opts" | awk '{ print $NF }'`
	local group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
	if test "x$group_exists" = "x"; then
		eval flock -x $rootdir/etc -c \"$PSEUDO groupadd \$opts\" || true
		group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
		if test "x$group_exists" = "x"; then
			bbfatal "systemd: groupadd command did not succeed."
		fi
	else
		bbnote "systemd: group $groupname already exists, not re-creating it"
	fi
}

# line: 53, file: /srv/pokybuild/yocto-worker/beaglebone-alt/build/layers/openembedded-core/meta/classes/useradd_base.bbclass
perform_groupmems() {
	local rootdir="$1"
	local opts="$2"
	bbnote "systemd: Performing groupmems with [$opts]"
	local groupname=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-g" || $i == "--group") print $(i+1) }'`
	local username=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-a" || $i == "--add") print $(i+1) }'`
	local prefix=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-P" || $i == "--prefix") print $(i+1) }'`
	if test "x$groupname" = "x"; then
		bbfatal "systemd: groupmems: No user specified using --add."

	elif test "x$username" = "x"; then
		bbfatal "systemd: groupmems: No group specified using --group."
	fi
	bbnote "systemd: Emulating groupmems command using usermod with group $groupname and user $username"
	local mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*$" $rootdir/etc/group || true`"
	if test "x$mem_exists" = "x"; then
		eval flock -x $rootdir/etc -c \"$PSEUDO usermod \${prefix:+--prefix \$prefix} --append --groups \$groupname \$username\" || true
		mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*$" $rootdir/etc/group || true`"
		if test "x$mem_exists" = "x"; then
			bbfatal "systemd: groupmems command (emulated using usermod) did not succeed."
		fi
	else
		bbnote "systemd: group $groupname already contains $username, not re-adding it"
	fi
}

# line: 36, file: /srv/pokybuild/yocto-worker/beaglebone-alt/build/layers/openembedded-core/meta/classes/useradd_base.bbclass
perform_useradd() {
	local rootdir="$1"
	local opts="$2"
	bbnote "systemd: Performing useradd with [$opts]"
	local username=`echo "$opts" | awk '{ print $NF }'`
	local user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
	if test "x$user_exists" = "x"; then
		eval flock -x $rootdir/etc -c  \"$PSEUDO useradd \$opts\" || true
		user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
		if test "x$user_exists" = "x"; then
			bbfatal "systemd: useradd command did not succeed."
		fi
	else
		bbnote "systemd: user $username already exists, not re-creating it"
	fi
}

# line: 143, file: /srv/pokybuild/yocto-worker/beaglebone-alt/build/layers/openembedded-core/meta/classes/useradd_base.bbclass
perform_usermod() {
	# Same reason with groupmod, temporarily disable -e option
	set +e
	local rootdir="$1"
	local opts="$2"
	bbnote "systemd: Performing usermod with [$opts]"
	local username=`echo "$opts" | awk '{ print $NF }'`
	local user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
	if test "x$user_exists" != "x"; then
		eval flock -x $rootdir/etc -c \"$PSEUDO usermod \$opts\"
		if test $? != 0; then
			bbfatal "systemd: usermod command did not succeed."
		fi
	else
		bbwarn "systemd: user $username doesn't exist, unable to modify it"
	fi
	set -e
}

# line: 70, file: /srv/pokybuild/yocto-worker/beaglebone-alt/build/layers/openembedded-core/meta/classes-global/logging.bbclass
bbfatal() {
	if [ -p FIXME_LOGFIFO ] ; then
		printf "%b\0" "bbfatal $*" > FIXME_LOGFIFO
	else
		echo "ERROR: $*"
	fi
	exit 1
}

# line: 27, file: /srv/pokybuild/yocto-worker/beaglebone-alt/build/layers/openembedded-core/meta/classes-global/logging.bbclass
bbnote() {
	if [ -p FIXME_LOGFIFO ] ; then
		printf "%b\0" "bbnote $*" > FIXME_LOGFIFO
	else
		echo "NOTE: $*"
	fi
}

groupadd_sysroot
