-
Notifications
You must be signed in to change notification settings - Fork 19
Building Shoes on Pi2
The pi is just a Linux box. It's a bit slow for big compiles but it's just Linux. In this case, its Raspbian (Stretch) from June 2018. Things like package names and library names do change and you have to find them if and when these instructions fail. I have a Pi3B that boots off of a USB SSD so its about as fast as I can buy.
Overview
- Get RVM working
- Build another Ruby
- Shoes source and gems
- Build Shoes
I like RVM - it's smart and it installs Ruby dependencies and that alone is worth the effort to install RVM.
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable
Logout and log back in and make sure ~/.rvm is in your PATH. Modify .bashrc and .bash_profile if needed. NOTE: rvm did not set my $PATH correctly and I'm very reluctant to change the user 'pi' bash setup.
Now we install an RVM ruby, our way.
$ rvm install 2.3.7 -C --enable-load-relative --enable-shared
Updating system...
Installing required packages: gawk, autoconf, automake, bison, libffi-dev, libgdbm-dev, libncurses5-dev, libsqlite3-dev, libtool, libyaml-dev, sqlite3, libgmp-dev, libreadline-dev, libssl1.0-dev
Requirements installation successful.
Installing Ruby from source to: /home/pi/.rvm/rubies/ruby-2.3.7, this may take a while depending on your cpu(s)...
ruby-2.3.7 - #downloading ruby-2.3.7, this may take a while depending on your connection...
a long time later ...
ruby-2.3.7 - #making binaries executable..
ruby-2.3.7 - #downloading rubygems-2.7.7
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 894k 100 894k 0 0 1416k 0 --:--:-- --:--:-- --:--:-- 1415k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.3.7 - #extracting rubygems-2.7.7....................................................................................................................................................................................................................................
ruby-2.3.7 - #removing old rubygems........
ruby-2.3.7 - #installing rubygems-2.7.7................................
ruby-2.3.7 - #gemset created /home/pi/.rvm/gems/ruby-2.3.7@global
ruby-2.3.7 - #importing gemset /home/pi/.rvm/gemsets/global.gems...................................................
ruby-2.3.7 - #generating global wrappers.......
ruby-2.3.7 - #gemset created /home/pi/.rvm/gems/ruby-2.3.7
ruby-2.3.7 - #importing gemsetfile /home/pi/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.3.7 - #generating default wrappers.......
ruby-2.3.7 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.3.7 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
The way Shoes is built for distribution, strongly suggests (aka requires) that you use a second ruby for Shoes. Yes, it is slow to build Ruby on the Pi. But, it's not hard. We need a place to store the new ruby and a place for the source code. I used ~/shoesdeps/pi3 and ~/shoesdeps/src Download Ruby 2.3.7ruby 2.3.7 (not one of the 2.4 or 2.5 - Shoes can't use them). Move the tar ball into that `src' and untar it. Get the latest rubygems too. You should have:
pi@pi3:~ $ ls -l shoesdeps/src
total 18368
-rwxr-xr-x 1 pi pi 197 Jul 6 00:48 pi3-ruby.sh
drwxr-xr-x 26 pi pi 12288 Jul 6 02:49 ruby-2.3.7
-rw-r--r-- 1 pi pi 17859100 Jul 6 01:20 ruby-2.3.7.tar.gz
drwxr-xr-x 8 pi pi 4096 May 17 19:18 rubygems-2.7.7
-rw-r--r-- 1 pi pi 915847 Jul 6 01:22 rubygems-2.7.7.tgz
The contents of pi3-ruby.sh is:
#! /bin/bash
export dest=~/shoesdeps/pi3
./configure \
--enable-shared \
--enable-load-relative \
--disable-install-doc \
--without-tk --without-tcllib --without-tcltk \
--prefix=${dest}
cd into ruby-2.3.7 and do ../pi3-ruby.sh
- that runs the configure step for ruby. It takes a while. Now do make
and after a very long while, make install
That puts the new ruby in ~/shoesdeps/pi3
pi@pi3:~ $ ls shoesdeps/pi3
bin include lib share
Gems are a bit trickier. cd into shoesdeps/src/rubygems-2.7.7 (or the version you downloaded). We're going to use our new ruby to update its gem version.
~/shoesdeps/pi3/bin/ruby setup.rb --no-rdoc --no-ri
You just tested the new ruby! --help works too ;-)
Now we need a place for Shoes and the Gems that Shoes needs. I do this in ~/Projects/shoes3 and ~/Projects/gems/rb23. Note that rb23 is for gems compiled with and for ruby 2.3.x. One could image there is a rb22 in there from older versions of Shoes.
git clone https://github.com/shoes/shoes3.git
I mount the ~/Projects directory with NFS which is some additional work and has cautions. Obviously you need and NFS server that exports that directory.
$ sudo apt-get install nfs-common -y
$ sudo mount -t nfs 192.168.1.2:/Projects Projects
Works for me - you would use your IP number and names. For the long term, we need to modify /etc/fstab to mount the NSF directory at boot time. This requires systemd on my version of raspbian. At the end of /etc/fstab I have these two lines.
# nfs mount
192.168.1.2:/Projects /home/pi/Projects nfs noauto,x-systemd.automount,noatime,nolock,bg,nfsvers=4,intr,tcp,actimeo=1800 0 0
That x-systemd.automount parameter is important.
There are many options when dealing with Gems included with Shoes. The very easiest is to get them from someone who has done the work already. Pick rpigems.tgz, move it to ~/Projects/gems/ and untar it.
The harder way is to use our ruby to install and build them and then extract them into the ~Projects/gems/rb23 space That is documented later
sudo apt-get install makeself libgtk-3-dev libyaml-dev librsvg2-dev libjpeg-dev libgif-dev
cd into shoes3 and create a rpi-custom.yaml file. That file tells rake where you put all the bits and pieces. Mine looks like:
Ruby: /home/pi/shoesdeps/pi3
Deps:
Gemloc: /home/pi/Projects/gems/rb23
Extloc: /home/pi/Projects/gems/rb23
Gems:
InclGems:
- chipmunk-6.1.3.4
- sqlite3-1.3.13
- nokogiri-1.8.0
- mini_portile2-2.2.0
- byebug-9.0.6
- rb-readline-0.5.4
- ffi-1.9.18
# picky needs:
- activesupport-5.1.2
- concurrent-ruby-1.0.5
- i18n-0.8.6
- multi_json-1.12.1
- picky-4.31.3
- rack_fast_escape-2009.06.24
- thread_safe-0.3.6
- tzinfo-1.2.3
- url_escape-2009.06.24
- yajl-ruby-1.3.0
# typhoeus
- ethon-0.10.1
- typhoeus-1.1.2
Debug: false
Deprecations: true
Note that those gem names include a version number. You will get errors if the yaml doesn't match your gems. Don't worry, it will tell you if it cant find it.
There is a useful option to the rakefiles: If you set an environment variable export NFS_ALTP=/home/pi/build/
the the compiled output goes there. This is handy when writing to NFS or CIFS is slow. I use it on the pi. The trailing slash is important.
export NFS_ALTP=/home/pi/build/
$ rake -T
$ rake linux:setup:rpi
$ rake
That final rake is going to copy the gems and ruby, compile a bunch of source code and link it. If there are no fatal errors the end will look similar to this.
new_link: arg=/home/pi/build/rpi/shoes
gcc -o /home/pi/build/rpi/shoes-bin /home/pi/build/rpi/tmp/main.o -L/home/pi/build/rpi -lshoes -L/home/pi/build/rpi -lgif -ljpeg -lyaml -rdynamic -Wl,-export-dynamic -L/home/pi/shoesdeps/pi3/lib -lruby -L/usr/lib/arm-linux-gnueabihf -lrt -ldl -lcrypt -lm -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 /usr/lib/arm-linux-gnueabihf/librsvg-2.so
echo 'cd "$OLDPWD"
LD_LIBRARY_PATH=$APPPATH $APPPATH/shoes-bin "$@"' >> /home/pi/build/rpi/shoes
echo 'cd "$OLDPWD"
LD_LIBRARY_PATH=$APPPATH gdb $APPPATH/shoes-bin "$@"' >> /home/pi/build/rpi/debug
pi@pi3:~/Projects/shoes3 $
Notice where the ouput is - /home/pi/build/rpi/shoes because I used the NFS_ALTP trick. That's how to run your Shoes.
If you wanted (try it) package up Shoes rake package
and after a lot of output you'll get something like
$ ls -lh ~/build/pkg/
drwxr-xr-x 6 pi pi 4.0K Jul 14 21:10 shoes-3.3.7-gtk3-armhf
-rwxr-xr-x 1 pi pi 13M Jul 14 21:10 shoes-3.3.7-gtk3-armhf.install
You could install that just like a downloaded Shoes.
If you want or need to modify one of the code in Shoes (c or .rb) then make your change and do 'rake' again. It will figure out what files need compiling again. If you want to recompile everything then 'rake clean'. If you want to really start over 'rake clobber' followed by 'rake linux:setup:rpi`
Basically we use Ruby to install gems, then we copy the gems. Then we tell Ruby to un-install them. This is tedious on any system but the pi is more tedious. Decide which Ruby to use. I like to use the RVM ruby for this step because it's less likely for a mistake to cause a problem with the ruby in ~/shoesdeps/pi3 Its possible that your $PATH is not setup correctly by RVM - mine isn't.
Try a simple gem first, chipmunk and lets see where things are installed.
$ ~/.rvm/rubies/ruby-2.3.7/bin/gem install chipmunk --no-doc
Fetching: chipmunk-6.1.3.4.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.3.0 directory.
Hmmm. sudo is a pain for what we need to do. Doesn't work either - Raspbian has the header files in the wrong place or didn't include them. We can use our Ruby.
pi@pi3:~ $ ~/shoesdeps/pi3/bin/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
That works - and compiling is still slow on the pi. Do not forget the --no-doc unless you really like slow. Repeat for the other gems - some will drag in the dependent gems. Write down all the version numbers because they will be different. Repeat for sqlite3, nokogiri, rb-readline, byebug, ffi, yajl-ruby, ethon, typhoeus and picky.
May I recommend you create a worksheet?
gem name full name install copy remove
chipmunk chipmunk-6.1.34 x
sqlite3 sqlite3-1.3.13 x
nokogiri nokogiri-1.8.4 x
mini_portile2-2.3.0 x
rb-readline rb-readline-0.0.5 x
byebug byebug-10.0.2 x
ffi ffi-1.9.25 x
yajl-ruby yajl-ruby-1.4.0 x
ethon ethon-0.11.0 x
typhoeus typhoeus-1.3.0 x
picky picky-4.31.3 x
concurrent-ruby-1.0.5 x
i18n-1.0.1 x
thread_safe-0.3.6 x
tzinfo-1.2.5 x
activesupport-5.2.0 x
multi_json-1.13.1 x
url_escape-2009.06.24 x
rack_fast_escape-2009.06.24 x
Verify your gems are installed in the Ruby you used. $ ~/shoesdeps/pi3/bin/gem list -l
and that you can get there. $ ls ~/shoesdeps/pi3/lib/ruby/gems/2.3.0/specifications/
The copy or extract can be done with a Shoes program (CopyGem.rb or a command line script, extract1gem.rb . Both are in your shoes3/gemutils/ directory. Take a look at them and get a feel for what they do.
Hint: If your gems are installed in a '.' dot dir like .rvm then you need to create a symbolic link to it because the graphic file chooser may not show them. cd ~/ ; ln -s ../.rvm/gems/ruby-2.3.7 gemloc
Make your destination (~/Projects/gems/rb23/ in this example). You can cd into Projects/shoes3 and run ~/shoesdeps/pi3/bin/ruby gemutils/CopyGem.rb
to run the Shoes program to extract the gems. Like the gem install, it will process the dependent gems for something like 'Picky'. Eventually, you'll get your own rb23 set of pre-built gems and you can change your rpi-custom.yaml to reflect the gem version numbers for your build.
Now, You should uninstall all of the gems we installed or caused to be installed. Why? Because, if you leave them in the Ruby the Shoes is going to use (see the rpi-custom.yaml) and you supply a Gemloc: then you'll have duplicates and perhaps you'll confuse Ruby or yourself. Of course, you'll cross-off the progress on your work sheet and verify the right gems a no long inside ruby and in your rb23 set.
Menu
In This Section:
- Shoes Rakefiles
- Rake files
- App.yaml secrets
- Custom.yaml
- Gems for Shoes
- Build with Vagrant
- Building Shoes on Linux
- Building Shoes on Pi2
- Mingw Dependencies
- Building Shoes on Windows
- Cross compile mingw
- OSX 10.10 Dependencies
- OSX 10.9 Dependencies
- OSX 10.6 Dependencies
- Caution Using brew 10.6
- Build-MinGW-with-OSX
- NSIS Installer for Windows
- MSYS2 cross compiling
- Cross-compile-for-arm-(raspberry)
- MXE-Dependencies
- FreeBSD and Shoes