Advertisement
Guest User

Untitled

a guest
Feb 21st, 2011
433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.69 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Where to do all the stuff, should be changed to needs
  4. directory=$HOME/Buildsystem
  5.  
  6. # The other options usually don't need to be changed.
  7.   srcDir=$directory/src
  8.  instDir=$directory/inst
  9. buildDir=$directory/build
  10.  
  11.      makeKrita=on
  12.     makeKarbon=off
  13.      makeWords=off
  14.     makeTables=off
  15.      makeStage=off
  16. makeKThesaurus=off
  17.       makeKexi=off
  18.       makePlan=off
  19.       makeFlow=off
  20.  makeBraindump=off
  21.  
  22. numCores=$((`cat /proc/cpuinfo | grep processor | wc -l`))
  23. # Number of cores² works best almost always.
  24. numThreads=$(($numCores*$numCores))
  25.  
  26. packageManager=
  27. if command -v apt-get &>/dev/null ; then
  28.   packageManager=aptget
  29. elif command -v zypper &>/dev/null ; then
  30.   packageManager=zypper
  31. else
  32.   echo ":: This script has currently only support for dependency installation on openSUSE and relatives of Debian. You'll need to install the dependencies yourself."
  33. fi
  34.  
  35. project=calligra
  36. gitRepo=git://anongit.kde.org/$project
  37. CMakeParameters="-DBUILD_words=$makeWords -DBUILD_tables=$makeTables -DBUILD_stage=$makeStage  -DBUILD_kthesaurus=$makeKThesaurus -DBUILD_kexi=$makeKexi  -DBUILD_plan=$makePlan -DBUILD_flow=$makeFlow -DBUILD_braindump=$makeBraindump -DBUILD_krita=$makeKrita -DBUILD_karbon=$makeKarbon -DBUILD_koconverter=off -DCMAKE_INSTALL_PREFIX=$instDir -DBUILD_cstester=OFF -DBUILD_koabstraction=OFF -DBUILD_f-office=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo"
  38.  
  39. _install_dependencies_zypper()
  40. {
  41.   sudo zypper install git
  42.   sudo zypper si -d koffice2 calligra
  43. }
  44.  
  45. _install_dependencies_aptget()
  46. {
  47.   sudo apt-get install git
  48.   sudo apt-get build-dep koffice2 calligra
  49. }
  50.  
  51. _configure()
  52. {
  53.   echo ":: Configurating"
  54.   cd $buildDir/$project
  55.   cmake $srcDir/$project $CMakeParameters
  56. }
  57.  
  58. _setup()
  59. {
  60.   mkdir -p $srcDir/$project
  61.   mkdir -p $buildDir/$project
  62.   mkdir -p $instDir/bin
  63.   cd $srcDir
  64.   echo ":: Starting cloning machine... The source code will be cloned from $gitRepo."
  65.   git clone $gitRepo $project
  66.  
  67.   if [ -z "$packageManager" ] ; then
  68.     echo ":: Skipping installation of building dependencies, unknown package manager. You will need to do this step manually."
  69.   else
  70.     echo ":: Installing packages required for building, you may be asked for your password. (Maybe even twice.)"
  71.     _install_dependencies_$packageManager
  72.   fi
  73.  
  74.   _configure
  75.  
  76.   echo ":: Add newly created paths to ~/.profile"
  77.   echo "# Automatically added by $0" >> ~/.profile
  78.   echo "export KDEDIRS=\$KDEDIRS:$instDir" >> ~/.profile
  79.   echo "export PATH=\$PATH:$instDir/bin" >> ~/.profile
  80. }
  81.  
  82. _build()
  83. {
  84.   echo ":: Building"
  85.   cd $buildDir/$project
  86.   make install -j$numThreads
  87.  
  88.   kbuildsycoca4
  89. }
  90.  
  91. _update()
  92. {
  93.   cd $srcDir/$project
  94.   git pull origin master
  95.  
  96.   cmake $buildDir/$project
  97. }
  98.  
  99. echo ":: This script will help you to configure, compile and install the latest non-stable version of $project."
  100. echo ":: Make sure to remove the stable version of $project before using this script."
  101. if [ -z "$1" ] ; then
  102.   echo ":: If you run this script for the first time run:"
  103.   echo ":: $0 setup"
  104.   echo ":: It will setup the required build-system in $directory. You want it elsewhere? Then edit this script."
  105. elif [ "$1" = "setup" ] ; then
  106.   echo ":: Setting up the buildsystem for $project in $directory."
  107.   _setup
  108.   echo ":: Setup finished! Now run"
  109.   echo ":: $0 build"
  110.   echo ":: to configurate the code. (This will be neccesary to build the stuff.)"
  111. elif [ "$1" = "build" ] ; then
  112.   _build
  113.   echo ":: Now you can simply run the newest versions of the applications by typing the name of it in the konsole. It will also show up in your KMenu, awesome!"
  114.   echo ":: Whenever you need an newer build, type"
  115.   echo ":: $0 update"
  116. elif [ "$1" = "update" ] ; then
  117.   _update
  118.   _build
  119. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement