Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix alpine linux detection #148

Merged
merged 1 commit into from
Jul 14, 2018

Conversation

at-wat
Copy link
Contributor

@at-wat at-wat commented Jul 12, 2018

This PR fixes OS detection on Alpine Linux.

rosdep update failed on Alpine showing an error pasted below.
FdoDetect checks ID field in /etc/os-release (which is defined as "alpine") and FdoDetect was constructed with ID of "Alpine Linux".

I'm trying to add alpine support to rosdep and rosdistro.
A working demo to install dependent package on alpine using rosdep is placed at https://github.com/at-wat/alpine-ros.

FYI: @Minipada
ref: #137

/ # apk add py-pip git
/ # pip install rosdep git+https://github.com/ros-infrastructure/rospkg.git
/ # rosdep init
/ # rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Warning: running 'rosdep update' as root is not recommended.
  You should run 'sudo rosdep fix-permissions' and invoke 'rosdep update' again without sudo.
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index.yaml
Add distro "groovy"

ERROR: Rosdep experienced an error: Could not detect OS, tried ['windows', 'ubuntu', 'slackware', 'rhel', 'qnx', 'osx', 'tizen', 'opensuse', 'opensuse', 'opensuse', 'neon', 'mint', 'linaro', 'gentoo', 'funtoo', 'freebsd', 'fedora', 'elementary', 'elementary', 'debian', 'cygwin', 'centos', 'manjaro', 'arch', 'alpine']
Please go to the rosdep page [1] and file a bug report with the stack trace below.
[1] : http://www.ros.org/wiki/rosdep

rosdep version: 0.12.2

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/rosdep2/main.py", line 140, in rosdep_main
    exit_code = _rosdep_main(args)
  File "/usr/lib/python2.7/site-packages/rosdep2/main.py", line 386, in _rosdep_main
    return _no_args_handler(command, parser, options, args)
  File "/usr/lib/python2.7/site-packages/rosdep2/main.py", line 395, in _no_args_handler
    return command_handlers[command](options)
  File "/usr/lib/python2.7/site-packages/rosdep2/main.py", line 592, in command_update
    error_handler=update_error_handler)
  File "/usr/lib/python2.7/site-packages/rosdep2/sources_list.py", line 490, in update_sources_list
    rosdep_data = get_gbprepo_as_rosdep_data(dist_name)
  File "/usr/lib/python2.7/site-packages/rosdep2/gbpdistro_support.py", line 150, in get_gbprepo_as_rosdep_data
    ctx = create_default_installer_context()
  File "/usr/lib/python2.7/site-packages/rosdep2/__init__.py", line 87, in create_default_installer_context
    m.register_platforms(context)
  File "/usr/lib/python2.7/site-packages/rosdep2/platforms/debian.py", line 53, in register_platforms
    register_linaro(context)
  File "/usr/lib/python2.7/site-packages/rosdep2/platforms/debian.py", line 70, in register_linaro
    (os_name, os_version) = context.get_os_name_and_version()
  File "/usr/lib/python2.7/site-packages/rosdep2/installers.py", line 115, in get_os_name_and_version
    os_name = self.os_detect.get_name()
  File "/usr/lib/python2.7/site-packages/rospkg/os_detect.py", line 660, in get_name
    self.detect_os()
  File "/usr/lib/python2.7/site-packages/rospkg/os_detect.py", line 630, in detect_os
    raise OsNotDetected("Could not detect OS, tried %s" % attempted)
OsNotDetected: Could not detect OS, tried ['windows', 'ubuntu', 'slackware', 'rhel', 'qnx', 'osx', 'tizen', 'opensuse', 'opensuse', 'opensuse', 'neon', 'mint', 'linaro', 'gentoo', 'funtoo', 'freebsd', 'fedora', 'elementary', 'elementary', 'debian', 'cygwin', 'centos', 'manjaro', 'arch', 'alpine']

Copy link
Member

@tfoote tfoote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I can confirm in your environment that I can reproduce this issue.

>>> detect.get_codename()
u'3.8.0'
>>> dir(detect)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'get_codename', 'get_version', 'is_os', 'release_info']
>>> detect.release_info()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'dict' object is not callable
>>> detect.release_info
{u'NAME': u'Alpine Linux', u'VERSION_ID': u'3.8.0', u'BUG_REPORT_URL': u'http://bugs.alpinelinux.org', u'PRETTY_NAME': u'Alpine Linux v3.8', u'HOME_URL': u'http://alpinelinux.org', u'ID': u'alpine'}
>>> 

The ID is 'alpine' and FDODetect logic is checking the ID: https://github.com/at-wat/rospkg/blob/b55f212eb672dba1a324037bad4db6814acbd226/src/rospkg/os_detect.py#L179

@Minipada Can you check if this is working for you?

@Minipada
Copy link
Contributor

You're totally right. I also just checked, the name field was filled instead of the ID

at-wat added a commit to at-wat/rosdistro that referenced this pull request Jul 13, 2018
With ros-infrastructure/rospkg#148 and
ros-infrastructure/rosdep#616,
ros_core is ready to be built on Alpine Linux (edge version)
at-wat added a commit to at-wat/rosdistro that referenced this pull request Jul 13, 2018
With ros-infrastructure/rospkg#148 and
ros-infrastructure/rosdep#616,
ros_core can be built from source on Alpine Linux (edge version)
at-wat added a commit to at-wat/rosdistro that referenced this pull request Jul 13, 2018
With ros-infrastructure/rospkg#148 and ros-infrastructure/rosdep#616,
All packages required by ros_core can be installed by rosdep on Alpine Linux (edge version)
at-wat added a commit to at-wat/rosdistro that referenced this pull request Jul 13, 2018
With ros-infrastructure/rospkg#148 and ros-infrastructure/rosdep#616,
all packages required by ros_core can be installed by rosdep on Alpine Linux (edge version)
@tfoote tfoote merged commit 7c968f7 into ros-infrastructure:master Jul 14, 2018
@at-wat at-wat deleted the fix-alpine-detect branch July 14, 2018 17:18
@at-wat at-wat restored the fix-alpine-detect branch July 17, 2018 08:54
mikaelarguedas pushed a commit to ros/rosdistro that referenced this pull request Jul 30, 2018
* Add minimal alpine rosdeps for ros_core

With ros-infrastructure/rospkg#148 and ros-infrastructure/rosdep#616,
all packages required by ros_core can be installed by rosdep on Alpine Linux (edge version)

* Use apk gtest and src gmock

* Use libressl instead of openssl

since Alpine Linux recommends to use libressl instead of openssl
(https://bugs.alpinelinux.org/issues/4970)

* Fix to use python2-dev instead of python2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants