FS#5245 - mkinitcpio functions problems
Attached to Project:
Arch Linux
Opened by Matt (v01d) - Saturday, 19 August 2006, 00:22 GMT
Last edited by Aaron Griffin (phrakture) - Wednesday, 21 May 2008, 23:26 GMT
Opened by Matt (v01d) - Saturday, 19 August 2006, 00:22 GMT
Last edited by Aaron Griffin (phrakture) - Wednesday, 21 May 2008, 23:26 GMT
|
Details
There are some problems in some of the functions
(/lib/initcpio/functions):
* add_symlink: it tries to see if $1 is a link, and then uses $1 as the link name. Both things can't happen, since $1 is either a real path (to make -L true) or a pathname where to create the file in the cpio archive. I mean, either strip BASEDIR from $1 or, even better, don't check if this is a symlink. The second option I think it is better if the user want's to use add_symlink itself. If the user is just going to use add_file, then I'd go with the first option. * add_dir has a problem when dealing with relative links. On add_symlink, add_dir is issued on the basedir's of fil and dst. When the link is realtive (like ./busybox), then the basedir is '.'. This makes add_dir go into infinite recursion and, finally, bash segfaults. |
This task depends upon
Closed by Aaron Griffin (phrakture)
Wednesday, 21 May 2008, 23:26 GMT
Reason for closing: Implemented
Additional comments about closing: Most suggestions implemented, final comment moved to FS#10466
Wednesday, 21 May 2008, 23:26 GMT
Reason for closing: Implemented
Additional comments about closing: Most suggestions implemented, final comment moved to
add_symlink ()
{
local fil dest dir
if [ -L ${1} ]; then
fil="${1##$BASEDIR}"
dest="${2##$BASEDIR}"
msg "$fil $dest"
# add_dir $(dirname "${dest}")
add_dir $(dirname "${fil}")
if ! grep "slink ${dest} " "${FILELIST}" 2>&1 > /dev/null; then
msg " adding link ${fil} -> ${dest}"
echo "slink ${fil} ${dest} $(stat -c '%a' ${1}) 0 0" >> "${FILELIST}"
fi
fi
#fail quietly
}
It assumes the destination parent directories are already there (which sounds reasonable, since I'm creating a symlink to something).
Also, I'm prunning $1 at fil declaration. Then I use the full path ($1) in stat.
Let me know if this fixes your issues.
Now, the only issue is that adding empty directories (as a result of an add_full_dir) complain when globbing:
for f in ${1}/*; do
with:
ERROR: file '/home/v01d/coding/projects/archcluster/images/rootfs/var/*' does not exist
That's all.
for f in $(find ${1}/* -maxdepth 0 2>/dev/null); do
Please check it.
The idea is to do something like this:
$ readlink -f /home/httpd/../httpd/html/./phpldapadmin/../../
/home/httpd
You could do readlink -f on everything before attempting to create directories and such.
Be careful that this makes readlink behave different regarding its exit code. If you need to check for a possible symbolic link, just use "readlink" (and check the exit code) and then, when you need the pointed file, use the -f.