Compile latest version of perl on Debian squeeze / Using latest version of perl on Debian squeeze

Debian squeeze comes with perl 5.10. For my tests with perl, I required 5.16.1, so I needed a newer version. Unfortunately only sid comes with newer perl versions.

Fortunately compiling from source is too easy.

Replace the perl source file name with the name of the file you download:

wget http://www.cpan.org/src/5.0/perl-5.16.3.tar.gz
tar -xf perl-5.16.3.tar.gz
cd perl-5.16.3/
sh Configure -d
make -j4
make install

Now, replace the system version with a symlink to your new version, unless you were smart enough to update the installation path with manual perl installation. when we used “Configure -d”, we used defaults for installation, so right now we have two versions of perl.

rm /usr/bin/perl
ln -s /usr/local/bin/perl /usr/bin/perl

Now install any optional modules:

cpan install WWW/Mechanize.pm
cpan install File/Find/Rule.pm

etc.


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.
Automatically update all WordPress plugins from Bash

Automatically update all WordPress plugins from Bash

I’ve updated the script radically. WordPress had changed their site structure so that the older script would fail. With the latest updates, it should still work.

Latest version:
Writeup
Download

I was searching for an idea on how to automatically update all my WordPress plugins from Linux command line. Google introduced me to a script by Ventz Petkov. It worked very well with minor modifications. This script could automatically download all plugins from WordPress.org according to the subdirectories in the WordPress plugin directory.

However a minor drawback of the script is that it would overwrite all plugins without checking whether our plugins are already up to date. I thought this was a waste of resources, since the obvious use of such a script is to get it to run as a cron job at regular intervals. There is no need to keep downloading the same versions of plugins that you already have, countless number of times. Even Petkov has conceded as much, stating that such an addition would be quite useful.

So there you are, my first perl script. I would like to record due credits to Petkov for his method of parsing the wordpress.org website, and his framework. All that I’ve done is to add code for comparing the plugin versions that are in your plugins directory, with those on the website to see if there are available updates. If there are, only then are the files downloaded.

The latest version of the script can always be downloaded from here (New link).

The script can take command line argument. Argument #1 is the path to plugin directory. Argument #2 is the plugin to update (meaning you can manually update one plugin at a time), and is a remnant of the original script. For my purpose, I wont be using Argument #2, since I intend the script to be run automatically, updating as when updates are found.

Screenshots:

Script command line options:

--help or -h: Display this help message
--source=/path/to/plugindirectory or -s/path/to/plugindirectory
	Multiple folders can be specified at a time.
	Eg: ./updater.pl --source=/var/www/virtual/joel.co.in/vettathu.com/htdocs/wp-content/plugins,/var/www/virtual/joel.co.in/drjoel.in/htdocs/wp-content/plugins
--version or -v: Display script version information
--plugin=PluginName or -pPluginName: Specify one or more plugins to process instead of all plugins under source directory. To specify more than one plugin,
you can either repeat this option, like:
	Eg: ./updater.pl --plugin=nextgen-gallery --plugin=genesis-beta-tester
	  Or,
you can alternately specify a comma seperated list of plugins, like:
	Eg: ./updater.pl --plugin=nextgen-gallery,genesis-beta-tester
--wp-path= or -wp: Specify wordpress root directory instead of plugin directory
	Eg: ./updater.pl --wp-path=/var/www/virtual/joel.co.in/droidzone.in/htdocs,/var/www/virtual/joel.co.in/vettathu.com/htdocs

Examples:

/root/wordpress_plugin_updater/updater.pl -w/var/www/virtual/joel.co.in/droidzone.in/htdocs

/root/wordpress_plugin_updater/beta.pl -s/var/www/virtual/joel.co.in/droidzone.in/htdocs/wp-content/plugins

If running from cron:

/usr/bin/perl /path/to/updater.pl -s/var/www/virtual/joel.co.in/vettathu.com/htdocs/wp-content/plugins

An example crontab entry would be:

* */6 * * * /usr/bin/perl /root/bash-advanced-scripts/updater.pl -s/var/www/virtual/joel.co.in/drjoel.in/htdocs/wp-content/plugins >> /root/wordpress_update.log

Here the script is being run sixth hourly every day, and a log appended. You can have multiple entries for multiple blogs.

The following line will automatically flush log files, keeping last 6 days of backups:

0 0 */3 * * mv /root/wordpress_update.log /root/wordpress_update.log.old

You can see the list of updated plugins by:

[[email protected]] ~/temp #cat /root/wordpress_update.log | grep -in 'updating' --color
83:Processing plugin: easy-contact-forms | Local version 1.4 | Remote version 1.4.2 | Updating now..
158:Processing plugin: wordpress-importer | Local version 0.6 | Remote version 0.6.1 | Updating now..
68527:Processing plugin: fancier-author-box | Local version 1.0.5 | Remote version 1.0.6.1 | Updating now..
68910:Processing plugin: fancier-author-box | Local version 1.0.5 | Remote version 1.0.6.1 | Updating now..
90869:Processing plugin: simple-backup | Local version 2.7.1 | Remote version 2.7.2 | Updating now..
91357:Processing plugin: look-see-security-scanner | Local version 13.01 | Remote version 13.04 | Updating now..
91740:Processing plugin: look-see-security-scanner | Local version 13.01 | Remote version 13.04 | Updating now..
113638:Processing plugin: bulletproof-security | Local version .48 | Remote version .48.1 | Updating now..
113686:Processing plugin: bulletproof-security | Local version .48 | Remote version .48.1 | Updating now..
113718:Processing plugin: bulletproof-security | Local version .48 | Remote version .48.1 | Updating now..

 

The current version as of 31/03/13 is included below:

#!/usr/bin/perl -w
# Original Author: Ventz Petkov
# Last updated by Original Author on
# Date: 06-15-2011
# Last: 12-20-2012
# Version: 2.0
#
# Rewritten by: Droidzone
# Date 31-03-2013 www.droidzone.in
# Version 3.0.0.2
# Usage:
# ./update-wp-plugins.pl
#   or
# ./update-wp-plugins.pl registered-name-of-plugin
# (and this works to update an exiting plugin or download+install a new one)

$progversion="3.0.0.2";
$debugmode=0;
use Term::ANSIColor;
print color 'bold blue';
print "Wordpress Plugin Updater script v$progversion.\n";
print color 'reset';
&argparser(@$ARGV);

if(!defined($ARGV[0])) {
    dprint ("No arguments supplied for folder path");
	$path="/var/www/virtual/joel.co.in/vettathu.com/htdocs/wp-content/plugins";
	dprint ("Path was specified on the command line\n");
}
else {
	#my @values = split(',', $ARGV[0]);	
	#foreach my $val (@values) 
	$path=$ARGV[0];
	print "Working on directory: $path\n";	    
    if ( -d $path )
    {
		dprint ("Path verified\n");
    }
    else
    {
		dprint ("The path does not exist\n");
	exit;
    }
}

dprint ("The path was set as ".$path."\n");
print "Plugin directory:$path\n";
chdir($path);

use WWW::Mechanize;
#use File::Find;
my $mech = WWW::Mechanize->new();
$mech->agent_alias( 'Mac Safari' );
my $wp_base_url = "http://wordpress.org/extend/plugins";

################################################
# Add New plugins Here:
# Format:
#   'registered-name-of-plugin',
#
my (@plugins, @plugins_notfound, @filepath, @pluginversion);

use File::Find::Rule;
use File::Spec;

my @folders = File::Find::Rule->directory->maxdepth(1)
    ->in( $path )
    ;

foreach my $i (@folders){
    ( $volume, $directories, $file ) = File::Spec->splitpath( $i );
	undef $volume, $directories;
    if ( $file ne "plugins" )
    {
        push @plugins, $file;
		push @filepath, $i;
		#print "Path: ".$i."\t Name: ".$file."\n";
    }
}

for (my $i = 0; $i < @plugins ; $i++ ) 
{
    dprint ("Processing ".$plugins[$i]."...");
    #print "Filename:".$filepath[$i]."/".$plugins[$i].".php"."\n";
    $filename=$filepath[$i]."/".$plugins[$i].".php";
	$varfound=0;
    if ( -f $filename ) 
    {
		dprint ("Meta File found at default location.\n");				
		open("txt", $filename);
		while($line = <txt>) 
		{			
			if ( $line =~ /^\s*\**\s*\bVersion:(.*)/i )
			{
				$pluginversion[$i]=$1;
				dprint ("Version found in file ".$filename);						
				$varfound=1;										
				dprint ($pluginversion[$i]."\n");
				dprint ("Array Num ".$i." Stored plugin name:".$plugins[$i]." Version found and stored ".$pluginversion[$i]);
			}
		}
		close("txt");			
    }
    else
    {
		$searchpath=$path."/".$plugins[$i];
		@files = <$searchpath/*.php>;
		dprint ("Search path is ".$searchpath."\n");
OUT: 	foreach $file (@files) 
		{
			dprint ("Checking alternate php file: ".$file."\n");
			open("txt", $file);
			while($line = <txt>) 
			{
				#  $line =~ /^[\s\*]*Version:(.*)/i
				# Discussion on regex: http://stackoverflow.com/questions/15728671/perl-regex-logic-error
				if ( $line =~ /^\s*\**\s*\bVersion:(.*)/i )
				{
					$pluginversion[$i]=$1;
					dprint ("Version found in file ".$file);						
					$varfound=1;										
					dprint ($pluginversion[$i]."\n");
					dprint ("Array Num ".$i." Stored plugin name:".$plugins[$i]." Version found and stored ".$pluginversion[$i]);
					last OUT;
				}
			}
			close("txt");	
		}
    }
	push @plugins_notfound, $plugins[$i];
}

if ( ! $varfound) 
{
	print "\nCould not parse version no from the follwing plugins:\n";
	for (my $i = 0; $i < @plugins_notfound ; $i++ ) 
	{
		print $i." ".$plugins_notfound[$i]."\n";
	}
}
else 
{
	dprint ("We found all version numbers");
}
print color 'red';
#print colored("Summary of scanning plugin directory", 'red'), "\n";
print "Summary of scanning plugin directory\n";
print "------------------------------------\n";
printf("%-4s %-45s %3s\n", "No", "Name", "Version");
print color 'reset';
#print "No:\tName\tVersion\n";
for (my $i = 0; $i < @plugins ; $i++ ) 
{
	$v = $pluginversion[$i];
	$v =~ s/[^a-zA-Z0-9\.]*//g;	
	printf("%-4s %-45s %3s\n", $i, $plugins[$i], $v );
	#print "$i\t$plugins[$i]\t$pluginversion[$i]\n";
}
print "\n";

################################################
$pluginsdone=0;

if(defined($ARGV[1])) {
    my $name = $ARGV[1];
    &update_plugin($name);
}
else {
	$i=-1;
    for my $name (@plugins) {
		$i++;
        &update_plugin($name,$i);
    }
}

print "Plugin updation completed successfully.\n";

if ( $pluginsdone > 1 )
{
	print "$pluginsdone plugin(s) were updated.\n";
}
else
{
	print "Plugins were already up-to-date. Nothing done.\n";
}

sub update_plugin {

    my $name = $_[0];
	my $index = $_[1];
    my $url = "$wp_base_url/$name";
    $mech->get( $url );
    my $page = $mech->content;
	$url="";
    my ($version,$description,$file) = "";
    if($page =~ /.*<p class="button"><a itemprop='downloadUrl' href='(.*)'>Download Version (.*)<\/a><\/p>.*/) 
	{
		$url = $1;
		$version = $2;
		if($page =~ /.*<p itemprop="description" class="shortdesc">\n(\s+)?(.*  
	)(\s+)(\t+)?<\/p>.*/) 
		{
			$description = $2;
		}
		if($url =~ /http:\/\/downloads\.wordpress\.org\/plugin\/(.*)/) 
		{
			$file = $1;
		}
    }	
	$oldversion = $pluginversion[$index];
	$version =~ s/[^a-zA-Z0-9\.]*//g;	
	$oldversion =~ s/[^a-zA-Z0-9\.]*//g;

    print "Processing plugin: ";
	print colored($name, 'green');	
	print " | Local version ";
	print colored($oldversion, 'green');		
	print " | Remote version ";

	if ( $version eq $oldversion )
	{
		print colored($version, 'green');	
		print " | ";
		print colored("Already update\n", 'green');
	}
	else
	{
		print colored($version, 'red');	
		print " | ";
		$pluginsdone++;
		print colored("Updating now..\n\n", 'blue');
		#print "Updating plugin $name now";
		`/bin/rm -f $file`; print "Downloading: \t$url\n";
		`/usr/bin/wget -q $url`; print "Unzipping: \t$file\n";
		`/usr/bin/unzip -o $file`; 
		print colored("Installed: \t$name\n\n", 'green');		
		`/bin/rm -f $file`;
	}
}

sub read_extract
{
	my $pl_version="";
    open("txt", my $file=$_[0]);
    while($line = <txt>)
    {
		for ($line)
		{
		 s/^\s+//;
		 s/\s+$//;
		}			
        if ( $line =~ /^Version:|^version:|^\* Version:/ )
        {
            $pl_version=&extract_version($line);
        }
    }
    close("txt");
	$pl_version;
}

sub extract_version
{
    my $line=$_[0];
    $string=substr($line,rindex($line, ":")+1);
    for ($string)
    {
     s/^\s+//;
     s/\s+$//;
    }
    $string;
}

sub dprint
{
	$debugtext=$_[0];
	if ($debugmode) 
	{
		print $debugtext."\n";
	}
}	

sub print_help 
{
	print "\nCommand syntax:";
	print "\n";
	print "wpupdater [path/to/plugin dir] [plugin name]\n";
	print "\nBoth arguments are optional\n\n";
}

sub argparser
{
	foreach (@ARGV) {
		$argu=$_;
		#print "Argument:$argu";
		if ($argu eq "--help")
		{
			&print_help;
			exit;
		}
	}

}

You can add these as a cron job.


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

Partially replace path in a sql field

 

SELECT *
FROM `wp_4_download_monitor_files`
WHERE `filename` LIKE '%/var/www/virtual%'
ORDER BY `wp_4_download_monitor_files`[/code]
 


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

Bash script for splitting a filename, extension and path from fullpath

Call the function split_filenames with the first argument as the full filename with path. Alternately, set the variable fullfile to this value.

#!/bin/bash

split_filenames() {
# echo "Called with Arg: $1"
if [ ! "$1" = "" ]
then
fullfile=$1

fi
# echo I got this filename for processing $fullfile
filename=$(basename "$fullfile")
fname=$(basename "$fullfile")
nameonly=${filename%.*}
ext=${fname##*.}

echo "filename $filename"

filename=${fullfile%.*}
pathonly=${fullfile%/*}

if [ "$pathonly" = "$fullfile" ]
then
pathonly="$pat"
fi

echo "Path $pathonly"
echo "Name $nameonly"

chkper=$(echo $fullfile | grep -c "\.")
# echo "Number of periods:$chkper"

if [ ! "$chkper" = "0" ]
then
echo "Extension $ext"
else
echo "No extension"
fi

#out_file=$pathonly/$nameonly"_signed."$ext

}

for i in ~/Dropbox/SSH\ Keys/*
do
echo
echo Path and Name: $i
split_filenames "$i"
#cp "$i" testssh/
done[/code]
In the example, the main event calls the function from a loop which cycles through all the files in the specified directory.


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

dpkg: warning: ‘ldconfig’ not found in PATH or not executable.

Error:

[[email protected] ~]$sudo apt-get autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  xaw3dg
0 upgraded, 0 newly installed, 1 to remove and 123 not upgraded.
After this operation, 460 kB disk space will be freed.
Do you want to continue [Y/n]? y
dpkg: warning: 'ldconfig' not found in PATH or not executable.
dpkg: warning: 'start-stop-daemon' not found in PATH or not executable.
dpkg: warning: 'update-rc.d' not found in PATH or not executable.
dpkg: 3 expected programs not found in PATH or not executable.
NB: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin.
E: Sub-process /usr/bin/dpkg returned an error code (2)

Try fix:

Edit /etc/sudoers with visudo and add the line:

Defaults        env_reset
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

The whole file now looks like this for me:

# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults        env_reset
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL

# Allow members of group sudo to execute any command
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d

droidzone ALL=(ALL) ALL

 

Trying the command which failed earlier:

[[email protected] ~]$sudo apt-get install emacs
Reading package lists... Done
Building dependency tree
Reading state information... Done
emacs is already the newest version.
The following package was automatically installed and is no longer required:
xaw3dg
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 122 not upgraded.[/code]
It now works!


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

Make sudo use current user’s $PATH

To do this, setup an alias for sudo in ~/.bashrc:

alias sudo='sudo env PATH=$PATH'

Credits to pixelbeat at Stackoverflow


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

Compile and install mc in a non root Linux environment (XDA and Goo.im)-WIP

Get the source:

mkdir ~/sources && cd ~/sources

wget http://ftp.gnu.org/gnu/mc/mc-4.6.1.tar.gz

tar -xvvf mc-4.6.1.tar.gz
cd ~/sources/mc-4.6.1
./configure –prefix=/home/droidzone/myapps

Error:
checking for pkg-config… no
*** The pkg-config script could not be found. Make sure it is
*** in your path, or set the PKG_CONFIG environment variable
*** to the full path to pkg-config.
*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config.
checking for glib-config… no
checking for glib12-config… no
checking for glib-config… no
checking for GLIB – version >= 1.2.6… no
*** The glib-config script installed by GLIB could not be found
*** If GLIB was installed in PREFIX, make sure PREFIX/bin is in
*** your path, or set the GLIB_CONFIG environment variable to the
*** full path to glib-config.
configure: error: Test for glib failed.
GNU Midnight Commander requires glib 1.2.6 or above.

So install pkg-config:
cd ~/sources
wget http://pkgconfig.freedesktop.org/releases/pkg-config-0.27.1.tar.gz
tar -xvvf pkg-config-0.27.1.tar.gz
cd pkg-config-0.27.1/
./configure –prefix=/home/droidzone/myapps –with-internal-glib
make && make install

Confirm that it works:
[email protected]:~/sources/pkg-config-0.27.1$ which pkg-config
/home/droidzone/myapps/bin/pkg-config

Now retry installing mc:
cd ~/sources/mc-4.6.1
./configure –prefix=/home/droidzone/myapps

Error:
checking for pkg-config… /home/droidzone/myapps/bin/pkg-config
checking for glib-2.0… checking for glib-config… no
checking for glib12-config… no
checking for glib-config… no
checking for GLIB – version >= 1.2.6… no
*** The glib-config script installed by GLIB could not be found
*** If GLIB was installed in PREFIX, make sure PREFIX/bin is in
*** your path, or set the GLIB_CONFIG environment variable to the
*** full path to glib-config.
configure: error: Test for glib failed.
GNU Midnight Commander requires glib 1.2.6 or above.

Ok, install glib now:
cd ~/sources
wget http://ftp.acc.umu.se/pub/GNOME/sources/glib/2.34/glib-2.34.0.tar.xz
tar -Jxvvf glib-2.34.0.tar.xz
cd glib-2.34.0/
./configure –prefix=/home/droidzone/myapps

Error:
checking for inflate in -lz… no
configure: error: *** Working zlib library and headers not found ***

cd ~/sources
wget http://zlib.net/zlib-1.2.7.tar.gz
tar -xvvf zlib-1.2.7.tar.gz
cd zlib-1.2.7/
./configure –prefix=/home/droidzone/myapps
make && make install

Now retried glib installation, to be met with another error:
checking for LIBFFI… no
configure: error: Package requirements (libffi >= 3.0.0) were not met:

No package ‘libffi’ found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBFFI_CFLAGS
and LIBFFI_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

wget ftp://sourceware.org/pub/libffi/libffi-3.0.11.tar.gz
tar -xvvf
cd libffi-3.0.11
./configure –prefix=/home/droidzone/myapps
make && make install
———————————————————————-
Libraries have been installed in:
/home/droidzone/myapps/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’

export LD_LIBRARY_PATH=/home/droidzone/myapps/lib

Rerying glib config:
checking for msgfmt… no
configure: error:
*** You must have either have gettext support in your C library, or use the
*** GNU gettext library. (http://www.gnu.org/software/gettext/gettext.html

Gettext make led to errors:
/home/droidzone/myapps/lib/libncurses.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[4]: *** [libgettextlib.la] Error 1
make[4]: Leaving directory `/home/droidzone/sources/gettext-0.18.1.1/gettext-tools/gnulib-lib’
make[3]: *** [all] Error 2
make[3]: Leaving directory `/home/droidzone/sources/gettext-0.18.1.1/gettext-tools/gnulib-lib’
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/droidzone/sources/gettext-0.18.1.1/gettext-tools’
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/droidzone/sources/gettext-0.18.1.1/gettext-tools’
make: *** [all-recursive] Error 1
[email protected]:~/sources/gettext-0.18.1.1$


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

Compile fuseiso in a non root environment

I needed fuseiso to mount .iso files in a non root ssh envt.

So I needed to compile fuseiso first.

To compile fuseiso, you need to first compile libfuse.

cd ~/sources
wget http://nchc.dl.sourceforge.net/project/fuseiso/fuseiso/20070708/fuseiso-20070708.tar.bz2 (Dynamic link)
tar -jxvvf fuseiso-20070708.tar.bz2
cd fuseiso-20070708/
mkdir ~/myapps/fuse
./configure --prefix=/home/droidzone/myapps/fuse

 

This led to an error stating that it needed libfuse.

cd ..
wget http://nchc.dl.sourceforge.net/project/fuse/fuse-2.X/2.9.2/fuse-2.9.2.tar.gz
tar -xvvf fuse-2.9.2.tar.gz
cd fuse-2.9.2/
./configure --prefix=/home/droidzone/myapps/fuse
make
make install

Interestingly the program errored out, as even though I had given a prefix directory, it seemed to be trying to install certain stuff in root directiries. Even more interestingly I found that even though it terminated with an error, I found the following compilation message:

Libraries have been installed in:
/home/droidzone/myapps/fuse/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’

Sure enough, it seemed to have compiled all headers and libraries fine. So I decided to try building fuseiso anyway.

cd ../fuseiso-20070708

export LD_LIBRARY_PATH="/home/droidzone/myapps/fuse/lib"
export LD_RUN_PATH="/home/droidzone/myapps/fuse/lib"
export LDFLAGS="-L/home/droidzone/myapps/fuse/lib"
export CPPFLAGS="-I/home/droidzone/myapps/fuse/include"

./configure --prefix=/home/droidzone/myapps/fuse
make

Though it configured fine, it errored out during make

Package fuse was not found in the pkg-config search path.
Perhaps you should add the directory containing `fuse.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘fuse’ found
Package glib-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `glib-2.0.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘glib-2.0’ found

I needed to export these flags because it seemed to have difficulty while configuring, in locatin these libraries and includes of libfuse.

 


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

Installing javac for Apktool on linux

The build steps of the latest Apktool is detailed below

http://code.google.com/p/android-apktool/wiki/BuildApktool?tm=4

 

It uses something called gradlew to build the latest version of the binary.

The instructions are as follows:

We use gradle to build. Its pretty easy. First clone the REPO.

git clone git://github.com/iBotPeaches/Apktool.git
Move into the directory.

cd Apktool
Issue the build.

./gradlew build
Then look in

/brut.apktool/apktool-cli/build/libs/apktool-xxxxx.jar
Other commands such as clean are

./gradlew clean

If you attempt that and dont have JDK installed, it will error out.

You need to download the latest version of the JDK available as a .tar.gz file at http://www.oracle.com/technetwork/java/javase/downloads/index.html

I used jdk-7u9-linux-i586.tar.gz

Once extracted, set the path as the path of the folder containing the bin folder (which contains javac). Note that the path should be the parent of the bin folder, and not include the bin folder itself.

export JAVA_HOME=/home/droidzone/android/java/jdk1.7.0_09

Here, jdk1.7.0_09/bin contains javac.

The final file will be produced in a location brut.apktool/apktool-cli/build/libs/ relative to the parent and named of the form apktool-cli-1.5.1-SNAPSHOT.jar

So

cp brut.apktool/apktool-cli/build/libs/*jar ./

should get you the latest file.

Note that you need the wrapper too.

wget http://android-apktool.googlecode.com/files/apktool-install-linux-r04-brut1.tar.bz2
tar -jxvvf apktool-install-linux-r04-brut1.tar.bz2

Finally since the apktool refers to a file named apktool.jar, create a symlink.

 

Possible errors:

Exception in thread "main" java.lang.UnsupportedClassVersionError: brut/apktool/Main : Unsupported major.minor version 51.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
Could not find the main class: brut.apktool.Main. Program will exit.

That happens when your main system version java is older than version 7.

You can solve it either by:

1. Upgrading your main java version

2. Setting the PATH of your local java to override your system java.

Eg: If PATH is :/usr/bin:~/bin, make it ~/bin:/usr/bin

3. Creating a symlink in /usr/bin, point it to your version

cd /usr/bin

su

mv java java.old

ln -s /home/droidzone/android/java/jdk1.7.0_09/bin/java java

 

 


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

Using Smitna’s Build tool

Issues found while using it on XDA server:

No autoconf2.13 found:

Compile and install autoconf2.13 to a different folder, now create a symlink:

ln -s autoconf autoconf2.13

Add both versions of Autoconf (the latest, and 2.13 version)’s bin path to $PATH

Now it should work

Other package I needed to install was scons


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