Tag Archives: linux

How to compile rsync for Android in Ubuntu

My situation

My machine

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04 LTS
Release:    14.04
Codename:   trusty

The latest rsync version to compile (for me it was rsync-3.1.0.tar.gz)

$ curl -s http://rsync.samba.org/ftp/rsync/ \
    | sed -r 's/^.*href="([^"]*)".*$/\1/' | grep 'rsync-[0-9].*\.tar\.gz$'

Procedure

  1. save the tarball name in a variable
    $ RSYNCTGZ="rsync-3.1.0.tar.gz"
    
  2. install needed software
    $ sudo aptitude install gcc-arm-linux-gnueabi
    
  3. download sources
    $ wget http://rsync.samba.org/ftp/rsync/$RSYNCTGZ
    $ tar xzf $RSYNCTGZ
    $ cd rsync-[0-9]*
    
  4. compile
    $ ./configure --host=arm-linux-gnueabi CFLAGS=-static
    $ make
    
  5. install on the device
    $ adb push rsync /data/local/tmp && adb shell chmod 775 /data/local/tmp/rsync
    
  6. test execution
    $ adb shell /data/local/tmp/rsync
    

References

Restore an etc configuration file from the original maintainer version on Debian

There are events that can not be stopped, for example when you delete a file by mistake under /etc.

Debian provides an elegant way to restore files of the maintainer’s version without touching your existing configuration.

Practical scenario

Let’s say I’ve removed the file /etc/apache2/sites-available/000-default.conf, here’s the procedure to recover it:

  • find the deb package containing the file
    # dpkg -S /etc/apache2/sites-available/000-default.conf
    
  • reinstall the package with a specific option
    # apt-get install --reinstall -o Dpkg::Options::="--force-confmiss" apache2
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 5 not upgraded.
    Need to get 86,7 kB of archives.
    After this operation, 0 B of additional disk space will be used.
    Get:1 http://archive.ubuntu.com/ubuntu/ saucy-updates/main apache2 amd64 2.4.6-2ubuntu2.1 [86,7 kB]
    Fetched 86,7 kB in 0s (264 kB/s)
    (Reading database ... 245864 files and directories currently installed.)
    Preparing to replace apache2 2.4.6-2ubuntu2.1 (using .../apache2_2.4.6-2ubuntu2.1_amd64.deb) ...
    Unpacking replacement apache2 ...
    Processing triggers for man-db ...
    Processing triggers for ufw ...
    Processing triggers for ureadahead ...
    ureadahead will be reprofiled on next reboot
    Setting up apache2 (2.4.6-2ubuntu2.1) ...
    
    Configuration file `/etc/apache2/sites-available/000-default.conf', does not exist on system.
    Installing new config file as you requested.
     * Restarting web server apache2
       ...done.
    

That’s all.

Practical scenario #2

There’s another interesting case when this procedure comes handy: if you changed a default etc file and you want to restore it. In that case you can simply delete it and use the same apt-get command:

# apt-get install --reinstall -o Dpkg::Options::="--force-confmiss" <package name>

References

Meet the “It’s All Text!” Firefox extension

Yes, I’m a vim addicted. I mean vim the text editor. I’m so addicted to it that I tend to use vim’s shortcuts even in LibreOffice documents, thunderbird e-mails, web forms etc. with awful results.

Then I found It’s All Text, a Firefox extension which saved my web experience when editing long textareas.

It’s really simple: it puts an overlay “edit” button beside each textarea which is visible only when overing it. When you click it, your preferred editor will come up filled of the text of the textarea. Now you can make your edits, close it and boom, the text is in the textarea.

Wonderful.

For me it’s a productivity boost.

I use it everywhere, like now, I’m writing this blog post in my preferred editor.

The nerd tip

There a deeper tip I use: I’m opening vim from a gnome-terminal.

I created a bash script under my $HOME/bin directory with this name editor-for-it-s-all-text.sh and which content is

#!/bin/bash
/usr/bin/gnome-terminal --full-screen -e "vim '$1'"

Then I configured “It’s All Text” to use that editor and now I use my beloved vim in a full screen terminal window.

Awesome.

Dockerfile: “no such file or directory” error using ADD

Testing docker is really interesting, but sometimes it’s difficult to understand what’s wrong with some configuration.

A problem I found recently dealed with the ADD directive used in the Dockerfile. I was trying to start some services with supervisor but I got this error during the image build process

Step 19 : ADD supervisord.conf /etc/supervisor/conf.d/
2014/02/10 00:40:55 build: supervisord.conf: no such file or directory

The file was right there, in the same path of the Dockerfile, but docker couldn’t find it.

After a good read of the official documentation I learned the conxept of “build context”. When you are building an image, the source directory from which you are operating is the build context, but when you are building passing the Dockerfile from the standard input, there’s no build context!

So this is ok

$ docker build -t mydebian .

and this can’t work

$ docker build -t mydebian - < Dockerfile

HP ProBook 4540s brightness control in Ubuntu 13.10

The HP ProBook 4540s is a good choice when you need a GNU/Linux machine, but there are some hit and miss on the details. The thing I found most tedious is the brightness controls using the keyboard: they simply don’t work at all.

My soloution

See the kernel parameters actually used:

$ cat /proc/cmdline 
BOOT_IMAGE=/boot/vmlinuz-3.11.0-15-generic root=UUID=8850c025-676a-4e8c-ac83-4ed1147b88d4 ro quiet splash vt.handoff=7

If there’s no reference to acpi_backlight, that’s the problem. Add the parameter to /etc/default/grub changing the following line from

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

to

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=vendor"

Done