All pastes #1948631 Raw Edit

argonel

public text v1 · immutable
#1948631 ·published 2010-09-26 04:49 UTC
rendered paste body
#! /usr/bin/perl{    use Term::ANSIColor;    use Getopt::Long;    GetOptions(        'clean',        'no-svn',        'no-configure',        'no-make',        'branch:s',        'help' );    print( "--- oxygen easy setup script\n" );    ###########################################    if($opt_help)    {        usage();        exit(0);    }    ###########################################    if($opt_clean)    {        do_clean();        exit(0);    }    print( "\n" );    my $work_dir = `pwd`;    chop($work_dir);    my $build_dir= "$work_dir/build";    ###########################################    if( !$opt_no_svn )    {        print( "--- checking out source code\n" );        my $repository="svn://anonsvn.kde.org";        #my $repository="svn+ssh://hpereiradacosta\@svn.kde.org";        my $base_directory="home/kde/trunk/KDE";        if( $opt_branch )        { $base_directory="home/kde/branches/KDE/$opt_branch/"; }        ### common        chdir_and_echo( $work_dir );        print( "---  common\n" );        if( -d "common" )        {            cmd_and_echo( "svn update common" );        } else {            cmd_and_echo( "svn co $repository/$base_directory/kdebase/workspace/libs/oxygen" );            cmd_and_echo( "mv oxygen common" );        }        print( "\n" );        ### decoration        print( "---  decoration\n" );        if( -d "decoration" )        {            cmd_and_echo( "svn update decoration" );        } else {            cmd_and_echo( "svn co $repository/$base_directory/kdebase/workspace/kwin/clients/oxygen" );            cmd_and_echo( "mv oxygen decoration" );        }        print( "\n" );        ### style        print( "---  style\n" );        if( -d "style" )        {            cmd_and_echo( "svn update style" );        } else {            cmd_and_echo( "svn co $repository/$base_directory/kdebase/workspace/kstyles/oxygen" );            cmd_and_echo( "mv oxygen style" );        }        print( "\n" );    }    ###########################################    if( !$opt_no_configure )    {        print( "--- creating CMakeLists.txt\n" );        chdir_and_echo( $work_dir );        open( FILE, ">CMakeLists.txt" );        print FILE ( "find_package (KDE4 REQUIRED)\n" );        print FILE ( "add_definitions (-DQT3_SUPPORT -DQT3_SUPPORT_WARNINGS)\n" );        print FILE ( "include (KDE4Defaults)\n" );        print FILE ( "include (MacroLibrary)\n" );        print FILE ( "add_definitions (\${QT_DEFINITIONS} \${KDE4_DEFINITIONS})\n" );        print FILE ( "include_directories (\${KDE4_INCLUDES} \${CMAKE_BINARY_DIR})\n" );        print FILE ( "include_directories( common )\n" );        print FILE ( "add_subdirectory( common )\n" );        print FILE ( "add_subdirectory( decoration )\n" );        print FILE ( "add_subdirectory( style )\n" );        close FILE;        print( "\n" );        print( "--- running cmake\n" );        chdir_and_echo( "$build_dir" );        cmd_and_echo( "cmake -DCMAKE_INSTALL_PREFIX=\`kde4-config --prefix\` -DCMAKE_BUILD_TYPE=release $work_dir" );        chdir_and_echo( "$work_dir" );        print( "\n" );    }    ###########################################    if( !$opt_no_make )    {        print( "--- compiling\n" );        chdir_and_echo( "$build_dir" );        cmd_and_echo( "make" );        chdir_and_echo( "$work_dir" );        print( "--- done\n" );        print( "\n" );    }    print( "type \"" );    print colored ['cyan'], 'cd build; make install';    print( "\" (as root, or using sudo) to install.\n" );    print( "report problems to \"hugo\@oxygen-icons.org\".\n" );}############################################ clean everythingsub do_clean{    print( "--- cleaning.\n" );    ### directories    my @dirs = (        "oxygen",        "common",        "style",        "decoration",        "CMakeFiles",        "CMakeTmp",        "lib" );    foreach $dir (@dirs)    { if( -d "$dir" ) { cmd_and_echo( "rm -rf $dir" ); } }    ### files    my @files = (        "CMakeCache.txt",        "cmake_install.cmake",        "CMakeLists.txt",        "cmake_uninstall.cmake",        "CTestTestfile.cmake",        "install_manifest.txt",        "Makefile" );    foreach $file (@files)    { if( -e "$file" ) { cmd_and_echo( "rm -f $file" ); } }    print( "--- done.\n" );    print( "report problems to \"hugo\@oxygen-icons.org\".\n" );}############################################ run command and logsub cmd_and_echo{  print( "$_[0]\n" );  goto END if &doSystemFail("$_[0]");}############################################ create directory and logsub mkdir_and_echo{    if( ! -d $_[0] ) { cmd_and_echo( "mkdir -p $_[0]" ) };}############################################ change directory and logsub chdir_and_echo{    mkdir_and_echo( "$_[0]" );    print("cd $_[0]\n");    chdir "$_[0]";}############################################ run command and check command returnsub doSystemFail{  my $arg = shift(@_) . ">&1";  my $status = system($arg);  if ($status)  { print( "system $arg failed: $?\n" ); }  return $status;}############################################ usagesub usage{    print( "usage: oxygen-setup.pl [options]\n");    print( "\n");    print( "oxygen-setup.pl checks out the relevant oxygen code from svn; configures it and compiles it.\n");    print( "installation is left to the user as it usually requires root privileges.\n" );    print( "\n");    print( "where options are one or several of the following:\n");    print( "  --no-svn              do not check-out and/or update the code from svn\n" );    print( "  --no-configure        do not generate CMakeLists.txt nor attempt to configure the compilation\n");    print( "  --no-make             do not attempt to compile the code\n");    print( "  --clean               removes everything for a fresh setup\n" );    print( "  --help                display this help and exit\n");    print( "  --branch=BRANCH       use given BRANCH to fetch sources. Default is trunk\n" );    goto END;}END: {}