Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update cpan2aur to only login with https.

  • Loading branch information...
commit 4573f6c0caa85cea0d0ae07d857160ef2ca886a9 1 parent fe1a012
@juster authored
Showing with 31 additions and 25 deletions.
  1. +31 −25 script/cpan2aur
View
56 script/cpan2aur
@@ -26,8 +26,8 @@ sub PKGBUILD_ERRCODE() { 2 }
sub NEEDLWP_ERRCODE() { 3 }
# should just make these scalars, too... hrmph
-sub AUR_LOGIN_URI() { 'http://aur.archlinux.org/' }
-sub AUR_UPLOAD_URI() { 'http://aur.archlinux.org/pkgsubmit.php' }
+sub AUR_LOGIN_URI() { 'https://aur.archlinux.org/' }
+sub AUR_UPLOAD_URI() { 'https://aur.archlinux.org/pkgsubmit.php' }
sub COOKIE_NAME() { 'AURSID' }
sub CAT_LIB() { 10 };
@@ -451,37 +451,43 @@ sub _post_upload
# as a package.
sub _load_web_modules
{
- my $loaded = eval {
- require LWP::UserAgent;
- require HTTP::Cookies;
- 1;
+ _req_or_install( 'perl-libwww',
+ 'LWP::UserAgent', 'HTTP::Cookies' );
+ _req_or_install( 'perl-lwp-protocol-https',
+ 'LWP::Protocol::https');
+}
+
+sub _req
+{
+ my $loaded = 1;
+ for my $mod ( @_ ) {
+ eval "require $mod; 1";
+ if ( $@ ) { $loaded = 0; last; }
};
+ return $loaded;
+}
- unless ( $loaded ) {
- my $answer = 1;
+sub _req_or_install
+{
+ my ($package, @modules) = @_;
- $answer = prompt_yn( <<'END_PROMPT' => 'yes' );
-You need the perl-libwww package installed to upload to the AUR.
+ return if _req( @modules );
+
+ my $answer = prompt_yn( <<"END_PROMPT" => 'yes' );
+You need the $package package installed to upload to the AUR.
Do you want to install it now?
END_PROMPT
- exit NEEDLWP_ERRCODE unless ( $answer );
-
- status 'Installing perl-libwww for uploads to the AUR...';
- my $modobj = find_module( 'LWP' );
- $modobj->install( type => 'install', format => 'CPANPLUS::Dist::Arch', );
+ exit NEEDLWP_ERRCODE unless ( $answer );
- # Try again after we install it!
- $loaded = eval {
- require LWP::UserAgent;
- require HTTP::Cookies;
- 1;
- };
-
- error( "Unable to load LWP::UserAgent and HTTP::Cookies" )
- unless $loaded;
- }
+ status "Installing $package for uploads to the AUR...";
+ my $modobj = find_module( $modules[0] );
+ $modobj->install( target => 'install', prereq_target => 'install',
+ format => 'CPANPLUS::Dist::Arch' );
+ # Try again after we install it!
+ my $list = join ', ', @modules;
+ error( "Unable to load $list" ) unless _req( @modules );
return;
}
Please sign in to comment.
Something went wrong with that request. Please try again.