Friday, December 11, 2015

Getting started with Chromium-OS

I like chrome a lot and as a Google Top Contributor on the chrome help forums, I liked to get something which looked like a chromebook, acts like it and actually works.

I've started searching the internet and came upon a few attempts which looked promising, though most of them are abandoned or require some obscure installations. So as every nerd I decided that I can do better. (Call me a fool with too much time)

So before getting started, a small warning I've only tested this once on an ubuntu 14.04 64-bit, while using the official developer builds on linux (also known as google-chrome-unstable), no chromium is available and executing the code below can make those profile corrupt. Please don't expect a step-to-step walkthrough for creating this, it that was possible, I would just provide a bash-script.

Getting started with chromium gave me a good place to start: The not-as-easy steps of using chromium redirected me to the official snapshots for chromium on Linux. If you click on the name column, you can get this one sorted to get the latest snapshot (Version 363342 on writing, or release 49 of chromium). Note that this page takes a while to load.  

Every subdirectory of the snapshot page contains a chrome-linux.zip file, which the executables, scripts and resources. I have extracted this to /opt/google/chromiumos similar to who the chrome executables are stored on my system.

So, let's run /opt/google/chromiumos/chrome and close this blog. ... You might have guessed it, I wouldn't have started writing this blog. Simply running this executable results into one line of text and a crash. Some investigation, was able to discover that I was missing some files. For some unknown reason, you need a file which is called icudtl.dat, which can be borrowed from your normal chrome installation. Also some libraries have a mismatch in version, so I renamed them and hoped for the best. (Most likely this will cause crashes later on, though let's take that risk). A small summary:
  • cd /opt/google/chromiumos && ln -s /lib/x86_64-linux-gnu/libudev.so.1 && ln -s libudev.so.1 libudev.so.0
  • cd /opt/google/chromiumos && cp /opt/google/chrome-unstable/icudtl.dat ./

If we start up again with one extra command line option (and one less feature) we get a nice result. (/opt/google/chromiumos/chrome --disable-setuid-sandbox) We have working chromium-os, which a decent user account. We can go through the settings, open chromium and the files app. A nice result for about an hour of investigations and try-outs. When you startup, you still get a warning about an unsupported option. The new way of providing this is by setting the environment variable CHROME_DEVEL_SANDBOX to an empty string.

Chromium OS after the first successful try
Let's look into more detail into the result. We have two warnings, one about the command line flag we added. Security can suffer? We are hacking, do you really think we are going do online banking with it? The second one is about Google API keys, which might be important. The Learn more already explains a lot, so you can just follow the instructions of 'Acquiring keys' to get some API keys and use them in some future steps.

Let's provide the the keys to the executable and try starting again. You can write the following in a bash-file or just type it in every time. My preferred way is creating an alias which gets included in my ~/.bashrc. Choose your preferred method and stick with it. As I create core files on crashes of my executables, I like them to be always at the same place, for which I choose ~/.config/chromiumos.

The script:
  • mkdir --parents ~/.config/chromiumos
  • cd ~/.config/chromiumos
  • export CHROME_DEVEL_SANDBOX=
  • export GOOGLE_API_KEY=my-very-own-key
  • export GOOGLE_DEFAULT_CLIENT_ID=my-very-own-client-id
  • export GOOGLE_DEFAULT_CLIENT_SECRET=my-very-own-client-secret
  • /opt/google/chromiumos/chrome

Starting via this script removes the warning, so I guess it worked. So we can look into the other stuff. Unlike at the beginning, the console is now full of spam, created by the executable. If you ever did the same with your chrome installation, you know it sometimes contains something useful. In my case, I discovered that libexif.so was missing. So fixing it is similar to the libudev:
  • cd /opt/google/chromiumos && ln -s /usr/lib/x86_64-linux-gnu/libexif.so.12 && ln -s libexif.so.12 libexif.so

We still are using a stub-user, so how cool would it be if we actually were able to import our profile? Would we just be able to copy it from chrome? The answer is yes:
  • cd ~/.config/chromium && rm -r Default/ test-user Local\ State && cp -R ../google-chrome-unstable/Default ./ && ln -s Default/ test-user

Chromium OS after importing my profile
As you can see on the image, the view is already different from the first time, though we get an annoying warning about an incorrectly opened profile. So let's rethink, search for some extra command line flags and try again:
  • cd ~/.config/chromium && rm -r *
  • /opt/google/chromiumos/chrome --login-manager

Chromium OS with an install screen
If you now log in the sync can start. You might want to restart to get you image loaded, though from now on, if you start chromium os you can log in like on a normal chromebook.
Chromium OS with login screen
For now, I consider myself a happy person. A half day of hacking resulted in something which I couldn't image when I started. Though I still have a lot to investigate:
  • I'm still getting some warning about a shared library of my graphics driver, though most likely I have to fix my system.
  • The installation still gives the warning 'Failed to load /opt/google/chromiumos/keyboard_resources.pak', while I have no idea what this file is meant for.
  • After the actual login, I only have a portion of my synced data, which might just be caused by the limitations of the free API-keys or a bug in this snapshot.
  • The Google-Now-integration is still missing, so some detailed investigation of the actual installation can still reveal some other missing components that should be made working.

Nice hacking
JVApen