Sunday, 23 November 2014

Running git, node, python,make and levelgraph on Chrome OS (inside a ChromeBook)

After creating the Chrome REPL extension, I was curious if it would run under Chrome OS and ChromeBook. To try it out, I was able to get my hands on a Dell ChromeBook 11, and It was nice to see that it worked perfectly.

While using the ChromeBook I was thinking that if I was able to run (tools like) git, node and LevelGraph (which is needed for my current dev focus at SI: TM_Graph_DB) I would have a really portable development environment (specially for running longish batches of Unit Tests).

After a bit of Linux fiddling, I was able to get it working and here is a screenshot of the final result:

What you see there is:

  • the nodejs execution of the TM_Graph_DB github project
    • which was cloned using git
      • which used npm install 
        • that (due to levelgraph/leveldown dependencies) used node-gyp, python, make and g++ 
          • that are not part of the Chrome OS distribution and where installed on a 
            • ubunto virtual environment
Crouton is actually a really nice solution, since it creates an 'Universal chroot environment' for ChromeOS.

My first efforts were based on manually getting/downloading the missing packages (like git, node and python from archlinux). Using the technique of 'mounting an folder from an SD Drive without the noexec setting' (into the /home/utills folder), I was able to get git, node and python to work ok (For example, I was able to clone and run the tests for the fluentnode project I recently published), but it got messy getting node-gyp to work, specially since it needed python (2.7) and make and g++.

The Crouton solution is much better, specially since it doesn't require touching the original Chrome OS bin folder (note: another prob to solve, was that by default /usr/bin folder only had 200Mb of free space, which is not enough to install node and git).

For reference here a number of links that helped me to figure this out:
  • wget
  • tar -xvf python2-2.7.8-2-x86_64.pkg.tar.xz
  • LD_LIBRARY_PATH=/home/tools/usr/lib
  • whereis git
  • alias npm='/home/tools/usr/bin/node /home/tools/usr/bin/npm'
  • PATH=/home/tools/usr/bin:$PATH
  • sh ~/Downloads/crouton
  • sudo sh ~/Downloads/crouton -t xfce
  • sudo enter-chroot
  • mkdir /mnt/stateful_partition/crouton/chroots/precise/home/_downloads
  • cp *.xz /mnt/stateful_partition/crouton/chroots/precise/home/_downloads/
  • df -h
  • du -s usr
  • apt-get install git
  • apt-get install node
  • apt-get install make
  • apt-get install g++
  • fdisk -l
  • mount -bind /dev/sdb1 /home/tools
  • mount -o remount,rw,exec
Post a Comment