{"action":"created","issue":{"url":"https://api.github.com/repos/LibreTime/libretime/issues/173","repository_url":"https://api.github.com/repos/LibreTime/libretime","labels_url":"https://api.github.com/repos/LibreTime/libretime/issues/173/labels{/name}","comments_url":"https://api.github.com/repos/LibreTime/libretime/issues/173/comments","events_url":"https://api.github.com/repos/LibreTime/libretime/issues/173/events","html_url":"https://github.com/LibreTime/libretime/issues/173","id":222915127,"number":173,"title":"Enable install script to auto-detect distribution and release version","user":{"login":"bburton","id":173415,"avatar_url":"https://avatars2.githubusercontent.com/u/173415?v=3","gravatar_id":"","url":"https://api.github.com/users/bburton","html_url":"https://github.com/bburton","followers_url":"https://api.github.com/users/bburton/followers","following_url":"https://api.github.com/users/bburton/following{/other_user}","gists_url":"https://api.github.com/users/bburton/gists{/gist_id}","starred_url":"https://api.github.com/users/bburton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bburton/subscriptions","organizations_url":"https://api.github.com/users/bburton/orgs","repos_url":"https://api.github.com/users/bburton/repos","events_url":"https://api.github.com/users/bburton/events{/privacy}","received_events_url":"https://api.github.com/users/bburton/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/LibreTime/libretime/milestones/3","html_url":"https://github.com/LibreTime/libretime/milestone/3","labels_url":"https://api.github.com/repos/LibreTime/libretime/milestones/3/labels","id":2388259,"number":3,"title":"3.0.0-alpha.2","description":"What comes after [3.0.0-alpha.1](https://github.com/LibreTime/libretime/milestone/2)","creator":{"login":"hairmare","id":116588,"avatar_url":"https://avatars1.githubusercontent.com/u/116588?v=3","gravatar_id":"","url":"https://api.github.com/users/hairmare","html_url":"https://github.com/hairmare","followers_url":"https://api.github.com/users/hairmare/followers","following_url":"https://api.github.com/users/hairmare/following{/other_user}","gists_url":"https://api.github.com/users/hairmare/gists{/gist_id}","starred_url":"https://api.github.com/users/hairmare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hairmare/subscriptions","organizations_url":"https://api.github.com/users/hairmare/orgs","repos_url":"https://api.github.com/users/hairmare/repos","events_url":"https://api.github.com/users/hairmare/events{/privacy}","received_events_url":"https://api.github.com/users/hairmare/received_events","type":"User","site_admin":false},"open_issues":28,"closed_issues":11,"state":"open","created_at":"2017-03-15T15:39:26Z","updated_at":"2017-06-05T08:19:18Z","due_on":null,"closed_at":null},"comments":35,"created_at":"2017-04-20T00:53:44Z","updated_at":"2017-06-07T15:03:51Z","closed_at":null,"body":"## Issue\r\n\r\nInstead of having to specify the --distribution and --release options to the install script, the script should be able to reliably detect which distribution and release it's running on and work appropriately. This detection must work on all supported and unsupported distribution and release combinations.\r\n\r\n## Assumptions\r\n\r\nThe assumption is the following distribution and release combinations are (for the install script):\r\n\r\n* Ubuntu Trusty (14.04 LTS)\r\n* Ubuntu Xenial (16.04 LTS)\r\n* Debian Jessie (8.7)\r\n* Debian Wheezy (7.11)\r\n* CentoOS 7\r\n\r\nAs LibreTime is rather complex with a significant number of dependencies, it's better to limit to known distro and release combinations that have been tested.\r\n\r\n## Proposed solution\r\n\r\nAll of the above distribution and release combinations support the standard file [/etc/os-release](https://www.freedesktop.org/software/systemd/man/os-release.html). This file can be sourced into any Bourne shell script to import the distribution and version configuration. There are several standard variables and some non-standard ones. The detection logic would reference the following:\r\n\r\n* ID - distribution id - one of \"ubuntu\", \"debian\" or \"centos\" (for supported OS's)\r\n* VERSION_ID - distribution version id (optional but available) - numeric version, eg. 14.04, 16.04, 7, etc.\r\n* VERSION_CODENAME - distribution codename (optional), eg. \"xenial\", etc.\r\n* PRETTY_NAME - descriptive name of the release, eg. \"Ubuntu 16.04.2 LTS\"\r\n\r\nThe combination of ID and VERSION_ID or VERSION_CODENAME can be used to reliably detect the distribution and release. VERSION_ID is optional but all supported distros set it to the numeric version. VERSION_CODENAME is also optional with the only supported distro that sets is Xenial. For all other distros, VERSION_ID should be used.\r\n\r\n## Proof of concept\r\n\r\nAttached is a Bash script that detects all five releases above. Any other distribution and version combination is considered as unsupported. \r\n\r\n[os-release-test.sh.txt](https://github.com/LibreTime/libretime/files/939011/os-release-test.sh.txt)\r\n\r\nThis script sets the following variables:\r\n* $dist variable to the lower case name of the distribution. It just so happens that the $ID variable already supplies the correct lower-case value.\r\n* $code variable to the lower case code name of the distribution version, eg. \"xenial\", \"jessie\", etc.\r\n\r\nIn addition, the script also sets a boolean variable for each distribution and each distribution and release combination. This makes the testing conditional syntax much cleaner and also ensures that if there's a typo in any test that the script will fail with a syntax error instead of performing an incorrect test that always evaluates to false. For instance:\r\n\r\n```bash\r\nif $is_ubuntu_dist; then ...\r\nif $is_ubuntu_xenial; then ...\r\nif $is_centos_7; then ...\r\nif $is_ubuntu_dist || $is_debian_dist; then ...\r\nelif $is_centos_dist; then ...\r\n```\r\n\r\nSingle line conditional statements are easy and clean:\r\n\r\n```bash\r\n$is_ubuntu_dist && echo \"This is some version of an Ubuntu distro\"\r\n$is_debian_jessie && echo \"This is Debian Jessie\"\r\n$is_ubuntu_dist || $is_debian_dist && echo \"This is some version of Ubuntu or Debian\"\r\n```\r\n\r\nThe above approach works reliably because all the test variables are initially set to false and then only set to true when appropriate. The result is each variable has the value of true or false and no other value. Because of this, these variables can be used directly in conditions without using brackets that would otherwise be required.\r\n\r\nNote that is preferable for the install script to test for specific features when possible instead of making too many assumptions about what configuration is used for a specific disto and version.  For instance, a feature test for the init system type would detect if systemd or Upstart are active irrespective of the distro and version as it's possible for some distros to be configured to support Upstart even if systemd is the default.\r\n\r\n## Implementation Questions and Assumptions\r\n\r\nBefore implementing a patch to the install script, some issues need to be clarified:\r\n\r\n* The core part of this script would be located after all the option parsing at around line 312 after the LibreTime ASCII art logo is displayed.\r\n* The options --distribution and --release would no longer be needed and would be removed. I can't see any reason to have the ability to override the distro and version detection.\r\n* Using the boolean variables for testing is a different stylistic approach which can be used or not in place of or in addition to $dist and $code variables. I think the change would be well worth it and would be willing to submit a PR once the detection logic is merged in.\r\n\r\n## Related\r\n\r\nHave written feature detection logic for init system detection which will be submitted separately.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/LibreTime/libretime/issues/comments/306823237","html_url":"https://github.com/LibreTime/libretime/issues/173#issuecomment-306823237","issue_url":"https://api.github.com/repos/LibreTime/libretime/issues/173","id":306823237,"user":{"login":"paddatrapper","id":7299909,"avatar_url":"https://avatars0.githubusercontent.com/u/7299909?v=3","gravatar_id":"","url":"https://api.github.com/users/paddatrapper","html_url":"https://github.com/paddatrapper","followers_url":"https://api.github.com/users/paddatrapper/followers","following_url":"https://api.github.com/users/paddatrapper/following{/other_user}","gists_url":"https://api.github.com/users/paddatrapper/gists{/gist_id}","starred_url":"https://api.github.com/users/paddatrapper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paddatrapper/subscriptions","organizations_url":"https://api.github.com/users/paddatrapper/orgs","repos_url":"https://api.github.com/users/paddatrapper/repos","events_url":"https://api.github.com/users/paddatrapper/events{/privacy}","received_events_url":"https://api.github.com/users/paddatrapper/received_events","type":"User","site_admin":false},"created_at":"2017-06-07T15:03:51Z","updated_at":"2017-06-07T15:03:51Z","body":"@Lapotor I haven't had a chance to start working on packaging, as I have had a lot of other things on my plate. This should hopefully die down in the next two months or so. The packaging repo is [here](https://github.com/LibreTime/libretime-debian-packaging). The current blockers is that liquidsoap packaging is orphaned (#192), so we need to decide what will happen there before we can package LT. \r\n\r\nI wasn't intending to set up a PPA, rather just to upload to Debian repos and let it trickle down as releases happen and letting people use the install script in the meantime, but I'm not against a PPA if that is useful for people. Then we just need to be careful around package versioning in the official repos and the PPA."}}
{"actor":{"display_login":"paddatrapper"}}