As @Greg said, ZIP does not support hardlinks.
But if I understand correctly, your goal is to reduce the size of the compressed archive. So think about an alternative solution.
Allows you to run simple tests to check the degree of compression of various archive libraries. I created two identical binaries and compressed them using ZIP, BZ2, RAR and 7z.
8641969 test.bin 8641969 test2.bin
The first time only one file was compressed. The second time, two files were compressed:
ZIP
$zip -9 test1.zip test.bin $zip -9 test2.zip test.bin test2.bin 8636837 test1.zip 17273654 test2.zip
Bzip2
$export BZIP=--fast $tar cjf test1.tbz test.bin $tar cjf test2.tbz test.bin test2.bin 8694997 test1.tbz 17389167 test2.tbz
7z
$7za -mx=9 test1.7z test.bin $7za -mx=9 test2.7z test.bin test2.bin 8705285 test1.7z 8707054 test2.7z
Rar
$rar a -m5 test1.rar test.bin $rar a -m5 test2.rar test.bin test2.bin 8649970 test1.rar 17299916 test2.rar
Conclusion : Only 7z seems to do the job well. Think about how to use it in your application.
Of course, you will need to do more tests in your environment with your files to see if this is really necessary. You can also play with the options to see at what compression level you get the best compression ratio / speed balance.
source share