App-Fetchware
view release on metacpan or search on metacpan
bin/fetchware view on Meta::CPAN
C<list> just prints out the names of all fetchware packages that have been
installed. It takes no arguments, and currently does not support listing only
packages that match a certain criteria. However, you can just pipe it to
L<grep(1)> to using a regex to limit which packages you're looking for.
=head2 look
fetchware look <package name>
C<look> looks up the specified program using your C<lookup_url>, downloads it,
verifies it, and unarchives it. Then it prints out the location of the
unarchived program, so you can take a look at its code, or install it manually
if you would like to.
=head2 clean
fetchware clean
C<clean> deletes all fetchware temporary files and directories to clean up your
system temporary directory.
lib/App/Fetchware.pm view on Meta::CPAN
#error not the specific code that actually threw the error.
use strict;
use warnings;
# CPAN modules making Fetchwarefile better.
use File::Spec::Functions qw(catfile splitpath splitdir file_name_is_absolute);
use Path::Class;
use Data::Dumper;
use File::Copy 'cp';
use HTML::TreeBuilder;
use Scalar::Util qw(blessed looks_like_number);
use Digest::SHA;
use Digest::MD5;
#use Crypt::OpenPGP::KeyRing;
#use Crypt::OpenPGP;
use Archive::Tar;
use Archive::Zip qw(:ERROR_CODES :CONSTANTS);
use Cwd 'cwd';
use Sub::Mage;
use URI::Split qw(uri_split uri_join);
use Text::ParseWords 'quotewords';
lib/App/Fetchware.pm view on Meta::CPAN
my @fields = split ' ', $listing_line;
###BUGALERT### Internationalization probably breaks this
#datetime parsing? Can a library do it?
# day-month-year time
# $fields[0] $fields[1]
# Normalize format for lookup algorithms .
my ($day, $month, $year) = split /-/, $fields[0];
# Ditch the ':' in the time.
$fields[1] =~ s/://;
# Some dirlistings use string months Aug, Jun, etc...
if (looks_like_number($month)) {
# Strip leading 0 if it exists by converting the
# string with the useless leading 0 into an integer.
# The %num_month hash lookup will add back a leading
# 0 if there was one. This stupid roundabout code is
# to ensure that there always is a leading 0 if the
# number is less than 10 to ensure that all of the
# numbers this hacky datetime parser outputs all
# have the same length so that the numbers can
# easily be compared with each other.
$month = sprintf("%u", $month);
lib/App/Fetchware.pm view on Meta::CPAN
after parsing your Fetchwarefile, and is used to name your Fetchwarefile when
using C<fetchware new>. It is required just like C<lookup_url>, C<mirror>,
perhaps C<filter>, and some method to verify downloads are.
=head2 filter 'perl regex here';
Specifies a Perl regular expression that fetchware uses when it determines what
the latest version of a program is. It simply compares each file in the
directory listing specified in your C<lookup_url> to this regular expression,
and only matching files are allowed to pass through to the next part of
fetchware that looks for source code archives to download.
See L<perlretut> for details on how to use and create Perl regular expressions;
however, actual regex know how is not really needed just paste verbatim text
between the single quotes C<'>. For example, C<filter 'httpd-2.2';> will cause
fetchware to only download Apache 2.2 instead of the version for Windows or
whatever is in the weird httpd-deps-* package.
=head2 temp_dir '/tmp';
C<temp_dir> tells fetchware where to store fetchware's temporary working
lib/App/Fetchware.pm view on Meta::CPAN
is fetchware's default behavior. It improves security, and allows fetchware to
avoid exposing the root account by downloading files as root.
Do B<not> use this feature unless you are absolutely sure you need it.
=over
=item SECURITY NOTICE
stay_root, when turned on, causes fetchware to not drop privileges when
fetchware looks up, downloads, verifies, and builds your program. Instead,
fetchware will stay root through the entire build cycle, which needlessly
exposes the root account when downloading files from the internet. These files
may come from trusted mirrors, but mirrors can, and do get cracked:
L<http://www.itworld.com/security/322169/piwik-software-installer-rigged-back-door-following-website-compromise?page=0,0>
L<http://www.networkworld.com/news/2012/092612-compromised-sourceforge-mirror-distributes-backdoored-262815.html>
L<http://www.csoonline.com/article/685037/wordpress-warns-server-admins-of-trojans>
lib/App/Fetchware.pm view on Meta::CPAN
L<CREATING A FETCHWARE EXTENSION>, for full details.
=head2 How Fetchware's configuration options are made
Each configuration option is created with L<App::Fetchware::CreateConfigOptions>
This package's import() is a simple code generator that generates configuration
subroutines. These subroutines have the same names as fetchware's configuration
options, because that is exactly what they are. Perl's
L<Prototypes|perlsub/Prototypes> are used in the code that is generated, so
that you can remove the parentheses typically required around each configuration
subroutine. This turns what looks like a function call into what could
believably be considered a configuration file syntax.
These prototypes turn:
lookup_url('http://somemirror.com/some/path');
Into:
lookup_url 'http://somemirror.com/some/path';
lib/App/Fetchware/CreateConfigOptions.pm view on Meta::CPAN
sub _add_export {
my ($sub_to_export, $caller) = @_;
{
no strict 'refs';
# If the $caller has not declared @EXPORT for us, then we'll do it here
# ourselves, so you don't need to declare a variable in your fetchware
# extension that you never even use yourself.
#
#The crazy *{...} contraption looks up @$caller::EXPORT up in the stash,
#and checks if it's defined in the stash, and if there's a stash entry,
#then it has been defined, and if not, then the variable is undeclared,
#so then delare it using the crazy eval.
#
#Also, note that use vars is used in favor of our, because our variables
#are bizarrely lexically scoped, which is insane. Why would a global be
#lexically scoped it's a global isn't it. But if you think that's
#bizarre, check this out, use vars is file scoped. Again, how is a
#global file scoped? Perhaps just the variable you declare with our or
#use vars is lexical or file scoped, but the stash entry it creates
lib/App/FetchwareX/HTMLPageSync.pm view on Meta::CPAN
EOA
user_agent => <<EOA,
user_agent, if specified, will be passed to HTML::Tiny, the Perl HTTP library
Fetchware uses, where the library will lie to the Web server you are Web
scraping from to hopefully prevent the Web sever from banning you, or updating
the page you want to scrap to use too much Javascript, which would prevent the
simple parser HTMLPageSync uses from working on the specified html_page_url.
EOA
html_treebuilder_callback => <<EOA,
html_treebuilder_callback allows you to specify a perl CODEREF that HTMLPageSync
will execute instead of its default callback that just looks for images.
It receives one parameter, which is an HTML::Element at the first C<a>,
anchor/link tag.
It must [return 'True';] to indicate that that link should be included in the
list of download links, or return false, [return undef], to indicate that that
link should not be included in the list of download links.
EOA
download_links_callback => <<EOA,
download_links_callback specifies an optional callback that will allow you to do
lib/App/FetchwareX/HTMLPageSync.pm view on Meta::CPAN
the page you want to scrap to use too much Javascript, which would prevent the
simple parser HTMLPageSync uses from working on the specified html_page_url.
EOP
},
html_treebuilder_callback => {
prompt => <<EOP,
What html_treebuilder_callback configuration option would you like?
EOP
print_me => <<EOP,
html_treebuilder_callback allows you to specify a perl CODEREF that HTMLPageSync
will execute instead of its default callback that just looks for images.
It receives one parameter, which is an HTML::Element at the first C<a>,
anchor/link tag.
It must [return 'True';] to indicate that that link should be included in the
list of download links, or return false, [return undef], to indicate that that
link should not be included in the list of download links.
Because Term::UI's imput is limited to just one line, please just press enter,
and a dummy value will go into your Fetchwarefile, where you can then replace
lib/App/FetchwareX/HTMLPageSync.pm view on Meta::CPAN
that you want to download are downloaded to.
=head3 user_agent [OPTIONAL]
This option is optional, and it allows you to have HTML::Tiny pretend to be a
Web browser or perhaps bot if you want to.
=head3 html_treebuilder_callback [OPTIONAL]
This optional option allows you to specify a perl C<CODEREF> that lookup() will
execute instead of its default callback that just looks for images.
It receives one parameter, which is an HTML::Element at the first C<a>,
anchor/link tag.
It must C<return 'True';> to indicate that that link should be included in the
list of download links, or return false, C<return undef>, to indicate that that
link should not be included in the list of download links.
=head3 download_links_callback [OPTIONAL]
( run in 0.339 second using v1.01-cache-2.11-cpan-64827b87656 )