delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2024/08/08/03:48:38

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3F706385828B
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1723103316;
bh=VgM2B/Y1DMCQ1EpzUvQvGeKwdHd3g0buYDYl430xpHs=;
h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive:
List-Post:List-Help:List-Subscribe:From:Reply-To:From;
b=mmhh4oxCBVuBylX+OH9jIyH8Q2b0F+Q/LgfWvjQ+qLsf8A2HSvbOii0owu1Rm36L+
hmkHP1JvKw60S+sg0xhsFTdTj+4GW65fIALE4kHu1wl5IDPefXMCIUrISQBImq77+i
ijusxzvvP7OiEGOk/NDbbJ67fE2WqR+7ZT5kNewk=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3BB233858C41
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3BB233858C41
ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1723103258; cv=pass;
b=H4/O/WFz96GHfaZcELH2/EW2WQ0LnSbFP2/vFAbQcnIDZHJni0IK+pyHHqXzbnDimLD+4dm0pyQQfydJU/IpdDE+b5a39iM2sGAB7qjxaE/6BClIpszjR7MIphnQ0HSLoUjw/bA4k5m5X/lltPnnCu96qMpPpk8TgC+pl/GntAU=
ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key;
t=1723103258; c=relaxed/simple;
bh=yITkKykVe3foaNDulVycoQkMcbZZ/a31jhjSBALPe9c=;
h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;
b=AHubDARlMwRms2rBTQWqXx6OjNV0mxEkFA/N124ylw4NGSFnr6O/vVnGrETQjpER8Toxvu3bfLcJD/tcHmm5TBehT9zk7OuEHKjmFQqgpcJzOthWcWpiZ1+ma854Vqw8BkNxhTSHsqA5H2Yj+VDyb0j9X6XDXe3QW/NrkzCg8Gk=
ARC-Authentication-Results: i=2; server2.sourceware.org
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
b=TeKgAxtAk4wauc+RKy49vG6aJgEF8lmus8yCls7aHoMf87Vc6UnhtHdRSthNQWvWkPEntgw+hgCEHKAdrpPUUnoy0z5LZGh+Vya+QYt9X2HfKPcCp17MfJsyfYwrMQx7JDX9twmWBUj29O+2T5usaGF/Bz+2ka+gyuCbdCbIuTJv9d4atk+UQq6t4pXc3L9Kl3VK5rlCxt0OEvq8tx+xcixm7yz93KeGgZ9bZKXESzzLTRohzfW9cwwPSGUFEAFbg0GXNsez+2fRz6pL5y73YMwmdOaErJX1wQyBDPTo6aN954X4mfDd6IEweDAyhDAPdERiNFoTWR+aN+f+nPMPiA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector10001;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=yITkKykVe3foaNDulVycoQkMcbZZ/a31jhjSBALPe9c=;
b=lEwxb3cIkM74pSZU4sLvZ3MaXw0JHre51jvJgQkWMwhqBdWoReHgx3FP6rkm7nTQEFo2HG8F4eOl1NB5Oi65WvG2aXCgKaw/Z8ClQBDVYk20g2LnMDFGVtjjpBdpbcIvZCqjX+OttxtwKmzVrZacJeA84Ruew7yJIvfak8vcEeF2NRxGQgWIsRUOASZHmARUq3GVbC0h2clo4ViDo8EGYsGZxoU34nFcJuaUtaotVftM3kXx+vKMI6LitIktc528mKZgbFUU6OYA4hscJtbfo9rYGIcCMil9UEF9Yfj10Hfppkc2LCs+UjSGRQ+OsVKl57tB7kldb+FKq5s7YqFBLQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none;
dkim=none; arc=none
To: "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
CC: Fergus Daly <fergusd84 AT outlook DOT com>
Subject: Re: How to repair the symlinks in a copied cygwin64 tree
Thread-Topic: Re: How to repair the symlinks in a copied cygwin64 tree
Thread-Index: AdrpY8JjXKVqLA9OT1S5/6YFpJmNkQ==
Date: Thu, 8 Aug 2024 07:47:33 +0000
Message-ID: <FRZP189MB2783695E6623D9CE21C5476BA4B92@FRZP189MB2783.EURP189.PROD.OUTLOOK.COM>
Accept-Language: en-GB, en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-exchange-messagesentrepresentingtype: 1
x-tmn: [xTF4MmWTCzcgek4eJHfAnHmFYwX6rVlV]
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: FRZP189MB2783:EE_|GV1P189MB2107:EE_
x-ms-office365-filtering-correlation-id: 77e8d6d9-84fa-4d0a-6a8e-08dcb77e5ce4
x-microsoft-antispam: BCL:0;
ARA:14566002|15080799003|461199028|19110799003|8060799006|102099032|3412199025|440099028|4295299021|1710799026;
x-microsoft-antispam-message-info: /Zch+K0mlRQ48jpf+dodtd4G2aKJS0tmFLVk4cmv+cbHdxyw7FCeNfZ4rDhWw6kvcBjzPGEC43lmU44UcQKgP6KsY65KSeM9RmsjwzYvECPV2xZoeEDhnKORAWHcoRKpJgwu+Pq3SxRHuerz5mc4g6dCPYrpH1NygJXDiu/cwoUP/LVvKE/RG/keDSh78JdisoT/SKnn3mzDrUukvZ7+zRPrnQ7AFc6FMLVcO0wnedHLLscvW4mP+0xHNMnn3SZzmf2VGwzA8r01xXIWqY1+qzyb3y5IN3E+JHOBdrs8V2TbccWhujY2/508jqOv2v3FCSOwlRL5NA3UbwpQ0uFomA5qW7oV5Op2YywiwDo+sk/I7L4oJ6ck48g0cbetiZLgBzGgKIhhkgnH1tL8i4ztj5h9xFyUQCkZyqNwPPhOTflOgkBg0lN7yJTEWz2YAwLudzAVF9N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9TQAN?=
=?us-ascii?Q?yNmNO9cviucbnb5Kz44siBwTh3I39AQ6gGSra6sHKON1mVcRA06LiD98yR+F?=
=?us-ascii?Q?Zc4sUVC5/A8almeFIgrtpufNVVXe0FcWlRsbALpBXhbu2JbKpaPTXniuMnZQ?=
=?us-ascii?Q?nlenSeduYoGyqrPC/U8q8JoEIzBehsN0JTZW5Huq/ZeGZzBR1BExfJxd7NOq?=
=?us-ascii?Q?wIvfOmnspk2U6ELFBCILNMDx9K/vBrpJRwx9/IWwNMceksZKsmlMY57HdoGR?=
=?us-ascii?Q?Alw57Bsxco2qF0cCn4vpQOVLhkuTxrQjv4ukPBQIoZJN4wN/5HmB4+K4cttJ?=
=?us-ascii?Q?ZcaY7e6QS2+LWG+U/5kkU7UUrqrYgYXVzKzW2xUjcjSa6VG7pOAbWkizE1Y9?=
=?us-ascii?Q?wv+CigXNdzE3agrZqI46GsNy4Yz6Mco8kkFSbTen2VMlHXoJLiwXGQuPI/v9?=
=?us-ascii?Q?VnO7FzRQtX2pyTIYLeKjDBVaMwRwamFEGJoBBpVTR+oN2HNh/FRHClqfL93T?=
=?us-ascii?Q?X+PmF+FWYGaa/UT3jT8j7cMaST8aNzzY/E9fV0lBKjtK3K150cmorJv7TZr1?=
=?us-ascii?Q?XEi01TjG3GRgPueYu3earlBUDIzkIOiuzhU9xOyntwPdLWYULyxyslLmh4hY?=
=?us-ascii?Q?S09zKof6LyPX3kT4CSAyJWcU4La+5/WF7VrXvdtEjpdYCNOLnGox/8Raiy0?=
=?us-ascii?Q?=3D?=
MIME-Version: 1.0
X-OriginatorOrg: outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: FRZP189MB2783.EURP189.PROD.OUTLOOK.COM
X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-CrossTenant-Network-Message-Id: 77e8d6d9-84fa-4d0a-6a8e-08dcb77e5ce4
X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Aug 2024 07:47:33.1770 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa
X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P189MB2107
X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT,
FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS,
TXREP autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Fergus Daly via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Fergus Daly <fergusd84 AT outlook DOT com>
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>

Could try this (see end).
Re-reading after writing, it looks most hellishly involved.
It uses attrib as Mark has suggested but tries to capture all the required
files instead of treating them one by one.
And maybe risky :o(
Maybe somebody else will come up with something slicker and quicker.
Sorry - I've done the best I can think of .. .. ..

Hi David,
On 8/7/2024 1:26 PM, David Karr via Cygwin wrote:

> At my work, I had to have my laptop reimagined for various reasons. I had
> them save my cygwin64 tree to external storage first. I now have the laptop
> back, and I copied the entire tree back in, but now I realize I should have
> done this differently, and I'm wondering how best to repair this. Some of
> you can probably guess, but now all of the files that were symlinks in
> Cygwin are now very small data files. I can tell they used to be symlinks
> because when I cat one, it shows "!<symlink>" in the first characters.
> What is the best strategy for repairing this? The most simple-minded
> approach that I can see is simply renaming the cygwin64 tree to get it out
> of the way, and then just reinstalling Cygwin, and then copying in all the
> files in my cygwin home directory in the saved tree. I will likely guess
> wrong on what packages I had installed before. Is there some way I can
> simply repair the symylink files directly?

If the path to Windows' attrib.exe is in your path (use 'which attrib' 
to check) then you can simply 'attrib +I +S <filename>' the file that 
contains "!<symlink>".

> Besides the symlink problem, is there anything else that I might have
> broken by doing it this way?

That I don't know.

> I'm guessing the correct way to have done this would have been instead
> storing the "tar czpf" output in external storage. I think that would have
> preserved the symlinks and restored them properly with "tar xzf".

That looks good OK me but I've never had to try it, so YMMV.
HTH,
..mark

Part 1 : How to mend what you've got.

Although you have many broken symlinks, can you start a Cygwin process in the usual way?
If so and assuming the top of your tree is called say cyg64 on drive D, you could try
$ find /d/cyg64 type f -print0 | xargs -0 grep -l "<symlink" > ./mysymlist
in order to create a list of all your files which contain that phrase.
Note 1 I guess you might need to use /cygdrive/d/cyg64 depending how /etc/fstab is defined.
Note 2 I really want to incorporate the leading exclamation ! before the <symlink
but for reasons I cannot fathom I cannot achieve this, with or without a backslash.
I'm moderately certain that ".. .. \!<sym .. .." used to work (??)
After some time the search will conclude and the file mysymlist will contain a list of links.
Also additionally some extras e.g. 
/d/cyg64/bin/cygcheck.exe
/d/cyg64/bin/cygwin1.dll
/d/cyg64/bin/profiler.exe
/d/cyg64/bin/strace.exe
which are not symlinks but which the grep command as typed has picked up.
Sorry, I don't know how to sieve these unwanted entries out of the list other than
by inspection. There may be others too, such as
/d/cyg64/usr/share/perl5/5.36/Archive/Tar/File.pm
/d/cyg64/usr/share/perl5/5.36/Archive/Tar.pm
/d/cyg64/usr/share/texmf-dist/scripts/texlive/tlmgr.pl
Sorry! Somebody else might know how to do all this better.
You now want to copy the corrected file mysymlist into a Windows command file
named say mysymlist.cmd and edit every line currently written
/d/cyg64/../../filename
to become
attrib +s D:\cyg64\..\..\filename
and then run the command file mysymlist.cmd from a Windows Command Prompt
window.
I think that should recover your links by marking all required files as +S.

Part 2 : How to prevent it happening again.

As an alternative to expressing symlinks as +S files they can also be expressed as +R files
with the name filename.lnk.
It is possible from within Cygwin to re-write all +S symlinks as +R symlinks with the .lnk extension
but, I'm sorry, although I once knew it I cannot recall it and anyway I think it must depend on
the setting of the environmental variable CYGWIN. For instance, I have
CYGWIN='winsymlinks nodosfilewarning'
but I daresay a different setting would enable the re-writing of all +R symlinks as +S if that was what
somebody wanted (??)
Then, if you do copy an entire Cygwin image from Machine A to Machine B you can (if it turns out to be necessary)
simply recover all symlinks by issuing the Windows command
attrib +R D:\cyg64\*.lnk /s
from a Windows Command Prompt (not Cygwin).


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019