Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Qt apt-get installation script for multiple Linux Distributions
Forum Updated to NodeBB v4.3 + New Features

Qt apt-get installation script for multiple Linux Distributions

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
3 Posts 3 Posters 449 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    anshah
    wrote on 21 Aug 2019, 16:43 last edited by anshah
    #1

    I'm trying to build a Qt install script for multiple Linux distributions. I know that Ubuntu uses "apt-get" repository and RHEL and CentOS use "yum" repository. What's the best way to detect the distribution in my script.

    I was thinking something like the following just wanted to know the best way to detect the distro.

    if (Ubuntu)
        sudo apt-get install -y [qt package]
    else-if (RHEL or CentOS)
        sudo yum -y install [qt package]
    endif
    

    I found lsb_release on Ubuntu but not on CentOS. So is there a way to detect whether "yum" or "apt-get" is used?

    J 1 Reply Last reply 23 Aug 2019, 11:31
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 21 Aug 2019, 18:35 last edited by
      #2

      Hi,

      https://whatsmyos.com/ gives some interesting clues.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A anshah
        21 Aug 2019, 16:43

        I'm trying to build a Qt install script for multiple Linux distributions. I know that Ubuntu uses "apt-get" repository and RHEL and CentOS use "yum" repository. What's the best way to detect the distribution in my script.

        I was thinking something like the following just wanted to know the best way to detect the distro.

        if (Ubuntu)
            sudo apt-get install -y [qt package]
        else-if (RHEL or CentOS)
            sudo yum -y install [qt package]
        endif
        

        I found lsb_release on Ubuntu but not on CentOS. So is there a way to detect whether "yum" or "apt-get" is used?

        J Offline
        J Offline
        JonB
        wrote on 23 Aug 2019, 11:31 last edited by SGaist
        #3

        @anshah
        As you found, lsb_release is not always there. In any case, that approach will require you to pre-enumerate which distros you know about use which, too much work to maintain.

        Stick to testing whether apt_get or yum is present, it's much easier, and your script requires it to run anyway. So like:

        if [ -f /usr/bin/apt-get ]
        then
            sudo apt-get install -y [qt package]
        elif [ -f /usr/bin/yum ]
        then
            sudo yum -y install [qt package]
        fi
        

        [edit: fixed executable check SGaist]

        1 Reply Last reply
        2

        1/3

        21 Aug 2019, 16:43

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved