Guest User

gimp-razor-custom-release-20130604

a guest
Jun 4th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.78 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Copyright (C) 2010 Stéphane Robert Richard.
  4. # All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions
  8. # are met:
  9. # 1. Redistributions of source code must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. # 2. Redistributions in binary form must reproduce the above copyright
  12. # notice, this list of conditions and the following disclaimer in the
  13. # documentation and/or other materials provided with the distribution.
  14. # 3. Neither the name of the project nor the names of its contributors
  15. # may be used to endorse or promote products derived from this software
  16. # without specific prior written permission.
  17. #
  18. # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  19. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
  22. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24. # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27. # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. # SUCH DAMAGE.
  29.  
  30.  
  31. ###
  32. ## readonly vars
  33.  
  34. pushd $(dirname $(readlink -f "$BASH_SOURCE")) > /dev/null
  35. readonly script_dir="$PWD"
  36. popd > /dev/null
  37.  
  38. readonly script_name=$(basename $0)
  39. build_id="$(date +'%Y-%m-%d-%H-%M-%S')"
  40.  
  41. ##
  42. ###
  43.  
  44.  
  45. ###
  46. ## Configuration: Here you have the oportunity, expected that you know what you're doing, to tweak the configuration to suit your needs.
  47.  
  48. # Where do you want your out of disto softwares to be installed?
  49. # If you want to put them in /opt or /usr/local,
  50. # you may need to change this script in order to call sudo before make install
  51. # or to run this script as root, neither of the two ideas being very bright...
  52. opt_dir="$HOME/opt"
  53.  
  54. # Where should we retrieve and look for git repositories?
  55. src_dir="$HOME/src/git"
  56.  
  57. # Where do you want your razor sharp gimp to be installed?
  58. gimp_install_dir="$opt_dir/gimp/build_$build_id"
  59.  
  60. # Sources directories for gimp, babl and gegl
  61. gimp_src_dir="$src_dir/gimp"
  62. babl_src_dir="$src_dir/babl"
  63. gegl_src_dir="$src_dir/gegl"
  64. cairo_src_dir="$src_dir/cairo"
  65. glib_src_dir="$src_dir/glib"
  66.  
  67. # How many processor to use for compilation. The default below will use them all.
  68. processors="$(cat /proc/cpuinfo | grep processor | wc -l)"
  69.  
  70. # Exports needed outside of this script's scope,
  71. # you probably don't need to tweak things here.
  72. export PATH="$gimp_install_dir/bin:$PATH"
  73. export PKG_CONFIG_PATH="$gimp_install_dir/lib/pkgconfig:$PKG_CONFIG_PATH"
  74. export LD_LIBRARY_PATH="$gimp_install_dir/lib:$LD_LIBRARY_PATH"
  75.  
  76. # The package management command to run
  77. pkg_cmd="sudo apt-get install"
  78.  
  79. # The packages to install
  80. # These are specific to Ubuntu 11.x
  81. # If you're running another distro, you'll need to pich the list by yourself
  82. # Read the ${gimp_src_dir}/INSTALL,
  83. # and do trial'n errors by running this script until you've resolved all dependencies
  84. # Ubuntu 12.04 add the following package: zlib, libbzip2 and liblzma
  85. deps="fontconfig gtk-doc-tools intltool libcairo2 libdbus-glib-1-2 libexif-dev libfontconfig1 libfreetype6 libgdk-pixbuf2.0-0 libgtk-3-0 libjasper-dev libjpeg-dev liblcms1-dev liblcms-dev libmng-dev libopenexr-dev libpango1.0-0 libpng-dev libpoppler-dev librsvg2-common librsvg2-dev libtiff4-dev libtiff-tools libtool libwebkit-dev libwmf-dev pkg-config python-dev python-gtk2-dev ruby libghc-zlib-dev libbz2-dev liblzma-dev "
  86.  
  87. ##
  88. ###
  89.  
  90.  
  91.  
  92. ###
  93. ## FUNCTIONS
  94.  
  95. ###
  96. ## HELPERS
  97.  
  98. log_entry() {
  99. echo
  100. printf -vch "%80s" ""
  101. printf "%s\n" "${ch// /$1}"
  102. echo "$1$1 $2"
  103. echo
  104. }
  105.  
  106. log_task(){
  107. log_entry '#' "$@"
  108. }
  109.  
  110. log_section() {
  111. log_entry '=' "$@"
  112. }
  113.  
  114. log_message() {
  115. log_entry '-' "$@"
  116. }
  117.  
  118. ask_user() {
  119. echo -n "-- $@: "
  120. }
  121.  
  122. exit_with(){
  123. echo "ERROR (exit code $?): $1"
  124. exit $?
  125. }
  126.  
  127. ##
  128. ###
  129.  
  130.  
  131. ###
  132. ## TASKS
  133.  
  134. mkdirs(){
  135. log_section "Creating directories"
  136. local dirs=( "$opt_dir" "$src_dir" "$gimp_install_dir" )
  137. for dir in ${dirs[@]}; do
  138. mkdir -vp $dir || exit_with "An error occured while trying to create $dir"
  139. done
  140. }
  141.  
  142. install_apt_deps(){
  143. log_section "Installing required apt dependencies"
  144. ${pkg_cmd} $deps || exit_with "package manager fail while trying to install dependencies $deps"
  145. }
  146.  
  147. update_git_repository(){
  148. local repo_name="$(basename $1)"
  149. ##local repo="git://git.gnome.org/$repo_name"
  150. ##--------------------------
  151. local repo=""
  152. if [ $repo_name = "cairo" ]; then
  153. repo="git://anongit.freedesktop.org/git/$repo_name"
  154. ##echo $repo
  155. elif [ $repo_name = "glib" ]; then
  156. repo="git://git.gnome.org/glib"
  157. else
  158. repo="git://git.gnome.org/$repo_name"
  159. fi
  160. ##--------------------------
  161. log_section "Checking state of git repository $repo"
  162. if [ -d "$1" ]; then
  163. cd "$1"
  164. if git status; then
  165. log_message "Local repository $repo_name already exist, updating from remote master"
  166. git pull --rebase || exit_with "git failed while trying to pull from master repository $repo"
  167. else
  168. log_message "$1 is not a git repository, cleaning"
  169. ask_user "$script_name is going to remove the directory $1 and all it's content. Proceed? [Y/n]"
  170. read input
  171. [ "$(echo ${input:-Y} | tr [a-z] [A-Z])" == 'Y' ] && rm -rfv "$1"
  172. update_git_repository
  173. fi
  174. else
  175. ##log_message "Cloning git://git.gnome.org/$repo_name in $1"
  176. log_message "Cloning $repo in $1"
  177. cd "$(dirname $1)"
  178. ##git clone "git://git.gnome.org/$repo_name" || exit_with "git failed while trying to clone repository $repo"
  179. git clone "$repo" || exit_with "git failed while trying to clone repository $repo"
  180. fi
  181. }
  182.  
  183. update_repositories(){
  184. log_section "Updating repositories"
  185. ##for repo in babl gegl gimp; do
  186. for repo in babl gegl cairo glib gimp; do
  187. update_git_repository "$src_dir/$repo"
  188. done
  189. }
  190.  
  191. get_commit_id(){
  192. cd "$gimp_src_dir"
  193. echo "git describe" | tr 'A-Z' 'a-z' | sed 's/[^a-zA-Z0-9_-]/-/g'
  194. }
  195.  
  196. build(){
  197. local name="$(basename $1)"
  198. log_section "Building $name"
  199. cd "$1"
  200. ./autogen.sh --prefix="$gimp_install_dir" || exit_with "while executing ${name}'s autogen.sh"
  201. make clean || exit_with "while executing 'make clean' for $name"
  202. make -j $processors || exit_with "while executing 'make' for $name"
  203. make install || exit_with "while executing 'make install' for $name"
  204. }
  205.  
  206. build_all(){
  207. build "$babl_src_dir"
  208. build "$gegl_src_dir"
  209. build "$cairo_src_dir"
  210. build "$glib_src_dir"
  211. build "$gimp_src_dir"
  212. }
  213.  
  214. test_build(){
  215. "$gimp_install_dir/bin/gimp-2.9" || exit_with "while trying to launch your rounded edge gimp :("
  216. }
  217.  
  218. ##
  219. ###
  220.  
  221. ##
  222. ###
  223.  
  224.  
  225. ###
  226. ## Main
  227.  
  228. log_task "Install distribution dependencies"
  229. install_apt_deps
  230.  
  231. log_task "Retrieving or updating sources"
  232. mkdirs
  233. update_repositories
  234.  
  235. log_task "Building from sources"
  236. build_all
  237.  
  238. log_task "Launching your cutting edge gimp, behave yourself..."
  239. test_build
  240.  
  241. ##
  242. ###
Advertisement
Add Comment
Please, Sign In to add comment