Skip to content

Commit

Permalink
test build with new builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxython committed Dec 30, 2024
1 parent cd3421f commit b80e57d
Showing 1 changed file with 27 additions and 73 deletions.
100 changes: 27 additions & 73 deletions gpkg/glibc/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,7 @@ TERMUX_PKG_RECOMMENDS="glibc-runner"
TERMUX_PKG_NO_STATICSPLIT=true
TERMUX_PKG_CONFFILES="glibc/etc/gai.conf, glibc/etc/locale.gen"
TERMUX_PKG_SEPARATE_SUB_DEPENDS=true

# Variables for glibc32 compilation
TERMUX_PKG_BUILD32=$(test "$TERMUX_ARCH" = "aarch64" || test "$TERMUX_ARCH" = "arm" && \
test "$TERMUX_ON_DEVICE_BUILD" = "false" && echo "true" || echo "false")
TERMUX_PKG_BUILDDIR32="${TERMUX_TOPDIR}/${TERMUX_PKG_NAME}/build32"
#if [ "$TERMUX_PKG_BUILD32" = "true" ]; then
# TERMUX_PKG_BUILD_DEPENDS="glibc32"
#fi

termux_setup_build32() {
case $TERMUX_ARCH in
"aarch64")
TERMUX_ARCH="arm"
TERMUX_HOST_PLATFORM="arm-linux-gnueabihf";;
"x86_64")
TERMUX_ARCH="i686"
TERMUX_HOST_PLATFORM="i686-linux-gnu";;
esac
termux_step_setup_toolchain
cd ${TERMUX_PKG_BUILDDIR32}
}
TERMUX_PKG_BUILD32=true

termux_step_pre_configure() {
if [ "$TERMUX_PACKAGE_LIBRARY" != "glibc" ]; then
Expand Down Expand Up @@ -112,8 +92,8 @@ termux_step_pre_configure() {

# replacing some hard paths that may not exist in some device
for i in /dev/stderr:/proc/self/fd/2 \
/dev/stdin:/proc/self/fd/0 \
/dev/stdout:/proc/self/fd/1; do
/dev/stdin:/proc/self/fd/0 \
/dev/stdout:/proc/self/fd/1; do
for j in $(grep -s -r -l ${i%%:*} ${TERMUX_PKG_SRCDIR}); do
sed -i "s|${i%%:*}|${i//*:}|g" ${j}
done
Expand All @@ -124,20 +104,16 @@ termux_step_pre_configure() {

# specifying the current release (use only when developing glibc)
sed -i "s/stable/dev.$(git -C ${TERMUX_PKG_BUILDER_DIR} rev-parse --short HEAD).$(date +%Y%m%d%H%M%S)/" ${TERMUX_PKG_SRCDIR}/version.h

if [ "$TERMUX_PKG_BUILD32" = "true" ]; then
rm -fr ${TERMUX_PKG_BUILDDIR32}
mkdir -p ${TERMUX_PKG_BUILDDIR32}
fi
}

termux_glibc_configure() {
local libdir="${1}"

echo "slibdir=${TERMUX_PREFIX}/${libdir}" > configparms
echo "rtlddir=${TERMUX_PREFIX}/${libdir}" >> configparms
termux_step_configure() {
echo "slibdir=${TERMUX_LIB_PATH}" > configparms
echo "rtlddir=${TERMUX_LIB_PATH}" >> configparms
echo "sbindir=${TERMUX_PREFIX}/bin" >> configparms
echo "rootsbindir=${TERMUX_PREFIX}/bin" >> configparms
if [ "$TERMUX_ARCH" != "$TERMUX_REAL_ARCH" ]; then
echo 'build-programs=no' >> configparms
fi

local _configure_flags=()
case $TERMUX_ARCH in
Expand All @@ -153,8 +129,8 @@ termux_glibc_configure() {

${TERMUX_PKG_SRCDIR}/configure \
--prefix=$TERMUX_PREFIX \
--libdir=${TERMUX_PREFIX}/${libdir} \
--libexecdir=${TERMUX_PREFIX}/${libdir} \
--libdir=$TERMUX_LIB_PATH \
--libexecdir=$TERMUX_LIB_PATH \
--host=$TERMUX_HOST_PLATFORM \
--build=$TERMUX_HOST_PLATFORM \
--target=$TERMUX_HOST_PLATFORM \
Expand All @@ -171,35 +147,17 @@ termux_glibc_configure() {
"${_configure_flags[@]}"
}

termux_step_configure() {
termux_glibc_configure "lib"

if [ "$TERMUX_PKG_BUILD32" = "true" ]; then
(
termux_setup_build32
termux_glibc_configure "lib32"
echo 'build-programs=no' >> configparms
)
fi
}

termux_step_make() {
make -O
make info

if [ "$TERMUX_PKG_BUILD32" = "true" ]; then
(
termux_setup_build32
make -O
)
if [ "$TERMUX_ARCH" = "$TERMUX_REAL_ARCH" ]; then
make info
fi
}

termux_glibc_make_syscall_without_fsc() {
local libname="libsyscall_without_fsc.so"
local libdir="$1"
echo "Compiling '${libname}'..."
$CC ${TERMUX_PKG_BUILDER_DIR}/syscall.c -o ${TERMUX_PREFIX}/${libdir}/${libname} \
$CC ${TERMUX_PKG_BUILDER_DIR}/syscall.c -o ${TERMUX_LIB_PATH}/${libname} \
-shared -DWITHOUT_FAKESYSCALL
echo "DONE"
}
Expand All @@ -212,9 +170,9 @@ termux_step_make_install() {
rm -f ${TERMUX_PREFIX}/etc/ld.so.cache
rm -f ${TERMUX_PREFIX}/bin/{tzselect,zdump,zic}

install -dm755 ${TERMUX_PREFIX}/lib/tmpfiles.d
install -dm755 ${TERMUX_LIB_PATH}/tmpfiles.d
install -m644 ${TERMUX_PKG_SRCDIR}/nscd/nscd.conf ${TERMUX_PREFIX}/etc/nscd.conf
install -m644 ${TERMUX_PKG_SRCDIR}/nscd/nscd.tmpfiles ${TERMUX_PREFIX}/lib/tmpfiles.d/nscd.conf
install -m644 ${TERMUX_PKG_SRCDIR}/nscd/nscd.tmpfiles ${TERMUX_LIB_PATH}/tmpfiles.d/nscd.conf
install -m644 ${TERMUX_PKG_SRCDIR}/posix/gai.conf ${TERMUX_PREFIX}/etc/gai.conf
install -m755 ${TERMUX_PKG_BUILDER_DIR}/locale-gen ${TERMUX_PREFIX}/bin
sed -i "s|@TERMUX_PREFIX@|$TERMUX_PREFIX|g; s|@TERMUX_PREFIX_CLASSICAL@|$TERMUX_PREFIX_CLASSICAL|g" \
Expand All @@ -227,7 +185,7 @@ termux_step_make_install() {
sed -e '1,3d' -e 's|/| |g' -e 's| \\||g' \
${TERMUX_PKG_SRCDIR}/localedata/SUPPORTED > ${TERMUX_PREFIX}/share/i18n/SUPPORTED

install -dm755 ${TERMUX_PREFIX}/lib/locale
install -dm755 ${TERMUX_LIB_PATH}/locale
make -C ${TERMUX_PKG_SRCDIR}/localedata objdir=${TERMUX_PKG_BUILDDIR} \
SUPPORTED-LOCALES="C.UTF-8/UTF-8 en_US.UTF-8/UTF-8" install-locale-files
sed -i '/#C\.UTF-8 /d' ${TERMUX_PREFIX}/etc/locale.gen
Expand All @@ -236,24 +194,20 @@ termux_step_make_install() {
install -Dm644 ${TERMUX_PKG_BUILDER_DIR}/sdt-config.h ${TERMUX_PREFIX}/include/sys/sdt-config.h

ln -sfr $PATH_DYNAMIC_LINKER ${TERMUX_PREFIX}/bin/ld.so
ln -sfr $PATH_DYNAMIC_LINKER ${TERMUX_PREFIX}/lib/ld.so

termux_glibc_make_syscall_without_fsc "lib"
ln -sfr $PATH_DYNAMIC_LINKER ${TERMUX_LIB_PATH}/ld.so

if [ "$TERMUX_PKG_BUILD32" = "true" ]; then
(
termux_setup_build32
termux_glibc_make_syscall_without_fsc
}

make DESTDIR=${TERMUX_PKG_BUILDDIR32} install
termux_step_make_install32() {
make DESTDIR=${TERMUX_PKG_BUILD32DIR} install

cp -r ${TERMUX_PKG_BUILDDIR32}/${TERMUX_PREFIX}/lib32 $TERMUX_PREFIX
cp -r ${TERMUX_PKG_BUILD32DIR}/${TERMUX_LIB_PATH} $TERMUX_PREFIX

ln -sfr ${TERMUX_PREFIX}/lib/locale ${TERMUX_PREFIX}/lib32/locale
ln -sfr ${TERMUX_LIB64_PATH}/locale ${TERMUX_LIB_PATH}/locale

ln -sfr ${TERMUX_PREFIX}/lib32/${DYNAMIC_LINKER} $PATH_DYNAMIC_LINKER
ln -sfr ${TERMUX_PREFIX}/lib32/${DYNAMIC_LINKER} ${TERMUX_PREFIX}/lib32/ld.so
ln -sfr ${TERMUX_LIB_PATH}/${DYNAMIC_LINKER} $PATH_DYNAMIC_LINKER
ln -sfr ${TERMUX_LIB_PATH}/${DYNAMIC_LINKER} ${TERMUX_LIB_PATH}/ld.so

termux_glibc_make_syscall_without_fsc "lib32"
)
fi
termux_glibc_make_syscall_without_fsc
}

0 comments on commit b80e57d

Please sign in to comment.