Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: creating zipfile with symlinks Date: Fri, 4 Mar 2016 08:58:03 +1100 Lines: 36 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 XxlddgAElL5NqcSJGcNQlwcz/HJPa0IjMySxqWlHNJEw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'broken': 0.03; 'received:209.85.223': 0.03; '---------': 0.05; 'mrab': 0.05; 'cc:addr:python-list': 0.09; '-------': 0.09; 'filename,': 0.09; 'symlink': 0.09; 'python': 0.10; '"zip': 0.16; '(there': 0.16; '08:45': 0.16; '2016': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'zipfile': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'handles': 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; '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; 'subject:: ': 0.37; 'received:209': 0.38; 'drop': 0.38; 'files': 0.38; 'sure': 0.39; 'subject:with': 0.40; 'some': 0.40; 'total': 0.62; 'within': 0.64; 'mar': 0.65; 'special': 0.73; 'chrisa': 0.84; 'to:none': 0.91; '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:date:message-id:subject:from:cc; bh=esbk/+vAeaTi6eorT5MSPYKGsLnvEZ86lThLQ3w9xTA=; b=l+DzSzZ70yF7lkkkV/jgwhaaRenBC0beDVKlmUhrsgsAwepQNXd867bfH4MEd34I0x /hnaqmKnROz+CHcOiNA1/fYMhAniahYEzuF05Li3Q4u2wRq1B6Kwf99OQLmviRiGTQ2n qS8KRaTwXDa5nDk/RBh9K1jb5glyvT7Ef/2BL+o9pLwQFwX4yUdD334UUDdc8Uc/VU7d IGu/QG9a4vJ3b2sXVjepXiZqIMlXDsnoWdVhXpKB8cxCuWAZ7yBOeknxsnvjIdzsD/ft 1l5M1cSy0ct1/0+c1CnExUjYmniImNyoJfaXH+VFG5FWPsK0bNHNebSC90Kb1ySOToos bQnA== 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:date :message-id:subject:from:cc; bh=esbk/+vAeaTi6eorT5MSPYKGsLnvEZ86lThLQ3w9xTA=; b=BgdcmoWtpv2GUpNHPUYLOplD5T7X7Q/d7cJWuWRh7DT77JXvAtj+OIaGr6M3eaa8aB 1xbHS/+FiS5GkdF4MMqqFo12D++0b4tbceQK5VuBnjLU5FX0EOhJVt70gQOi2IYY3aDd w2qa7qqfUX2jeIXRLPoayLsxUeEKce0umxGPpuBdN8/T3LfVHiT29jSWRgkJbUyQC0wi s9JWkMojmoP/8zvzMxfdwO2FMTAWwoXLc4a2EoHeJr5z7r/eK4yQEqy3l8bIjhrVu1rh U9QsEDjQr9JRB98qHn7pTi+IAGBmRN0AAb6tPy4eP8iwQXlEVSSL1JRAn27SXgpJAxb/ b9uQ== X-Gm-Message-State: AD7BkJI4rwek/njoraRDmOf6bLGSIPtgV3Xes2AoxCNNyu3ai8cyExCWZP2v6LoF/PJTLZjkt28u7FOa2p1iLw== X-Received: by 10.107.47.163 with SMTP id v35mr4796593iov.19.1457042283491; Thu, 03 Mar 2016 13:58:03 -0800 (PST) In-Reply-To: <56D8AEBB.6060102@mrabarnett.plus.com> 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:103996 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. ChrisA