Skip to content
Cecil Coupe edited this page Jan 20, 2018 · 5 revisions

We can support Shoes on FreeBSD 11.1 (very new bsd). But There are trade offs. and Bewares.

Shoes 3.3.4 users can package and app to run on FreeBSD and it will work if the end user has some dependencies already installed. There is no rational reason to expect your end users will have done that. They can do a pkg info gtk3 and there is gtk3 port available then they can do pkg install gtk3 Not Shoes thing to do just to try out an app but it's the only way. It's also the case that freebsd users are sophisticated enough to figure out what is missing.

Shoes does not have port package for bsd for the same reason it does not have a .deb or .rpm installer for Linux -- too many authorities about what to do, all different and too little time.

configuring freebsd 11.1 as a guest OS in VirtualBox

Only freebsd users think this is simple. It isn't, but you can get it done. You need to install some packages (ports in their lingo)

You need to install the emulators/virtualbox-ose-additions instead of the Guest Additions ISO

Networking

emulators/virtualbox-ose-additions does not support Shared Folders. I mount an nfs export from the VB host machihne. My /etc/fstab entry has the line(s) at the end

# mount nfs
bronco:/Projects /home/ccoupe/Projects nfs rw 0 0

That requires a /etc/hosts entry for bronco was setup first mine looks like

::1                     localhost localhost.local
127.0.0.1               localhost localhost.local
127.0.0.1               flaco flaco.local
192.168.1.2             bronco
...

The Virtualbox host is 'bronco' at 192.168.1.2. The freebsd guest is 'flaco' 127.0.0.1 means it does hot have regular IP number - it can only reached from the host via domain sockets. This is a meaningful distinction.

I want to ssh from bronco into the freebsd VM flaco - named after Flaco Jimenez I did pkg install sshd and set the /etc/ssh/sshd_config to look like

Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# The default requires explicit activation of protocol 1
Protocol 2

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 1h
ServerKeyBits 1024

# Ciphers and keying
#RekeyLimit default none

# Logging
# obsoletes QuietMode and FascistLogging
SyslogFacility AUTH
LogLevel INFO

# Authentication:

LoginGraceTime 2m
PermitRootLogin yes
StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

RSAAuthentication yes
PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes

# Change to yes to enable built-in password authentication.
#PasswordAuthentication no
PermitEmptyPasswords no

# Change to no to disable PAM authentication
ChallengeResponseAuthentication no 

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# Set this to 'no' to disable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation sandbox
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#UseBlacklist no
#VersionAddendum FreeBSD-20161230

# no default banner path
#Banner none

# override default of no subsystems
Subsystem       sftp    /usr/libexec/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#       X11Forwarding no
#       AllowTcpForwarding no
#       PermitTTY no
#       ForceCommand cvs server

It works for me in my situation: I want to ssh login even if X11 is not started. I chose to use port forwarding -- $ ssh -p 3022 [email protected] from bronco (the VB host). We need a port mapping from port 3022 to VM port 22 and we do this using the Virtual-box Settings (Network -> Advanced-> Port Forward for on the freebsd guest.

vbox-pf

Window managers with FreeBSD

I chose to install Mate for a window manager and once it's all debugged then you install slim if you want to boot to a graphical login screen (GDM). I don't - yet. startx will be fine. Configure as needed.

Ports you need to install

In no particular order, you'll want to pkg install git, makeself, vim, devel/ruby-gems, devel/rubygem-rake, databases/ruby-gdbm, xorg, and many more.

Build your Ruby for Tight Shoes

Build your Ruby for Loose Shoes

Although I don't need a Loose Shoes It's something I might want if freebsd was the main machine. Tight shoes has it's ruby in /opt and we can use that for Loose Shoes. I choose to set bash as the default

Building Loose Shoes

Now, if you want build Shoes from source on your FreeBSD box (or VM) - which you probably want to do then there is another rule or two or three. First rule - you'll want two rubies - Your system ruby and the one you package up with Shoes. So install a system ruby. sudo pkg install ruby which hints that you should pkg install devel/ruby-gems and pkg install rubygem-rake and pkg install databases/ruby-gdbm. Take the hints! Do it.

cd into the directory with your Shoes source (from git clone).

$ cd Projects/shoes3
$ rake -T
Please pick a bsd:setup: target - see rake -T
rake bsd:setup:freebsd         # freebsd 11.1 x86_64
rake bsd:setup:minbsd          # freebsd minimal
rake build                     # Build using your OS setup
rake clean                     # Remove any temporary products
rake clobber                   # Remove any generated files
rake default                   # Same as `rake build'
rake install                   # Install Shoes in your ~/.shoes Directory
rake linux:setup:i686_linux    # chroot build for i686 (32bit linux)
rake linux:setup:minlin        # build non-portable linux
rake linux:setup:pi2           # Native arm build - pi 2+
rake linux:setup:x86_64_linux  # chroot build for x86_64 (64bit linux)
rake linux:setup:xwin7         # Cross compile with  MingW32
rake osx:setup:xmavericks      # Setup to build Shoes for 10.9+ from 10.10+
rake package                   # Package Shoes for distribution
rake version                   # create VERSION.txt
rake win32:setup:msys2         # Windows build with msys2
rake win32:setup:win7        
$

We have a choice 'freebsd' and 'minbsd'. minbsd links against the system ruby and uses gems in that Ruby. This is a loose Shoes. Odds are high it's not built for redistribution. Loose Shoes also uses symlinks back into the source source tree so there is less copying. It also includes symbols. Perfect for playing around and debugging C. Let's build that first.

rake bsd:setup:minbsd
rake

Assuming it doesn't error out, this creates a minbsd directory, so ./minbsd/shoes is what to type to try it out. If you're following these instructions you'll notice that nothing useful is displayed. Alt-/ brings up the console which informs us the several gems failed to load. Easy solution, get those gems installed. If you like one-liners

$ su
# echo chipmunk sqlite3 nokogiri rb-readline byebug ffi picky yajl-ruby typhoeus | xargs -n 1 gem install --no-doc 

or you can do them individually:

$ sudo -s
Password:
# gem install chipmunk --no-doc
Fetching: chipmunk-6.1.3.4.gem (100%)
Building native extensions.  This could take a while...
Successfully installed chipmunk-6.1.3.4
1 gem installed
# gem install sqlite3 --no-doc
Fetching: sqlite3-1.3.13.gem (100%)
Building native extensions.  This could take a while...
Successfully installed sqlite3-1.3.13
1 gem installed
# gem install nokogiri --no-doc
Fetching: mini_portile2-2.2.0.gem (100%)
Successfully installed mini_portile2-2.2.0
Fetching: nokogiri-1.8.0.gem (100%)
Building native extensions.  This could take a while...
Successfully installed nokogiri-1.8.0
2 gems installed
# gem install rb-readline --no-doc
Fetching: rb-readline-0.5.5.gem (100%)
Successfully installed rb-readline-0.5.5
1 gem installed
# gem install byebug --no-doc
Fetching: byebug-9.1.0.gem (100%)
Building native extensions.  This could take a while...
Successfully installed byebug-9.1.0
1 gem installed
# gem install ffi --no-doc
Fetching: ffi-1.9.18.gem (100%)
Building native extensions.  This could take a while...
Successfully installed ffi-1.9.18
1 gem installed
# gem install picky --no-doc
Fetching: i18n-0.8.6.gem (100%)
Successfully installed i18n-0.8.6
Fetching: thread_safe-0.3.6.gem (100%)
Successfully installed thread_safe-0.3.6
Fetching: tzinfo-1.2.3.gem (100%)
Successfully installed tzinfo-1.2.3
Fetching: minitest-5.10.3.gem (100%)
Successfully installed minitest-5.10.3
Fetching: concurrent-ruby-1.0.5.gem (100%)
Successfully installed concurrent-ruby-1.0.5
Fetching: activesupport-5.1.4.gem (100%)
Successfully installed activesupport-5.1.4
Fetching: multi_json-1.12.2.gem (100%)
Successfully installed multi_json-1.12.2
Fetching: url_escape-2009.06.24.gem (100%)
Building native extensions.  This could take a while...
Successfully installed url_escape-2009.06.24
Fetching: rack_fast_escape-2009.06.24.gem (100%)
============================================================

Thank you for installing RackFastEscape!

============================================================
Successfully installed rack_fast_escape-2009.06.24
Fetching: picky-4.31.3.gem (100%)
Building native extensions.  This could take a while...
Successfully installed picky-4.31.3
10 gems installed
# gem install yajl-ruby --no-doc
Fetching: yajl-ruby-1.3.0.gem (100%)
Building native extensions.  This could take a while...
Successfully installed yajl-ruby-1.3.0
1 gem installed
# gem install typhoeus --no-doc
Fetching: ethon-0.10.1.gem (100%)
Successfully installed ethon-0.10.1
Fetching: typhoeus-1.3.0.gem (100%)
Successfully installed typhoeus-1.3.0
2 gems installed
#

Now ./minbsd/shoes does work. It would be a good idea to take a look inside the minbsd directory and subdirectories to see how every thing is put together.

A couple of notes: My shoes source is NFS mounted and writing to NFS is slow. I direct where to place that minbsd directory by setting a shell environment variable.export NFS_ALTP=/usr/home/ccoupe/build/ That trailing slash is required. That's not a network place so builds are faster for me.

How to run gdb on a Loose Shoes:

$ gdb ~/build/minbsd/shoes
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...
(gdb) br main
Breakpoint 1 at 0x427289: file shoes/main.c, line 31.
(gdb) r
Starting program: /usr/home/ccoupe/build/minbsd/shoes 

Breakpoint 1, main (argc=1, argv=0x7fffffffe8a0) at shoes/main.c:31
31	  char *path = NULL;
Current language:  auto; currently minimal
(gdb)

Building Tight Shoes

Tight Shoes is more button downed (or laced tight). It's what you can use to build and distribute your apps. It's what I build and put up on the website for download. If that's what you want build from source I encourage you to do

Clone this wiki locally