[Perl] install lib v1.0

作者:reistlin 发布时间:February 22, 2011 分类:原创文章

作者: reistlin
来源: http://www.reistlin.com/blog/172
更新时间: 2011.02
版权声明: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要

perl.gif

googlecode1.gifgooglecode2.gif
[https://reistlin.googlecode.com/svn/trunk/perl/install_lib.pl/]

#!/usr/bin/perl
 
# name: install_lib v1.0
# author: reistlin
# website: www.reistlin.com
# date: 2011.02.22
 
use strict;
use Data::Dumper;
use Time::Local;
 
# debug switch
my $debug = 0;
 
 
####################
# Configuration
####################
 
# download website
my $download = "http://www.reistlin.com/download/linux";
# home
my $home = $ENV{''HOME''};
# prefix
my $prefix = "$home/lib";
# pkgs
my $pkgs = "$home/pkgs";
# build
my $build = "$pkgs/build";
# core
my $core = "4";
 
 
####################
# Library Packages
####################
 
my %lib = (
	curl => "curl-7.20.1.tar.gz",
	freetype => "freetype-2.4.4.tar.gz",
	gd => "gd-2.0.35.tar.gz",
	gettext => "gettext-0.18.1.1.tar.gz",
	jpeg => "jpeg-8c.tar.gz",
	libevent => "libevent-1.4.14b-stable.tar.gz",
	libiconv => "libiconv-1.13.1.tar.gz",
	libmcrypt => "libmcrypt-2.5.7.tar.gz",
	libpng => "libpng-1.4.4.tar.gz",
	libxml2 => "libxml2-2.7.8.tar.gz",
	mhash => "mhash-0.9.9.9.tar.bz2",
	pcre => "pcre-8.10.tar.gz",
	zlib => "zlib-1.2.5.tar.gz"
);
 
 
####################
# Initialization
####################
 
if ( ! -e $prefix ) {
	system "mkdir -p $prefix";
}
if ( ! -e $pkgs ) {
        system "mkdir -p $pkgs";
}
if ( ! -e $build ) {
        system "mkdir -p $build";
}
 
 
####################
# Function
####################
 
sub install {
        my %hash = @_;
        while ( my ($key, $value) = each %hash ) {
                $value =~ m/^([a-zA-Z]+)(.+)(\.tar\.gz|\.tar\.bz2)$/;
 
		print "\n";
		print "*** INSTALL [$value] ***\n";
		print "\n";
 
		if ( ! -e "$pkgs/$value" ) {
			system "wget -P $pkgs $download/$value";
		} else {
			print "[INFO] [$value] already exists in the local\n";
		}
 
		if ( $3 eq "\.tar\.gz" ) {
			system "tar zxvf $pkgs/$value -C $build";
		} elsif ( $3 eq "\.tar\.bz2" ) {
			system "tar jxvf $pkgs/$value -C $build";
		} else {
			print "[ERROR] unknown compression file [$value]\n";
			next;
		}
 
		# change directory
		chdir "$build/$1$2/";
 
		system "./configure --prefix=$prefix/$1$2";
		system "make -j $core";
		system "make install";
		system "ln -s $prefix/$1$2 $prefix/$1";
 
		print "\n";
		print "*** END ***\n";
		print "\n";
        }
}
 
####################
# Main Program
####################
 
&install(%lib);

标签: perl

评论已关闭