This commit is contained in:
torger
2013-11-11 10:01:21 +01:00

View File

@@ -1,79 +1,283 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Written by DrSlony # Written by DrSlony
# Version 2.8, 2013-02-05 # buildRT version 3.3, 2013-11-11
# Please report bugs or enhancements to http://code.google.com/p/rawtherapee/issues/list # Please report bugs or enhancements to http://code.google.com/p/rawtherapee/issues/list
# www.rawtherapee.com # www.rawtherapee.com
# www.londonlight.org # www.londonlight.org
checkDeps () { head -n 4 $0 | tail -n 2
hash hg 2>/dev/null || { echo >&2 "Mercurial not found, install Mercurial first and then re-run this script."; exit 1; } echo
hash curl 2>/dev/null || { echo >&2 "Curl not found, install curl first and then re-run this script."; exit 1; }
if [[ $UID -eq 0 ]]; then
printf "%s\n" "Do not run this script as root!" "Aborting"
exit 1
fi
alert () {
case "$alert_type" in
notify-send) notify-send "RawTherapee" "$1" ;;
kdialog) kdialog --title "RawTherapee" --passivepopup "$(printf "%s\n" "$1")" ;;
zenity) zenity --notification --text="$(printf "%s\n" "$1")" ;;
xmessage) xmessage -nearmouse "$(printf "%s\n" "$1")" ;;
none) printf "%b\n" "" "Compilation complete:" "$1" ;;
esac
} }
getBranches () { #--- Set some variables
branches=() unset choiceNumber choiceNumbers buildType buildTypes list branch branches repo
while read branch _; do version="3.3"
branches+=("$branch") movetoPatched=""
done < <(curl -s 'https://rawtherapee.googlecode.com/hg/?cmd=branchmap' | sort) repo="${HOME}/rawtherapee"
} procTarget=2
hgClone () { while getopts "bc:np:uvh?-" opt; do
[[ -d "${repo}" ]] || { echo "${repo} not found, cloning from GoogleCode"; hg clone https://rawtherapee.googlecode.com/hg/ "${repo}"; } case "${opt}" in
b) patched="yes"
movetoPatched="_patched"
printf "%s\n" "Buildonly flag detected, will not hg pull or update" ;;
c) dCacheNameSuffix="$OPTARG"
#sanitize
dCacheNameSuffix=${dCacheNameSuffix//[^\.\-_a-zA-Z0-9]/};
printf "%s\n" "Cache and config name suffix: $dCacheNameSuffix" ;;
n) noomp="-DOPTION_OMP=OFF"
printf "%s\n" "OpenMP disabled" ;;
p) procTarget="$OPTARG"
if [[ $procTarget -lt 1 || $procTarget -gt 9 ]]; then
printf "%s\n" "Invalid processor target value." "Use a value from 1 to 9, e.g." "./buildRT -p 1" "See ProcessorTargets.cmake" "Aborting"
exit 1
fi ;;
u) gcVer="$(curl "http://rawtherapee.googlecode.com/hg/tools/buildRT" 2>/dev/null | grep "^#.*[vV]ersion.*")" || { echo "\"curl\" program not found, please install it first."; exit 1; }
gcVer="${gcVer#*[[:alpha:]] }"
gcVer="${gcVer%%,*}"
latestVer="$(printf "%s\n" "$version" "$gcVer" | sort -rV | head -n 1)"
if [[ $version = $latestVer ]]; then
printf "%s\n" "You are using the latest version of buildRT, $version"
exit 0
else
printf "%s\n" "You are using version $version but version $gcVer is available on Google Code." "You can download the Google Code version from this URL:" " https://rawtherapee.googlecode.com/hg/tools/buildRT" "Replace it with this script, and remember to run \"chmod +x buildRT\""
exit 0
fi ;;
v) verbose=yes
printf "%s\n" "Verbose mode, I will spam your screen with warnings" ;;
h|\?|-) printf "%s\n" "Usage:" "" \
" $0 [-b] [-c <string>] [-n] [-p <1-9>] [-v]" "" \
" -b" \
"Build-only mode. buildRT uses \"hg update -C default\" to update your source code repository to the newest revision, however doing so might destroy any uncommitted or unpushed changes you made or any patches you applied. With the -b flag the script will not update the source code, so that you can easily compile RawTherapee with whatever patches you manually applied. buildRT should automatically detect if you modified the source code, but you can use this flag to force build-only mode." "" \
" -c <string>" \
"Specify a suffix to the cache and config directory names. Only alphanumerics, periods, dashes and underscores are valid. The default value is \"4\", which will result in your build of RawTherapee storing the cache in \"${HOME}/.cache/RawTherapee4\" and config in \"${HOME}/.config/RawTherapee4\". For example, use \"-c _testing\" if you want to test older or patched versions of RawTherapee without potentially damaging your cache and config files." "" \
" -n" \
"Disable OpenMP." "" \
" -p <1-9>" \
"Set which processor target to use. Takes a single digit from 1 to 9. The default is 2. See ProcessorTargets.cmake" "" \
" -u" \
"Check for an update of buildRT on Google Code" "" \
" -v" \
"Make compilation verbose, so you see all compiler warnings." | fold -s
exit 0 ;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
printf "%s\n" "Repository: ${repo}"
printf "%s\n" "Processor target: ${procTarget}"
if [[ -z $verbose ]]; then
Wcflags="-Wno-unused-result"
fi
cpuCount="$(grep -c 'processor' /proc/cpuinfo)"
# We can assume that if grep returns more than 32 lines (CPUs), or nothing at all, something's wrong
if (( cpuCount < 1 || cpuCount > 32 )); then
cpuCount="1"
fi
printf "%s\n" "CPU count: ${cpuCount}"
if hash notify-send 2>/dev/null; then alert_type="notify-send"
elif hash kdialog 2>/dev/null; then alert_type="kdialog"
elif hash zenity 2>/dev/null; then alert_type="zenity"
elif hash xmessage 2>/dev/null; then alert_type="xmessage"
else alert_type="none"
fi
# list from http://linuxmafia.com/faq/Admin/release-files.html
distributions=(
"Annvix /etc/annvix-release"
"Arch /etc/arch-release"
"Arklinux /etc/arklinux-release"
"Aurox /etc/aurox-release"
"BlackCat /etc/blackcat-release"
"Cobalt /etc/cobalt-release"
"Conectiva /etc/conectiva-release"
"Debian /etc/debian_version"
"Fedora /etc/fedora-release"
"Gentoo /etc/gentoo-release"
"Immunix /etc/immunix-release"
"Knoppix knoppix_version"
"Linux-From-Scratch /etc/lfs-release"
"Linux-PPC /etc/linuxppc-release"
"Mandrake /etc/mandrake-release"
"Mandriva_Mandrake /etc/mandriva-release /etc/mandrake-release /etc/mandrakelinux-release"
"Mint /etc/linuxmint/info"
"MkLinux /etc/mklinux-release"
"Novell /etc/nld-release"
"PLD /etc/pld-release"
"RedHat /etc/redhat-release"
"CentOS /etc/centos-release"
"Slackware /etc/slackware-version"
"SME /etc/e-smith-release"
"Solaris /etc/release"
"SunJDS /etc/sun-release"
"SUSE /etc/SuSE-release"
"TinySofa /etc/tinysofa-release"
"TurboLinux /etc/turbolinux-release"
"Ubuntu /etc/lsb-release"
"UltraPenguin /etc/ultrapenguin-release"
"United /etc/UnitedLinux-release"
"VA-Linux /etc/va-release"
"YellowDog /etc/yellowdog-release"
)
for element in "${distributions[@]}"; do
read distro loc1 loc2 loc3 <<< "$element"
for loc in $loc1 $loc2 $loc3
do
# distribution=${distro} because if none of the elements match, distro will =YellowDog (last item in the list)
# add "break 2;" to the end if we really want to, but Ubuntu gets detected as Debian first, then as Ubuntu,
# so we might want to not break the loop.
[[ -e "$loc" ]] && distribution=${distro}
[[ "$distribution" = Gentoo ]] && break 2
done
done
if [[ -z ${distribution} ]]; then
printf "%s\n" "" "Could not automatically detect your distribution. Please enter your distribution's name below followed immediately by the version, without any spaces or punctuation marks, and hit enter to confirm, e.g. \"Ubuntu1310\", \"Mint15\" or \"OpenSUSE123\"" | fold -s
read distribution
#sanitize
distribution=${distribution//[^a-zA-Z0-9]/}
fi
printf "%s\n" "Distribution: ${distribution}";
bits="$(uname -m)" || { printf "%s\n" "Is your system a 32-bit or 64-bit one?" "Enter 32 or 64 and hit enter: "; read bits; bits=${bits//[^0-9]/}; }
if [[ $bits = *64* ]]; then
bits=64
else
bits=32
fi
printf "%s\n" "System: ${bits}-bit" ""
#--- Check script dependencies
hash hg 2>/dev/null || { echo >&2 "Mercurial not found, install Mercurial first and then re-run this script."; exit 1; }
#--- Clone and/or pull
if [[ ! -d "${repo}" ]]; then
printf "%s\n" "${repo} not found, cloning from GoogleCode..."
hg clone https://rawtherapee.googlecode.com/hg/ "${repo}"
cd "${repo}" || exit 1 cd "${repo}" || exit 1
} hg parents --template 'RawTherapee-{latesttag}.{latesttagdistance}, Latest tag: {latesttag}, Latest tag distance: {latesttagdistance}, Changeset: {rev}:{node|short}\n\n'
printf "%b" "Repository cloned succesfully.\n" "Press 'q' to quit or any other key to continue... "
read -r -n 1
echo
echo
[[ $REPLY = q || $REPLY = Q ]] && { printf "%s\n" "Quitting." ""; exit 0; }
fi
cd "${repo}" || exit 1
hg pull || echo "Could not \"hg pull\" (check your internet connection), but continuing anyway."
menu () { #--- Update or decide what to do if user edited the source code (e.g. by applying a patch)
num="1" uncommitted="$(hg status | sed "s/^/\t/")"
# list[0] is manually set to clone to avoid columns, so we make a bogus one and hide it so that the index will match the list entries unpushed="$(hg outgoing -q | sed "s/^/\t/" || echo "Could not check for unpushed changes (check your internet connection), but continuing anyway.")"
list[0]="im hungry omnonom" if [[ -z $uncommitted && -z $unpushed && -z $patched ]]; then
buildTypes=("release" "debug") hg update -C default
for branch in "${branches[@]}"; do echo
hg parents --template 'Repository head:\n RawTherapee-{latesttag}.{latesttagdistance}\n Latest tag: {latesttag}\n Latest tag distance: {latesttagdistance}\n Changeset: {rev}:{node|short}\n\n'
elif [[ -z $patched ]]; then
printf "%s\n" "" "Warning! There are uncommitted or unpushed changes in the repository!" "Uncommitted:" "$uncommitted" "Unpushed:" "$unpushed" "" "This means that you edited the source code (e.g. applied a patch). If the script proceeds to update the repository, those changes you made to the source code might be lost. Your choices are to force the update and possibly lose the changes, not to update and to compile RT as-is, or to abort the script." | fold -s
read -r -p "[f]orce update, [c]ompile as-is, or [a]bort? " fca
case $fca in
f|F) hg update -C default
echo ;;
c|C) printf "%s\n" "Retaining edited source code and compiling RT as-is." ""
patched="yes"
movetoPatched="_patched" ;;
*) printf "%s\n" "User aborted" ""
exit 0 ;;
esac
else
printf "%s\n" "Retaining edited source code and compiling RT as-is." ""
movetoPatched="_patched"
fi
#--- Print the menu
branches=()
if [[ -z $patched ]]; then
while read -r branch; do
branches+=("$branch")
done < <(hg branches -q)
else
branches="$(hg branch)"
fi
num="1"
# Can't print the list[0] "clone repository" text nicely when using "column -t",
# so fill list[0] with junk to start counting from 1 and printf the 0 option manually later on
list[0]="# - Branch - Buildtype"
buildTypes=("Release" "Debug")
for branch in "${branches[@]}"; do
for buildType in "${buildTypes[@]}"; do for buildType in "${buildTypes[@]}"; do
list+=("$num - ${branch} - ${buildType}") list+=("$num - ${branch} - ${buildType}")
((num++)) ((num++))
done done
done done
((num--)) # cause of num++ in the for loop increasing a number after the last list item ((num--))
# ^ Because of num++ in the for loop increasing a number after the last list item
printf "%s\n" "------------------------------------------"
printf "%s\n" "${list[0]}"
printf "%s\n" "------------------------------------------"
printf "%s\n" "0 - abort - exit" "${list[@]:1}" | column -t
printf "%s\n" "------------------------------------------" "" "Enter your choices, each number separated by a single space, e.g. 1 2" "If you don't know which option to choose, then choose the \"default\" branch, \"Release\" build type." "" | fold -s
read -r -p "Your choices: " -a choiceNumbers
printf "%s\n" "" "------------------------------------------"
#sanitize
choiceNumbers="${choiceNumbers//[^0-9 ]/}"
printf "%s\n------------------------------------------\n# - branch - build type\n------------------------------------------\n" #--- Compile the chosen builds
printf "%s\n" "0 - only clone the repository and exit" for choiceNumber in ${choiceNumbers[*]}; do
printf "%s\n" "${list[@]:1}" | column -t if [[ $choiceNumber = 0 ]]; then
printf "%s\n" "------------------------------------------" "" "If you don't know which option to choose, then choose the \"default\" branch, \"release\" build type. Enter your choices, each number separated by a single space, e.g. 5 6" "" | fold -s printf "%s\n" "User exited."
read -p "Your choices: " -a choiceNumbers
#sanitize
choiceNumbers=${choiceNumbers//[^0-9 ]/}
echo
}
compile () {
for choiceNumber in ${choiceNumbers[@]}
do
[[ $choiceNumber = 0 ]] && {
printf "%s\n" "Repository cloned."
hg parents --template 'RawTherapee-{latesttag}.{latesttagdistance} Latest tag: {latesttag}, Latest tag distance: {latesttagdistance}, Changeset: {rev}:{node|short}\n'
exit 0; exit 0;
} fi
read -r _ _ branch _ buildType < <(printf "%s\n" "${list[$choiceNumber]}")
read _ _ branch _ buildType < <( echo ${list[$choiceNumber]} ) # This seems useless "$branch != default"
# if [[ -z $patched && $branch != default ]]; then
if [[ -z $patched ]]; then
printf "%s\n" "" "Updating to branch $branch"
hg update -C "$branch" || exit 1
fi
echo echo
printf "%-15b %b\n" "About to compile:" "" "\tChoice number:" "$choiceNumber" "\tBranch:" "$branch" "\tBuild type:" "$buildType" "\tTarget:" "$procTarget" "" "" printf "%-15b %b\n" "Starting to compile:" "" "\tChoice number:" "$choiceNumber" "\tBranch:" "$branch" "\tBuild type:" "$buildType" "\tTarget:" "$procTarget" "" ""
rev="`hg parents --template {rev}`" rev="$(hg parents --template {rev})"
# Clean up leftovers from previous successful and failed builds # Clean up leftovers from previous successful or failed builds
[[ -d "${repo}/${buildType}" ]] && { printf "%s\n" "Found old build directory \"${repo}/$buildType\". Removing it."; rm -rf "${repo}/${buildType}"; } [[ -d "${repo}/${buildType}" ]] && { printf "%s\n" "Found old build directory \"${repo}/$buildType\". Removing it."; rm -rf "${repo}/${buildType}"; }
[[ -d "${repo}/rawtherapee" ]] && { printf "%s\n" "Found old build directory \"${repo}/rawtherapee\". Removing it."; rm -rf "${repo}/rawtherapee"; } [[ -d "${repo}/rawtherapee" ]] && { printf "%s\n" "Found old build directory \"${repo}/rawtherapee\". Removing it."; rm -rf "${repo}/rawtherapee"; }
[[ -d "${repo}/build" ]] && { printf "%s\n" "Found old build directory \"${repo}/build\". Removing it."; rm -rf "${repo}/build"; } [[ -d "${repo}/build" ]] && { printf "%s\n" "Found old build directory \"${repo}/build\". Removing it."; rm -rf "${repo}/build"; }
[[ -d "${HOME}/rt_${branch}_${buildType}${movetoPatched}" ]] && { [[ -d "${HOME}/rt_${branch}_${buildType}${movetoPatched}" ]] && {
printf "%s\n" "Found old build directory ${HOME}/rt_${branch}_${buildType}${movetoPatched}" "It must be removed to proceed." printf "%s\n" "Found old build directory ${HOME}/rt_${branch}_${buildType}${movetoPatched}" "To proceed you must either delete it, or choose a suffix for the destination folder for this build."
read -p "Do you want to remove it and proceed? y/n: " YN read -r -p "[d]elete old build, [r]ename this build destination folder, or [a]bort "
[[ "$YN" = y ]] && rm -rf "${HOME}/rt_${branch}_${buildType}${movetoPatched}" || exit 1 echo
case $REPLY in
d|D) rm -rf "${HOME}/rt_${branch}_${buildType}${movetoPatched}" || exit 1 ;;
r|R) printf "%s\n" "The build will be saved to \"${HOME}/rt_${branch}_${buildType}${movetoPatched}X\" where \"X\" will be replaced with whatever suffix you choose next. Only alphanumerics, dashes and underscores are valid." | fold -s
read -r -p "Suffix: "
movetoPatched="${REPLY//[^\.\-_a-zA-Z0-9]/}"
printf "%s\n" "Build will be compiled to \"${HOME}/rt_${branch}_${buildType}${movetoPatched}\"" ;;
a|A) printf "%s\n" "Cannot proceed if old build directory exists." "Remove it or rename it, then re-run this script." "Aborting"
exit 0 ;;
*) printf "%s\n" "Unknown response \"$REPLY\""
esac
} }
# Clean up old CMake junk # Clean up old CMake junk
cd "$repo" || exit 1 cd "${repo}" || exit 1
echo printf "%s\n" "" "Cleaning out old CMake files"
printf "%s\n" "Cleaning out old CMake files"
make clean || { printf "%s\n" "Error while running \"make clean\", aborting." "Easiest solution: delete ${repo} and re-run buildRT."; exit 1; } make clean || { printf "%s\n" "Error while running \"make clean\", aborting." "Easiest solution: delete ${repo} and re-run buildRT."; exit 1; }
./clean.sh || { printf "%s\n" "Error while running \"./clean.sh\", aborting." "Easiest solution: delete ${repo} and re-run buildRT."; exit 1; } ./clean.sh || { printf "%s\n" "Error while running \"./clean.sh\", aborting." "Easiest solution: delete ${repo} and re-run buildRT."; exit 1; }
echo echo
@@ -81,35 +285,48 @@ compile () {
# print current line in script: # print current line in script:
# printf "%s\n" "LINENO is \"$LINENO\", BASH_LINENO[i] is \"${BASH_LINENO[$i]}\". Patched is $patched" # printf "%s\n" "LINENO is \"$LINENO\", BASH_LINENO[i] is \"${BASH_LINENO[$i]}\". Patched is $patched"
# if you manually applied a patch, this check avoids having it undone or broken by a hg update
if [[ ! $patched = b ]]; then
printf "%s\n" "Updating the local repository."
hg pull
hg update -C ${branch}
else
printf "%s\n" "You ran this script with the \"b\" option (\"build-only\")." "Skipping repository update and binary zip creation."
fi
printf "%s\n" "" "Starting compilation:" printf "%s\n" "" "Starting compilation:"
verLatesttag="`hg parents --template '{latesttag}'`" verLatesttag="$(hg parents --template '{latesttag}')"
verLatesttagdistance="`hg parents --template '{latesttagdistance}'`" verLatesttagdistance="$(hg parents --template '{latesttagdistance}')"
verMajor=${verLatesttag%%.*} [[ -z $dCacheNameSuffix ]] && dCacheNameSuffix="${verLatesttag%%.*}"
mkdir "${repo}/build" || exit 1 mkdir "${repo}/build" || exit 1
# As of changeset 1930:067e362c6f28 on Mon Jun 25 2012, revision number 1930, RT supports and encourages out-of-source builds. # As of changeset 1930:067e362c6f28 on Mon Jun 25 2012, revision number 1930, RT supports and encourages out-of-source builds.
if ((${rev} < 1930 )); then if (( rev < 1930 )); then
cmake -DCMAKE_BUILD_TYPE="$buildType" -DPROC_TARGET_NUMBER="$procTarget" -DCMAKE_C_FLAGS="-pipe" -DCMAKE_CXX_FLAGS="$CMAKE_C_FLAGS" "$noomp" -DCMAKE_INSTALL_PREFIX="build" -DBUILD_BUNDLE="ON" -DBINDIR="." -DDATADIR="." -DCACHE_NAME_SUFFIX="$verMajor" || { echo "Error during cmake, exiting." >&2; exit 1; } cmake \
-DCMAKE_BUILD_TYPE="$buildType" \
-DPROC_TARGET_NUMBER="$procTarget" \
-DCMAKE_C_FLAGS="-pipe" \
-DCMAKE_CXX_FLAGS="$CMAKE_C_FLAGS $Wcflags" \
"$noomp" \
-DCMAKE_INSTALL_PREFIX="build" \
-DBUILD_BUNDLE="ON" \
-DBINDIR="." \
-DDATADIR="." \
-DCACHE_NAME_SUFFIX="$dCacheNameSuffix" \
|| { echo "Error during cmake, exiting."; exit 1; }
else else
cd "${repo}/build" || exit 1 cd "${repo}/build"
cmake -DCMAKE_BUILD_TYPE="$buildType" -DPROC_TARGET_NUMBER="$procTarget" -DCMAKE_C_FLAGS="-pipe" -DCMAKE_CXX_FLAGS="$CMAKE_C_FLAGS" "$noomp" -DCMAKE_INSTALL_PREFIX="build" -DBUILD_BUNDLE="ON" -DBINDIR="." -DDATADIR="." -DCACHE_NAME_SUFFIX="$verMajor" ../ || { echo "Error during cmake, exiting." >&2; exit 1; } cmake \
-DCMAKE_BUILD_TYPE="$buildType" \
-DPROC_TARGET_NUMBER="$procTarget" \
-DCMAKE_C_FLAGS="-pipe" \
-DCMAKE_CXX_FLAGS="$CMAKE_C_FLAGS $Wcflags" \
"$noomp" \
-DCMAKE_INSTALL_PREFIX="build" \
-DBUILD_BUNDLE="ON" \
-DBINDIR="." \
-DDATADIR="." \
-DCACHE_NAME_SUFFIX="$dCacheNameSuffix" ../ \
|| { echo "Error during cmake, exiting."; exit 1; }
fi fi
time { make -j${cpuCount} install; } || { printf "%s\n" "" "Error during make, exiting."; exit 1; } time { make -j${cpuCount} install; } || { printf "%s\n" "" "Error during make, exiting."; exit 1; }
printf "%-15b %b\n" "" "" "Rawtherapee compiled:" "" "\tChoice number:" "$choiceNumber" "\tBranch:" "$branch" "\tBuild type:" "$buildType" "\tTarget:" "$procTarget" "" "" printf "%-15b %b\n" "" "" "RawTherapee compiled:" "" "\tChoice number:" "$choiceNumber" "\tBranch:" "$branch" "\tBuild type:" "$buildType" "\tTarget:" "$procTarget" "\tCache:" "${HOME}/.cache/RawTherapee${dCacheNameSuffix}" "\tConfig:" "${HOME}/.config/RawTherapee${dCacheNameSuffix}" "" ""
# RT used to build into various places over the years. # RT used to build into various places over the years.
# We want to end up with the build in a folder called "<repo>/build/rawtherapee" regardless of which old version you compile, and then to zip it, so we move dirs around: # We want to end up with the build in a folder called "<repo>/build/rawtherapee" regardless of which old version you compile, and then to zip it, so we move dirs around:
if ((${rev} < 1930 )); then if (( rev < 1930 )); then
if [[ -d "${repo}/${buildType}" ]]; then if [[ -d "${repo}/${buildType}" ]]; then
printf "%s\n" "Moving \"${repo}/${buildType}\" to \"${repo}/build/rawtherapee\"" printf "%s\n" "Moving \"${repo}/${buildType}\" to \"${repo}/build/rawtherapee\""
mv "${repo}/${buildType}" "${repo}/build/rawtherapee" mv "${repo}/${buildType}" "${repo}/build/rawtherapee"
@@ -134,7 +351,7 @@ compile () {
cat AboutThisBuild.txt || { printf "%s\n" "${repo}/build/AboutThisBuild.txt not found, exiting."; exit 1; } cat AboutThisBuild.txt || { printf "%s\n" "${repo}/build/AboutThisBuild.txt not found, exiting."; exit 1; }
if [[ ! $patched = b ]]; then if [[ -z $patched ]]; then
printf "%s\n" "Zipping the compiled RawTherapee dir \"${repo}/build/rawtherapee\" and putting it in \"/tmp/RawTherapee_${branch}_${distribution}_${bits}_${verLatesttag}.${verLatesttagdistance}_${buildType}.zip\"" printf "%s\n" "Zipping the compiled RawTherapee dir \"${repo}/build/rawtherapee\" and putting it in \"/tmp/RawTherapee_${branch}_${distribution}_${bits}_${verLatesttag}.${verLatesttagdistance}_${buildType}.zip\""
[[ -e "/tmp/RawTherapee_${branch}_${distribution}_${bits}_${verLatesttag}.${verLatesttagdistance}_${buildType}.zip" ]] && { rm "/tmp/RawTherapee_${branch}_${distribution}_${bits}_${verLatesttag}.${verLatesttagdistance}_${buildType}.zip" || exit 1; } [[ -e "/tmp/RawTherapee_${branch}_${distribution}_${bits}_${verLatesttag}.${verLatesttagdistance}_${buildType}.zip" ]] && { rm "/tmp/RawTherapee_${branch}_${distribution}_${bits}_${verLatesttag}.${verLatesttagdistance}_${buildType}.zip" || exit 1; }
zip -Xrq "/tmp/RawTherapee_${branch}_${distribution}_${bits}_${verLatesttag}.${verLatesttagdistance}_${buildType}.zip" AboutThisBuild.txt rawtherapee zip -Xrq "/tmp/RawTherapee_${branch}_${distribution}_${bits}_${verLatesttag}.${verLatesttagdistance}_${buildType}.zip" AboutThisBuild.txt rawtherapee
@@ -147,145 +364,11 @@ compile () {
printf "%-15b %b\n" "" "" "Build ready:" "" "\tChoice number:" "$choiceNumber" "\tBranch:" "$branch" "\tBuild type:" "$buildType" "\tTarget:" "$procTarget" printf "%-15b %b\n" "" "" "Build ready:" "" "\tChoice number:" "$choiceNumber" "\tBranch:" "$branch" "\tBuild type:" "$buildType" "\tTarget:" "$procTarget"
printf "%s\n" "" "To run RawTherapee, fire up a terminal and type:" "~/rt_${branch}_${buildType}${movetoPatched}/rawtherapee" "" "------------------------------------------" printf "%s\n" "" "To run RawTherapee, fire up a terminal and type:" "~/rt_${branch}_${buildType}${movetoPatched}/rawtherapee" "" "------------------------------------------"
alert "RawTherapee-${verLatesttag}.${verLatesttagdistance} ready.\nChoice number ${choiceNumber}, branch: ${branch}, type: ${buildType}, target: ${procTarget}" alert "RawTherapee-${verLatesttag}.${verLatesttagdistance} ready.\nChoice number ${choiceNumber}, branch: ${branch}, type: ${buildType}, target: ${procTarget}"
done
}
checkDistro () {
# list from http://linuxmafia.com/faq/Admin/release-files.html
distributions=(
"Annvix /etc/annvix-release"
"Arch /etc/arch-release"
"Arklinux /etc/arklinux-release"
"Aurox /etc/aurox-release"
"BlackCat /etc/blackcat-release"
"Cobalt /etc/cobalt-release"
"Conectiva /etc/conectiva-release"
"Debian /etc/debian_version"
"Fedora /etc/fedora-release"
"Gentoo /etc/gentoo-release"
"Immunix /etc/immunix-release"
"Knoppix knoppix_version"
"Linux-From-Scratch /etc/lfs-release"
"Linux-PPC /etc/linuxppc-release"
"Mandrake /etc/mandrake-release"
"Mandriva_Mandrake /etc/mandriva-release /etc/mandrake-release /etc/mandrakelinux-release"
"Mint /etc/linuxmint/info"
"MkLinux /etc/mklinux-release"
"Novell /etc/nld-release"
"PLD /etc/pld-release"
"RedHat /etc/redhat-release"
"CentOS /etc/centos-release"
"Slackware /etc/slackware-version"
"SME /etc/e-smith-release"
"Solaris /etc/release"
"SunJDS /etc/sun-release"
"SUSE /etc/SuSE-release"
"TinySofa /etc/tinysofa-release"
"TurboLinux /etc/turbolinux-release"
"Ubuntu /etc/lsb-release"
"UltraPenguin /etc/ultrapenguin-release"
"United /etc/UnitedLinux-release"
"VA-Linux /etc/va-release"
"YellowDog /etc/yellowdog-release"
)
for element in "${distributions[@]}"; do
read distro loc1 loc2 loc3 <<< "$element"
for loc in $loc1 $loc2 $loc3
do
# distribution=${distro} because if none of the elements match, distro will =YellowDog (last item in the list)
# add "break 2;" to the end if we really want to, but Ubuntu gets detected as Debian first, then as Ubuntu,
# so we might want to not break the loop.
[[ -e "$loc" ]] && { distribution=${distro}; echo "Distribution: ${distribution}"; }
[[ "$distribution" = Gentoo ]] && break 2
done
done
if [[ -z ${distribution} ]]
then
echo -e "\nCould not automatically detect your distribution.\nPlease enter it below followed immediately by the version\nwithout any spaces or punctuation marks and hit enter,\n.e.g. \"Ubuntu1104\", \"Mint11\" or \"Musix20\""
read distribution
#sanitize
distribution=${distribution//[^a-zA-Z0-9]/}
echo "Distribution: ${distribution}"
fi
}
checkBits () {
bits=`uname -m` || { echo -e "Is your system a 32 or 64 bit one?\nEnter 32 or 64 and hit enter."; read bits; bits=${bits//[^0-9]/}; echo "bits entered manually: ${bits}"; }
if [[ $bits = *64* ]]
then
bits=64
else
bits=32
fi
echo "System: ${bits}-bit"
[[ $bits != 32 ]] && [[ $bits != 64 ]] && checkBits
}
setVars () {
unset choiceNumber choiceNumbers buildType buildTypes list branch branches repo
checkDistro
checkBits
repo="${HOME}/rawtherapee" && echo "Repository: ${repo}"
cpuCount="`grep -c 'processor' /proc/cpuinfo`"
if (( "$cpuCount" >= 1 && "$cpuCount" <= 32 )); then echo "CPU count: ${cpuCount}"; else cpuCount="1"; echo "CPU count: ${cpuCount}"; fi
procTarget="2" && echo "procTarget: ${procTarget}"
if hash notify-send 2>/dev/null; then alert_type="notify-send"
elif hash kdialog 2>/dev/null; then alert_type="kdialog"
elif hash zenity 2>/dev/null; then alert_type="zenity"
elif hash xmessage 2>/dev/null; then alert_type="xmessage"
else alert_type="none"
fi
}
alert () {
case "$alert_type" in
notify-send) notify-send "RawTherapee" "$1";;
kdialog) kdialog --title "RawTherapee" --passivepopup "`printf "$1"`";;
zenity) zenity --notification --text="`printf "$1"`" &;;
xmessage) xmessage -nearmouse "`printf "$1"`" &;;
none) printf "%b\n" "" "Compilation complete:" "$1";;
esac
}
finishUp () {
# builds=( /tmp/RawTherapee* ); for f in ${builds[@]}; do echo ${f#/tmp/}; done
if [[ $patched != b ]]; then
printf "%s\n" "RawTherapee zipped builds ready in /tmp"
ls -lh /tmp/RawTherapee*
fi
printf "%s\n" "" "Finished building all chosen versions of RawTherapee"
}
# PROGRAM START
printf "%s\n\n" "Running the RawTherapee build script."
movetoPatched=""
while getopts "bh?-nh" opt; do
case $opt in
b) patched="b"
movetoPatched="_patched"
printf "%s\n" "Buildonly flag detected, will not hg pull or update";;
n) noomp="-DOPTION_OMP=OFF"
printf "%s\n" "OpenMP disabled";;
h|\?|\-) printf "%s\n\n" "Usage: $0 [-b] [-n]" "-b stands for \"buildonly mode\", which skips hg pull && hg update, so that you can use this script to easily compile RawTherapee with whatever patches you manually applied." "-n disables OpenMP." | fold -s
exit 0;;
esac
done done
shift $((OPTIND-1)) # builds=( /tmp/RawTherapee* ); for f in ${builds[@]}; do echo ${f#/tmp/}; done
[ "$1" = "--" ] && shift if [[ -z $patched ]]; then
printf "%s\n" "RawTherapee zipped builds ready in /tmp"
setVars ls -lh /tmp/RawTherapee*
checkDeps fi
getBranches printf "%s\n" "" "Finished building all chosen versions of RawTherapee"
menu
hgClone
compile
finishUp