Tag Archives: ubuntu

Cross compile fstrim for Android on Ubuntu 18.10

Install compiler

$ sudo apt install gcc-arm-linux-gnueabi 

Get sources and compile

$ apt source util-linux
$ cd util-linux-*
$ ./autogen.sh
$ ./configure --host=arm-linux-gnueabi CFLAGS="-static"
$ make LDFLAGS="--static" fstrim
# OK with warnings

Check

$ file fstrim
fstrim: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=5f6d5789d8c27197fb5fadbc18f5cd506b330dc4, with debug_info, not stripped

Useful aptitude commands

A simple list of installed packages

max@wonko:~$ aptitude search '~i' -F '%p'

Search for installed packages from the testing repo

max@wonko:~$ aptitude versions '~i ~Atesting' --group-by=none

Finding why a package is installed

I found fonts-font-awesome in my headless server, but there’s a reason

max@wonko:~$ aptitude why fonts-font-awesome
i   owncloud Depends fonts-font-awesome

Select packages that were removed but not purged

max@wonko:~$ aptitude search '~c'

Search in the package description

max@wonko:~$ aptitude search '~d"web browser"'

Upgradable packages

max@wonko:~$ aptitude search '~U'

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

How to display PHP errors only in public_html directories

How to display PHP errors

I always use servers where PHP errors are not shown by default and I always forget how to enable error messages in development environments.

My situation

On a server I usually prefer Debian OS, but when I develop on the go I use laptops with Ubuntu.
In this case I’m running Ubuntu 14.04 LTS with Apache2 (v2.4.7) and libapache2-mod-php5 (v5.5.9).

I want PHP errorors displayed for projects in my public_html folder.

Solution 1 (only Apache conf files)

Create the file /etc/apache2/sites-enabled/800-public-html.conf with this content:

<Directory /home/*/public_html>
  AllowOverride Options
  php_admin_flag display_errors On
</Directory>

Solution 2 (using .htaccess)

Create the file /etc/apache2/sites-enabled/800-public-html.conf with this content:

<Directory /home/*/public_html>
  AllowOverride Options
</Directory>

Create the file /home/max/public_html/project1/.htaccess with this content:

php_admin_flag display_errors On

Conclusions

It’s easy and easily forgettable. Don’t forget to add

error_reporting(E_ALL | E_NOTICE);

in your .php files.

Cache deb packages with apt-cacher-ng

I’m playing with Docker and I’m constantly tuning my Dockerfile to install the needed packages.

This continuous refinement forces the build process to download the same deb packages every time and it becomes an actual waste of time and bandwidth.

Solution

apt-cacher-ng is a service which can be run on a Debian or Ubuntu host and will serve as a local cache for deb packages from Debian or Ubuntu repositories.

That’s what I need because I’m on an Ubuntu machine emulating a Debian container.

Host setup

The setup is really easy:

# aptitude install apt-cacher-ng

After the installation I changed the bind address of the service to keep it local (I don’t need LAN exposure), I added my local proxy to reach the internet and I disabled ReuseConnections (see Problems):

root@yoda:/etc/apt-cacher-ng# diff acng.conf acng.conf.old 
28d27
< BindAddress: localhost 172.17.42.1
35d33
< proxy: http://127.0.0.1:5865
322d319
< ReuseConnections: 0

Client setup

On the client side it’s necessary to force apt requests to use the proxy.
In the Dockerfile I added

RUN echo 'Acquire::http::Proxy "http://172.17.42.1:3142";' > /etc/apt/apt.conf.d/90-apt-cacher.conf

which creates the configuration file read by apt-get or aptitude when downloading packages.

Problems

The apt-cacher-ng server seems buggy at least when used in conjunction with a regular proxy. Sometimes I get errors like these on the client side

Err http://http.debian.net/debian/ wheezy/main netbase all 5.0
500  Invalid header

one possible solution is to perform a

# apt-get update

on the host machine (it seems to help). Another useful setting is

ReuseConnections: 0

as explained before.