I'm using the zip command line tool on OS X to compress an Xcode project folder.
Included in that folder is a .framework for OS X which includes symlinks like xx.framework/Versions/Current
which points to xx.framework/Versions/A
. When I zip the project, then unzip it, both Versions/A and Versions/Current contain the same set of files - basically they are contained twice in the archive - I need to avoid that.
However I also have symlinks in the project folder pointing to resource files that need to be copied in the zip archive. So I can't just use the global zip flags to store the symlinks rather than the files/dirs pointed to.
How can I create a single ZIP file where only certain symlinks are stored while others will store the content they point to?
Is that even possible with zip? Is there another zip-compatible tool I could use? Could I run the zip command multiple times, excluding/including certain files while storing the files to the same archive to achieve what I want?
PS: I can not have a zip inside the zip. Once unzipped, the project must be usable and not require unzipping a contained zip.
Things I've tried:
zip -rq4y $ZIPFILE $TARGETFOLDER/xx.framework
zip -rq4u $ZIPFILE $TARGETFOLDER
The idea was to zip the .framework first, preserving the symlinks. Then update the archive to add the rest of the files, including any files/folders pointed to by symlinks not already in the archive (or so I hoped). Result: corrupt archive (Error 20 - Not a directory).
I also tried the opposite, excluding the framework on the first pass and then updating the archive with the framework:
zip -rq4 $ZIPFILE $TARGETFOLDER -x xx.framework
zip -rq4uy $ZIPFILE $TARGETFOLDER
Result: corrupt archive (Error 21 - Is a directory).