Lessons from building AOSP and CM

A few notes from my builds on AOSP and CM.

Google made a great work with they’re build system, but many of this features are non documented :S, or not documented on the web … boomer.

Anyway, there are many interesting things:

  • find all the available modules (libraries and executables):
make modules
  • build specific module:
make <module>
  • clean specific module:
make clean-<module>

Reference

Advertisements
Posted in Android, AOSP, CyanogenMod | Tagged , , , , , | Leave a comment

Splitting changes from CodeAuroraForum into Android Open Source Software by rebasing and branching

Here are some useful instructions on how to add some of the changes that CodeAuroraForum did to the Bluetooth stack on AOSP so they can be integrated into CyanogenMod. Don’t think you can ahead and do this without reading rebase docuemetation which can be find my doing

git rebase --help

$ git clone git://codeaurora.org/platform/external/bluetooth/bluez
$ cd bluez
$ git branch -a # look for the branch you want to take changes 
                # from, and the source branch
$ git checkout -b caf_jb origin/jb
$ git checkout -b aosp_jb origin/aosp-new/jb-release
$ git merge-base aosp_jb caf_jb # this will let you know what is 
                # the common ancestor you have between both 
                # branches
dfe961f591046174be590c46f7acfc674417f67e
$ git checkout caf_jb
$ git rebase -i dfe961f591046174be590c46f7acfc674417f67e

This will get you into the text editor so you can pick, squash, edit,etc it. Check the doc on how to rebase

You can use the following snippet to see what the changes are for each commit, so you can discard those that you don’t want:

for i in $(cat .git/rebase-merge/git-rebase-todo | grep pick | grep -v \# | awk '{ print $2}'); do git log -1 --summary  ${i} | less; done
| Leave a comment

Git Notes

Some git notes or future reference:

Get all changes between two tags that modify certain files.

FILES=$(git diff --name-only remotes/origin/aosp-new/ics-mr1-release ics | grep -i blue)
git log --no-merges --stat remotes/origin/aosp-new/ics-mr1-release..ics ${FILES}

Replace AOSP repository with one from CodeAurora

cd external/bluetooth/bluez
git remote add ca git://codeaurora.org/platform/external/bluetooth/bluetooth.git
git fetch ca
git checkout ca/jb
cd ../../..

cd frameworks/base
git remote add ca git://codeaurora.org/platform/frameworks/base.git
git fetch ca
git checkout ca/jb
cd ../..

cd system/bluetooth
git remote add ca git://codeaurora.org/platform/system/bluetooth.git
git fetch ca
git checkout ca/jb
cd ../..

Show all branches that contain a commit:

git branch --contains [commit]

Extract folder into different branch with subtree and eliminte project from parent:

git subtree split -d --prefix=[ path ] -m "splitted" -b [ branch ]
git clone -b [ branch ] . temp
git filter-branch --tree-filter 'rm -rf [ path ]' HEAD
git commit -m "eliminated [ path ] from project history"
cd temp
git remote rm origin
git remote add origin
git branch -m [ branch ] master
git push origin master
cd ..
rm -rf temp
git gc --prune=0
git push -f origin master

Eliminate a Commit from branch:
NOTE: make sure the commit referenced by some other branch first, unless you really wanna loose it

git rebase --onto 8c2d4feb4~1 8c2d4feb4 master
git push -f origin master

Posted in Android, AOSP, CodeAurora, git | Leave a comment

Installing XUbuntu with Radeon HD 6620G

Ok, this is a quick not complete guide on what where the steps I needed to follow in order to install XUbuntu 11.10 into my NV55S05u. Basically the problem is that the guys from Ubuntu decided not to include the readeon privative drivers into the build, and for some reason this board fails to start with the radeonhd driver.

First when you boot the cdrom or usb drive you need to enable nomodeset by pressing F6. It will boot into the command line, then you can either connect to the internet using Wifi (with no wpa stuff as it’s a pain to enable from command line if you are lazy as I am) or with the easy to use ethernet wire :D. Then run:
sudo apt-get update
sudo apt-get install fglrx
startx

Do the installation, reboot.

In grub press e to edit the initial settings and replace quite splash with nomodeset verbose. You will get into a login again, you run:

sudo apt-get update
sudo apt-get install fglrx
startx

And you’re done :D.

| Leave a comment

Serving static content from egg files with Twisted

So it’s been a long time since I started working on AIRi package and now it’s time to start addressing performance issues. One of the problems was that I noticed it wasn’t using the browser cache at all!

By researching I noticed the problem was actually my PkgFile class which was dumping content from the egg file using pkg_resources.resource_stream…. Which in fact isn’t the most efficient way, as pkg_resources actually uncompress the hole egg file (or just uses a folder if accessible).

So the way to serve static content from either egg files or folder with pkg_resources in Twisted is REALLY simple, here’s an example:

from twisted.web.resource import Resource
from twisted.web.static import File
from twisted.web.server import Site
from twisted.internet import reactor
import pkg_resources

root = Resource()
PATH=pkg_resources.resource_filename("airi", "/media")
root.putChild("media", File(PATH), defaultType=None)
reactor.listenTCP(8000, Site(root))
reactor.run()

This is actually the most important line:

PATH=pkg_resources.resource_filename("airi", "/media")

Here airi is the name of the package we want to resolve, and media is a path inside that package, airi package will be resolved to either an egg file or a real folder by setup tools.

Posted in egg files, python, setup tools, twisted | Leave a comment

Puzzles de Facebook

Entonces un día sucedió… Ya casi me recibí y no queda otra, hay que buscar trabajo, la cosa es que miéntras buscaba me tope con los puzzles de Facebook y empece a resolver un par… bueno por ahora uno.

Acá resolví el primero que es simplemente de prueba jeje

#!/usr/bin/python
import sys

def work(magic):
    for i in range(1,magic+1):
        a = i%3 == 0
        b = i%5 == 0
        if a and b:
            print "Hop"
        elif a:
            print "Hoppity"
        elif b:
            print "Hophop"

if __name__ == '__main__':
    if len(sys.argv) == 1:
        print "Usage %s inputfile" % sys.argv[0]
        sys.exit(1)
    if sys.argv[1] == '-':
        f=sys.stdin
    else:
        f=open(sys.argv[1])
    inp = f.read()
    work(int(inp.strip()))

El enunciado está acá: http://www.facebook.com/careers/puzzles.php?puzzle_id=7

Posted in facebook, puzzles, python | Leave a comment

Leyendo el RTC con Python

En la segunda parte del trabajo práctico número 5 de Informática Electrónica se propone leer el RTC en un sistema Linux haciendo uso de la interfaz ioctl, resulta que investigando un poco encontramos que hay una forma aún mejor y más sencilla que es usando el API definidio por sysfs, esté código implementa una posible solución usando python (aviso por ser un ejemplo academico esta cargado de cosas no del todo necesarias, el código se puede reducir en muchas lineas)

#!/bin/env python
# -*- coding: utf-8 -*-

'''
Código simple que muestra el estado del RTC utilizando la interfaz
provista por sysfs, según: 
    http://www.kernel.org/doc/Documentation/rtc.txt

Este método no sólo es más simple que el acceso via ioctl, sino que
además permite que cualquier usuario lea el RTC, sin comprometer la
seguridad del sistema.

Autores:
    Naranjo Manuel Francisco 
    Sanchez Gonzalo Daniel 
'''

import os
from os import path

SYS_CLASS_RTC = path.join(path.sep, 'sys', 'class', 'rtc')

class RTC():
    def __init__(self, rtc=None):
        '''
        Inicializa el acceso al RTC, chequea que el acceso sea
        valido
        '''
        if not rtc:
            rtc = self.encontrarRTC()
        if not path.isdir(rtc):
            raise Exception("RTC invalido")
        self.rtc = rtc
        self.__date = path.join(self.rtc, 'date')
        self.__time = path.join(self.rtc, 'time')
        self.__epoch = path.join(self.rtc, 'since_epoch')

    def encontrarRTC(self):
        '''
            Esta funcion trata de encontrar el RTC por defecto provisto
            en cualquier sistema compatible con x86 o con acceso ACPI
        '''
        return path.join(SYS_CLASS_RTC, os.listdir('/sys/class/rtc/')[0])
    
    def __leer(self, arg):
        '''
        Función genérica que lee el contenido provisto por el RTC
        '''
        return open(arg, 'r').readline().strip()

    def leerDia(self):
        '''
        Devuelve el día según lo que indica el RTC
        '''
        return self.__leer(self.__date)

    def leerHora(self):
        '''
        Devuelve la hora según lo que indica el RTC
        '''
        return self.__leer(self.__time)

    def leerEpoch(self):
        '''
        Devuelve la cantidad de segundos desde las 00:00:00 UTC del 
        1ero de Enero de 1970 día
        '''
        return self.__leer(self.__epoch)

    def __str__(self):
        '''
        Generar representacion lejible de este objeto
        '''
        return '%12s|%10s|%10s' % \
            (self.leerEpoch(), self.leerDia(), self.leerHora())

if __name__ == '__main__':
    # se ejecuta sólo cuando se ejecuta la aplicación
    import time
    try:
        # instanciar objeto
        rtc = RTC()

        #imprimir formato
        print "%-12s|%-10s|%-10s" %("Desde 1-1-70", "dia", "hora")

        while 1:
            print "%s" % rtc # forzar conversion a string
            time.sleep(.1) # esperar 100 millisegundos
    except KeyboardInterrupt:
        print "Chau"

El código se debe bajar a un archivo (no es necesaria la extensión .py) y darle permisos de ejecución.

La salida del mismo resulta

[manuel@localhost:tmp]$ ./leerrtc
Desde 1-1-70|dia |hora
1290899928|2010-11-27| 23:18:48
1290899928|2010-11-27| 23:18:48
1290899928|2010-11-27| 23:18:48
1290899928|2010-11-27| 23:18:48
1290899928|2010-11-27| 23:18:48
1290899928|2010-11-27| 23:18:48
1290899928|2010-11-27| 23:18:48
1290899928|2010-11-27| 23:18:48
1290899928|2010-11-27| 23:18:48
1290899928|2010-11-27| 23:18:48
1290899929|2010-11-27| 23:18:49
1290899929|2010-11-27| 23:18:49
1290899929|2010-11-27| 23:18:49
1290899929|2010-11-27| 23:18:49
1290899929|2010-11-27| 23:18:49
1290899929|2010-11-27| 23:18:49
1290899929|2010-11-27| 23:18:49
1290899929|2010-11-27| 23:18:49
1290899929|2010-11-27| 23:18:49
1290899929|2010-11-27| 23:18:49
1290899930|2010-11-27| 23:18:50
1290899930|2010-11-27| 23:18:50
1290899930|2010-11-27| 23:18:50
1290899930|2010-11-27| 23:18:50
1290899930|2010-11-27| 23:18:50
1290899930|2010-11-27| 23:18:50
1290899930|2010-11-27| 23:18:50
1290899930|2010-11-27| 23:18:50
1290899930|2010-11-27| 23:18:50
1290899931|2010-11-27| 23:18:51
1290899931|2010-11-27| 23:18:51
1290899931|2010-11-27| 23:18:51
1290899931|2010-11-27| 23:18:51
1290899931|2010-11-27| 23:18:51
1290899931|2010-11-27| 23:18:51
1290899931|2010-11-27| 23:18:51
1290899931|2010-11-27| 23:18:51
1290899931|2010-11-27| 23:18:51
1290899931|2010-11-27| 23:18:51
1290899932|2010-11-27| 23:18:52
1290899932|2010-11-27| 23:18:52
1290899932|2010-11-27| 23:18:52
^CChau

Posted in facultad, python | Leave a comment