cleanup_and_exit () {
trap EXIT
test -z "$1" && set 0
+ rm -f $BUILD_ROOT/.repo.config
rm -f $BUILD_ROOT/exit
if test "$1" -eq 1 -a -x /bin/df ; then
# okay, it failed, but maybe because disk space?
export VM_INITRD
}
+hide_passwords()
+{
+ local i j
+ r=()
+ rm -f $BUILD_ROOT/.repo.config
+ for i in "${repos[@]}"; do
+ if [ "$i" == "--repo" -o "$i" == "--repository" ]; then
+ r=("${r[@]}" "$i")
+ else
+ echo $i |grep -E "^http[s]?:\/\/[^\/]*\/?" >/dev/null && echo $i >> $BUILD_ROOT/.repo.config
+ j=$(echo $i | sed -e "s#://[^@]*@#://#")
+ r=("${r[@]}" "$j")
+ fi
+ done
+ repos=("${r[@]}")
+ echo ${repos[@]}
+}
+
check_for_ppc()
{
local uname
fi
mkdir_build_root
+hide_passwords
if [ "$BUILD_ROOT" = / ]; then
browner="$(stat -c %u /)"
use strict;
+sub hide_passwd {
+ my $url = shift;
+ $url =~ s|://[^@]*@|://|;
+ return $url
+}
+
die "USAGE: $0 DIR URLS..." unless $#ARGV >= 1;
my $dir = shift @ARGV;
timeout => 42);
for my $url (@ARGV) {
+ my $original = $url;
if ($url =~ /^zypp:\/\/([^\/]*)\/?/) {
use Build::Zypp;
my $repo = Build::Zypp::parsecfg($1);
last;
}
} else {
- $url = URI->new($url);
+ my $found = 0;
+ if ( defined $ENV{BUILD_ROOT} && -e $ENV{BUILD_ROOT} . "/.repo.config" ) {
+ open FILE, "<", $ENV{BUILD_ROOT} . "/.repo.config" or die $!;
+ while (<FILE>) {
+ next if ($_ !~ /^http[s]?:\/\/([^\/]*)\/?/);
+ chomp($_);
+ my $hidden = URI->new($_);
+ my $ui = $hidden->userinfo;
+ $hidden->userinfo(undef);
+ if ( $url =~ m/^$hidden/ ) {
+ $url = URI->new($url);
+ $url->userinfo($ui);
+ $found = 1;
+ last;
+ }
+ }
+ close FILE;
+ }
+ if ($found == 0 ) {
+ $url = URI->new($url);
+ }
}
$ua->env_proxy if $url->scheme ne 'https';
my $dest = "$dir/".basename($url->path);
my $res = $ua->mirror($url, $dest);
last if $res->is_success;
# if it's a redirect we probably got a bad mirror and should just retry
- die "requesting $url failed: ".$res->status_line."\n" unless $retry && $res->previous;
- warn "retrying $url\n";
+ die "reqesting " . hide_passwd($original) . " failed: ".$res->status_line."\n" unless $retry && $res->previous;
+ warn "retrying " . hide_passwd($original) . "\n";
}
}