Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

svn-multipkg authenticates to SVN #41

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion root/usr/bin/svn-multipkg
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use File::Path;
use File::Temp;
use SVN::Client;
use HTTP::Date;
use Term::ReadKey;

# metadata tracing
my @actions;
Expand Down Expand Up @@ -41,6 +42,10 @@ sub usage() {
-v, verbose verbose
-p, platform=s platform
-s, set=s List of variables to set
-U, username=s username for SVN server authentication (default
is the username running this program)
-P, password=s password for SVN server authentication (default
is to prompt for the password)
EOF
exit(0);
}
Expand All @@ -61,6 +66,8 @@ my %getoptions = (
'v|verbose' => 'verbose',
'p|platform=s' => 'platform',
's|set=s' => 'List of variables to set',
'U|username=s' => 'username for SVN server authentication',
'P|password=s' => 'password for SVN server authentication'
);

usage() unless GetOptions( $opt, keys %getoptions );
Expand All @@ -70,7 +77,11 @@ my $package = shift || usage();
my $url = $opt->{b} . '/' . $package;
my $verbose = $opt->{v};
my $wantrev = $opt->{r};
my $ctx = SVN::Client::->new;
my $username = $opt->{U} || getpwuid($<);
my $ctx = SVN::Client::->new(auth => [
SVN::Client::get_simple_provider(),
SVN::Client::get_simple_prompt_provider(\&simple_prompt, 2),
SVN::Client::get_username_provider()]);
my $tmp = File::Temp::tempdir( CLEANUP => ( !defined( $opt->{k} ) ) );
my $srcdir = "$tmp/src";
my $build = "$tmp/build";
Expand All @@ -79,6 +90,21 @@ my $rev;
# options to pass through to multipkg
my @multipkg_opts = map { ("-$_") } grep { $opt->{$_} } (qw/k v/);

sub simple_prompt {
my ($cred, $realm, $default_username, $may_save, $pool) = @_;

$cred->username($username);
print "Password: ";
# flush stdout
BEGIN { $| = 1 }
Term::ReadKey::ReadMode(2); # noecho
my $password = <>;
Term::ReadKey::ReadMode(0); # restore
chomp($password);
$cred->password($password);
$cred->may_save($may_save);
}

info("get last change revision $url @ $wantrev");
$ctx->info(
$url, undef, $wantrev,
Expand Down
16 changes: 15 additions & 1 deletion source/lib/Seco/Multipkg.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,17 @@ sub _init {

$finaldata->{whoami} = _whoami();

if ( $self->{verbose} ) {
$self->infomsg( "Data:" );
foreach my $key ( keys %$finaldata ) {
$self->infomsg( " $key: $finaldata->{$key}" );
}
$self->infomsg( "Scripts" );
foreach my $key ( keys %$scripts ) {
$self->infomsg( " $key: $scripts->{$key}" );
}
}

$self->data($finaldata);
$self->scripts($scripts);

Expand Down Expand Up @@ -1433,7 +1444,9 @@ sub platforms {
my $rel = <$f>;
close $f;

if ( $rel =~ /Red Hat Enterprise Linux AS release (\S+)/ ) {
if ( $rel =~ /Red Hat Enterprise Linux .* release (\S+)/ ) {
my @parts = split /\./, $1;
push @platforms, "rhel-$parts[0]";
push @platforms, "rhel-$1";
}

Expand All @@ -1451,6 +1464,7 @@ sub platforms {

unshift @platforms, 'default';
$self->{platforms} = \@platforms;
$self->infomsg( "Platforms: " . join(",", @platforms) );
return @platforms;
}

Expand Down