3 ####################################
6 # Ardour/Mixbus bundle installer
9 ###################################
15 PGM_EXEC_FILE="ardour2"
17 INSTALL_DEST_BASE="/usr/local/bin"
19 #### Derived Variables ####
20 PGM_NAME_LOWER=$(echo $PGM_NAME | tr '[:upper:]' '[:lower:]')
21 ICON_NAME="${PGM_VENDOR}-${PGM_NAME}"
22 MENU_FILE="${PGM_VENDOR}-${PGM_NAME}.desktop"
23 DESKTOP_LINK_FILE="${PGM_NAME}.desktop"
25 PGM_EXEC_PATH="${INSTALL_DEST_BASE}/${PGM_NAME}/bin/${PGM_EXEC_FILE}"
26 ICON_PATH="${INSTALL_DEST_BASE}/${PGM_NAME}/etc/icons"
27 MENU_FILE_PATH="${INSTALL_DEST_BASE}/${PGM_NAME}/${MENU_FILE}"
29 #### Global Variables ####
32 ########################
33 # Function Definitions
34 ########################
36 VaildateYesNoQuestion ()
43 until test "y" = $INPUT_OK;
46 read -p "$1 [y/n]: " USER_INPUT
49 if [ ! -z $USER_INPUT ];
51 if [ "Y" = $USER_INPUT -o "y" = $USER_INPUT -o "n" = $USER_INPUT -o "N" = $USER_INPUT ];
58 echo $USER_INPUT | tr '[:upper:]' '[:lower:]'
65 # Determine which software install app to use and then install requested package
68 if which yum > /dev/null;
70 sudo yum -y install $1
76 echo "!!! ERROR !!! yum install failed for an unknown reason."
77 echo "Please install package $1 after this installer completes."
81 elif which apt-get > /dev/null;
83 sudo apt-get -y install $1
89 echo "!!! ERROR !!! apt-get install failed for an unknown reason."
90 echo "Please install package $1 after this installer completes."
96 echo "!!! ERROR !!! - Not able to detect which software install tool to use (yum or apt-get)."
97 echo "Please install package $1 using the system software install tool."
106 ########################################################################
108 ########################################################################
119 echo "Either you don't know the root password or the user is not allowed to sudo"
120 echo "Please correct this and run the installer again (hint: use visudo to edit sudoers file)"
122 read -p "Press ENTER to exit installer:" BLAH
126 ############################
127 # Determine processor type
128 ############################
131 i[3456789]86|x86|i86pc)
132 echo "Architecture is x86"
134 BUNDLE_DIR=${PGM_NAME}_${ARCH}-*
137 echo "Architecture is x86_64"
139 BUNDLE_DIR=${PGM_NAME}_${ARCH}-*
143 echo "!!! ERROR !!! - Unknown architecture `uname -m`"
145 read -p "Press ENTER to exit installer:" BLAH
150 # untar the correct bundle for us to install
151 echo "Unpacking bundle for $ARCH"
152 tar -xjf ${BUNDLE_DIR}.tar.bz2
155 #######################
156 # Check for xdg utils
157 #######################
159 XDG_MENU_VER=$(xdg-desktop-menu --version 2> /dev/null)
160 if [ -z "$XDG_MENU_VER" ];
162 echo "System does not have xdg-desktop-menu installed"
166 XDG_ICON_VER=$(xdg-icon-resource --version 2> /dev/null)
167 if [ -z "$XDG_ICON_VER" ];
169 echo "System does not have xdg-icon-resource installed"
173 #################################################
174 # Check if system libs are OK (libc, etc)
175 #################################################
178 echo "Checking system libs to see if they are compatible with ${PGM_NAME}."
182 LD_PATH=`pwd`/${BUNDLE_DIR}/lib
185 LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd ${BUNDLE_DIR}/bin/${PGM_NAME_LOWER}-* 2>&1 > /dev/null)
187 if [ -n "$LDD_RESULT" ];
194 LIB_FILES=$(find ${BUNDLE_DIR}/lib -name "*.so")
196 for path in $LIB_FILES
198 LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd $path 2>&1 > /dev/null)
199 if [ -n "$LDD_RESULT" ];
206 if test "T" = $LIB_ERROR;
209 echo "!!! ERROR !!! - Missing library detected!"
210 echo "This system does not have the correct libs to run ${PGM_NAME}."
211 echo "Installation will not complete. Please use a compatible distro."
213 read -p "Press ENTER to exit installer:" BLAH
219 ################################
220 # Install bundle and Menu/Link
221 ################################
223 # uninstall any older versions
224 if [ -d ${INSTALL_DEST_BASE}/${PGM_NAME} ];
227 echo "Removing existing ${PGM_NAME} installation from ${INSTALL_DEST_BASE}"
230 if [ "T" = ${HAS_XDG} ];
232 sudo xdg-desktop-menu uninstall ${MENU_FILE_PATH}
233 sudo xdg-icon-resource uninstall --size 16 ${ICON_NAME}
234 sudo xdg-icon-resource uninstall --size 22 ${ICON_NAME}
235 sudo xdg-icon-resource uninstall --size 32 ${ICON_NAME}
236 sudo xdg-icon-resource uninstall --size 48 ${ICON_NAME}
238 if [ -e /usr/share/icons/hicolor/scalable/apps/${ICON_NAME}.svg ];
240 sudo rm -f /usr/share/icons/hicolor/scalable/apps/${ICON_NAME}.svg
244 if [ -e ~/Desktop/${DESKTOP_LINK_FILE} ];
246 sudo rm -f ~/Desktop/${DESKTOP_LINK_FILE}
249 # delete the old package
250 sudo rm -rf ${INSTALL_DEST_BASE}/${PGM_NAME}
254 echo "Installing ${PGM_NAME} in ${INSTALL_DEST_BASE}"
257 # Copy the new version in the install directory
258 sudo mkdir ${INSTALL_DEST_BASE}/${PGM_NAME}
259 sudo cp -Rf ${BUNDLE_DIR}/* ${INSTALL_DEST_BASE}/${PGM_NAME}
261 # write the desktop/menu file
262 echo "[Desktop Entry]" > /tmp/${MENU_FILE}
263 echo "Encoding=UTF-8" >> /tmp/${MENU_FILE}
264 echo "Version=1.0" >> /tmp/${MENU_FILE}
265 echo "Type=Application" >> /tmp/${MENU_FILE}
266 echo "Terminal=false" >> /tmp/${MENU_FILE}
267 echo "Exec=${PGM_EXEC_PATH}" >> /tmp/${MENU_FILE}
268 echo "Name=${PGM_NAME}" >> /tmp/${MENU_FILE}
269 echo "Icon=${ICON_NAME}" >> /tmp/${MENU_FILE}
270 echo "Comment=Digital Audio Workstation" >> /tmp/${MENU_FILE}
271 echo "Categories=AudioVideo;Audio;Recorder;" >> /tmp/${MENU_FILE}
273 chmod ugo+rx /tmp/${MENU_FILE}
274 sudo mv /tmp/${MENU_FILE} ${MENU_FILE_PATH}
276 # install the Menu, Link, and Icon(s)
277 if [ "T" = ${HAS_XDG} ];
279 echo "Adding ${PGM_NAME} to the applications menu"
280 sudo xdg-icon-resource install --context apps --size 16 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_16px.png ${ICON_NAME}
281 sudo xdg-icon-resource install --context apps --size 22 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_22px.png ${ICON_NAME}
282 sudo xdg-icon-resource install --context apps --size 32 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_32px.png ${ICON_NAME}
283 sudo xdg-icon-resource install --context apps --size 48 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_48px.png ${ICON_NAME}
285 if [ -e ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg -a -d /usr/share/icons/hicolor/scalable/apps ];
287 sudo cp -f ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg /usr/share/icons/hicolor/scalable/apps/${ICON_NAME}.svg
290 sudo xdg-desktop-menu install ${MENU_FILE_PATH}
292 echo "Creating a desktop link for ${PGM_NAME}"
293 cp ${MENU_FILE_PATH} ~/Desktop/${DESKTOP_LINK_FILE}
294 chmod ugo+rx ~/Desktop/${DESKTOP_LINK_FILE}
296 echo "Creating a desktop link for ${PGM_NAME}"
297 cp ${MENU_FILE_PATH} ~/Desktop/${DESKTOP_LINK_FILE}
298 chmod ugo+rx ~/Desktop/${DESKTOP_LINK_FILE}
302 ###########################
303 # Check Jack and qjackctl
304 ###########################
307 echo "Checking to see if Jack is installed"
309 if ! which jackd > /dev/null;
312 echo "The program Jack is missing from this system. Jack is a required component of $PGM_NAME."
315 ANSWER=$(VaildateYesNoQuestion "Install jack using system software repository?")
317 if test "y" = $ANSWER;
319 echo "Attempting to install Jack"
320 SystemInstall "jackd"
325 read -p "Press ENTER to continue:" BLAH
333 if ! which qjackctl > /dev/null;
336 echo "The program QjackCtl is missing from this system. QjackCtl is an OPTIONAL component of $PGM_NAME."
339 ANSWER=$(VaildateYesNoQuestion "Install QjackCtl using system software repository?")
341 if test "y" = $ANSWER;
343 echo "Attempting to install QjackCtl"
344 SystemInstall "qjackctl"
349 read -p "Press ENTER to continue:" BLAH
355 ########################
357 ########################
359 USER_GROUP_ADJUSTED="f"
361 if ! ./${BUNDLE_DIR}/sanityCheck -a > /dev/null;
364 echo "System failed the quick sanity check... Looking for the cause"
366 if ! ./${BUNDLE_DIR}/sanityCheck -rt > /dev/null;
369 echo "System does not allow realtime for the current user... Looking for a solution"
371 if ./${BUNDLE_DIR}/sanityCheck -hasaudiogroup > /dev/null;
373 if ./${BUNDLE_DIR}/sanityCheck -memberaudiogroup > /dev/null 2>&1;
375 ## This is an odd case. We have an audio group and are a member.
377 echo "!!! WARNING !!! - The current user can not execute realtime processes."
378 echo "This will adversely affect audio latency."
379 echo "This system has an audio group and the user is a member. If jack was"
380 echo "just installed, a simple log out/in may fix this."
382 echo "For best results, please correct this on your system."
383 echo "(Hint: check /etc/security/limits.conf or /etc/security/limits.d/)"
385 read -p "Press ENTER to continue:" BLAH
387 # Not a member of an audio group. Try to fix it.
389 if ./${BUNDLE_DIR}/sanityCheck -hasgroup audio > /dev/null && find /etc/security -type f -name "*.conf" | xargs grep -q "^@audio.*rtprio";
391 # add user to audio group
393 echo "Adding user `whoami` to the audio group."
394 echo "This should allow you to run realtime tasks. Please re-login for this change to take affect."
396 read -p "Press ENTER to continue:" BLAH
399 if sudo usermod -a -G audio $user;
401 USER_GROUP_ADJUSTED="t"
404 echo "!!! ERROR !!! - Not able to add user to the audio group (usermod failed)!"
406 echo "Please add yourself to the audio group and re-login"
408 read -p "Press ENTER to continue:" BLAH
411 elif ./${BUNDLE_DIR}/sanityCheck -hasgroup jackuser > /dev/null && find /etc/security -type f -name "*.conf" | xargs grep -q "^@jackuser.*rtprio";
413 # add user to jackuser group
415 echo "Adding user `whoami` to the jackuser group."
416 echo "This should allow you to run realtime tasks. Please re-login for this change to take affect."
418 read -p "Press ENTER to continue:" BLAH
421 if sudo usermod -a -G jackuser $user;
423 USER_GROUP_ADJUSTED="t"
426 echo "!!! ERROR !!! - Not able to add user to the jackuser group."
428 echo "Please add yourself to the audio group and re-login"
430 read -p "Press ENTER to continue:" BLAH
437 # No audio group found on this system!
439 echo "!!! WARNING !!! - The system does not seem to have an audio group (audio or jackuser)."
441 echo "We will not attempt to fix this. Please configure your system to allow"
442 echo "non-root users to execute realtime tasks."
444 read -p "Press ENTER to continue:" BLAH
448 if ! ./${BUNDLE_DIR}/sanityCheck -freqscaling > /dev/null;
451 echo "!!! WARNING !!! - Your system seems to use frequency scaling."
452 echo "This can have a serious impact on audio latency. You have two choices:"
453 echo "(1) turn it off, e.g. by chosing the 'performance' governor."
454 echo "(2) Use the HPET clocksource by passing \"-c h\" to JACK"
455 echo "(this second option only works on relatively recent computers)"
457 read -p "Press ENTER to continue:" BLAH
460 if [ "f" = $USER_GROUP_ADJUSTED ];
462 if ! ./${BUNDLE_DIR}/sanityCheck -memlock > /dev/null;
465 echo "!!! WARNING !!! - You are not allowed to lock memory."
467 echo "We will not attempt to fix this. Please configure your system to allow"
468 echo "non-root users to execute lock memory."
470 read -p "Press ENTER to continue:" BLAH
476 ########################
478 ########################
482 rm -rf ${BUNDLE_DIR}/
485 echo "!!! Install Complete !!!"
487 if [ "t" = $USER_GROUP_ADJUSTED ];
489 echo "You will need to logout and then login again for all changes to be complete"
493 read -p "Press ENTER to close this window:" BLAH