{"action":"created","issue":{"url":"https://api.github.com/repos/ocaml/opam/issues/3058","repository_url":"https://api.github.com/repos/ocaml/opam","labels_url":"https://api.github.com/repos/ocaml/opam/issues/3058/labels{/name}","comments_url":"https://api.github.com/repos/ocaml/opam/issues/3058/comments","events_url":"https://api.github.com/repos/ocaml/opam/issues/3058/events","html_url":"https://github.com/ocaml/opam/issues/3058","id":257709442,"number":3058,"title":"RFC: variables to check for OS, distribution, etc.","user":{"login":"AltGr","id":807966,"avatar_url":"https://avatars0.githubusercontent.com/u/807966?v=4","gravatar_id":"","url":"https://api.github.com/users/AltGr","html_url":"https://github.com/AltGr","followers_url":"https://api.github.com/users/AltGr/followers","following_url":"https://api.github.com/users/AltGr/following{/other_user}","gists_url":"https://api.github.com/users/AltGr/gists{/gist_id}","starred_url":"https://api.github.com/users/AltGr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AltGr/subscriptions","organizations_url":"https://api.github.com/users/AltGr/orgs","repos_url":"https://api.github.com/users/AltGr/repos","events_url":"https://api.github.com/users/AltGr/events{/privacy}","received_events_url":"https://api.github.com/users/AltGr/received_events","type":"User","site_admin":false},"labels":[{"id":13152843,"url":"https://api.github.com/repos/ocaml/opam/labels/AREA:%20DESIGN","name":"AREA: DESIGN","color":"d7e102","default":false},{"id":13153093,"url":"https://api.github.com/repos/ocaml/opam/labels/AREA:%20PORTABILITY","name":"AREA: PORTABILITY","color":"e102d8","default":false},{"id":8798339,"url":"https://api.github.com/repos/ocaml/opam/labels/KIND:%20FEATURE%20WISH","name":"KIND: FEATURE WISH","color":"02d7e1","default":false},{"id":22445274,"url":"https://api.github.com/repos/ocaml/opam/labels/STATE:%20NEED%20INVESTIGATION","name":"STATE: NEED INVESTIGATION","color":"ff6600","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-09-14T12:55:39Z","updated_at":"2017-09-15T09:40:36Z","closed_at":null,"author_association":"MEMBER","body":"Here is a proposal for new pre-defined variables, with examples. It's mostly inspired from the current state of [opam-depext](https://github.com/ocaml/opam-depext).\r\n\r\nFirst some examples:\r\n\r\n\r\n| host\\variables | arch    | os     | distribution | dist-version | distribution-family |\r\n|----------------|---------|--------|--------------|--------------|---------------------|\r\n| Debian stretch | x86\\_64 | linux  | debian       | 9            | debian              |\r\n| OSX Yosemite   | x86\\_64 | darwin | homebrew     | 10.10.5      | homebrew            |\r\n| OpenBSD 6.1    | x86\\_64 | bsd    | openbsd      | 6.1          | openbsd             |\r\n| multiarch/debian-debootstrap:armhf-jessie container | armv7l  | linux  | debian       | 8            | debian              |\r\n| 32bit/ubuntu:16.04 container | x86\\_64 (known docker issue) | linux  | ubuntu       | 16.04        | debian              |\r\n| centos:7 container | x86_64  | linux  | centos       | 7            | rhel                |\r\n| Android 5.1.1  | armv7l  | linux  | android      | 5.1.1        | android             |\r\n| resin/rpi-raspbian container | armv6l  | linux  | raspbian     | 8            | debian              |\r\n\r\n* `arch` is the output of `uname -m`, with `i?86` rewritten to `x86`, `amd64` rewritten to `x86_64`. We might want some normalisation on `arm` too ? Note: any solution for Windows ? Assume `x86_64` ?\r\n* `os` is either the output of `Sys.os_type`, or the lowercased output of `uname -s` when the former is `Unix`, except for `bsd` in the case of `*BSD` and `DragonFly` (this differs from `depext`). Note: should the win32/cygwin distinction rather be made at the `distribution` level ? Do we want to translate `darwin` to `osx` ?\r\n* `distribution` is (originally following code from [opam-depext](https://github.com/ocaml/opam-depext/blob/e0e6a3c28b28bdacb3bbde0d9745fbcaa7510b52/depext.ml#L92-L130)):\r\n  - on OSX, the first of `homebrew` or `macport` that has a binary installed (resp. `brew` and `port`) , or undefined otherwise\r\n  - on Linux, the field `ID`, from `/etc/os-release`, or `/usr/lib/os-release`, or the output of `lsb_release -i -s` if that exists, or the first word of any of `/etc/{redhat,centos,gentoo}-release` or `/etc/issue`. The result is always lowercased. We could also define `distribution-family` using the (first word of the) field `ID_LIKE` from `os-release`, falling back to `distribution` if that is not defined (useful to get the package manager, for example).\r\n  - lowercase `uname -s` when `os` is `bsd`, yielding `freebsd`, `openbsd`, `dragonfly`...\r\n  - maybe win32/cygwin on Windows ?\r\n  - assumed to be `android` if `getprop ro.build.version.release` exists and returns 0\r\n  - undefined otherwise\r\n* `dist-version` is\r\n  - On Linux, defined from `os-release` field `VERSION_ID` (see above), or some custom parsing of the different other cases that needs to be investigated\r\n  - On OSX, the output of `sw_vers -productVersion` (note: this is the OS version and not the distribution version — versions of macports/homebrew don't really make sense here. Maybe find a better name for this variable ?)\r\n  - On Windows, something like the output of `ver` ? There are solution using greps on the output of `systeminfo`, but that's _extremely_ slow.\r\n  - On Android, the output of `getprop ro.build.version.release`\r\n  - On other systems, defined from `uname -r` (this is in general the kernel version, but it seems to match OS releases on *BSD ? Is it correct ?)\r\n\r\nThe fact that it is a big zoo was my main reason to do this as a plugin first, so that it could evolve and be fixed more rapidly than opam :)\r\n\r\nNote: I am not sure `distribution` is the best term in general, as that seems Linux-specific; but had no idea for a better name. `dist-version` isn't a perfectly accurate name, either. Also, a OSX user may have _both_ homebrew and macports, so in that case we assume they want to use homebrew...\r\n\r\nShould we add `os-version`, which would make more sense on non-Linux OSes, and point to the kernel version on Linux ? Or just rename `dist-version` to `os-version`, since we don't care about the kernel version ?\r\n\r\n**Please** if you have access to / need support for any specific system, check the above, extend, propose, and give feedback! Thanks.\r\n"},"comment":{"url":"https://api.github.com/repos/ocaml/opam/issues/comments/329733831","html_url":"https://github.com/ocaml/opam/issues/3058#issuecomment-329733831","issue_url":"https://api.github.com/repos/ocaml/opam/issues/3058","id":329733831,"user":{"login":"AltGr","id":807966,"avatar_url":"https://avatars0.githubusercontent.com/u/807966?v=4","gravatar_id":"","url":"https://api.github.com/users/AltGr","html_url":"https://github.com/AltGr","followers_url":"https://api.github.com/users/AltGr/followers","following_url":"https://api.github.com/users/AltGr/following{/other_user}","gists_url":"https://api.github.com/users/AltGr/gists{/gist_id}","starred_url":"https://api.github.com/users/AltGr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AltGr/subscriptions","organizations_url":"https://api.github.com/users/AltGr/orgs","repos_url":"https://api.github.com/users/AltGr/repos","events_url":"https://api.github.com/users/AltGr/events{/privacy}","received_events_url":"https://api.github.com/users/AltGr/received_events","type":"User","site_admin":false},"created_at":"2017-09-15T09:40:36Z","updated_at":"2017-09-15T09:40:36Z","author_association":"MEMBER","body":"@samoht @avsm you probably want to get involved in this design process :)"}}
{"actor":{"display_login":"AltGr"}}