Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Copy symlinks as symlinks and add missing symlink targets at the end #2740

Closed
jsmeix opened this issue Jan 17, 2022 · 4 comments
Closed
Assignees
Milestone

Comments

@jsmeix
Copy link
Member

jsmeix commented Jan 17, 2022

When creating the recovery system files and directories get copied.
The problem is how to deal best with (possibly dangling) symlinks.

See #2739
therein in particular
#2739 (comment)
that reads (a bit adapted excerpts):

Perhaps we should in general not specfically care about symlinks
in the individual scripts i.e. that in general we just copy symlinks as symlinks
and leave it completely to build/default/490_fix_broken_links.sh
to fix the broken symlinks inside the recovery system?

On first glance this looks wrong because each code part should do its task right
but on a second glance fix only actually broken symlinks in a generic script at the end
could have general advantages.

Example:
Assume in the original system there are

/path/to/huge_file
/path1/to/symlink1 -> /path/to/huge_file
/path2/to/symlink2 -> /path/to/huge_file

then cp -L results that in the recovery system
both /path1/to/symlink1 and /path2/to/symlink2 are regular files
with identical contents as /path/to/huge_file
cf. #2739 (comment)
so cp -L can result needlessly duplicated content
in particular when /path/to/huge_file gets included anyway.

Another reason is that in practice it gets rather complicated
to deal correctly with symlinks at each code place
(e.g. see #2739)
so it could be better in practice to not care at each code place
and only fix what actually needs to be fixed at the end by a generic script.

@jsmeix
Copy link
Member Author

jsmeix commented Jan 17, 2022

Code lines that call cp ... -L ...:

# find usr/sbin/rear usr/share/rear/ -type f | xargs grep 'cp .*-.*L'

usr/share/rear/output/RAWDISK/Linux-i386/280_create_bootable_disk_image.sh
cp -rL $v "${staged_boot_partition_contents[@]}" "$boot_partition_root" >&2 || Error "Could not populate boot partition"

usr/share/rear/output/default/940_grub_rescue.sh
cp -pLlf $v $KERNEL_FILE /boot/rear-kernel || BugError "Failed to hardlink '$KERNEL_FILE' to /boot/rear-kernel"
cp -pLf $v $KERNEL_FILE /boot/rear-kernel || BugError "Failed to copy '$KERNEL_FILE' to /boot/rear-kernel"

usr/share/rear/output/default/940_grub2_rescue.sh
cp -pLlf $v $KERNEL_FILE $boot_kernel_file || BugError "Failed to hardlink '$KERNEL_FILE' to '$boot_kernel_file'"
cp -pLf $v $KERNEL_FILE $boot_kernel_file || BugError "Failed to copy '$KERNEL_FILE' to '$boot_kernel_file'"

usr/share/rear/output/USB/Linux-i386/830_copy_kernel_initrd.sh
cp -pL $v "$KERNEL_FILE" "$BUILD_DIR/outputfs/$USB_PREFIX/kernel" >&2 || Error "Could not create $BUILD_DIR/outputfs/$USB_PREFIX/kernel"

usr/share/rear/output/USB/Linux-i386/100_create_efiboot.sh
cp -L $v "$UEFI_BOOTLOADER" "$efi_dst/BOOTX64.efi" || Error "Failed to copy UEFI_BOOTLOADER '$UEFI_BOOTLOADER' to $efi_dst/BOOTX64.efi"
cp -L $v "$KERNEL_FILE" "$efi_dst/kernel" || Error "Failed to copy KERNEL_FILE '$KERNEL_FILE' to $efi_dst/kernel"
cp -L $v "$TMP_DIR/$REAR_INITRD_FILENAME" "$efi_dst/$REAR_INITRD_FILENAME" || Error "Failed to copy initrd to $efi_dst/$REAR_INITRD_FILENAME"

usr/share/rear/output/PXE/default/800_copy_to_tftp.sh
cp -L $v "$KERNEL_FILE" "$PXE_TFTP_LOCAL_PATH/$PXE_KERNEL" || Error "Failed to copy KERNEL_FILE '$KERNEL_FILE'"
cp -L $v "$TMP_DIR/$REAR_INITRD_FILENAME" "$PXE_TFTP_LOCAL_PATH/$PXE_INITRD" || Error "Failed to copy initrd '$REAR_INITRD_FILENAME'"

usr/share/rear/output/ISO/Linux-i386/800_create_isofs.sh
cp -pL $v $KERNEL_FILE $TMP_DIR/isofs/isolinux/kernel || Error "Failed to copy KERNEL_FILE '$KERNEL_FILE'"
cp -pL $v ${ISO_FILES[@]} $TMP_DIR/isofs/isolinux/ || Error "Failed to copy ISO_FILES '${ISO_FILES[@]}'"

usr/share/rear/output/ISO/Linux-i386/300_create_isolinux.sh
cp -L $v "$ISO_ISOLINUX_BIN" $TMP_DIR/isolinux/isolinux.bin >&2

usr/share/rear/output/ISO/Linux-i386/250_populate_efibootimg.sh
cp -pL $v $KERNEL_FILE $efi_boot_tmp_dir/kernel || Error "Failed to copy KERNEL_FILE '$KERNEL_FILE' to $efi_boot_tmp_dir/kernel"

usr/share/rear/output/ISO/Linux-ia64/300_create_bootimg.sh
cp -L $v "$ELILO_BIN" $TMP_DIR/mnt/boot || Error "Failed to copy elilo.efi '$ELILO_BIN'"

usr/share/rear/output/ISO/Linux-ppc64le/800_create_isofs.sh
cp -pL $v $KERNEL_FILE $TMP_DIR/kernel || Error "Failed to copy KERNEL_FILE '$KERNEL_FILE'"

usr/share/rear/output/RAMDISK/default/900_copy_ramdisk.sh
cp $v -pLf $KERNEL_FILE $kernel_file || Error "Failed to copy KERNEL_FILE '$KERNEL_FILE'"
cp $v -pLf $TMP_DIR/$REAR_INITRD_FILENAME $initrd_file || Error "Failed to copy initramfs '$REAR_INITRD_FILENAME'"

usr/share/rear/build/GNU/Linux/100_copy_as_is.sh
cp $v -r -L $CONFIG_DIR/. $ROOTFS_DIR/etc/rear/

usr/share/rear/build/GNU/Linux/420_copy_firmware_files.sh
find /lib*/firmware -ipath "$find_ipath_pattern" | xargs cp $verbose -t $ROOTFS_DIR -p -L --parents 2>&1 | grep -v 'omitting directory' 1>&2 || true

usr/share/rear/build/GNU/Linux/400_copy_modules.sh
if ! cp $verbose -t $ROOTFS_DIR -a -L --parents /lib/modules/$KERNEL_VERSION 2>>/dev/$DISPENSABLE_OUTPUT_DEV 1>&2 ; then
if ! cp $verbose -t $ROOTFS_DIR -L --preserve=all --parents $loaded_modules_files 1>&2 ; then
if ! cp $verbose -t $ROOTFS_DIR -L --preserve=all --parents $module_files 1>&2 ; then

@github-actions
Copy link

Stale issue message

@github-actions
Copy link

Stale issue message

@hpannenb
Copy link
Contributor

hpannenb commented Jan 3, 2023

@jsmeix Unfortunately closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants