Not able to set an empty --root option

Bug #1702059 reported by Boris
46
This bug affects 9 people
Affects Status Importance Assigned to Milestone
debmirror (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

# lsb_release -rd
Description: Ubuntu 14.04.5 LTS
Release: 14.04

debmirror:
  Installiert: 1:2.16ubuntu1.1
  Installationskandidat: 1:2.16ubuntu1.1
  Versionstabelle:
 *** 1:2.16ubuntu1.1 0
        500 http://xxx/ubuntu/ trusty-updates/universe amd64 Packages
        100 /var/lib/dpkg/status
     1:2.16ubuntu1 0
        500 http://xxx/ubuntu/ trusty/universe amd64 Packages

Following command will be executed:
debmirror /srv/debmirror/puppet \
 --method=http \
 --nosource \
 --root=/ \
 --host=apt.puppetlabs.com \
 --dist=trusty,precise \
 --section=main \
 --arch=amd64,i386 \
 --check-gpg \
 --verbose \
 --keyring=/home/debmirror/.gnupg/pubring.gpg \
 --postcleanup \
 --rsync-extra=none \
 2>&1 | egrep -v '(Warning: --rsync-extra is not configured to mirror the trace files|This configuration is not recommended)'

And gives the following error:
Mirroring to /srv/debmirror/puppet from http://apt.puppetlabs.com//
Arches: amd64,i386
Dists: trusty,precise
Sections: main
Pdiff mode: use
Will clean up after mirroring.
Attempting to get lock ...
Getting meta files ...
[ 0%] Getting: dists/trusty/Release... failed 404 Not Found
[ 0%] Getting: dists/precise/Release... failed 404 Not Found
Errors:
 Download of dists/trusty/Release failed: 404 Not Found
 Download of dists/precise/Release failed: 404 Not Found
Failed to download some Release or Release.gpg files!
WARNING: releasing 1 pending lock...

---
The Problem is, there is no option to unset --root, because it defaults to /ubuntu.
If you try to fetch the file http://apt.puppetlabs.com//dists/trusty/Release you will get an 404 error.
If you fetch http://apt.puppetlabs.com/dists/trusty/Release you will get the content.

At first I would say "The puppet repo is a broken piece of ..." but it would be nice to set it empty. I also tried to set --root=. but this expands to http://apt.puppetlabs.com/./dists/trusty/Release witch works with curl but not with debmirror.

Any suggestions?

Tags: trusty
Boris (kervyn)
description: updated
tags: added: trusty
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in debmirror (Ubuntu):
status: New → Confirmed
Revision history for this message
Joel Smith (dalesit) wrote :

It is possible to override the --root option by creating an /etc/debmirror.conf file with the appropriate entry to override the default:

# Taken from /usr/share/doc/debmirror/examples/debmirror.conf
$remoteroot="";
# The config file must return true or perl complains.
# Always copy this.
1;

However, debmirror still fails to mirror the puppet repo, trying to download:

http://apt.puppetlabs.com//dists/trusty/Release

still with a // in the URL, which generates a 404 error in a browser as well.

Revision history for this message
Joel Smith (dalesit) wrote :

It is possible to bypass the default root entry by creating /etc/debmirror.conf with the following entry:

# Taken from /usr/share/doc/debmirror/examples/debmirror.conf
$remoteroot="";
# The config file must return true or perl complains.
# Always copy this.
1;

However, debmirror still fails with a 404 error as it tries to download

http://apt.puppetlabs.com//dists/trusty/Release => 404 Not Found

still with a double // in the URL, which also generates a 404 when tried in a browser

Revision history for this message
Boris (kervyn) wrote :

Ah ok,
thanks for the input.

We switched to rsync for puppet. See: https://gist.github.com/KervyN/be6ee207792a08d757e939d436c5aa58

Revision history for this message
Benjamin (popibrossard) wrote :

Hello,

Personally, I modified the /usr/bin/debmirror script:

sed -i 's#$remoteroot/#$remoteroot#g' /usr/bin/debmirror
sed -i 's#${remoteroot}/#${remoteroot}#g' /usr/bin/debmirror
sed -i '/^$remoteroot =~.*/i $remoteroot =~ s|/?$|/| ;' /usr/bin/debmirror

For some explanation, if you want to understand, I'm just including the final '/' inside the $remoteroot variable, and adding it automatically if it wasn't at the end of the string ( "ubuntu" became "ubuntu/"). If the variable is empty, the line 793 "$remoteroot =~ s%^[:/]%% unless downloads_via_file();" will remove my extra "/" ("" => "/" => "").
I don't know if it's the best way to do this in perl, but it does the work. In case it can help / save time to somebody.
I'm not proposing a pull request because I don't know how package management works and don't want to do something wrong.

Revision history for this message
Benjamin (popibrossard) wrote :

Sorry, little mistake in my previous comment,
it's not:
sed -i '/^$remoteroot =~.*/i $remoteroot =~ s|/?$|/| ;' /usr/bin/debmirror
But:
sed -i '/^$remoteroot =~.*/i $remoteroot =~ s|\/?$|\/| ;' /usr/bin/debmirror

Revision history for this message
Jean-Christophe (kibidouil-i) wrote :

Hi, i've got the same issue with Ubuntu 22.04.1 LTS.

My patch :

$ diff -u /usr/bin/debmirror.old /usr/bin/debmirror
--- /usr/bin/debmirror.old 2022-08-11 13:42:34.104000000 +0200
+++ /usr/bin/debmirror 2022-08-11 13:49:24.384000000 +0200
@@ -600,6 +600,7 @@
 use if $] lt "5.022", "Net::INET6Glue";
 use Net::FTP;
 use LWP::UserAgent;
+use URI ();

 our $version="1:2.36ubuntu1";

@@ -856,12 +857,12 @@
 $|=1 if $debug;
 if ($passwd eq "anonymous@") {
   if (downloads_via_http()) {
- say("Mirroring to $mirrordir from $download_method://$host/$remoteroot/");
+ say("Mirroring to $mirrordir from ", URI->new_abs($remoteroot, "$download_method://$host"));
   } else {
- say("Mirroring to $mirrordir from $download_method://$user\@$host/$remoteroot/");
+ say("Mirroring to $mirrordir from ", URI->new_abs($remoteroot, "$download_method://$user\@$host"));
   }
 } else {
- say("Mirroring to $mirrordir from $download_method://$user:XXX\@$host/$remoteroot/");
+ say("Mirroring to $mirrordir from ", URI->new_abs($remoteroot, "$download_method://$user:XXX\@$host"));
 }
 say("Arches: ".join(",", @arches));
 say("Dists: ".join(",", @dists));
@@ -1796,10 +1797,10 @@
   my $file=shift;
   my $url;
   if ($user eq 'anonymous'){
- $url="$download_method://${host}/${remoteroot}/${file}";
+ $url = URI->new_abs("${remoteroot}/${file}", "$download_method://$host");
   }
   else {
- $url="$download_method://${user}:${passwd}\@${host}/${remoteroot}/${file}";
+ $url = URI->new_abs("${remoteroot}/${file}", "$download_method://${user}:${passwd}\@$host");
   }
   my $ret=1;

Revision history for this message
Jean-Christophe (kibidouil-i) wrote (last edit ):

Oops!

Sorry, something just went wrong in Launchpad.

We’ve recorded what happened, and we’ll fix it as soon as possible. Apologies for the inconvenience.

If you report this as a bug, please include the error ID below, preferably by copying and pasting it rather than by taking a screenshot.

(Error ID: OOPS-cdfd6f23868dac26ead11b923923f0ba)

-> Can't attach the patch

Revision history for this message
Sven (sacredsheep) wrote :

Hi, I'm also affected by this (debmirror 1:2.36ubuntu1 on Ubuntu 22.04.1 LTS)

Is there any timeline when this be fixed?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.