You are here: Noosfero>Dev>Schroot (13 Sep 2017, FelipeAraujo) EditAttach

schroot — a simple and protected environment to develop

Most of us uses GNU/Linux as workstation, some of us uses (and likes) Debian as well...
but none of us uses (as desktop) Debian Stable, the target system to develop Noosfero.

RVM is a solution, but we have other non-ruby dependences to be hold. Some guys like to install a virtual machine to develop, but if you uses GNU/Linux, a chroot will save some resources and a schroot will make your life easier.

Installing schroot

On Debian based systems:
# apt-get install schroot debootstrap
(debootstrap is used to install a Debian base system)

Then at /etc/schroot/chroot.d you can add many configuration files to define all your schroots. So create the file noosfero-dev.conf as root with this content:
[noosfero-dev]
description=Debian Jessie (stable) for Noosfero Development
aliases=noosfero
personality=linux32
type=directory
directory=/home/myuser/chroot/noosfero-dev
groups=users
users=myuser
root-users=myuser
preserve-environment=true
(That is enough, but you can find more config options with man schroot.conf )

If you prefer to build your own chroot from scratch, then create your caged root system:
$ mkdir -p /home/myuser/chroot/noosfero-dev
# debootstrap jessie /home/myuser/chroot/noosfero-dev
(that will take some time...)

"What the devil?"
-- Picard about "host system"

"host system" is your current system, where you are installing the schroot.

I'm using Ubuntu as desktop workstation. I'm installing the schroot on this workstation, so my Ubuntu desktop is the "host system"?
Yes! Right!

Now you can enter on your chroot!
$ schroot -c noosfero-dev

See: preserve-environment makes a link from your host system home to the caged home. Your personal configuration remains on schrooted system making your life easy.

Debian's default configuration also adds a chroot identity to the command line prompt:
(noosfero-dev)myuser@gnu:/home/myuser/noosfero$

If your user do not have this prompt configuration, you can add this to your ~/.bashrc:
debian_chroot=$(cat /etc/debian_chroot)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"

Install Noosfero Dependences

Before all: you have a copy of the Noosfero source, right?
If you don't, Copy the git repository on your home as explained at "GettingStartedWithNoosferoDevelopment".

Understanding

You don't need to use the schroot for everything. The schroot is only to run Noosfero related code.

  • Where to edit the code? On the host system. You don't need to install vim or any other alike thing on schroot.
  • Where to run git commands? On the host system. The schroot doesn't need to manage versioning.
  • Where to run a browser to see the localhost? On the host system. The schroot shares the host network (that is the same to both).
  • Where to run noosfero's console? On the schroot. The Noosfero console uses noosfero code, ruby+rails specific version and other dependences.
  • Where to run noosfero's server? On the schroot. That is obvious. wink
  • Where to run noosfero's tests? On the schroot. Still using Noosfero and its specific dependences.
Understand this and your life will be easy.

Noosfero's quick-start

Well... you are in the noosfero's root directory on your host system.

Run $ schroot -c noosfero-dev   and you will land on the same dir, but in the caged Debian Stable system.

Is a good idea to have a terminal tab on schroot and other tab on your host system allowing to run commands as you need easily.

On the schroot run ./script/quick-start
That will install all needed packages and will configure your Noosfero to run.
(that will take some time...)

Noosfero's sample-data

Now you need some users, communities, relations and articles to test properly while you develop new features. So, inside the schroot, run:
./script/sample-data
(that will take some time...)

Running Noosfero

When you open a terminal window you will see your host system, so first enter on the schroot and then run Noosfero. That is faster and simpler than a virtual machine:
$ cd /path/to/noosfero
$ schroot -c noosfero-dev
$ ./script/development # Engage!

Solving Problems

Unconfigured Locales

Sometimes, in your chroot, you may get this errors while using apt:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
   LANGUAGE = (unset),
   LC_ALL = (unset),
   LANG = "en_GB"

To solve this you must enter in the chroot and run:
$ sudo aptitude install locales  # make sure you have it installed 
$ sudo dpkg-reconfigure locales  # make sure you select your lang (use UTF8!) 
$ sudo locale-gen

My PostgreSQL is not responding

You may get the error bellow in several Noosfero related actions. If your PostgreSQL installation is not working you may get this fail while running the ./script/quick-start script:
could not connect to server: No such file or directory
   Is the server running locally and accepting
   connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Did you try sudo service postgresql start in your chroot? Still not working? Ok... continue reading.

We don't know why sometimes the PostgreSQL installation fails, but you must consider two variables:
  • A PostgreSQL running in the host system: please stop it!
  • A unconfigured locale: you can configure it.

Now that you have cleared the two variables, you can reinstall the postgres, but, not so fast.

First: You must discover all postgresql related packages installed on the chroot:
$ aptitude search ~ipostgresql
i   postgresql                                     - object-relational SQL database (supported version)       
i A postgresql-8.4                                 - object-relational SQL database, version 8.4 server       
i A postgresql-client-8.4                          - front-end programs for PostgreSQL 8.4                    
i A postgresql-client-common                       - manager for multiple PostgreSQL client versions          
i A postgresql-common                              - PostgreSQL database-cluster manager

Second: purge all postgresql related packages (that removes config files):
$ sudo aptitude purge postgresql postgresql-X.Y postgresql-client-X.Y postgresql-client-common postgresql-common
(Where X.Y is the version discovered on the first step)

Sometimes the APT can't remove the directory /usr/share/postgresql to protect your data. Make sure that was removed:
$ sudo rm -r /usr/share/postgresql

Third: now you have a clean environment, you simply install it again:
$ sudo aptitude install postgresql

Now the ./script/quick-start, and any db related action must work. wink


Add comment
You need to login to be able to comment.
 
Topic revision: r17 - 13 Sep 2017, FelipeAraujo

irc Talk with Devs Now!

 
Translations: English
Search on Docs:
   
ActionItem Search:

Copyright © 2007-2018 by the Noosfero contributors
Colivre - Cooperativa de Tecnologias Livres