0

I'm trying to write a Makefile script that zips a directory's contents. Then renames the zip file e.g. public_html.zip to test-1.0.zip. But uncompressing unzip maintained the first zips names.

So far I have

    plugin=test
    directory=public_html
    version=0.0.1
    all:
        @ echo "Build archive for plugin ${plugin} version=${version}"
        @ rm -f ${directory}.zip && zip -rj ${directory}.zip ./* 
        @ rm -f ${plugin}-${version}.zip && mv ${directory}.zip   ${plugin}-${version}.zip

However, renaming on my mac or using the mv commmand and then unzipping or uncompressing gives me the new name test-1.0 rather than public_html.

I know that git archive --prefix allows you to give a different name for paths. I looked into zip -j & --junk-path, but they don't seem to solve it.

I couldn't find any other questions that asked this specifically. The others just wanted to rename the folder and didn't care about keeping the original zip name.

lastlink
  • 1,505
  • 2
  • 19
  • 29
  • You want to start with `public_html/`, compress that directory into `public_html.zip`, rename that file to `test-1.0.zip`, perhaps delete `public_html/`, then unpack `test-1.0.zip` and thereby restore `public_html/`, is that right? – Beta Feb 17 '18 at 21:59
  • yes, that is the desired behavior. – lastlink Feb 23 '18 at 18:38
  • No problem. The command `zip -r test-1.0 public_html` will do the first part, and `unzip test-1.0` will do the second. do you need help with a makefile that will do that? – Beta Feb 24 '18 at 00:54

0 Answers0