QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1439|回复: 2

E17自动安装脚本

[复制链接]
发表于 2006-6-3 23:40:50 | 显示全部楼层 |阅读模式
使用方法:
保存成inse17.pl

./inse17,pl --cvs
只进行cvs更新,不编译

./inse17.pl  
自动编译EFL程序源码成deb包 然后自动安装

./inse17.pl  --e17
只编译e17窗口管理器并安装

./inse17.pl  --buildnext
如果你前面已经编译了一部分,现在想继续而不是从头开始编译所有包,那使用这个选项

./inse17.pl --help
查看帮助

由于新的debian 从changelog里面读版本信息,而这个文件每次make distclean时都会删除
所以我根据configure 里面的信息生成新的changelog

最新改正:
2006.6.5 增加buildnext选项
增加examine目录,这个目录被engage依赖

2006.6.4 版本信息从configure文件里面拿

另外debian sid里面编译时会出错,这个问题是因为sid中autoconf有兼容问题引起的
需要安装debian stable里面的autoconf(版本号2.59a-3,,下载地址http://ftp.us.debian.org/debian/pool/main/a/autoconf/autoconf_2.59a-3_all.deb,下载后使用dpkg -i autoconf_2.59a-3_all.deb安装)
然后修改一下/etc/apt/preferences
我的内容如下:
[code:1]
Package: enlightenment
Pin: version 0.16.999*
Pin-Priority: 999

Package: enlightenment-data
Pin: version 0.16.999*
Pin-Priority: 999

Package: autoconf
Pin: version 2.59a-3
Pin-Priority: 999

[/code:1]

inse17.pl的内容:
[code:1]
#!/usr/bin/perl
#
use strict;
use FileHandle;
use Getopt::Long;

my  $versuffix            = "";   #        if you want to special the suffix to all deb package's versions,you can add to here,such as "-0527"

#        cvs server address
my  $cvsserver                = ":pserver:anonymous\@anoncvs.enlightenment.org:/var/cvs/e";

#        if you use make to install,you can set build options
my  $manualinsdir        ="/usr";        #        where install e17 to
my  $manualinscflags        ='CFLAGS="-O3 -mtune=pentium4" '; # compile optimize




my  $usedeb            = 1;    #   if true, will create deb and install deb package,else use "make install" to install
my  $autobuilddir   = 1;    #   if true,then auto build all directory
my  $autobuildsubdir= 1;    #   if true,auto build all packages in a directory
my  $autocvs        = 0;    #   if true, auto download source code from CVS

my  $builde17                = 0;        # if not set, default build all efl program
my  $help                    = 0;
my  $make                    = 0;
my  $confirmdir                = 0;
my  $confirmsubdir        = 0;
my  $buildnext                = 0;
GetOptions(
    'cvs'   =>\$autocvs,
    'e17'   =>\$builde17,
    'help'  =>\$help,
    'make'  =>\$make,
    'deb'   =>\$usedeb,
    'idir'        =>\$confirmdir,
    'isubdir'        =>\$confirmsubdir,
    'buildnext'        =>\$buildnext
);
usage()  if($help);
$usedeb        = 0 if($make);
$autobuilddir        = 0 if($confirmdir);
$autobuildsubdir        = 0 if($confirmsubdir);

my @e17objs =(
    ['e17/libs','../..',
    'eet',
    'evas',
    'ecore',
    'embryo',
    'edje'
    ],
    ['e17/apps','../..',
    'e'
    ],
);
my @eflobjs =(
    ['e17/libs','../..',
    'eet',
    'edb',
    'evas',
    'ecore',
    'embryo',
    'imlib2',
    'edje',
    'epeg',
    'epsilon',
    'esmart',
    'emotion',#        (note that you'll need to have xine-lib installed as emotion uses it)
    'engrave',#        (this is currently needed for e_utils only)
    'ewl'        #        (this is needed for some apps only)
    ],
    ['e17/proto','../..',
    'etk'         #        (this is needed for some apps only)
    ],
    ['e17/apps','../..',
    'e',
    'entice',        #         (image viewer)
    'entrance',#         (login manager)
    'eclair',        #         (media player)
    'elicit',         #         (color picker/screen magnifier)
    'examine'
    ],
    ['misc','..',
    'engage',        #         (standalone dockbar and E17 module)
    'erss',        #         (RSS feed application that does not work correctly in E17)
    'embrace' #         (mail checker and E17 module)
    ],
    ['misc','..',
    'entropy',#         (file manager)
    'exhibit'        #         (image viwer)
    ],
);

my  $fd_build             = new FileHandle ">build.log";
my  $fd_screen          = new FileHandle ">screen.log";
my  $useobjs                = \@eflobjs;
$useobjs                = \@e17objs if( $builde17 );

print        "\nthe script output will redefine to\n\tbuild.log\n,the screen output will redefine to \n\tscreen.log\nif you want to check fail reason, please open these two files\n";

if($autocvs){
    get_cvs_dirs(@$useobjs);
    die;
}

check_debbuildenv();    # if you don't want to build deb package, comment this line
do_install(@$useobjs);

close($fd_build);
close($fd_screen);



sub usage{
print   "inse17.pl options:\n";
print   "\t--cvs        only do cvs update,then exit\n";
print   "\t--e17        only build E17 windows manager,default will build all EFL program\n";
print   "\t--make        use \"$manualinscflags autogen.sh --prefix=$manualinsdir;make;make install\" to build and install the E17\n";
print   "\t--deb        build deb pkg then install\n";
print   "\t--idir        when build every big dir,make sure first\n";
print   "\t--isubdir        when build every sub dir,make sure first\n";
print   "\t--buildnext        if you want to skip the first build dir,use this options\n";
print   "\t--help        show help file\n";
print   "default is --deb\nif you want to sepcial build packages,you can edit \@eflobjs array\n";
die;
}

sub do_install(){
    my @compileobjs = @_;
    log_screen("\n\nstart build debian packages\n\n");
    my $objs;
    foreach $objs (@compileobjs){
        my   @objarray   = @$objs;
        my   $dir       = shift(@objarray);
        my   $back_dir   = shift(@objarray);
        if( ! -d $dir ){
            log_screen("dir:$dir not exist,will skip compile it\n");
            next;
        }
        next if( ((!$autobuilddir) || $buildnext )
            && (!choseact("are you want to build dir:$dir\n")) );

        log_screen("start parse:<<<<<   $dir  >>>>>: back:$back_dir\n");
        chdir $dir;
        system('rm -f *.deb *.dsc *.tar.gz *.changes');

        my   $subdir;
        foreach $subdir (@objarray){
            if( !(-d $subdir) ){
                log_screen("dir:$subdir not exist,skip compile it\n");
                next;
            }
            chdir($subdir);
            while( parsedir($subdir) ){}
            $fd_build->autoflush(1);
            log_screen("\n");
            chdir("../");
            system('rm -f *.dsc *.tar.gz *.changes');
        }
        chdir $back_dir;
    }
}




sub parsedir()
{
    my $pkg   = $_[0];
    log_screen("\n\nenter directory:".$pkg."\n");
    if( ((!$autobuildsubdir) || $buildnext)
        && (!choseact("are you want to build:$pkg\n")) ){
        return 0;
    }

    $buildnext  = 0;

    my $curpwd   = qx(pwd);
    chomp($curpwd);

    $fd_build->autoflush(0);
    log_screen("\tcur dir is:\n\t$curpwd\n");

    chmod 755,'debian/rules' if(! -x 'debian/rules');
    chmod 755,'autogen.sh' if(! -x 'autogen.sh');

    if(!$usedeb){
#if you don't use deb,then will call these line
        system("make distclean >/dev/null 2>&1");
        run_cmd($manualinscflags.'./autogen.sh --prefix='.$manualinsdir);
        run_cmd('make');
        run_cmd('make uninstall');
        run_cmd('make install');
        return ;
    }


    run_cmd($manualinscflags."./autogen.sh --prefix=/usr",1);

    system("make distclean >/dev/null 2>&1");
    mk_changelog();
    log_screen("\trun:   dpkg-buildpackage -us -uc -rfakeroot 2>&1\n");
    open(MAKEFI,"dpkg-buildpackage -us -uc -rfakeroot 2>&1|") || die "exec fail\n";
    log_screen( 'dpkg-buildpackage -us -uc -rfakeroot 2>&1'."\n");

    my @pkgs;
    my $line;
    while($line=<MAKEFI>){
        my $notlog   = 1;
        if($line=~m/\berror\b/i){
            if($line!~m/dpkg-genchanges:\s+error:\s+cannot\s+open\s+\.dsc/
                && $line!~m/\(ignored\)/ ){
                $notlog = 0;
                log_screen($line);
            }
        }
        log_build( $line) if($notlog);

        if($line=~m/\bUnmet\s+build\s+dependencies\b/i){
            log_screen($line);
            log_screen("are you want to install missing dependence then rebuild this package or skip build this package\n");
            log_screen("if the dependence is refer to a deprecate package,you can edit $curpwd/debian/control file to remove or modify the dependence\n");
            log_screen("press n to skip,else you press 'Y' after finish install missing packages\n");
            return choseact("") ;
        }
        next if($line!~m/dpkg-deb:\s+building\s+package\s+\`([^']+)\'\s+in\s+\`([^']+)\'/);

        log_screen("\tpkg:[$1:\t$2]\n");
        push(@pkgs,$2) if( $2!~m/debug/);
    }
    close(MAKEFI);

    my $pkgfile = join(" ",@pkgs);
    chomp($pkgfile);
    if( $pkgfile ){
        run_cmd("dpkg -i $pkgfile");
    }
    else{
        log_screen("error no package found,build message is write to build.log file\n");
    }

    log_screen("\n");
    return 0;
}





#
#   choose user select
#
sub choseact()
{
    log_screen( $_[0]."\nplease input yes or no [Y]\n");
    my $in=<STDIN>;
    if($in=~m/n/i){
        log_screen( "cancel\n");
        return 0;
    }
    log_screen( "\n");
    return 1;
}


#
#   downlaod E17 source code from CVS
#
sub get_cvs_dirs()
{
    my @dirs = @_;
    log_screen("\n\nstart get CVS sourcecode\n\n");
    log_screen("cvs -d$cvsserver login\n");
    system("cvs -d$cvsserver login");
    log_screen('check out E17:'."\n");
    my $objs;
    foreach $objs (@dirs){
        my   @objarray   = @$objs;
        my   $dir       = shift(@objarray);
        shift(@objarray);

        log_screen("start checkout:<<<<<   $dir  >>>>>\n");

        my   $subdir;
        foreach $subdir (@objarray){
            run_cmd("cvs -z3 -d$cvsserver co $dir/$subdir",1);
        }
    }
}


#
#   check debian build env
#
sub check_debbuildenv()
{
    my @pkglist = qx(dpkg --get-selections);
    my $lines   = join(':',@pkglist);

    check_pkg($lines,"autoconf",1);
    check_pkg($lines,"automake",1,"(version >=1.7)");
    check_pkg($lines,"libtool",1);
    check_pkg($lines,"pkg-config",1);

    if($usedeb){
        check_pkg($lines,"fakeroot",1);
        check_pkg($lines,"dpkg-dev",1);
    }

    check_pkg($lines,"libxcursor-dev",0,"(it may need by ecore,if link ecore fail, please install it)");

    log_screen("if you use xorg and the build script report xlibs-dev not install, you need to modify the {directory}/debian/control file, replace xlibs-dev with xorg-dev\n");
}
sub check_pkg()
{
    my  ($pkglists,$pkgname,$exitmode,$version)=@_;
    my  $exit   = 0;
    $exit       = 1 if( $pkglists!~m/\b$pkgname[^:]*\s+install/);
    if( $exit ){
        log_screen("WARNNING: ") if(! $exitmode );
        log_screen("you don't install $pkgname, please use \n\tapt-get install $pkgname\n to install it.$version \n");
        die if( $exitmode );
    }
}







#
#   run a command,and log command output to screen.log
#
sub run_cmd()
{
    my ($cmd,$hide)   = @_;
    my $fd;
    open($fd,"$cmd 2>&1 |");
    log_screen("\trun:\t$cmd\n");
    if( ! $fd ){
        log_screen("\trun $cmd fail,check build.log to look the fail\n");
        die;
    }
    my $line;
    while($line=<$fd>){
        if($hide){
            log_build($line);
        }
        else{
            log_screen($line);
        }
    }
}




sub mk_changelog()
{
    my        $fcontrl;
    open($fcontrl,"configure");
    if( ! $fcontrl ){
        log_screen("open configure to read version info fails\n");
        return ;
    }

    my        $line;
    my        $ver;
    my        $stat        = 0;
    while($line=<$fcontrl>){
        if($line=~m/^\s*PACKAGE=\s*/){
            $stat   = 1;
            next;
        }

        if($stat == 1 ){
            if( $line=~m/^\s*VERSION\s*=\s*(\w.*)/i){
                $ver        = $1;
                chomp($ver);
                last;
            }
            $stat   = 0;
        }
    }

    close($fcontrl);
    if(!$ver){
        log_screen("get version fail\n");
        return ;
    }
    log_screen("\tversion number is:$ver\n");

    my        $fi;
    my        $fo;
    open($fi,"debian/changelog.in");
    open($fo,">debian/changelog");

    $line   = <$fi>;

    $line   =~s/\@VERSION\@/$ver$versuffix/;
    print   $fo $line;
    while($line=<$fi>){
        print        $fo $line;
    }
    close($fi);
    close($fo);
}






#
#   log screen output
#
sub log_screen()
{
    print   @_;
    print   $fd_screen @_;
    log_build(@_);
}

#
#   log build result to build.log
#
sub log_build()
{
    print   $fd_build @_;
}
[/code:1]
 楼主| 发表于 2006-6-3 23:44:11 | 显示全部楼层
最新debian E17编译时可能会发现下面的问题(ewl或是e中)

/tmp/edje_cc.sma-tmp-mFRfql(1) : fatal error 100: cannot read from file: "edje"

这个根据shadoi的解释是autoconf的版本问题,把它降到2.59a-9然后再做build应该就可以

Submitted by shadoi on Mon, 2006-05-22 05:08.

I investigated this. The problem is the new autoconf version 2.59.cvs.2006.05.13-1. Downgrade to 2.59a-9 and rebuild, it will fix it.
reply | quote | not spam
回复

使用道具 举报

 楼主| 发表于 2006-6-4 22:53:51 | 显示全部楼层
更新
并且编译最新源码通过
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-22 18:41 , Processed in 0.082393 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表