explicitly set destination path

This commit is contained in:
illiliti 2020-09-08 22:36:20 +03:00
parent 55e32d6457
commit 9ca7b1c590
3 changed files with 17 additions and 17 deletions

View File

@ -4,6 +4,6 @@
# false positive
# shellcheck disable=2154
{
copy_file "$keymap_path" "${keymap_path%/*}" 644 0
copy_file "$keymap_path" "$keymap_path" 644 0
copy_binary loadkmap
}

View File

@ -16,10 +16,10 @@
# avoid possible issues with libgcc_s.so.1
# see https://bugs.archlinux.org/task/56771
[ -e /lib/libgcc_s.so.1 ] && copy_file /lib/libgcc_s.so.1 /lib 755 1
[ -e /lib/libgcc_s.so.1 ] && copy_file /lib/libgcc_s.so.1 /lib/libgcc_s.so.1 755 1
[ "$luks_key" ] && {
copy_file "${luks_key#*=}" /root 400 0
copy_file "${luks_key#*=}" /root/key 400 0
sed "s|${luks_key#*=}|/root/key|" \
"${tmpdir}/etc/tinyramfs/config" > "${tmpdir}/_"
@ -28,7 +28,7 @@
}
[ "$luks_header" ] && {
copy_file "${luks_header#*=}" /root 400 0
copy_file "${luks_header#*=}" /root/header 400 0
sed "s|${luks_header#*=}|/root/header|" \
"${tmpdir}/etc/tinyramfs/config" > "${tmpdir}/_"

View File

@ -140,8 +140,8 @@ prepare_initramfs()
print "blkid not found. you will unable to use UUID, LABEL, PARTUUID"
fi
copy_file "${srcdir}/init" / 755 0
copy_file "$config" /etc/tinyramfs 644 0
copy_file "${srcdir}/init" /init 755 0
copy_file "$config" /etc/tinyramfs/config 644 0
}
copy_file()
@ -149,9 +149,9 @@ copy_file()
file="$1"; dest="$2"; mode="$3"; strip="$4"
# check if file already exist
[ -e "${tmpdir}${dest}/${file##*/}" ] && return 0
[ -e "${tmpdir}${dest}" ] && return 0
mkdir -p "${tmpdir}${dest}" || panic
mkdir -p "${tmpdir}${dest%/*}" || panic
# iterate throught symlinks and copy them
while [ -h "$file" ]; do
@ -159,19 +159,19 @@ copy_file()
cd -P "${file%/*}"
symlink=$(ls -ld "$file")
symlink=${symlink##* -> }
symlink="${symlink##* -> }"
file="${PWD}/${symlink##*/}"
done
{
cp "$file" "${tmpdir}${dest}"
chmod "$mode" "${tmpdir}${dest}/${file##*/}"
chmod "$mode" "${tmpdir}${dest}"
} || panic
# false positive
# shellcheck disable=2015
[ "$strip" = 1 ] && strip "${tmpdir}${dest}/${file##*/}" > /dev/null 2>&1 || :
[ "$strip" = 1 ] && strip "${tmpdir}${dest}" > /dev/null 2>&1 || :
)
copy_binary()
@ -200,7 +200,7 @@ copy_binary()
;;
esac
copy_file "$binary" /bin 755 1
copy_file "$binary" "/bin/${binary##*/}" 755 1
# copy binary dependencies if any
ldd "$binary" 2> /dev/null |
@ -212,7 +212,7 @@ copy_binary()
[ -e "$_library" ] || continue
copy_file "$_library" /lib 755 1
copy_file "$_library" "/lib/${_library##*/}" 755 1
done
}
@ -227,7 +227,7 @@ copy_module()
# check if module contains full path(not builtin)
[ "${module##*/*}" ] && continue
copy_file "$module" "${module%/*}" 644 0
copy_file "$module" "$module" 644 0
done
}
@ -251,7 +251,7 @@ copy_hook()
print "copying ${hook}.${_file}"
copy_file "${_dir}/${hook}/${hook}.${_file}" \
"/usr/share/tinyramfs/hooks/${hook##*/}" 644 0
"/usr/share/tinyramfs/hooks/${hook}/${hook}.${_file}" 644 0
done
}
@ -327,8 +327,8 @@ copy_modules()
copy_binary modprobe
copy_file "${moddir}/${kernel}/modules.order" "${moddir}/${kernel}" 644 0
copy_file "${moddir}/${kernel}/modules.builtin" "${moddir}/${kernel}" 644 0
copy_file "${moddir}/${kernel}/modules.order" "/lib/modules/${kernel}/modules.order" 644 0
copy_file "${moddir}/${kernel}/modules.builtin" "/lib/modules/${kernel}/modules.builtin" 644 0
depmod -b "$tmpdir" "$kernel"
}