tags 435574 + patch
thanks

Hi Colin,

as pre-discussed in IRC, here’s my first version of a patch for
debmirror (git master) to make it work with servers that don’t
accept two leading slashes, trying to not break anything else ;)

The approach is thus:

- first, I changed it so that the $remoteroot is assumed to end
  with a trailing slash everywhere, and added a normalisation RE
  (new line 819 and 821) so that any amount of trailing slashes
  given by the user in -r ROOT or --root=ROOT (even zero) is
  replaced by exactly one
  ‣ all applicable "$remoteroot/" are now "$remoteroot"

- I also changed the default value and the documentation thereof
  so that using --root=/ for subdirectory-less servers is hopefully
  natural to users, as Getopt::Long unfortunately does not make it
  possible to allow --root= (it *does* allow -r '')
  ‣ hmu (or change it yourself) if you think that this needs some
    more elaboration
  ‣ I also changed this in the example file but without adding a
    comment there for empty root; in theory, users setting…
        $remoteroot="";
    … should work the same as…
        $remoteroot="/";
    … but I only tested command-line usage

- as a consequence of this, the FTP login path got an extra local
  variable that has a leading slash but no trailing slash; FTP chdir
  for subdirectory-less servers will now do 'cd /' as well, just one
  slash, and for others, 'cd /debian' etc. as before

This brings us to a situation in which no extra *trailing* slashes
are added anywhere. Now we need to collapse the slash after the
hostname (if any) with the normalised-one trailing slash of $remoteroot

- add a new variable $remoteslashroot which is initialised to the same
  value as $remoteroot (after removing the optional prefix), but with
  a leading slash added; $remoteroot and $remoteslashroot then have the
  trailing slashes normalised *individually* so that the leading slash
  is collapsed with the trailing ones for subdirectory-less servers

- change all places where we have "/$remoteroot" to "$remoteslashroot"

I’m a bit wary of the rsync block from new line 1000 onwards. I changed
the length condition to make up for the newly enforced trailing slash,
but this means subdirectory-less servers will end up in the else branch
still, where if (downloads_via_rsync()) dies (I am not familiar with all
the various codepaths and ways debmirror can download things). This
should not *break* anything, but it doesn’t fix anything either.

A full run of the following command does succeed (and only downloads a
couple of hundred KiB):

        debmirror --method=http -v -p -h apt.puppetlabs.com -r '' \
            -d trusty -s dependencies --no-check-gpg foo

I’d be glad if you could review this and, if you think it’s okay,
include with new debmirror releases.

Thanks,
//Thorsten
-- 
Thorsten Glaser
Linux / Unix Developer
Tel.: +49 160 91168501
E-Mail: [email protected]

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / https://www.b1-systems.de/
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt, HRB 3537

Attachment: debmirror-435574.diff.gz
Description: application/gzip

Reply via email to