summaryrefslogtreecommitdiff
path: root/system/musl
diff options
context:
space:
mode:
Diffstat (limited to 'system/musl')
-rw-r--r--system/musl/APKBUILD5
-rw-r--r--system/musl/ldconfig196
-rwxr-xr-xsystem/musl/musl-utils.trigger3
3 files changed, 187 insertions, 17 deletions
diff --git a/system/musl/APKBUILD b/system/musl/APKBUILD
index 0505e9ebd..09bb9b58b 100644
--- a/system/musl/APKBUILD
+++ b/system/musl/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: A. Wilcox <awilfox@adelielinux.org>
pkgname=musl
pkgver=1.1.20
-pkgrel=0
+pkgrel=1
pkgdesc="System library (libc) implementation"
url="http://www.musl-libc.org/"
arch="all"
@@ -11,6 +11,7 @@ license="MIT"
depends=""
depends_dev="!uclibc-dev"
makedepends="$depends_dev"
+triggers="$pkgname-utils.trigger=/etc/ld.so.conf.d"
subpackages="$pkgname-dev $pkgname-dbg"
case "$BOOTSTRAP" in
nocc) pkgname="musl-dev"; subpackages=""; options="$options !dbg" builddir="$srcdir"/musl-$pkgver;;
@@ -113,6 +114,6 @@ sha512sums="d3a7a30aa375ca50d7dcfbd618581d59e1aa5378417f50a0ca5510099336fd74cc9d
2c8e1dde1834238097b2ee8a7bfb53471a0d9cff4a5e38b55f048b567deff1cdd47c170d0578a67b1a039f95a6c5fbb8cff369c75b6a3e4d7ed171e8e86ebb8c 2000-pthread-internals-increase-DEFAULT_GUARD_SIZE-to-2-p.patch
88ae443dbb8e0a4368235bdc3a1c5c7b718495afa75e06deb8e01becc76cb1f0d6964589e2204fc749c9c1b3190b8b9ac1ae2c0099cab8e2ce3ec877103d4332 3001-make-real-lastlog-h.patch
6a7ff16d95b5d1be77e0a0fbb245491817db192176496a57b22ab037637d97a185ea0b0d19da687da66c2a2f5578e4343d230f399d49fe377d8f008410974238 handle-aux-at_base.patch
-8d3a2d5315fc56fee7da9abb8b89bb38c6046c33d154c10d168fb35bfde6b0cf9f13042a3bceee34daf091bc409d699223735dcf19f382eeee1f6be34154f26f ldconfig
+cce2f1eeb61e55674469c26871a573cce61d739c3defe9c8f56f2b774f6ba5435849ad542a6714120efddc98c297098e9c98a1a424ac593df2243d4aa479f9a9 ldconfig
378d70e65bcc65bb4e1415354cecfa54b0c1146dfb24474b69e418cdbf7ad730472cd09f6f103e1c99ba6c324c9560bccdf287f5889bbc3ef0bdf0e08da47413 getent.c
9d42d66fb1facce2b85dad919be5be819ee290bd26ca2db00982b2f8e055a0196290a008711cbe2b18ec9eee8d2270e3b3a4692c5a1b807013baa5c2b70a2bbf iconv.c"
diff --git a/system/musl/ldconfig b/system/musl/ldconfig
index ccf7c2aa4..7699c6722 100644
--- a/system/musl/ldconfig
+++ b/system/musl/ldconfig
@@ -1,18 +1,184 @@
-#!/bin/sh
-scan_dirs() {
- scanelf -qS "$@" | while read SONAME FILE; do
- TARGET="${FILE##*/}"
- LINK="${FILE%/*}/$SONAME"
- case "$FILE" in
- /lib/*|/usr/lib/*|/usr/local/lib/*) ;;
- *) [ -h "$LINK" -o ! -e "$LINK" ] && ln -sf "$TARGET" "$LINK"
- esac
+#!/bin/sh -eu
+# Copyright 2016-2018 Samuel Holland <samuel@sholland.org>
+# SPDX-License-Identifier: 0BSD
+
+ME=${0##*/}
+VERSION=0.2.0
+
+echo() {
+ printf '%s\n' "$*"
+}
+
+echo_lines() {
+ printf '%s\n' "$@"
+}
+
+msg() {
+ printf >&2 '%s: %s\n' "$ME" "$*"
+}
+
+musl_arch() {
+ $ROOT/usr/lib/libc.so |& sed -n 's/^musl libc (\(.*\))$/\1/p'
+}
+
+musl_version() {
+ $ROOT/usr/lib/libc.so |& sed -n 's/^Version //p'
+}
+
+read_ldso_conf() {
+ local conf="$*" d dir file glob line
+
+ # Start with the default "trusted" directories
+ set -- /lib /usr/lib
+ for file in $conf; do
+ test -r "$file" || continue
+ $VERBOSE && msg "Reading ${file}"
+ while read -r line; do
+ line=$(tokenize ${line%%#*})
+ if test "${line#include }" != "$line"; then
+ glob=${file%/*}/${line#include }
+ $VERBOSE && msg "Including ${glob}"
+ line=$(read_ldso_conf $glob)
+ fi
+ for dir in $line; do
+ # Ignore missing directories
+ test -d "$ROOT$dir" || continue
+ # Ignore duplicate directories
+ for d; do test "$d" = "$dir" && continue 2; done
+ set -- "$@" "$dir"
+ done
+ done < "$file"
done
- return 0
+
+ echo_lines "$@"
+}
+
+tokenize() {
+ echo "$*" | sed 's/=libc[456]//g;y/:,/ /' | xargs
}
-# eat ldconfig options
-while getopts "nNvXvf:C:r:" opt; do
- :
+
+LDSO_CACHE="/etc/ld.so.cache"
+LDSO_CONF="/etc/ld.so.conf"
+LIBRARY_MODE=false
+ONLYARG_MODE=false
+PRINT_CACHE=false
+PRINT_VERSION=false
+ROOT=
+UPDATE_CACHE=true
+UPDATE_LINKS=true
+VERBOSE=false
+
+while getopts ":c:C:Df:ilnNpr:vVX" OPTION; do
+ case "$OPTION" in
+ C)
+ LDSO_CACHE=$OPTARG
+ ;;
+ D)
+ UPDATE_CACHE=false
+ UPDATE_LINKS=false
+ ;;
+ f)
+ LDSO_CONF=$OPTARG
+ ;;
+ l)
+ LIBRARY_MODE=true
+ ;;
+ n)
+ ONLYARG_MODE=true
+ ;;
+ N)
+ UPDATE_CACHE=false
+ ;;
+ p)
+ PRINT_CACHE=true
+ ;;
+ r)
+ ROOT=$OPTARG
+ if ! test -x $ROOT/usr/lib/libc.so; then
+ msg "${ROOT} does not appear to be a valid root directory"
+ exit 1
+ fi
+ ;;
+ v)
+ VERBOSE=true
+ ;;
+ V)
+ PRINT_VERSION=true
+ ;;
+ X)
+ UPDATE_LINKS=false
+ ;;
+ c|i)
+ msg "Ignored option -${OPTION}"
+ ;;
+ \?)
+ msg "Invalid option -${OPTARG}"
+ cat >&2 <<- EOF
+ Usage: $ME [-DnNvX] [-C cache] [-f conf] [-r root] [dir...]
+ $ME [-v] -l lib...
+ $ME [-v] [-C cache] [-r root] -p
+ $ME -V
+ EOF
+ exit 1
+ ;;
+ esac
done
-shift $(( $OPTIND - 1 ))
-[ $# -gt 0 ] && scan_dirs "$@"
+shift $((OPTIND-1))
+
+BANNER="ldconfig ${VERSION} for musl $(musl_version)"
+LDSO_CACHE="$ROOT$LDSO_CACHE"
+LDSO_CONF="$ROOT$LDSO_CONF"
+LDSO_PATH="$ROOT/etc/ld-musl-$(musl_arch).path"
+LDSO_PATH_TMP="$LDSO_PATH.$$"
+
+if $PRINT_VERSION; then
+ echo "$BANNER"
+ exit 0
+elif $PRINT_CACHE; then
+ test -r "$LDSO_PATH" && cat "$LDSO_PATH"
+ exit 0
+fi
+
+$VERBOSE && echo "$BANNER"
+
+if $LIBRARY_MODE; then
+ for lib; do
+ soname=$(scanelf -qS "$ROOT$lib")
+ soname=${soname%% *}
+ done
+ exit 0
+fi
+
+# Update musl's list of library paths
+if ! test -w "${LDSO_PATH%/*}"; then
+ msg "You do not have permission to update ${LDSO_PATH}"
+ exit 0
+fi
+trap 'rm -f "$LDSO_PATH_TMP"' EXIT
+read_ldso_conf "$LDSO_CONF" > "$LDSO_PATH_TMP"
+$VERBOSE && msg "Writing ${LDSO_PATH}"
+mv "$LDSO_PATH_TMP" "$LDSO_PATH"
+trap - EXIT
+
+# Read the updated list of library paths
+$ONLYARG_MODE || set -- "$@" $(cat "$LDSO_PATH")
+
+if $UPDATE_LINKS; then
+ for dir; do
+ # Packages are responsible for libraries in these directories
+ if test "$dir" = /lib || test "$dir" = /usr/lib; then
+ continue
+ fi
+ $VERBOSE && msg "Scanning ${ROOT}${dir}"
+ scanelf -qS "$ROOT$dir" | while read soname file; do
+ link=${file%/*}/$soname
+ test -f "$link" && continue
+ $VERBOSE && msg "Creating link ${link}"
+ ln -fns "${file##*/}" "$link"
+ done
+ done
+fi
+
+if $UPDATE_CACHE && test $# -gt 0; then
+ touch "$ROOT$LDSO_CACHE"
+fi
diff --git a/system/musl/musl-utils.trigger b/system/musl/musl-utils.trigger
new file mode 100755
index 000000000..ee3a3c053
--- /dev/null
+++ b/system/musl/musl-utils.trigger
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+ldconfig -NX