Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Larry Martell Newsgroups: comp.lang.python Subject: Re: creating zipfile with symlinks Date: Thu, 3 Mar 2016 22:32:56 -0500 Lines: 37 Message-ID: References: <56D8AEBB.6060102@mrabarnett.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de zN/UL2jZPc64RC7AxCzJdQY5lo/a5cv/WSn2T975a/Cg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'broken': 0.03; '---------': 0.05; 'mrab': 0.05; '-------': 0.09; 'filename,': 0.09; 'symlink': 0.09; 'python': 0.10; 'thu,': 0.15; '"zip': 0.16; '(there': 0.16; '08:45': 0.16; '2016': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'zipfile': 0.16; 'wrote:': 0.16; 'thanks.': 0.18; 'handles': 0.20; 'to:name:python- list@python.org': 0.20; 'file.': 0.22; 'am,': 0.23; 'bit': 0.23; 'this:': 0.23; 'header:In-Reply-To:1': 0.24; 'feature': 0.24; 'module': 0.25; '----------': 0.25; "doesn't": 0.26; 'command': 0.26; 'chris': 0.26; 'external': 0.27; '----': 0.27; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; "skip:' 10": 0.28; 'fine': 0.28; 'regular': 0.29; '-----': 0.29; "i'm": 0.30; 'system,': 0.30; 'that.': 0.30; 'know.': 0.34; 'file': 0.34; 'received:google.com': 0.35; 'set.': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'possible': 0.36; 'mode': 0.36; 'to:addr :python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'drop': 0.38; 'files': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'some': 0.40; 'total': 0.62; 'within': 0.64; 'mar': 0.65; 'special': 0.73; 'different.': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=hbHrjIw35U1RbhAnO5i9a8bF+fZt8dEXvgNU0jOQFhY=; b=aI02gwvMBePsPJXHA6zsjAUlPv5ZCz+z052D62nX0xJzkGEYA2QgmEIiiaHoAnR1pD kwQTGSwFtO1fYM1h6Mfd6h0tivj6Ul0zI930uVvoXQYUbpgg+fkD+OpKIgR79pH7n7+s ekeMRdc0zcGFy1/69Otl7Cf3bGnft4BbU//8BXNd9dKrrsXJ77RAEkbe7nWEwgOKhQX3 LMe7v+ICcQkmthrOWuOb24o7SaTXGx/mdlf1owIu4/vC9rTfZdJbI2LOgNJ1zvloVjPA e/ovb1GmWyUc8XVjUcWZR0wUcbulwztbyGAxMXaklyUyWHURar9z0S4ZgmHdNEQVo+0q z9aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=hbHrjIw35U1RbhAnO5i9a8bF+fZt8dEXvgNU0jOQFhY=; b=GJNCmZqB7cAWBmRBUpXixU6iUnJA42gFJhnAxxTNhgyd0fKsjmc+CXXFSgCBLBxUZ+ Iqz+UVeu8GHNoxmo3i4CdMpY7TTTFl6Jn4vaMCDGGfMCyMaq1O5HvyDqHXHkz8nU61Xg e5U4/kNouSLU/ezt65g/Ap8sHW9X+2yv2N8rz83k2EujjzWJldvhZztYCjRr/5ema3Vx ddzmL/hwZ+u7nJ4KHYdZb12H3FjHbQZRBRNU5dDyUD0BBml99QNeDDpgMSwZaLeUjGaz 5HRSnNC9FvymqQ7zCysciKGfjYp2NR5/TUXVXb6qIkFyZfafGCHatDkXwzxb6UK0/0WV Ht+A== X-Gm-Message-State: AD7BkJKs+cznvZ527Wo9E5/BT9zNSUxqulZ2qUipwQwiBkL8HI9RQMtu/Q3GR6/CIiWngXQ4DMSWujWUKfNFcw== X-Received: by 10.50.43.161 with SMTP id x1mr2560858igl.47.1457062416436; Thu, 03 Mar 2016 19:33:36 -0800 (PST) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104012 On Thu, Mar 3, 2016 at 4:58 PM, Chris Angelico wrote: > On Fri, Mar 4, 2016 at 8:38 AM, MRAB wrote: >> Is it even possible to zip a link? >> >> A quick search came up with this: >> >> Are hard links possible within a zip archive? >> http://stackoverflow.com/questions/8859616/are-hard-links-possible-within-a-zip-archive > > Hard links are different. Symlinks are files containing the target > filename, with a special mode bit set. I'm not sure if it's a standard > feature of all zip archivers, but on my Debian system, I can use "zip > --symlinks" to create such a zip. How that will unzip on a system that > doesn't understand symlinks, I don't know. > > rosuav@sikorsky:~/tmp$ ls -l > total 4 > -rw-r--r-- 1 rosuav rosuav 162 Mar 4 08:48 aaa.zip > lrwxrwxrwx 1 rosuav rosuav 4 Mar 4 08:49 qwer -> asdf > rosuav@sikorsky:~/tmp$ unzip -l aaa.zip > Archive: aaa.zip > Length Date Time Name > --------- ---------- ----- ---- > 4 2016-03-04 08:45 qwer > --------- ------- > 4 1 file > > > That's a broken symlink (there is no "asdf" in the directory), and zip > and unzip are both fine with that. > > Now, how the Python zipfile module handles this, I don't know. The > ZipInfo shows a file mode of 'lrwxrwxrwx', but when I call extract(), > it comes out as a regular file. You might have to do some work > manually, or else just drop to an external command with --symlinks. Thanks. That's what I ended up doing.