How to repair the symlinks in a copied cygwin64 tree

Andrey Repin anrdaemon@yandex.ru
Fri Aug 9 10:06:31 GMT 2024


Greetings, David Karr!

> 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.

These symlinks usually point to Cygwin directory tree and should be fine.
Just chmod +S them.

> 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?

Easiest I've encountered is to

0. Have a backup of your existing installation, for reference.
1. Install Cygwin anew.
2. Pull /etc/setup/installed.db from backup into a temporary directory.
3. Get a list of manually installed packages from backup
    # sed -Ee '/ 1$/s/^([^[:space:]]+) [^[:space:]]+?(\.tar[^[:space:]]+ 1)$/\1 \1-0\2/; t; d;' < $backup/installed.db
    Warning note: There will be failures, not all package versions adhere to
    the same pattern.
4. Append the list to the end of current /etc/setup/installed.db
5. Run setup to pull the package "updates".

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

None that I 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".

It would have a chance of destroying permissions, I prefer reinstall, with
backup of /etc/ and /usr/local directories (that's where I keep custom stuff).
Since I don't use Cygwin's /home, it's easy for me.


-- 
With best regards,
Andrey Repin
Friday, August 9, 2024 12:54:41

Sorry for my terrible english...



More information about the Cygwin mailing list