Linux: Specifying top level-directory when creating zip archive

archivinglinuxpathunixzip

I have project with the usual directory structure (src/, bin/, …), i.e

project-name/
|-- bin
|-- lib
|-- src
`-- Makefile

And would like to create an archive with the following directory structure:

project-name-version/
|-- bin
|-- lib
|-- src
`-- Makefile

Is there a neat way to do this, which avoids creating a temporary directory project-name/ elsewhere, then copying the files inside a finally calling zip -r ... on that temporary directory?

(I am basically looking for some kind of path prefix or relative path option.)

Best Answer

Maybe this already occurred to you, but why not just use a sym link rather than copy everything?

ln -s project-name project-name-version

then use zip -r through the sym link (zip will dereference sym links by default)? When you're done you can simply rm the sym link. Perhaps it's not the most elegant solution, but I don't know an obvious way to do it through zip directly.

Related Question