mirror of
https://gitlab.archlinux.org/tpowa/archboot.git
synced 2024-09-19 19:40:37 +02:00
optimize library handling
This commit is contained in:
parent
ee159bf309
commit
cb19bc0a3b
4 changed files with 27 additions and 21 deletions
|
@ -82,6 +82,7 @@ for i in "${_HOOKS[@]}"; do
|
|||
_run_hook "${i}"
|
||||
_HOOK_COUNT="$((_HOOK_COUNT+1))"
|
||||
done
|
||||
_install_libs
|
||||
_install_modules "${!_MOD_PATH[@]}"
|
||||
ldconfig -r "${_ROOTFS}" &>"${_NO_LOG}" || exit 1
|
||||
# remove /var/cache/ldconfig/aux-cache for reproducibility
|
||||
|
|
|
@ -168,27 +168,8 @@ _file_rename() {
|
|||
}
|
||||
|
||||
_binary() {
|
||||
if [[ "${1:0:1}" != '/' ]]; then
|
||||
_BIN="$(type -P "${1}")"
|
||||
else
|
||||
_BIN="${1}"
|
||||
fi
|
||||
_BIN="$(type -P "${1}")"
|
||||
_file "${_BIN}"
|
||||
# non-binaries
|
||||
if ! _LDD="$(ldd "${_BIN}" 2>"${_NO_LOG}")"; then
|
||||
return 0
|
||||
fi
|
||||
# resolve libraries
|
||||
_REGULAR_EXPRESSION='^(|.+ )(/.+) \(0x[a-fA-F0-9]+\)'
|
||||
while read -r i; do
|
||||
if [[ "${i}" =~ ${_REGULAR_EXPRESSION} ]]; then
|
||||
_LIB="${BASH_REMATCH[2]}"
|
||||
fi
|
||||
if [[ -f "${_LIB}" && ! -e "${_ROOTFS}${_LIB}" ]]; then
|
||||
_file "${_LIB}"
|
||||
fi
|
||||
done <<< "${_LDD}"
|
||||
return 0
|
||||
}
|
||||
|
||||
_init_rootfs() {
|
||||
|
@ -238,6 +219,28 @@ _install_modules() {
|
|||
rm "${_ROOTFS}${_MODULE_DIR}"/modules.!(*.bin|*.modinfo|devname|softdep)
|
||||
}
|
||||
|
||||
_install_libs() {
|
||||
# add libraries for binaries in bin/ and /lib/systemd
|
||||
echo "Adding libraries for / and /lib/systemd..."
|
||||
_LIBS="$(objdump -p "${_ROOTFS}"/bin/* "${_ROOTFS}"/lib/systemd/{systemd-*,libsystemd*} 2>${_NO_LOG} |
|
||||
grep 'NEEDED' | sort -u | sed -e 's#NEEDED##g' -e 's# .* #/lib/#g')"
|
||||
while read -r i; do
|
||||
[[ -e "${i}" ]] && _file "${i}"
|
||||
done <<< "${_LIBS}"
|
||||
echo "Checking libraries in /lib..."
|
||||
_LIB_COUNT=""
|
||||
while true; do
|
||||
_LIBS="$(objdump -p "${_ROOTFS}"/lib/*.so* |
|
||||
grep 'NEEDED' | sort -u | sed -e 's#NEEDED##g' -e 's# .* #/lib/#g')"
|
||||
while read -r i; do
|
||||
[[ -e "${i}" ]] && _file "${i}"
|
||||
done <<< "${_LIBS}"
|
||||
_LIB_COUNT2="$(ls "${_ROOTFS}"/lib/*.so* | wc -l)"
|
||||
[[ "${_LIB_COUNT}" == "${_LIB_COUNT2}" ]] && break
|
||||
_LIB_COUNT="${_LIB_COUNT2}"
|
||||
done
|
||||
}
|
||||
|
||||
_create_cpio() {
|
||||
case "${_COMP}" in
|
||||
cat) echo "Creating uncompressed image: ${_GENERATE_IMAGE}"
|
||||
|
|
|
@ -164,7 +164,7 @@ var/lib/pacman/local \
|
|||
# mask systemd-gpt-auto-generator, errors out on initramfs usage
|
||||
_symlink /etc/systemd/system-generators/systemd-gpt-auto-generator /dev/null
|
||||
### add udev
|
||||
_map _binary /usr/lib/systemd/systemd-udevd udevadm systemd-tmpfiles logger
|
||||
_map _binary udevadm systemd-tmpfiles logger
|
||||
# add schedule rules file
|
||||
_file_rename /usr/share/archboot/base/etc/udev/rules.d/60-ioschedulers.rules /etc/udev/rules.d/60-ioschedulers.rules
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ _run() {
|
|||
_map _binary bash sh blkid mount mountpoint switch_root bsdcpio mkfs.btrfs setfont \
|
||||
/usr/lib/systemd/systemd-udevd udevadm systemd-tmpfiles kmod insmod modprobe \
|
||||
gzip uname cat cp dmesg grep ln ls mv rm umount lsblk rmmod cut sed find mkdir dialog
|
||||
# needed library for udevadm!
|
||||
_map _file /usr/lib/systemd/libsystemd-shared*
|
||||
_file /usr/share/terminfo/l/linux
|
||||
_file_rename /usr/share/kbd/consolefonts/ter-v16n.psf.gz /consolefont-16.psf.gz
|
||||
_file_rename /usr/share/kbd/consolefonts/ter-v32n.psf.gz /consolefont-32.psf.gz
|
||||
|
|
Loading…
Reference in a new issue