Pushing a file via ftp and the bash command line to an ftp server

Since I work with the XDA server, I often have to work on stuff in the XDA server, finish it and upload it to my host. Now Goo.im conveniently offers a sftp access, that makes everything very easy. A simple scp command can transfer the file (already descibed elsewhere on my blog). However when it comes to transferring the files via simple ftp, things are a bit different. You need a bash scrip to do it.

I’ve used this script from  Ubuntuforums to suit my needs perfectly:

# The next 9 lines are lifted from mickwombat's script
#!/bin/sh
USERNAME="[email protected]"
PASSWORD="myftppassword"
SERVER="ftp.droidzone.in"
# Directory where file is located
DIR=$2
#  Filename of backup file to be transfered
FILE=$1
# login to ftp server and transfer file

curl -T $FILE -u $USERNAME:$PASSWORD $SERVER/$DIR/

This very neatly takes the file specified in the first argument, and transfers it to ftp.droidzone.in/dir where dir is the specified directory.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Building a host toolchain without sudo or apt

Installing GCC: Manual One
============

First decide on a prefix directory (installation dir)

export $P=that dir path

export $PREFIX=that dir path

Install GMP first
============

with:

wget http://ftp.gnu.org/gnu/gmp/gmp-5.0.5.tar.bz2

tar -jxvvf  gmp-5.0.5.tar.bz2

cd gmp-5.0.5
./configure --prefix=$P --enable-cxx
make ; make install
export LD_LIBRARY_PATH=/home/users/d/dr/droidzone/hostusr/lib
export LD_RUN_PATH=/home/users/d/dr/droidzone/hostusr/lib

cd ..

 

Note the following compiler message:
Libraries have been installed in:
/home/droidzone/buildtools/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR’
flag during linking and do at least one of the following:
– add LIBDIR to the `LD_LIBRARY_PATH’ environment variable
during execution
– add LIBDIR to the `LD_RUN_PATH’ environment variable
during linking
– use the `-Wl,-rpath -Wl,LIBDIR’ linker flag
– have your system administrator add LIBDIR to `/etc/ld.so.conf’

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.

Install PPL next
============
PPL depends on GMP, so specify its location

./configure --prefix=$P --with-gmp-prefix=$P

I think that something has changed with PPL 1.0. Because it doesnt seem to recognize the option –with-gmp-prefix

I needed:

./configure --prefix=$PREFIX --with-gmp=$PREFIX

 

make ; make install

 

Install MPFR
============

wget http://www.mpfr.org/mpfr-current/mpfr-3.1.1.tar.bz2
tar -jxvvf mpfr-3.1.1.tar.bz2
cd mpfr-3.1.1
./configure --prefix=/home/users/d/dr/droidzone/hostusr --with-gmp=/home/users/d/dr/droidzone/hostusr
make ; make install

I think that something has

Now, Install MPC (http://www.multiprecision.org/?prog=mpc&page=download)
================
Install MPFR and GMP first

, and then specify their path for MPC!

wget http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz
tar -xvvf mpc-1.0.1.tar.gz
cd mpc-1.0.1
./configure --prefix=$P --with-gmp=$P --with-mpfr=$P
make
make install

Now, install CLOOG-PPL (For Graphite Loop Optimizations) http://www.cloog.org/
========================

wget http://www.bastoul.net/cloog/pages/download/cloog-0.17.0.tar.gz
./configure --prefix=$P --with-gmp=$P --with-ppl=$P
make
make install

 

Now, Install GCC http://ftp.gnu.org/gnu/gcc/

================
cd ~/depend/gcc-4.6.2/ ;
export LD_LIBRARY_PATH=/home/users/d/dr/droidzone/hostusr/lib:/home/users/d/dr/droidzone/hostusr:$LD_LIBRARY_PATH ; ./configure –prefix=$P –with-gmp=$P –with-ppl=$P –with-cloog=$P –with-mpc=$P –with-mpfr=$P
make

Libraries have been installed in:
/home/users/d/dr/droidzone/hostusr/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR’
flag during linking and do at least one of the following:
– add LIBDIR to the `LD_LIBRARY_PATH’ environment variable
during execution
– add LIBDIR to the `LD_RUN_PATH’ environment variable
during linking
– use the `-Wl,-rpath -Wl,LIBDIR’ linker flag
– have your system administrator add LIBDIR to `/etc/ld.so.conf’

———————————————————————-
Libraries have been installed in:
/home/users/d/dr/droidzone/hostusr/libexec/gcc/x86_64-unknown-linux-gnu/4.6.2

/home/users/d/dr/droidzone/hostusr/lib/../lib64

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR’
flag during linking and do at least one of the following:
– add LIBDIR to the `LD_LIBRARY_PATH’ environment variable
during execution
– add LIBDIR to the `LD_RUN_PATH’ environment variable
during linking
– use the `-Wl,-rpath -Wl,LIBDIR’ linker flag
– have your system administrator add LIBDIR to `/etc/ld.so.conf’

ERROR (gcc build)
=====

-fvisibility=hidden -DHIDE_EXPORTS
In file included from /home/users/d/dr/droidzone/depend/gcc-4.6.2/host-x86_64-unknown-linux-gnu/gcc/include-fixed/features.h:361:0,
from /usr/include/stdio.h:28,
from ../../.././libgcc/../gcc/tsystem.h:87,
from ../../.././libgcc/../gcc/libgcc2.c:29:
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
compilation terminated.
make[5]: *** [_muldi3.o] Error 1
make[5]: Leaving directory `/home/users/d/dr/droidzone/depend/gcc-4.6.2/x86_64-unknown-linux-gnu/32/libgcc’
make[4]: *** [multi-do] Error 1
make[4]: Leaving directory `/home/users/d/dr/droidzone/depend/gcc-4.6.2/x86_64-unknown-linux-gnu/libgcc’
make[3]: *** [all-multi] Error 2
make[3]: Leaving directory `/home/users/d/dr/droidzone/depend/gcc-4.6.2/x86_64-unknown-linux-gnu/libgcc’
make[2]: *** [all-stage1-target-libgcc] Error 2
make[2]: Leaving directory `/home/users/d/dr/droidzone/depend/gcc-4.6.2′
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/users/d/dr/droidzone/depend/gcc-4.6.2′
make: *** [all] Error 2

FIX
===
./configure with –disable-multilib

./configure –prefix=/home/users/d/dr/droidzone/hostusrgcc –with-gmp=/home/users/d/dr/droidzone/hostusr –with-ppl=/home/users/d/dr/droidzone/hostusr –with-cloog=/home/users/d/dr/droidzone/hostusr –with-mpc=/home/users/d/dr/droidzone/hostusr –with-mpfr=/home/users/d/dr/droidzone/hostusr –disable-multilib

ERROR
=====
Autoconf installed but “installed autoconf does not work”

Fix
===
Autoconf 2.13 required by Smitna’s script was too old. Soln was to compile and install a newer version.

Error on compiling glibc with new gcc
=====================================
if test -r /home/users/d/dr/droidzone/hostusr/include/gnu/stubs-64.h && cmp -s /home/users/d/dr/droidzone/depend/glibcb/stubs.h /home/users/d/dr/droidzone/hostusr/include/gnu/stubs-64.h;
then echo ‘stubs.h unchanged’;
else /home/users/d/dr/droidzone/hostusr/bin/install -c -m 644 /home/users/d/dr/droidzone/depend/glibcb/stubs.h /home/users/d/dr/droidzone/hostusr/include/gnu/stubs-64.h; fi
rm -f /home/users/d/dr/droidzone/depend/glibcb/stubs.h
/home/users/d/dr/droidzone/depend/glibcb/elf/sln /home/users/d/dr/droidzone/depend/glibcb/elf/symlink.list
rm -f /home/users/d/dr/droidzone/depend/glibcb/elf/symlink.list
rm: error while loading shared libraries: /home/users/d/dr/droidzone/hostusr/lib/libc.so.6: ELF file OS ABI invalid
make[1]: *** [install-symbolic-link] Error 127
make[1]: Leaving directory `/home/users/d/dr/droidzone/depend/glibc-2.14′
make: *** [install] Error 2

Compile binutils
./configure –prefix=/home/users/d/dr/droidzone/hostusr –with-mpc=/home/users/d/dr/droidzone/hostusr –with-ppl=/home/users/d/dr/droidzone/hostusr –with-mpfr=/home/users/d/dr/droidzone/hostusr –with-gmp=/home/users/d/dr/droidzone/hostusr –with-cloog=/home/users/d/dr/droidzone/hostusr

configure: error: in `/home/users/d/dr/droidzone/depend/binutils-2.22′:
configure: error: C compiler cannot create executables
See `config.log’ for more details.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Compiling GCC for Sourceforge Host

One should follow a specific order to compile GCC, making sure that all dependencies are compiled properly. Some dependencies depend on others. In general the packages required to compile GCC properly are

Essential prerequisites:

Autoconf
Automake
M4

Direct Dependencies

GMP (requires -cxx option)
PPL (dep: GMP)
MPFR (dep: GMP)
MPC (dep: GMP, MPFR)
CLOOG-PPL (dep: GMP,PPL)

Install GMP first
============

./configure --prefix=/home/users/d/dr/droidzone/hostusr --enable-cxx
make ; make install[/code]

Install PPL next

============
PPL depends on GMP, so specify its location

./configure --prefix=/home/users/d/dr/droidzone/hostusr --with-gmp-prefix=/home/users/d/dr/droidzone/hostusr[/code]
make ; make install

Install MPFR

============

./configure --prefix=/home/users/d/dr/droidzone/hostusr --with-gmp=/home/users/d/dr/droidzone/hostusr
make ; make install[/code]

Now, Install MPC

================
Install MPFR and GMP first

, and then specify their path for MPC!

./configure --prefix=/home/users/d/dr/droidzone/hostusr --with-gmp=/home/users/d/dr/droidzone/hostusr --with-mpfr=/home/users/d/dr/droidzone/hostusr
make ; make install[/code]

Now, install CLOOG-PPL (For Graphite Loop Optimizations)

========================

./configure --prefix=/home/users/d/dr/droidzone/hostusr --with-gmp=/home/users/d/dr/droidzone/hostusr --with-ppl=/home/users/d/dr/droidzone/hostusr[/code]

Now, Install GCC

================

export LD_LIBRARY_PATH=/home/users/d/dr/droidzone/hostusr/lib:$LD_LIBRARY_PATH[/code]

./configure --prefix=/home/users/d/dr/droidzone/hostusr --with-gmp=/home/users/d/dr/droidzone/hostusr --with-ppl=/home/users/d/dr/droidzone/hostusr --with-cloog=/home/users/d/dr/droidzone/hostusr --with-mpc=/home/users/d/dr/droidzone/hostusr --with-mpfr=/home/users/d/dr/droidzone/hostusr --disable-multilib[/code]

Finally I found that GCC needs Glibc. Glibc needs Binutils!

Now, Install Binutils

================

./configure --prefix=/home/users/d/dr/droidzone/hostusr --with-gmp=/home/users/d/dr/droidzone/hostusr--with-ppl=/home/users/d/dr/droidzone/hostusr --with-cloog=/home/users/d/dr/droidzone/hostusr --with-mpc=/home/users/d/dr/droidzone/hostusr --with-mpfr=/home/users/d/dr/droidzone/hostusr
make ; make install
[/code]

You have to do a make clean if you get errors

Errors likely

However, with this, I got a specific error after around 10 minutes of building!

checking for x86_64-unknown-linux-gnu-gcc... /home/users/d/dr/droidzone/depend/gcc-4.6.2/host-x86_64-unknown-linux-gnu/gcc/xgcc -B/home/users/d/dr/droidzone/depend/gcc-4.6.2/host-x86_64-unknown-linux-gnu/gcc/ -B/home/users/d/dr/droidzone/hostusr/x86_64-unknown-linux-gnu/bin/ -B/home/users/d/dr/droidzone/hostusr/x86_64-unknown-linux-gnu/lib/ -isystem /home/users/d/dr/droidzone/hostusr/x86_64-unknown-linux-gnu/include -isystem /home/users/d/dr/droidzone/hostusr/x86_64-unknown-linux-gnu/sys-include
checking for suffix of object files... configure: error: in `/home/users/d/dr/droidzone/depend/gcc-4.6.2/x86_64-unknown-linux-gnu/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[2]: *** [configure-stage1-target-libgcc] Error 1
make[2]: Leaving directory `/home/users/d/dr/droidzone/depend/gcc-4.6.2'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/users/d/dr/droidzone/depend/gcc-4.6.2'
make: *** [all] Error 2
[/code]
This means you had to pass LIB path.

Then I got another one..

In file included from /home/users/d/dr/droidzone/depend/gcc-4.6.2/host-x86_64-unknown-linux-gnu/gcc/include-fixed/features.h:361:0,
from /usr/include/stdio.h:28,
from ../../.././libgcc/../gcc/tsystem.h:87,
from ../../.././libgcc/../gcc/libgcc2.c:29:
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
[/code]

FIX
===

./configure for gcc with --disable-multilib[/code]

./configure --prefix=/home/users/d/dr/droidzone/hostusr --with-gmp=/home/users/d/dr/droidzone/hostusr --with-ppl=/home/users/d/dr/droidzone/hostusr --with-cloog=/home/users/d/dr/droidzone/hostusr --with-mpc=/home/users/d/dr/droidzone/hostusr --with-mpfr=/home/users/d/dr/droidzone/hostusr --disable-multilib[/code]

For this, the following bit of information is useful:

Some other useful info:

Libraries have been installed in:
/home/users/d/dr/droidzone/hostusr/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'[/code]


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Compiling Glib2 on Sourceforge ssh environment

First, config and install libffi to /home/users/d/dr/droidzone/hostusr

Download libffi, config:

./configure --prefix=/home/users/d/dr/droidzone/hostusr
make
make install
[/code]

Download Glib2

export LIBFFI_LIBS=-lffi
export LIBFFI_CFLAGS=-I//home/users/d/dr/droidzone/hostusr/lib/libffi-3.0.10/include
./configure --prefix=/home/users/d/dr/droidzone/hostusr
make
make install[/code]


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.