[原]用perl写了个自动配置脚本
Posted by bianbian on 2007-04-08 11:26
经常要安装各种包,而且每个包的configure参数千差万别;而且以后升级版本或者换个机器装的话又记不得加哪些参数,实在不方便。于是写了个自动配置的脚本。
升级包的版本的时候要把旧版本的目录删除。
我自己用觉得很方便,主要是为了记录configure的参数,省得用到的时候又得找。
配置:
在@list里面第1行写好包的前缀名(省去版本,能grep出唯一结果即可);紧接一行是configure的参数
使用:
./autoConfigure.pl <参数>
<参数>:make(每个目录调用make);install(每个目录调用make install);其他(每个目录configure)
第二次用perl,写得烂不要见效。
- #!/usr/bin/perl
- # AutoConfigure
- # first line: name to match, like nginx-
- # second line: configure parameters
- @list = (
- "nginx-",
- "--prefix=/home/nginx --without-http_browser_module"
- ,
- "fcgi-",
- "--prefix=/usr"
- );
- # -------- below need not to modify --------
- for($i=0; $i < @list; $i += 2) {
- $cmd = "ls -d */ | grep \"$list[$i]\" |";
- open (PIPE, $cmd);
- @out = <PIPE>;
- chomp($out[0]); #chop \n
- $cmd = "cd " . $out[0] . "; ";
- if ($ARGV[0] eq "make") {
- $cmd .= "make";
- } elsif ($ARGV[0] eq "install") {
- $cmd .= "make install";
- } else {
- $cmd .= "./configure " . $list[$i + 1];
- }
- close PIPE;
- $cmd .= "; cd ..";
- system($cmd);
- }
遵守创作共用协议,转载请链接形式注明来自http://bianbian.org 做人要厚道