public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Broken links in Cygwin installation
@ 2022-08-21 11:42 Andrey Repin
  2022-08-21 15:09 ` Ken Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Andrey Repin @ 2022-08-21 11:42 UTC (permalink / raw)
  To: All

Greetings, All!

# LC_ALL=C.UTF-8 find -L / -xdev -type l -exec ls -ld --color '{}' +
lrwxrwxrwx 1 anrdaemon None 28 Dec 26  2021 ./bin/rcs2log -> ../share/cvs/contrib/rcs2log
lrwxrwxrwx 1 anrdaemon None 15 Nov 10  2021 ./lib/tcl8.6/tclConfig.sh -> ../tclConfig.sh
lrwxrwxrwx 1 anrdaemon None 17 Feb  2  2020 ./lib/terminfo -> ../share/terminfo
lrwxrwxrwx 1 anrdaemon None 14 Nov 18  2021 ./lib/tk8.6/tkConfig.sh -> ../tkConfig.sh
lrwxrwxrwx 1 anrdaemon None 15 Nov 10  2021 ./usr/lib/tcl8.6/tclConfig.sh -> ../tclConfig.sh
lrwxrwxrwx 1 anrdaemon None 14 Nov 18  2021 ./usr/lib/tk8.6/tkConfig.sh -> ../tkConfig.sh

Is this… normal ?


-- 
With best regards,
Andrey Repin
Sunday, August 21, 2022 14:41:23

Sorry for my terrible english...

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Broken links in Cygwin installation
  2022-08-21 11:42 Broken links in Cygwin installation Andrey Repin
@ 2022-08-21 15:09 ` Ken Brown
  2022-08-22 16:12   ` Andrey Repin
  0 siblings, 1 reply; 4+ messages in thread
From: Ken Brown @ 2022-08-21 15:09 UTC (permalink / raw)
  To: cygwin

On 8/21/2022 7:42 AM, Andrey Repin wrote:
> Greetings, All!
> 
> # LC_ALL=C.UTF-8 find -L / -xdev -type l -exec ls -ld --color '{}' +
> lrwxrwxrwx 1 anrdaemon None 28 Dec 26  2021 ./bin/rcs2log -> ../share/cvs/contrib/rcs2log
> lrwxrwxrwx 1 anrdaemon None 15 Nov 10  2021 ./lib/tcl8.6/tclConfig.sh -> ../tclConfig.sh
> lrwxrwxrwx 1 anrdaemon None 17 Feb  2  2020 ./lib/terminfo -> ../share/terminfo
> lrwxrwxrwx 1 anrdaemon None 14 Nov 18  2021 ./lib/tk8.6/tkConfig.sh -> ../tkConfig.sh
> lrwxrwxrwx 1 anrdaemon None 15 Nov 10  2021 ./usr/lib/tcl8.6/tclConfig.sh -> ../tclConfig.sh
> lrwxrwxrwx 1 anrdaemon None 14 Nov 18  2021 ./usr/lib/tk8.6/tkConfig.sh -> ../tkConfig.sh
> 
> Is this… normal ?

The first four are consequences of the fact that /bin is the same as /usr/bin 
and /lib is the same as /usr/lib.  The links in question were actually installed 
in /usr/bin or /usr/lib.  The package maintainers could avoid this issue by 
using absolute paths instead of relative ones in the symlink content, but I 
don't think it's likely to cause problems in practice.

The last two symlinks would get resolved if you installed tcl-devel and 
tcl-tk-devel.  I think it's fine to leave dangling symlinks in this situation.

Ken

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Broken links in Cygwin installation
  2022-08-21 15:09 ` Ken Brown
@ 2022-08-22 16:12   ` Andrey Repin
  2022-08-22 18:43     ` Andrey Repin
  0 siblings, 1 reply; 4+ messages in thread
From: Andrey Repin @ 2022-08-22 16:12 UTC (permalink / raw)
  To: Ken Brown, cygwin

[-- Attachment #1: Type: text/plain, Size: 1794 bytes --]

Greetings, Ken Brown!

> On 8/21/2022 7:42 AM, Andrey Repin wrote:
>> Greetings, All!
>> > # LC_ALL=C.UTF-8 find -L / -xdev -type l -exec ls -ld --color '{}' +
>> lrwxrwxrwx 1 anrdaemon None 28 Dec 26  2021 ./bin/rcs2log -> ../share/cvs/contrib/rcs2log
>> lrwxrwxrwx 1 anrdaemon None 15 Nov 10  2021 ./lib/tcl8.6/tclConfig.sh -> ../tclConfig.sh
>> lrwxrwxrwx 1 anrdaemon None 17 Feb  2  2020 ./lib/terminfo -> ../share/terminfo
>> lrwxrwxrwx 1 anrdaemon None 14 Nov 18  2021 ./lib/tk8.6/tkConfig.sh -> ../tkConfig.sh
>> lrwxrwxrwx 1 anrdaemon None 15 Nov 10  2021 ./usr/lib/tcl8.6/tclConfig.sh -> ../tclConfig.sh
>> lrwxrwxrwx 1 anrdaemon None 14 Nov 18  2021 ./usr/lib/tk8.6/tkConfig.sh -> ../tkConfig.sh
>> > Is this… normal ?

> The first four are consequences of the fact that /bin is the same as
> /usr/bin and /lib is the same as /usr/lib.  The links in question were
> actually installed in /usr/bin or /usr/lib.  The package maintainers could
> avoid this issue by using absolute paths instead of relative ones in the
> symlink content, but I don't think it's likely to cause problems in practice.

> The last two symlinks would get resolved if you installed tcl-devel and
> tcl-tk-devel.  I think it's fine to leave dangling symlinks in this situation.

Thanks, Ken! That helped me formulate the solution.

Small background: I've been moving my Cygwin installations around to match
path locations between different systems. I've ended up with a lot of broken
symlinks, between which some are actually lost.
I've baked a PowerShell script to solve the issue (see attachment).
Also in attachment a powershell startup wrapper for /usr/local/bin/


-- 
With best regards,
Andrey Repin
Monday, August 22, 2022 15:49:38

Sorry for my terrible english...

[-- Attachment #2: pwsh --]
[-- Type: application/octet-stream, Size: 119 bytes --]

#!/bin/sh

_cmd="$( cygpath -am "$1" )"
shift

"/c/Program Files/PowerShell/7/pwsh.exe" "-NoLogo" "-File" "$_cmd" "$@"

[-- Attachment #3: Fix-Cygwin_64.ps1 --]
[-- Type: application/octet-stream, Size: 1023 bytes --]

#!/usr/bin/env pwsh

Param(
    [Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $false)]
    [System.String]
    $oldPath,

    [Parameter(Mandatory = $True, Position = 1, ValueFromPipeline = $false)]
    [System.String]
    $newPath,

    [Parameter(Mandatory = $True, Position = 2, ValueFromPipeline = $false, ValueFromRemainingArguments = $True)]
    [System.String[]]
    $paths
)

$paths | Where-Object {
    $_ -and (Get-Item -Path $_).LinkTarget
} | ForEach-Object {
    $target = $(Get-Item -Path $_)
    If ($target.FullName.IndexOf($oldPath)) {
        Write-Host "$($target.FullName)`n -> $($target.LinkTarget)"
        $newTarget = $target.LinkTarget.Replace($oldPath, $newPath)
        Write-Host -NoNewline " => $($newTarget)"
        if (Test-Path -LiteralPath $newTarget) {
            $rc = New-Item -Type SymbolicLink -Path $target.FullName -Target $newTarget -Force
            Write-Host ''
        } else {
            Write-Host -ForegroundColor DarkRed ' (unfixed)'
        }
    }
}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Broken links in Cygwin installation
  2022-08-22 16:12   ` Andrey Repin
@ 2022-08-22 18:43     ` Andrey Repin
  0 siblings, 0 replies; 4+ messages in thread
From: Andrey Repin @ 2022-08-22 18:43 UTC (permalink / raw)
  To: Andrey Repin, cygwin

Greetings, Andrey Repin!

> Small background: I've been moving my Cygwin installations around to match
> path locations between different systems. I've ended up with a lot of broken
> symlinks, between which some are actually lost.
> I've baked a PowerShell script to solve the issue (see attachment).
> Also in attachment a powershell startup wrapper for /usr/local/bin/

find -L / -xdev -type l -execdir fixmylinks.ps1 OldPathFragment New\\PathFragment '{}' +

In all broken links, script will look for "OldPathFragment", and if replacing
the fragment with "New\\PathFragment" produce valid existing path, it will
create a new link in place.


-- 
With best regards,
Andrey Repin
Monday, August 22, 2022 21:38:22

Sorry for my terrible english...


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-22 18:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-21 11:42 Broken links in Cygwin installation Andrey Repin
2022-08-21 15:09 ` Ken Brown
2022-08-22 16:12   ` Andrey Repin
2022-08-22 18:43     ` Andrey Repin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).