TheLocehiliosan / yadm

Yet Another Dotfiles Manager
https://yadm.io/
GNU General Public License v3.0
4.92k stars 176 forks source link

Symlink to symlink dosnt work with "yadm alt" command #424

Closed elyashivhazan closed 1 year ago

elyashivhazan commented 2 years ago

ENV

> uname -a
Linux ehlemurpro 5.15.50-1-MANJARO #1 SMP PREEMPT Sun Jun 26 07:06:30 UTC 2022 x86_64 GNU/Linux

> yadm version
bash version 5.1.16(1)-release
git version 2.37.0
yadm version 3.2.1

Bug

When im creating a simlink to a file named {{ name }}.bin##a.x86_64 yadm dosnt create an alt file to it. e.g:

PWD=~/.bin
ln -s ../bins/brave_vx.x.x_amd64.bin brave##a.x86_64
cd
yadm add .bin/brave##a.x86_64
# yadm should create a file named brave in ~/.bin but it dose nothing

But with folders that are symlinked its working fine.

PWD=~/
# NOTE: ~/bins/games is a dir
ln -s ../bins/games games##a.x86_64
cd
yadm add .bin/brave##a.x86_64
# yadm creates a symlink in ~/.bin/games linked to ~/.bim/games##a.x86_64
TheLocehiliosan commented 1 year ago

@elyashivhazan : I am not able to recreate the problem. Please take a look at my steps to recreate:

❯ make testhost
Using local yadm (3.2.1-17-g36fda72)
Starting testhost
root@testhost:~# yadm init
Initialized empty shared Git repository in /root/.local/share/yadm/repo.git/
root@testhost:~# mkdir .bin
root@testhost:~# mkdir bins
root@testhost:~# echo thebinary > bins/brave_vx.x.x_amd64.bin
root@testhost:~# cd .bin
root@testhost:~/.bin# ln -s ../bins/brave_vx.x.x_amd64.bin brave##a.x86_64
root@testhost:~/.bin# cd
root@testhost:~# yadm add .bin/brave##a.x86_64
root@testhost:~# ls -l .bin
total 0
lrwxrwxrwx 1 root root 15 Sep  4 01:03 brave -> brave##a.x86_64
lrwxrwxrwx 1 root root 30 Sep  4 01:03 brave##a.x86_64 -> ../bins/brave_vx.x.x_amd64.bin

Can you try again, and help me understand what might be different between what you and I have done?

elyashivhazan commented 1 year ago

Hi, thanks for the replay. I'm sorry I forgot to add that bins/brave_vx.x.x_amd64.bin (in your example) is a symbolic link its self (that is all the point of the bug/problem I'm having)

TheLocehiliosan commented 1 year ago

@elyashivhazan - I just tried again, making bins/brave_vx.x.x_amd64.bin a symlink itself.

❯ make testhost
Using local yadm (3.2.1-17-g36fda72)
Starting testhost
root@testhost:~# yadm init
Initialized empty shared Git repository in /root/.local/share/yadm/repo.git/
root@testhost:~# mkdir .bin
root@testhost:~# mkdir bins
root@testhost:~# echo thebinary > bins/an_actual_file_which_will_be_symlinked
root@testhost:~# cd bins
root@testhost:~/bins# ln -s an_actual_file_which_will_be_symlinked brave_vx.x.x_amd64.bin
root@testhost:~/bins# cd
root@testhost:~# cd .bin
root@testhost:~/.bin# ln -s ../bins/brave_vx.x.x_amd64.bin brave##a.x86_64
root@testhost:~/.bin# cd ..
root@testhost:~# find .bin bins -ls
   534170      4 drwxr-xr-x   2 root     root         4096 Sep 13 16:47 .bin
   534174      0 lrwxrwxrwx   1 root     root           30 Sep 13 16:47 .bin/brave##a.x86_64 -> ../bins/brave_vx.x.x_amd64.bin
   534171      4 drwxr-xr-x   2 root     root         4096 Sep 13 16:47 bins
   534173      0 lrwxrwxrwx   1 root     root           38 Sep 13 16:47 bins/brave_vx.x.x_amd64.bin -> an_actual_file_which_will_be_symlinked
   534172      4 -rw-r--r--   1 root     root           10 Sep 13 16:46 bins/an_actual_file_which_will_be_symlinked
root@testhost:~# yadm add .bin/brave##a.x86_64
root@testhost:~# ls -l .bin
total 0
lrwxrwxrwx 1 root root 15 Sep 13 16:48 brave -> brave##a.x86_64
lrwxrwxrwx 1 root root 30 Sep 13 16:47 brave##a.x86_64 -> ../bins/brave_vx.x.x_amd64.bin
root@testhost:~# cat .bin/brave
thebinary
root@testhost:~#

I still don't see the problem.

elyashivhazan commented 1 year ago

Hi, I just had time to check it out and the problem isn't with the script but with busybox (Alpine Linux). Do you have any idea how to fix it to work with busybox? or point me to the function that creates the alt files?

TheLocehiliosan commented 1 year ago

Can you elaborate on what the issue with busybox is? Is it a particular invocation of busybox that is the issue?

For example, is ln -nfs supported?

Which version of busybox is being used?

elyashivhazan commented 1 year ago

Hi, I checked again to give the info you asked and it just worked. I checked the busybox repo and no commit that I saw was made to ln, but something must have changed in Alpine (at least I hope).

I will close this issue. Sorry for wasting you are time and thanks a lot for the script.