App-Repo

 view release on metacpan or  search on metacpan

lib/App/Repo/Agent.pm  view on Meta::CPAN

    maxredirs => 10,
);

sub get_packages {
    my $repo_url = shift; $repo_url =~ s/\/$//;
    my @packages_list = qw( Packages Packages.bz2 Packages.gz );

    mkpath($base_path);
    for(@packages_list){
        my $packages_tmp_file = "$base_path/$_";
        say "packages_tmp_file: $packages_tmp_file";
        say "trying $repo_url/$_";
        my $system = system("curl --user-agent \"Telesphoreo APT-HTTP/1.0.592\" -kLo $packages_tmp_file $repo_url/$_");
        say "system: $system";

        #my $res = $curl->get("$repo_url/$_");
        #if($res->is_success){
        #open(my $fh,"> :raw :bytes",$packages_tmp_file);
        #        print $fh $res->content;
        #        close $fh;
        #        }
    }
    return parse_control($repo_url, "Packages.gz");
}

sub parse_control {
    my( $repo_url, $packages_tmp_file ) = @_;
    my( @packages, %packages, $i ) = ();

    if( -f "$base_path/Packages.gz"){
        say "gz exist";
        system("gunzip -f $base_path/Packages.gz");
    } 
    if( -f "$base_path/Packages.bz2"){
        say "bz2 exist";
        system("bzcat $base_path/Packages.bz2 > $base_path/Packages");
    }

    if( -f "$base_path/Packages"){
        open(my $fh, '<', "$base_path/Packages") || die "cant open $base_path/Packages: $!";
        while(<$fh>){ 
            if( /\:\ /){ 
                s/(.*?)(\:\ )(.*)/$1$2$3/;
                my($key, $value) = ($1, $3); chomp $value;
                $packages{$key} = $value;

lib/App/Repo/Agent.pm  view on Meta::CPAN

    my @p = @{get_packages(shift)};
    my %lenght = ();
    for(@p){
        print colored(['white on_cyan'],"$_->{number}") . " $_->{Name}" . colored(['blue']," - ");
    }
}


#my @url = grep { $_->{Name} } @{get_packages("$ARGV[0]")};
#for(@url){
#    say $_->{url};
#}





printer("$ARGV[0]");
#for(@p){ say $_->{Name} };

__DATA__
my $res = $furl->get('http://repo.biteyourapple.net/#download.php?package=repo.biteyourapple.net.phixretroios9');
open( my $fh,">", 'debian.deb' ) || die "cant write to debian.deb: $!";
print $fh $res->content;
close $fh;

die;

# print Dumper($furl->env_proxy());

repo  view on Meta::CPAN

        my $repo_lib_dir = `perldoc -l App::Repo`; chomp $repo_lib_dir;
        $repo_lib_dir =~ s/\.pm/\/CydiaIcon\.png/;
        return $repo_lib_dir;
    };
    
    my $repo_icon = $repo_icon_path->();
    unless( -f "$base_dir/CydiaIcon.png" ){
        system("cp $repo_icon $base_dir/");
    }

    if( defined $switch{p} ){ say "refreshed"; return }

    say "starting $0: PID $$";

    daemonize();

    app->static->paths->[0] = $base_dir;
    any '/' => sub {
        shift->reply->static('Packages.txt');
    };

    app->start('daemon');

repo  view on Meta::CPAN

    my @ps = grep{ /repo/ } qx{ ps aux };
    for(@ps){
        push my @pid, split(" ", $_);
        if( $pid[10] eq $0 ){
            $pids .= " $pid[1]" unless $pid[1] eq $$;
        }
    }

    if($switch{s} eq 'top'){
        system("kill -9 $pids");
        say "killed $0: PID $pids";
        exit;
    }

    if($switch{s} eq 'tatus'){
        if($pids eq ' '){
            say "$0: not running";
        } else { say "$0 running: PID $pids" }
    }
}


=head1 NAME

repo - Creates list of Debian packages and starts APT repository on port 3000.

=head1 DESCRIPTION 



( run in 0.479 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )