forked from openSUSE/obs-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for using the system's zypp repos
- Loading branch information
Showing
8 changed files
with
162 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package Build::Zypp; | ||
|
||
use strict; | ||
|
||
our $root = ''; | ||
|
||
sub parsecfg($) | ||
{ | ||
my $file = shift; | ||
my $repocfg = "$root/etc/zypp/repos.d/$file.repo"; | ||
open(REPO, '<', $repocfg) or return undef; | ||
my $name; | ||
my $repo = {}; | ||
while(<REPO>) { | ||
chomp; | ||
if(/^\[(.+)\]/) { | ||
$name = $1; | ||
} else { | ||
my ($key, $value) = split(/=/,$_,2); | ||
$repo->{$key} = $value; | ||
} | ||
} | ||
return undef unless $name; | ||
$repo->{'description'} = $repo->{'name'} if exists $repo->{'name'}; | ||
$repo->{'name'} = $name; | ||
close(REPO); | ||
return $repo; | ||
} | ||
|
||
1; | ||
|
||
# vim: sw=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/perl -w | ||
|
||
BEGIN { | ||
unshift @INC, ($::ENV{'BUILD_DIR'} || '/usr/lib/build'); | ||
} | ||
|
||
use LWP::UserAgent; | ||
use URI; | ||
use File::Path; | ||
use File::Basename; | ||
|
||
use strict; | ||
|
||
die "USAGE: $0 DIR URLS..." unless $#ARGV >= 1; | ||
|
||
my $dir = shift @ARGV; | ||
|
||
my $ua = LWP::UserAgent->new( | ||
agent => "openSUSE build script", | ||
env_proxy => 1, | ||
timeout => 42); | ||
|
||
for my $url (@ARGV) { | ||
my $dest = $dir; | ||
if ($url =~ /^zypp:\/\/([^\/]*)\/?/) { | ||
use Build::Zypp; | ||
my $repo = Build::Zypp::parsecfg($1); | ||
die "can't parse $1\n" unless $repo; | ||
die "missing url in repo ".$repo->{'name'}."\n" unless exists $repo->{'baseurl'}; | ||
my $u = $repo->{'baseurl'}; | ||
$u .= '/' unless substr($u, -1, 1) eq '/'; | ||
$url =~ s/^zypp:\/\/[^\/]*\/*//; | ||
$url = URI->new($u.$url) | ||
} else { | ||
$url = URI->new($url); | ||
} | ||
my $res = $ua->mirror($url, $dest.'/'.basename($url->path)); | ||
die "reqesting $url failed: ".$res->status_line."\n" unless $res->is_success; | ||
} | ||
|
||
# vim:sw=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters