in reply to Re^2: CPANPLUS broken custom sources
in thread CPANPLUS broken custom sources

Just a follow on message to let people know this is resolved, and custom sources works fine as long as you do the following two things:

  1. Use "old style" versions (i.e. $VERSION = "1.50"), which have a "2-digit zero padded minor form". Do not use extended versions (i.e. use version; our $VERSION = qv ("1.5")) as this doesn't seem to work.
  2. Make sure to refresh both the custom sources and update indexes any time there is a change. The non-obvious method (using a side effect of --write) to do this is:
    1. /cs --list
    2. /cs --write /dir
    3. /cs --update 1
    4. x

You can validate that cpanp can "see" your sources by doing "m Your::Package". If this search doesn't find it, then cpanp won't install it.

Custom sources are much easier than the MiniCPAN approach, in my opinion, if you just want to add your own libs.

Replies are listed 'Best First'.
Re^4: CPANPLUS broken custom sources
by ikegami (Patriarch) on Mar 03, 2009 at 05:50 UTC
    Do you realize qv("1.5") means 1.005?
    >perl -le"use version; print qv('1.5')->numify" 1.005000

    And for the numbers in the the grandparent

    >perl -le"use version; print qv('v0.9')->numify" 0.009000 >perl -le"use version; print qv('v0.10')->numify" 0.010000

    The "qv" forms work fine with cpan and CPAN. You just stick to using "qv" or stick to not using "qv". Switching can require a major version change.

Re^4: CPANPLUS broken custom sources
by zerohero (Monk) on Mar 02, 2009 at 22:59 UTC

    Here is a script which automates the cpanp steps to update a custom source dir, which I find tedious and error prone. It assumes that there is a writeable directory (so it can do /cs --write /dir), which is also readable through URI file:///dir. Just Build your .tar.gz files, drop them in your custom source dir, and execute this script prior to running cpanp.

    The script is a little unfinished in places (I didn't complete the part to read from ~/.xxx/config, and so $custom_src_dir is currently hardcoded).

    One thing I think could be better is reload_indices takes a long time. If we could selectively reload the index on a single custom source, this would be very fast.

    cpanp's scriptability is extremely well done. Great API.

    #!/usr/bin/perl
    
    use Getopt::Long;
    use Pod::Usage;
    use Data::Dumper;
    
    use CPANPLUS::Backend;
    
    sub main
    {
        my %options;
    
        GetOptions
            (\%options,
             'help|?',
             'man') or pod2usage (2);
    
        pod2usage (1) if $options{help};
        pod2usage (-exitstatus => 0, -verbose => 2)
            if $options{man};
    
        # TODO - get this from ~/.qws/devel_config custom_src_dir
        # this assumes that we have a custom source that is a file:/// which is also a writeable directory.
    
        my $custom_src_dir = "/Applications/MAMP/svn/deploy";
    
        # TODO - make sure this is an absolute path
    
        # Remove optional end / on $custom_src_dir
    
        if ($custom_src_dir =~ /^(.+)\/$/)
        {
            $custom_src_dir = $1;
        }
    
        my $custom_src_uri = "file://$custom_src_dir";
    
    
        my $cb = new CPANPLUS::Backend ();
    
        my %files = $cb->list_custom_sources ();
    
        my $found = 0;
        while (my ($n, $v) = each %files)
        {
            # match on URI => file:///fn
    
            if ($v =~ /^file:\/\/(.*)$/)
            {
                my $filename = $1;
                $found = 1 if ($filename eq $custom_src_dir);
            }
        }
    
    
        # If we don't have the source, add it.
    
        if ( ! $found)
        {
            # $cb->add_custom_source ($custom_src_uri);
    
            print STDERR "Added custom source '$custom_src_uri' to cpanp " .
                "from your '~/.qws/devel_config' file.\n";
        }
    
        print STDERR "Writing custom source index\n";
    
        my $file = $cb->write_custom_source_index (path => $custom_src_dir);
    
        print STDERR "Updating custom source\n";
    
        my $updated = $cb->update_custom_source (remote => $custom_src_uri);
    
        print STDERR "Reloading indices\n";
    
        my $reloaded = $cb->reload_indices ();
    }