Below is a summary of a way to create a short shell script that will re-create symlinks that cannot be stored in certain archive formats (e.g. 7z archives or zip files [when created with certain tools]).
{ printf 'cd "$(dirname "$0")"\n'; find . -type l -printf 'ln -sfn "%l" "%p"\n' ; } > symlinksThe resultant file (symlinks) can be executed as follows to recreate symlinks on a UNIX-like system OS at a later point, e.g.
sh symlinksWhen creating the archive, the actual symlinks must be excluded (so that the real file/directory they link to is not added to the archive instead). In addition the symlinks file itself must be included. Here is a practical example with the correct order.
Create an archive:
# Create the symlink re-creation script inside the directory we will archive
( cd vivaldi-symbols; { printf 'cd "$(dirname "$0")"\n'; find . -type l -printf 'ln -sfn "%l" "%p"\n' ; } > symlinks )
# Write a listing of just files, exclude directories and symlinks ('-type f')
find vivaldi-symbols -type f > vivaldi-symbols-list.txt
# Archive the files from the listing created above (includes the 'symlinks' script)
7zz a vivaldi-symbols.7z @vivaldi-symbols-list.txt
# Remove the temporary files from the local filesystem
rm vivaldi-symbols/symlinks vivaldi-symbols-list.txtRestore the archive contents, then re‑create the symlinks and finally remove the now redundant symlinks script:
7zz x vivaldi-symbols.7z && sh vivaldi-symbols/symlinks && rm vivaldi-symbols/symlinks