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

[WIP] Add support for FreeBSD #2378

Closed

Conversation

kyleedwardsny
Copy link

@kyleedwardsny kyleedwardsny commented Jun 7, 2019

Description

Add support for FreeBSD

Fixes #2377

Type of change

  • Bug fix (change which fixes an issue).
  • New feature (change which adds functionality).
  • New Server (new server added).
  • Refactor (restructures existing code).
  • Comment update (typo, spelling, explanation, examples, etc).
  • This change requires a documentation update.

Checklist

  • This code follows the style guidelines of this project.
  • This pull request links to an issue.
  • This pull request uses the develop branch as its base.
  • I have provided Co-author details below.
  • I have performed a self-review of my own code.
  • I have squashed commits.
  • I have commented my code, particularly in hard to understand areas.
  • I have made corresponding changes to the documentation if required.

Distro Tests Required

  • Ubuntu 16.04
  • Debian 8
  • CentOS 7
  • Fedora 30

Provide Github Email

Fill out below info or tick box below:

Co-authored-by: Kyle Edwards <kyleedwardsny@gmail.com>
  • I do not wish to provide an email. I am aware this will hide me as the author of this commit.

All pull requests will now be squashed to create a tidy commit history and simplify changelog creation. You can provide either your own email or a GitHub-provided no-reply email.

When a PR is squashed the author becomes the person who squashed the PR. This removes you as the author of your own PR.
The only workaround for this is to add your details as a co-author. More info about co-authors can be found here.

@conventional-release-bot
Copy link

v19.7.0

🎉 New Features

🐛 Bug Fixes

v19.6.0...v19.7.0

@kyleedwardsny kyleedwardsny changed the base branch from master to develop June 7, 2019 07:02
@GameServerManagers GameServerManagers deleted a comment Jun 9, 2019
@dgibbs64
Copy link
Member

Tested this and installation does not work currently. Work needs to be completed on the installer and the dependencies check. This PR needs some more development. As I don't use FreeBSD I am limited on the amount I can help.

needed to install this to get started

pkg install bash wget 

had to change the bash location to this

#!/usr/local/bin/bash

Got this error

Installing Just Cause 2 Server
=================================
./steamcmd.sh: line 37: /usr/home/linuxgsm/jc2server/steamcmd/Steam.AppBundle/Steam/Contents/MacOS/steamcmd: No such file or directory
Warning! SteamCMD did not complete the download, retrying: Attempt 2

@dgibbs64 dgibbs64 changed the title Add support for FreeBSD [WIP] Add support for FreeBSD Jun 15, 2019
@dgibbs64 dgibbs64 added the type: feature request New feature or request label Jun 15, 2019
@dgibbs64 dgibbs64 closed this Jun 15, 2019
@dgibbs64 dgibbs64 reopened this Jun 15, 2019
@Frisasky
Copy link
Contributor

Frisasky commented Jun 16, 2019

well in order to run steamcmd under freebsd you need to install linux compatibility layer, even though both linux and freebsd superficially looks similar their kernel and ABI are completely different
not all games run under compatibility layer, especially those require libraries not available under freebsd
when i test steamcmd under freebsd 11 it did not work due to unsupported socket option, dunno how things going on freebsd 12

@kyleedwardsny
Copy link
Author

kyleedwardsny commented Jun 16, 2019

There's no ideal solution for the shebang, unfortunately. Changing it to #!/usr/local/bin/bash will of course break it for Linux users. I suppose we could change it to #!/usr/bin/env bash, or we could make the script patch its own shebang if it detects a FreeBSD installation.

FWIW, FreeBSD users usually work around issues like this by just making a symlink: /bin/bash -> /usr/local/bin/bash. I've just been running bash linuxgsm.sh.

@kyleedwardsny
Copy link
Author

As far as the package installation... personally, I've never liked packages that automatically connect to my system's package manager without asking me. I would be OK with adding support for FreeBSD's pkg if there's a way to disable this behavior (some sort of "don't install any packages, let me install them myself" option.)

@kyleedwardsny
Copy link
Author

Also, FreeBSD has two different ways of installing software packages from their repository: Ports and pkg. pkg downloads binary packages similar to apt-get, yum, etc., while Ports download and build the source code (with the option to disable things that the user doesn't want/need.) We should not assume the user's preference in this regard.

@kyleedwardsny
Copy link
Author

As @Frisasky correctly pointed out, FreeBSD doesn't support some of the socket options that steamcmd uses. Granted, it might happen to work if you ignore the error, but this brings up a larger issue: most games aren't made for FreeBSD. Most of them certainly won't work without the Linux compatibility layer, and some won't work even with it. (Minecraft is a notable exception: it runs on Java, and works beautifully on the FreeBSD build of OpenJDK 8. The OpenComputers mod even has a built-in FreeBSD library for its Lua interpreter.)

To that end, I think we should either:

  1. Blacklist games that are known not to work on FreeBSD, or
  2. Preemptively only whitelist games like Minecraft that are known to work, and people can add support for others later on

@kyleedwardsny
Copy link
Author

@dgibbs64 What sort of workflow do you prefer? Do you want me to rebase and squash, or add commits on top of the merge commits you've already made?

@dgibbs64
Copy link
Member

Add commits on top I squash on merge.

@kyleedwardsny
Copy link
Author

On closer inspection, it looks like one of the merges completely botched my code. I think I would rather rebase the commits onto the latest develop than try to duplicate/fix everything that got messed up.

@dgibbs64
Copy link
Member

I have never used rebase before. But I normally just squash a merge to allow one since commit once completed. What has gone wrong?

@dgibbs64
Copy link
Member

dgibbs64 commented Jun 18, 2019

I agree with whitelisting only tested games. My other concern is I have no knowledge of freebsd so I am unable to properly support it. There is a risk of my development breaking a FreeBSD installation so FreeBSD would have to have a caveat of very limited support. There was a suggestion of using
/usr/bin/env in the past but was rejected. Since distros have moved on since then it is possible that /usr/bin/env is perfectly fine to use. There will need to be tested on the oldest supported distros to ensure that there are no issues.
#1652

It will be great to support a new distro but we will have to tread carefully and I will need extra support to make it work. Good documentation for both user and developer will be a must for this.

@kyleedwardsny
Copy link
Author

What has gone wrong?

#2389 had a lot of merge conflicts with my code. Unfortunately, they didn't get resolved properly, which resulted in a lot of my code getting erased. In the end, I decided it was easier to rebase my commits on top of the latest master so I could resolve the conflicts properly. Everything appears to be back in order now.

There was a suggestion of using
/usr/bin/env in the past but was rejected. Since distros have moved on since then it is possible that /usr/bin/env is perfectly fine to use.

Alternatively, if /usr/bin/env still creates an issue, we can leave it as it is and let the extremely small set of FreeBSD users (currently only me) either locally patch their script, add a /bin/bash symlink, or just run bash linuxgsm.sh.

It will be great to support a new distro but we will have to tread carefully and I will need extra support to make it work. Good documentation for both user and developer will be a must for this.

I absolutely agree, and I completely understand that I have an extremely niche use case. Honestly, I would have been fine with just keeping my patches local, but I wanted to be a good open source citizen so that other potential FreeBSD users don't have to duplicate my work.

In short, I am totally fine with saying "we've made some meager attempts to support FreeBSD, but in the end, mainstream Linux is our priority, and you're on your own if something goes wrong."

@@ -261,6 +264,9 @@ fn_found_missing_deps(){
elif [ -n "$(command -v yum 2>/dev/null)" ]; then
cmd="sudo yum -y install ${array_deps_missing[@]}"
eval "${cmd}"
elif [ -n "$(command -v pkg 2>/dev/null)" ]; then
cmd="sudo pkg -y install ${array_deps_missing[@]}"
Copy link
Author

Choose a reason for hiding this comment

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

I'm very confused as to why Codacy doesn't like this line... it is exactly the same as 3 lines above. Should I change this along with the existing lines to Codacy's suggestion?

On FreeBSD, wc -l emits a tab before the result. Account for this
when checking its output.
This makes the scripts more portable by using whichever bash is in
the path, rather than looking for it in a hard-coded location. This
is to support FreeBSD, which installs bash into /usr/local/bin by
default, rather than /bin.
@kyleedwardsny
Copy link
Author

I have confirmed via Docker that /usr/bin/env is present in all of the Linux distros you mentioned. I have not actually tested the script in them. Do you have a test suite I can run?

@GameServerManagers GameServerManagers deleted a comment Aug 30, 2019
@dgibbs64 dgibbs64 closed this Nov 15, 2019
@dgibbs64 dgibbs64 reopened this Nov 15, 2019
@dgibbs64
Copy link
Member

There has been no update on this for around 9 months. I am unable to support FreeBSD myself. I will be closing this as I do not think it is feasible to add support at this time.

@dgibbs64 dgibbs64 closed this Mar 10, 2020
@pull-assistant
Copy link

@github-actions
Copy link
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature request New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants