test-functions revision 898720b7e9cf3bdf7a93e435cbed5dd6942ecf9b
0N/A# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- 0N/A# ex: ts=8 sw=4 sts=4 et filetype=sh 0N/A [[ -e "${initdir}${prefix}/$d" ]] && continue 0N/A if [ -L "/$d" ]; then 0N/A mkdir -m 0755 -p "${initdir}${prefix}/$d" 0N/A if [ -L "/$d" ]; then 0N/A## @brief Converts numeric logging level to the first letter of level name. 0N/A# @param lvl Numeric logging level in range from 1 to 6. 1774N/A# @retval 1 if @a lvl is out of range. 1774N/A# @retval 0 if @a lvl is correct. 0N/A# @result Echoes first letter of level name. 0N/A## @brief Internal helper function for _do_dlog() 0N/A# @param lvl Numeric logging level. 0N/A# @param msg Message. 0N/A# @retval 0 It's always returned, even if logging failed. 0N/A# @note This function is not supposed to be called manually. Please use 0N/A# dtrace(), ddebug(), or others instead which wrap this one. 1774N/A# This function calls _do_dlog() either with parameter msg, or if 1774N/A# none is given, it will read standard input and will use every line as 1774N/A# echo "This is a warning" | dwarn 1774N/A## @brief Logs message at TRACE level (6) 0N/A# @param msg Message. 1774N/A# @retval 0 It's always returned, even if logging failed. 0N/A## @brief Logs message at DEBUG level (5) 0N/A# @param msg Message. 1774N/A# @retval 0 It's always returned, even if logging failed. 0N/A## @brief Logs message at INFO level (4) 0N/A# @retval 0 It's always returned, even if logging failed. 0N/A## @brief Logs message at WARN level (3) 1774N/A# @retval 0 It's always returned, even if logging failed. 0N/A## @brief Logs message at ERROR level (2) 0N/A# @param msg Message. 0N/A# @retval 0 It's always returned, even if logging failed. 0N/A## @brief Logs message at FATAL level (1) 1774N/A# @retval 0 It's always returned, even if logging failed. 1130N/A# Generic substring function. If $2 is in $1, return 0. 1130N/A# Prints the normalized path, where it removes any duplicated 0N/A# convert_abs_rel <from> <to> 0N/A# Prints the relative path, when creating a symlink to <to> from <from>. 1774N/A # corner case #1 - self looping link 1774N/A [[ "$1" == "$2" ]] && { echo "${1##*/}"; return; } 2999N/A # corner case #2 - own dir link 1774N/A [[ "${1%/*}" == "$2" ]] && { echo "."; return; } 2999N/A# Install a directory, keeping symlinks as on the original system. 2999N/A# Example: if /lib points to /lib64 on the host, "inst_dir /lib/file" 2999N/A# and a symlink ${initdir}/lib -> lib64. 2999N/A while [[ "$_part" != "${_part%/*}" ]] && ! [[ -e "${initdir}/${_part}" ]]; do 2999N/A # iterate over parent directories 2999N/A# $1 = file to copy to ramdisk 2999N/A# $2 (optional) Name for the file on the ramdisk 2999N/A# Location of the image dir is assumed to be $initdir 2999N/A# We never overwrite the target if it exists. 2999N/A # install checksum files also 2999N/A if [[ -e "${_src%/*}/.${_src##*/}.hmac" ]]; then 2999N/A inst "${_src%/*}/.${_src##*/}.hmac" "${target%/*}/.${target##*/}.hmac" 2999N/A# find symlinks linked to given library file 2999N/A# Function searches for symlinks by stripping version numbers appended to 2999N/A# library filename, checks if it points to the same target and finally 2999N/A# prints the list of symlinks to stdout. 2999N/A# Same as above, but specialized to handle dynamic libraries. 2999N/A# It handles making symlinks according to how the original library 1774N/A # install checksum files also 2086N/A if [[ -e "${_src%/*}/.${_src##*/}.hmac" ]]; then 1774N/A inst "${_src%/*}/.${_src##*/}.hmac" "${_dest%/*}/.${_dest##*/}.hmac" 1774N/A # Create additional symlinks. See rev_symlinks description. 835N/A# find a binary. If we were not passed the full path directly, 835N/A# search in the usual places to find the binary. 1774N/A# Same as above, but specialized to install binary executables. 1774N/A# Install binary executable, and all shared library dependencies, if any. 835N/A# same as above, except for shell scripts. 835N/A# If your shell script does not start with shebang, it is not a shell script. 1774N/A # If debug is set, clean unprintable chars to prevent messing up the term 835N/A# same as above, but specialized for symlinks 835N/A [[ -L $1 ]] || return 1 1787N/A# attempt to install any programs specified in a udev rule 1130N/A #dinfo "Installing $_bin due to it's use in the udev rule $(basename $1)" 1774N/A# udev rules always get installed in the same place, so 1774N/A# create a function to install them to make life simpler. 2086N/A# general purpose installation function 1130N/A# install any of listed files 1130N/A# If first argument is '-d' and second some destination path, first accessible 2086N/A# source is installed into this path, otherwise it will installed in the same 2086N/A# path as source. If none of listed files was installed, function return 1. 2086N/A# On first successful installation it returns with 0 status. # Lets assume that /bin/baz exists, so it will be installed as /bin/foo in [[ $1 = '-d' ]] && to="$2" && shift 2 # dracut_install [-o ] <file> [<file> ... ] # Install <file> to the initramfs image # -o optionally install the <file> and don't fail, if it is not there dinfo "Skipping program $1 as it cannot be found and is" \ # inst_libdir_file [-n <pattern>] <file> [<file>...] # Install a <file> located on a lib directory to the initramfs image # -n <pattern> install non-matching files if [[ "$1" == "-n" ]]; then [[ $UID != "0" ]] && exit 0