X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=tools%2Flinux_packaging%2Fstage2.run;h=7075e52c35a3e1bfd9004764ce9407f420db6893;hb=ae91577f2c34119d07be11cc03d99483eeb5d4e6;hp=207df675c892903be0dc227a26c82d4e7800efbf;hpb=3d51ea0ed2f7c163afffb3566870ec756d5d1a64;p=ardour.git diff --git a/tools/linux_packaging/stage2.run b/tools/linux_packaging/stage2.run index 207df675c8..7075e52c35 100755 --- a/tools/linux_packaging/stage2.run +++ b/tools/linux_packaging/stage2.run @@ -59,7 +59,7 @@ SystemInstall () if which yum > /dev/null; then - sudo yum -y install $1 + ${SUPER} yum -y install $1 rtrn=$? if [ $rtrn -ne 0 ]; @@ -72,7 +72,7 @@ SystemInstall () elif which apt-get > /dev/null; then - sudo apt-get -y install $1 + ${SUPER} apt-get -y install $1 rtrn=$? if [ $rtrn -ne 0 ]; @@ -108,20 +108,53 @@ echo "" echo "Welcome to the ${PGM_NAME} installer" echo "" -############## -# Check sudo -############## +############################# +# Check for root privileges +############################# -if ! sudo date; -then +SUPER="" + +if [ "$(id -u)" != "0" ]; then + + if ! which sudo > /dev/null; + then + echo "" + echo "!!! ERROR !!!" + echo "" + echo "The installer requires root privileges. It is currently not" + echo "running as root AND the program sudo is missing from this system." + echo "" + echo "Please correct this by installing and configuring sudo or running" + echo "the installer as root." + echo "" + read -p "Press ENTER to exit installer:" BLAH + exit 1 + fi + + if ! sudo date; + then + echo "" + echo "!!! ERROR !!!" + echo "" + echo "Either you don't know the root password or the user is not allowed to sudo" + echo "Please correct this and run the installer again" + echo "(hint: use visudo to edit sudoers file)" + echo "" + read -p "Press ENTER to exit installer:" BLAH + exit 1 + fi + SUPER="sudo" +else echo "" - echo "!!! ERROR !!!" + echo "!!! Warning !!!" echo "" - echo "Either you don't know the root password or the user is not allowed to sudo" - echo "Please correct this and run the installer again (hint: use visudo to edit sudoers file)" + echo "The installer is running as the root user which is not the prefered method." + echo "There are checks run at the end of the installer to help ensure proper operation" + echo "of ${PGM_NAME} (realtime priviledges, memory locking, frequency scaling)." + echo "Running as root will invalidate these tests." echo "" - read -p "Press ENTER to exit installer:" BLAH - exit 1 + read -p "Press ENTER to continue:" BLAH + fi ############################ @@ -146,6 +179,47 @@ case `uname -m` in ;; esac +#################### +# Check disk space +#################### + +# We have to check the current folder and the INSTALL_DEST_BASE just +# in case they are on different devices +echo "Checking for required disk space" + +if [ ! -e .${PGM_NAME}_${ARCH}-*.size ]; then + echo "" + echo "!!! ERROR !!! Can't locate .size file for ${ARCH} bundle." + echo "" + exit 1 +else + REQUIRED_BYTES=$(cat .${PGM_NAME}_${ARCH}-*.size) + + #Check space in current folder + FREE_BYTES=$(df -B 1 ${PKG_PATH} | grep / | awk '{print $4}') + + if [ ${FREE_BYTES} -le ${REQUIRED_BYTES} ] ; then + echo "" + echo "!!! ERROR !!! - Insufficient disk space in ${PKG_PATH}" + echo "" + exit 1 + fi + + #Check space in INSTALL_DEST_BASE + FREE_BYTES=$(df -B 1 ${INSTALL_DEST_BASE} | grep / | awk '{print $4}') + + if [ ${FREE_BYTES} -le ${REQUIRED_BYTES} ] ; then + echo "" + echo "!!! ERROR !!! - Insufficient disk space in ${INSTALL_DEST_BASE}" + echo "" + exit 1 + fi +fi + +##################### +# Unpack the bundle +##################### + # untar the correct bundle for us to install echo "Unpacking bundle for $ARCH" @@ -278,7 +352,7 @@ then echo "Running uninstaller $i" ${i} - sudo rm -f ${i} + ${SUPER} rm -f ${i} fi done fi @@ -291,8 +365,8 @@ echo "Installing ${PGM_NAME} ${PGM_VERSION} built from ${PGM_BUILD} in ${INSTALL echo "" # Copy the new version in the install directory -sudo mkdir ${INSTALL_DEST_BASE}/${PGM_FULL_NAME} -sudo cp -Rf ${BUNDLE_DIR}/* ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/ +${SUPER} mkdir ${INSTALL_DEST_BASE}/${PGM_FULL_NAME} +${SUPER} cp -Rf ${BUNDLE_DIR}/* ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/ # write the desktop/menu file echo "[Desktop Entry]" > /tmp/${MENU_FILE} @@ -312,24 +386,24 @@ echo "Comment=Digital Audio Workstation" >> /tmp/${MENU_FILE} echo "Categories=AudioVideo;AudioEditing;Audio;Recorder;" >> /tmp/${MENU_FILE} chmod ugo+rx /tmp/${MENU_FILE} -sudo mv /tmp/${MENU_FILE} ${MENU_FILE_PATH}/. +${SUPER} mv /tmp/${MENU_FILE} ${MENU_FILE_PATH}/. # install the Menu, Link, and Icon(s) if [ "T" = ${HAS_XDG} ]; then echo "Adding ${PGM_NAME} to the applications menu" - sudo xdg-icon-resource install --context apps --size 16 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_16px.png ${ICON_NAME} - sudo xdg-icon-resource install --context apps --size 22 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_22px.png ${ICON_NAME} - sudo xdg-icon-resource install --context apps --size 32 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_32px.png ${ICON_NAME} - sudo xdg-icon-resource install --context apps --size 48 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_48px.png ${ICON_NAME} + ${SUPER} xdg-icon-resource install --context apps --size 16 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_16px.png ${ICON_NAME} + ${SUPER} xdg-icon-resource install --context apps --size 22 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_22px.png ${ICON_NAME} + ${SUPER} xdg-icon-resource install --context apps --size 32 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_32px.png ${ICON_NAME} + ${SUPER} xdg-icon-resource install --context apps --size 48 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_48px.png ${ICON_NAME} if [ -e ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg -a -d /usr/share/icons/hicolor/scalable/apps ]; then - sudo cp -f ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg /usr/share/icons/hicolor/scalable/apps/${ICON_NAME}.svg + ${SUPER} cp -f ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg /usr/share/icons/hicolor/scalable/apps/${ICON_NAME}.svg fi - sudo xdg-desktop-menu install ${MENU_FILE_PATH}/${MENU_FILE} - sudo xdg-desktop-menu forceupdate --mode system # Some systems need an extra kick + ${SUPER} xdg-desktop-menu install ${MENU_FILE_PATH}/${MENU_FILE} + ${SUPER} xdg-desktop-menu forceupdate --mode system # Some systems need an extra kick echo "" echo "Creating a desktop link for ${PGM_NAME}" @@ -346,7 +420,7 @@ echo "" echo "Copying uninstall script to ${INSTALL_DEST_BASE}" echo "" -sudo cp -f ${BUNDLE_DIR}/bin/*.uninstall.sh ${INSTALL_DEST_BASE}/. +${SUPER} cp -f ${BUNDLE_DIR}/bin/*.uninstall.sh ${INSTALL_DEST_BASE}/. ########################### # Check Jack and qjackctl @@ -448,7 +522,7 @@ then read -p "Press ENTER to continue:" BLAH user=`whoami` - if sudo usermod -a -G audio $user; + if ${SUPER} usermod -a -G audio $user; then USER_GROUP_ADJUSTED="t" else @@ -470,7 +544,7 @@ then read -p "Press ENTER to continue:" BLAH user=`whoami` - if sudo usermod -a -G jackuser $user; + if ${SUPER} usermod -a -G jackuser $user; then USER_GROUP_ADJUSTED="t" else