mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2011-11-05 09:17 pm

[dw-free] Allow local package installation

[commit: http://hg.dwscoalition.org/dw-free/rev/c73da7d459cd]

Allow local package installation

This is mostly for my development environment. It allows the usage of cpanm
(http://cpanmin.us/) to install packages locally as the dw user. These
packages are installed in $LJHOME/extlib/ by convention.

I'm testing this out and seeing if it's a good plan for production or not.
It might be interesting because then we can just push the extlib directory
out, possibly? I'll experiment with it.

Patch by [staff profile] mark.

Files modified:
  • bin/checkconfig.pl
  • bin/upgrading/update-db.pl
  • cgi-bin/ljlib.pl
  • cgi-bin/modperl.pl
--------------------------------------------------------------------------------
diff -r da2a8b8b1814 -r c73da7d459cd bin/checkconfig.pl
--- a/bin/checkconfig.pl	Fri Nov 04 20:59:36 2011 +0800
+++ b/bin/checkconfig.pl	Sat Nov 05 21:18:36 2011 +0000
@@ -18,7 +18,7 @@
 use Getopt::Long;
 
 my $debs_only = 0;
-my ($only_check, $no_check, $opt_nolocal);
+my ($only_check, $no_check, $opt_nolocal, $opt_cpanm);
 
 my %dochecks;   # these are the ones we'll actually do
 my @checks = (  # put these in the order they should be checked in
@@ -33,6 +33,7 @@
     die "Usage: checkconfig.pl
 checkconfig.pl --needed-debs
 checkconfig.pl --only=<check> | --no=<check>
+checkconfig.pl --cpanm
 
 Checks are:
  " . join(', ', @checks);
@@ -43,6 +44,7 @@
                           'only=s'      => \$only_check,
                           'no=s'        => \$no_check,
                           'nolocal'     => \$opt_nolocal,
+                          'cpanm'       => \$opt_cpanm,
                           );
 
 if ($debs_only) {
@@ -69,11 +71,18 @@
     die "\nProblem:\n" . join('', map { "  * $_\n" } @_);
 };
 
+# base packages we need installed
+my @packages = ('apache2-mpm-prefork');
+
+# packages we need if we're building from source (using cpanm)
+my @cpanm_packages = ('libexpat1-dev', 'g++', 'make', 'libgtop2-dev', 'libgmp3-dev',
+        'libxml2-dev');
+
 my %modules = (
                "Date::Parse" => { 'deb' => 'libtimedate-perl' },
                "DateTime" => { 'deb' => 'libdatetime-perl' },
-               "DBI" => { 'deb' => 'libdbi-perl',  },
-               "DBD::mysql" => { 'deb' => 'libdbd-mysql-perl', },
+               "DBI" => { 'deb' => 'libdbi-perl', 'system' => 1, },
+               "DBD::mysql" => { 'deb' => 'libdbd-mysql-perl', 'system' => 1, },
                "Class::Autouse" => { 'deb' => 'libclass-autouse-perl', },
                "Digest::MD5" => { 'deb' => 'libmd5-perl', },
                "Digest::SHA1" => { 'deb' => 'libdigest-sha1-perl', },
@@ -95,10 +104,11 @@
                "HTML::Parser" => { 'deb' => 'libhtml-parser-perl', },
                "LWP::Simple" => { 'deb' => 'libwww-perl', },
                "LWP::UserAgent" => { 'deb' => 'libwww-perl', },
-               "GD" => { 'deb' => 'libgd-gd2-perl' },
+               "GD" => { 'deb' => 'libgd-gd2-perl', 'system' => 1, },
                "GD::Graph" => {
                    'deb' => 'libgd-graph-perl',
                    'opt' => 'Required for making graphs for the statistics page.',
+                   'system' => 1,
                },
                "Mail::Address" => { 'deb' => 'libmailtools-perl', },
                "Proc::ProcessTable" => {
@@ -155,6 +165,7 @@
                "Image::Magick" => {
                    'deb' => 'perlmagick',
                    'opt' => "Required for the userpic factory.",
+                   'system' => 1,
                },
                "Class::Accessor" => {
                    'deb' => 'libclass-accessor-perl',
@@ -187,10 +198,12 @@
                "Apache2::RequestRec"   => {
                    'deb' => "libapache2-mod-perl2",
                    'opt' => "Required for modperl2",
+                   'system' => 1, # don't cpanm this
                },
                "Apache2::Request"      => {
                    'deb' => "libapache2-request-perl",
                    'opt' => "Required for Apache2",
+                   'system' => 1, # don't cpanm this
                },
                "Test::More" => {
                    'deb' => "libtest-simple-perl",
@@ -208,6 +221,9 @@
                    'opt' => "Required for taking credit/debit cards in the shop.",
                },
                "Hash::MultiValue" => {},
+               "Sys::Syscall" => { dev => 'libsys-syscall-perl' },
+               "Danga::Socket" => { dev => 'libdanga-socket-perl' },
+               "IO::AIO" => { dev => 'libio-aoi-perl' },
               );
 
 
@@ -215,7 +231,7 @@
     print "[Checking for Perl Modules....]\n"
         unless $debs_only;
 
-    my @debs;
+    my (@debs, @mods);
 
     foreach my $mod (sort keys %modules) {
         my $rv = eval "use $mod;";
@@ -228,7 +244,12 @@
                     push @errors, "Missing perl module: $mod";
                 }
             }
-            push @debs, $dt->{'deb'} if $dt->{'deb'};
+            if ($opt_cpanm) {
+                push @debs, $dt->{'deb'} if $dt->{'deb'} && $dt->{'system'};
+                push @mods, $mod;
+            } else {
+                push @debs, $dt->{'deb'} if $dt->{'deb'};
+            }
             next;
         }
 
@@ -265,6 +286,10 @@
             print STDERR "\n# apt-get install ", join(' ', @debs), "\n\n";
         }
     }
+    if (@mods) {
+        print "\n# curl -L http://cpanmin.us | sudo perl - --self-upgrade\n";
+        print "# cpanm -L \$LJHOME/extlib/ " . join(' ', @mods) . "\n\n";
+    }
 
     $err->(@errors);
 }
diff -r da2a8b8b1814 -r c73da7d459cd bin/upgrading/update-db.pl
--- a/bin/upgrading/update-db.pl	Fri Nov 04 20:59:36 2011 +0800
+++ b/bin/upgrading/update-db.pl	Sat Nov 05 21:18:36 2011 +0000
@@ -18,12 +18,12 @@
 use strict;
 use lib "$ENV{LJHOME}/cgi-bin";
 
+BEGIN { require "ljlib.pl"; }
 use Getopt::Long;
 use File::Path ();
 use File::Basename ();
 use File::Copy ();
 use Image::Size ();
-BEGIN { require "ljlib.pl"; }
 use LJ::S2;
 use MogileFS::Admin;
 
diff -r da2a8b8b1814 -r c73da7d459cd cgi-bin/ljlib.pl
--- a/cgi-bin/ljlib.pl	Fri Nov 04 20:59:36 2011 +0800
+++ b/cgi-bin/ljlib.pl	Sat Nov 05 21:18:36 2011 +0000
@@ -31,6 +31,7 @@
 # now that the library is setup, we can start pulling things in.  start with
 # the configuration library we need.
 use lib "$LJ::HOME/cgi-bin";
+use lib "$LJ::HOME/extlib/lib/perl5";
 use LJ::Config;
 
 BEGIN {
diff -r da2a8b8b1814 -r c73da7d459cd cgi-bin/modperl.pl
--- a/cgi-bin/modperl.pl	Fri Nov 04 20:59:36 2011 +0800
+++ b/cgi-bin/modperl.pl	Sat Nov 05 21:18:36 2011 +0000
@@ -18,6 +18,7 @@
 
 use strict;
 use lib "$ENV{LJHOME}/cgi-bin";
+use lib "$ENV{LJHOME}/extlib/lib/perl5";
 
 # very important that this is done early!  everything else in the LJ
 # setup relies on $LJ::HOME being set...
--------------------------------------------------------------------------------
pauamma: Cartooney crab wearing hot pink and acid green facemask holding drink with straw (Default)

[personal profile] pauamma 2011-11-06 02:58 pm (UTC)(link)
Does anything in the installation and maintenance documentation need to change following that?
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)

[personal profile] afuna 2011-11-11 04:18 am (UTC)(link)
Hmm, interesting. Looking forward to see where this goes.

One question: + "Sys::Syscall" => { dev => 'libsys-syscall-perl' },


deliberate as dev, or should it be deb? I can tweak if it's a typo.
fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)

[personal profile] fu 2011-11-11 08:18 am (UTC)(link)