Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.64 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 ~/.bashrc"
  77.   echo "export KDEDIRS=\$KDEDIRS:$instDir" >> ~/.bashrc
  78.   echo "export PATH=\$PATH:$instDir/bin" >> ~/.bashrc
  79. }
  80.  
  81. _build()
  82. {
  83.   echo ":: Building"
  84.   cd $buildDir/$project
  85.   make install -j$numThreads
  86.  
  87.   kbuildsycoca4
  88. }
  89.  
  90. _update()
  91. {
  92.   cd $srcDir/$project
  93.   git pull origin master
  94.  
  95.   cmake $buildDir/$project
  96. }
  97.  
  98. echo ":: This script will help you to configure, compile and install the latest non-stable version of $project."
  99. echo ":: Make sure to remove the stable version of $project before using this script."
  100. if [ -z "$1" ] ; then
  101.   echo ":: If you run this script for the first time run:"
  102.   echo ":: $0 setup"
  103.   echo ":: It will setup the required build-system in $directory. You want it elsewhere? Then edit this script."
  104. elif [ "$1" = "setup" ] ; then
  105.   echo ":: Setting up the buildsystem for $project in $directory."
  106.   _setup
  107.   echo ":: Setup finished! Now run"
  108.   echo ":: $0 build"
  109.   echo ":: to configurate the code. (This will be neccesary to build the stuff.)"
  110. elif [ "$1" = "build" ] ; then
  111.   _build
  112.   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!"
  113.   echo ":: Whenever you need an newer build, type"
  114.   echo ":: $0 update"
  115. elif [ "$1" = "update" ] ; then
  116.   _update
  117.   _build
  118. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement