Trying to Build AOSP Gingerbread - Motorola Droid Android Development

I'm trying to build the AOSP Gingerbread for my Droid using this tutorial to patch the source, but I'm getting this error:
Code:
Nathan-Camposs-MacBook-Pro:AOSP Nathan$ lunch generic_sholes-userdebug
sed: illegal option -- r
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
build/core/product_config.mk:194: *** _nic.PRODUCTS.[[device/motorola/sholes/sholes.mk]]: "build/target/product/small_base.mk" does not exist. Stop.
** Don't have a product spec for: 'generic_sholes'
** Do you have the right repo manifest?
Nathan-Camposs-MacBook-Pro:AOSP Nathan$
What am I doing wrong? What should I do?

Sorry this is so late.
You're on a mac. The built-in 'sed' doesn't have the options needed. I'll assume you installed gsed from ports (if not, do so). Then:
Code:
sudo mv /usr/bin/sed /usr/bin/sed.old
sudo ln -s `which gsed` /usr/bin/sed
Note that this mark is a back-tick, not a single quote:
Code:
`

Related

[Q] Error compiling ROM

I'm trying to compile a ROM from CM7 sources, but when I try it I keep getting this error.
Code:
sed: illegal option -- r
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
build/core/combo/HOST_darwin-x86.mk:31: *****************************************************
build/core/combo/HOST_darwin-x86.mk:32: * You are building on Mac OSX 10.6.
build/core/combo/HOST_darwin-x86.mk:33: * Can not find SDK 10.5 at /Developer/SDKs/MacOSX10.5.sdk
build/core/combo/HOST_darwin-x86.mk:34: * Falling back to 10.6 SDK.
build/core/combo/HOST_darwin-x86.mk:35: *****************************************************
I'm using SDK 10.6, as it says on CM Wiki.
Can anyone tell me what I'm doing wrong please?

Optware for Android, another try

If you're interested in running more complete Unix/Linux environment on your Android device, you might have heard about Optware for Android, here is thread for example.
Well, that project had few issues, like: shipping binaries of unknown origin and running them on user's device as root; coded and advertised as applying to one particular device; making too much changes on the device in one turn (like alter rootfs image).
That's why I decided to create another Optware install script to address those points. It is explicitly envisioned to support Android as an OS/Platform, i.e. all devices, not one particular model. Well, that may be not exactly easy, but that's at least good aim to pursue. It also doesn't come with any random binaries, but instead downloads them from a trusted source during the installation process (sources being Optware itself for bootstrap packages and CodeSourcery toolchain package for libc on which Optware depends).
Due to the last point, the installation script runs on a Linux host, so ADB connection to the device is required. Device also should have working "su" command (i.e. be rooted).
The source code is on github: https://github.com/pfalcon/optware-android
Just a bit of DISCLAIMER: you should run this script only if you understand what Optware is, and how to use it. Some experience with Unix/Linux command line and shell scripts is required, in particular you should skim thru the install script before running it.
Otherwise, it works quite well on my Nook Tablet, and I'd be happy to receive suggestions, success/bug reports, patches, etc.
Great work.
I took the liberty of using your script as a base to install OpenSSH. Should work on any device. I can't post links so I attached an archive with the script and the necessary files.
CyanogenMod on my Touchpad has some sort of sysinit '/etc/init.d', so I initialize Optware and Optware init scripts from there. I don't know how other mods handle this, probably different. SSH authentication is key-based, since passwords are not set. Have a look at the script to figure out how to deal with that.
Glad it was useful for you. Issue how to automatically start up daemons on Android indeed exists. The native Android way is /init.rc config file (of adhoc format). The problem is that this file is located on rootfs, which is ramdisk, i.e. any changes are lost and not available during boot. And initial content of that ramdisk comes from initramfs/initrd, but it has many ways to be implemented - compiled into kernel or on separate partition, checksumed against any changes, etc. So, in general case it's not possible to update, and even if it is, a mistake can lead to bricked device.
So, I for now skipped that issue altogether in my installer, but hope to get to it eventually (have some ideas).
So, if you have CyanogenMod, then using /etc/init.d is for sure a good solution.
One suggestion/question... is it possible to alter the script to run directly off of the device's command line? That would eliminate the Linux (and optionally would eliminate the ADB requirement).
I'm sure there's a static wget binary for ARM already compiled somewhere, and the rest can be done through busybox.
That would really make it universal. I'm a Windows user, and haven't had the time to parse out your script and figure out what the end result is supposed to look like on the device
merwin said:
One suggestion/question... is it possible to alter the script to run directly off of the device's command line?
Click to expand...
Click to collapse
There's now FAQ at http://sf.net/p/optware-android which discusses why this isn't possible on pristine Android system (lack of basic POSIX utilities and wget). It also has a suggestion for Windows users ;-).
That would eliminate the Linux (and optionally would eliminate the ADB requirement).
I'm sure there's a static wget binary for ARM already compiled somewhere, and the rest can be done through busybox.
Click to expand...
Click to collapse
The question is not if it's available, but whether you can trust such binary. The responsible user's answer is "No". Nook Color's optware installer does exactly that - ships binaries of unknown origin, and dissatisfaction with such approach is what prompted be to develop alternative installer.
The only way you can trust it if [easily buildable] source is provided, then it's up to the user to either compile it themselves or on their own risk to use provided binary. I don't have such source at my hands, and not interested to make it zillion's time just for this adhoc purpose - instead, there should be well-established community project to provide such build framework for all other projects to reuse. I hope, we'll tackle that under auspices of f-droid.org project.
That would really make it universal. I'm a Windows user, and haven't had the time to parse out your script and figure out what the end result is supposed to look like on the device
Click to expand...
Click to collapse
Other possible approach is to just skip "shell script" (and need for busybox) thing at all, and write installer in Java, to be run as normal Android app. That's certainly neat idea which will make users' life easier, and I have that on my (very long) TODO list ;-).
awesome! great work!
i have one small issue though: /etc/hosts doesnt seem to have any effect. a lot of stuff won't work because localhost cant be resolved. any suggestions?
2 onemandivision: Confirmed this issue, looking into it.
Ok, it turns out that GLibc's nsswitch default is weird in favoring DNS over /etc/hosts, and with Google DNS it didn't even look in the latter. Fixed by installing explicit nsswitch.conf:
# ping localhost
PING localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: seq=0 ttl=64 time=0.274 ms
Let's dub this 1.0 then (tagged).
pfalcon said:
There's now FAQ at http://sf.net/p/optware-android which discusses why this isn't possible on pristine Android system (lack of basic POSIX utilities and wget). It also has a suggestion for Windows users .
The question is not if it's available, but whether you can trust such binary. The responsible user's answer is "No". Nook Color's optware installer does exactly that - ships binaries of unknown origin, and dissatisfaction with such approach is what prompted be to develop alternative installer.
The only way you can trust it if [easily buildable] source is provided, then it's up to the user to either compile it themselves or on their own risk to use provided binary. I don't have such source at my hands, and not interested to make it zillion's time just for this adhoc purpose - instead, there should be well-established community project to provide such build framework for all other projects to reuse. I hope, we'll tackle that under auspices of f-droid.org project.
Other possible approach is to just skip "shell script" (and need for busybox) thing at all, and write installer in Java, to be run as normal Android app. That's certainly neat idea which will make users' life easier, and I have that on my (very long) TODO list .
Click to expand...
Click to collapse
Most phones that are rooted have a fairly recent version of busybox on it, which includes wget. Also, standard practice on kernels these days (non stock ones) is to have all scripts that exist in /etc/init.d execute. That would solve any service startup issue.
I don't see any problems with requiring root and busybox
Solves all of the issues.
Hello
I tried the script and i was able to install ipkg on my Samsung Galaxy II
the only problem is... if i try to install any package... i get a segmentation fault error
Code:
[email protected]:/ # [B]cd /data/opt[/B]
[email protected]:/data/opt # [B]./start.sh[/B]
[B]BusyBox v1.10.3 (2012-02-14 09:43:47 UTC) built-in shell (ash)
Enter 'help' for a list of built-in commands.[/B]
$(precmd)[email protected]$HOSTNAME:${PWD:-?} #
$(precmd)[email protected]$HOSTNAME:${PWD:-?} # [B]ipkg install rsync[/B]
[B]Installing rsync (3.0.9-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable/rsync_3.0.9-1_arm.ipk
Segmentation fault[/B]
$(precmd)[email protected]$HOSTNAME:${PWD:-?} #
any advice? :'(
If you already have shell access to your device and don't want to connect via ADB, I modified the script to have the ability to run directly on your device (your device will need at least a functional wget executable already, which I had from SSHDroid):
Code:
# OPTWARE_DIR is where to install optware, it should be on a partition with
# normal Unix filesystem (permissions, etc.)
OPTWARE_DIR=/data/opt
# Particular field to install from, stable by default
FEED=http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable
# DO NOT edit anything below this line unless you know what you are doing
start_script=start.sh
cs08q1_url=https://sourcery.mentor.com/sgpp/lite/arm/portal/package2549/public/arm-none-linux-gnueabi/arm-2008q1-126-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
cs08q1_fname=$(basename $cs08q1_url)
libc_path=arm-2008q1/arm-none-linux-gnueabi/libc
libc_libs="lib/ld-2.5.so ld-linux.so.3 \
lib/libc-2.5.so libc.so.6 \
lib/libm-2.5.so libm.so.6 \
lib/librt-2.5.so librt.so.1 \
lib/libpthread-2.5.so libpthread.so.0 \
lib/libresolv-2.5.so libresolv.so.2 \
lib/libdl-2.5.so libdl.so.2 \
lib/libnss_dns-2.5.so libnss_dns.so.2 \
lib/libutil-2.5.so libutil.so.1 \
lib/libgcc_s.so.1 libgcc_s.so \
lib/libnsl-2.5.so libnsl.so.1 \
lib/libcrypt-2.5.so libcrypt.so.1 \
lib/libBrokenLocale-2.5.so libBrokenLocale.so.1 \
lib/libanl-2.5.so libanl.so.1 \
lib/libcidn-2.5.so libcidn.so.1 \
lib/libnss_compat-2.5.so libnss_compat.so.2 \
lib/libnss_files-2.5.so libnss_files.so.2 \
lib/libnss_hesiod-2.5.so libnss_hesiod.so.2 \
lib/libnss_nis-2.5.so libnss_nis.so.2 \
lib/libnss_nisplus-2.5.so libnss_nisplus.so.2 \
lib/libthread_db-1.0.so libthread_db.so.1 \
"
#
# On-target (device) commands
#
t_cp () {
# copy file on a device
cat $1 >$2
}
t_cd_ln () {
local dir=$1
shift
cd $dir; ln $*
}
t_ln () {
ln $*
}
t_chmod () {
chmod $*
}
t_mkdir_p () {
# This doesn't complain if dir exists, but can't create intermediate dirs
ls $1 >/dev/null 2>&1 || mkdir $1
}
t_rm_f () {
# Doesn't complain if file not there
ls $1 >/dev/null 2>&1 && rm $1
}
t_rm_rf () {
# Doesn't complain if dir not there
ls $1 >/dev/null 2>&1 && rm -r $1
}
t_remount_rw () {
mount -o rw,remount $1 $1
}
t_remount_ro () {
mount -o ro,remount $1 $1
}
extract_libc () {
if [ ! -d $(echo $libc_path | sed -e 's%/.*%%') ]; then
echo Extracting $cs08q1_fname
tar xjf $cs08q1_fname $list
fi
}
install_system_lib () {
local f=$(basename $1)
echo "Installing system lib: $f"
t_cp $libc_path/$1 /lib/$f
t_chmod 0755 /lib/$f
t_ln -s $f /lib/$2
}
install_system_bin () {
local f=$(basename $1)
echo "Installing system bin: $1"
t_cp $libc_path/$1 /bin/$f
t_chmod 0755 /bin/$f
}
install_libc () {
while [ -n "$1" ]; do
local lib=$1
shift
local symlink=$1
shift
install_system_lib $lib $symlink
done
}
install_bin () {
echo "Installing /opt/bin/$1"
t_cp opt/bin/$1 /opt/bin/$1
t_chmod 755 /opt/bin/$1
}
install_ipkg () {
t_mkdir_p /opt/bin
t_mkdir_p /opt/lib
install_bin ipkg
t_cp opt/lib/libipkg.so.0.0.0 /opt/lib/libipkg.so.0.0.0
t_ln -s libipkg.so.0.0.0 /opt/lib/libipkg.so.0
t_ln -s libipkg.so.0.0.0 /opt/lib/libipkg.so
}
fetch_package_index () {
if [ ! -f Packages ]; then
echo "Downloading Optware package index"
wget -q $FEED/Packages
else
echo "Using cached Optware package index"
fi
}
get_package_fname () {
awk "/^Filename: ${1}_/ {print \$2}" Packages
}
fetch_package () {
if [ -z "$1" ]; then
echo "Unexpected error: package '$1' not found in index"
exit 1
fi
if [ ! -f "$1" ]; then
echo "Downloading Optware package $1"
wget -q $FEED/$1
else
echo "Using cached package $1"
fi
}
fetch_toolchain () {
if [ ! -f $cs08q1_fname ]; then
echo "You need CodeSourcery ARM-Linux toolchain release 2008q1: $cs08q1_fname"
echo "if you have this file on your system already, press Ctrl-C now and copy"
echo "it into the current directory. Otherwise, press Enter to download it (65MB)."
read
wget $cs08q1_url
fi
}
optware_uninstall () {
t_remount_rw /
t_remount_rw /system
rm -r $OPTWARE_DIR
rm /lib
rm /bin
rm /opt
rm /tmp
t_remount_ro /
rm /etc/resolv.conf
rm /etc/mtab
rm /etc/passwd
rm /etc/group
t_remount_ro /system
echo "Optware sucessfully uninstalled"
}
#
# Main code
#
if [ "$1" == "" ]; then
echo "This script installs NSLU Optware on an Android device connected using ADB"
echo "Usage: $0 install|uninstall"
exit 1
fi
if [ "$1" == "uninstall" ]; then
optware_uninstall
exit
fi
fetch_toolchain
fetch_package_index
ipkg_fname=$(get_package_fname ipkg-opt)
wget_fname=$(get_package_fname wget)
busybox_fname=$(get_package_fname busybox-base)
fetch_package $ipkg_fname
fetch_package $wget_fname
fetch_package $busybox_fname
t_remount_rw /
t_remount_rw /system
# Start from scratch
echo "== Initializing optware environment =="
t_mkdir_p $OPTWARE_DIR
t_ln -s $OPTWARE_DIR /opt
t_mkdir_p $OPTWARE_DIR/rootbin
t_ln -s $OPTWARE_DIR/rootbin /bin
t_mkdir_p $OPTWARE_DIR/rootlib
t_ln -s $OPTWARE_DIR/rootlib /lib
t_mkdir_p $OPTWARE_DIR/tmp
t_ln -s $OPTWARE_DIR/tmp /tmp
t_mkdir_p $OPTWARE_DIR/home
t_mkdir_p $OPTWARE_DIR/home/root
t_mkdir_p $OPTWARE_DIR/home/user
echo "== Installing libc =="
extract_libc
install_libc $libc_libs
install_system_bin usr/bin/ldd
echo "== Installing bootstrap ipkg =="
rm -rf opt
tar -xOzf $ipkg_fname ./data.tar.gz | tar -xzf -
install_ipkg
echo "== Installing bootstrap wget =="
rm -rf opt
tar -xOzf $wget_fname ./data.tar.gz | tar -xzf -
install_bin wget
echo "== Installing bootstrap busybox =="
rm -rf opt
tar -xOzf $busybox_fname ./data.tar.gz | tar -xzf -
install_bin busybox
echo "== Initializing bootstrap /bin =="
# We need sane shell as /bin/sh
t_ln -s /opt/bin/busybox /bin/sh
# We need minimal set of sane shell commands to run update-alternatives
# script to properly (re)install busybox itself
t_ln -s /opt/bin/busybox /bin/echo
t_ln -s /opt/bin/busybox /bin/rm
t_ln -s /opt/bin/busybox /bin/rmdir
t_ln -s /opt/bin/busybox /bin/sed
t_ln -s /opt/bin/busybox /bin/mkdir
t_ln -s /opt/bin/busybox /bin/head
t_ln -s /opt/bin/busybox /bin/sort
t_ln -s /opt/bin/busybox /bin/dirname
t_ln -s /opt/bin/busybox /bin/ln
t_ln -s /opt/bin/busybox /bin/mv
t_ln -s /opt/bin/busybox /bin/cat
t_ln -s /opt/bin/busybox /bin/chown
t_ln -s /opt/bin/busybox /bin/chmod
# gzip and tar should be part of Android, but there were reports
# that some implementations may be broken
t_ln -s /opt/bin/busybox /bin/tar
t_ln -s /opt/bin/busybox /bin/gzip
echo "== Configuring package feed =="
t_mkdir_p /opt/etc
t_mkdir_p /opt/etc/ipkg
echo src cross $FEED >/opt/etc/ipkg/feeds.conf
echo "== Configuring domain name resolution =="
echo nameserver 8.8.8.8 >/opt/etc/resolv.conf
# On a normal Android system, /etc is symlink to /system/etc, but just in case...
t_mkdir_p /etc
# but for normal system, we need to remount /system
t_rm_f /etc/resolv.conf
t_ln -s /opt/etc/resolv.conf /etc/resolv.conf
echo "== Configuring GLIBC Namespace Switch =="
t_cp nsswitch.conf /etc/nsswitch.conf
t_chmod 0644 /etc/nsswitch.conf
echo "== Configuring /etc/mtab =="
t_ln -s /proc/mounts /etc/mtab
echo "== Configuring users =="
echo root:x:0:0:root:/opt/home/root:/bin/sh >/opt/etc/passwd
echo shell:x:2000:2000:shell:/opt/home/user:/bin/sh >>/opt/etc/passwd
t_ln -s /opt/etc/passwd /etc/passwd
echo "== Configuring groups =="
echo root:x:0:root >/opt/etc/group
echo shell:x:2000:shell >>/opt/etc/group
t_ln -s /opt/etc/group /etc/group
echo "== Creating optware init script =="
echo '#!/system/bin/sh' >/opt/optware-init.sh
echo 'ls /opt >/dev/null 2>&1 && exit' >>/opt/optware-init.sh
echo echo Reinitializing optware rootfs links >>/opt/optware-init.sh
echo mount -o rw,remount rootfs / >>/opt/optware-init.sh
echo ln -s $OPTWARE_DIR /opt >>/opt/optware-init.sh
echo ln -s $OPTWARE_DIR/rootlib /lib >>/opt/optware-init.sh
echo ln -s $OPTWARE_DIR/rootbin /bin >>/opt/optware-init.sh
echo ln -s $OPTWARE_DIR/tmp /tmp >>/opt/optware-init.sh
echo mount -o ro,remount rootfs / >>/opt/optware-init.sh
t_chmod 0755 /opt/optware-init.sh
echo "== Creating optware startup script =="
echo '#!/system/bin/sh' >/opt/$start_script
echo 'ls /opt >/dev/null 2>&1 ||' su -c $OPTWARE_DIR/optware-init.sh >>/opt/$start_script
echo '# You may want to add /opt/local/bin to PATH below' >>/opt/$start_script
echo export PATH=/opt/sbin:/opt/bin:/bin:/system/bin >>/opt/$start_script
echo 'if busybox test $(busybox id -u) = 0; then HOME=/opt/home/root; else HOME=/opt/home/user; fi' >>/opt/$start_script
echo export HOME>>/opt/$start_script
echo export TMPDIR=/tmp >>/opt/$start_script
echo umask 022 >>/opt/$start_script
echo /bin/sh >>/opt/$start_script
t_chmod 0755 /opt/$start_script
# Create "s" symlink to ease typing on touchscreen devices
t_ln -s $start_script /opt/s
t_remount_ro /
echo "== Reinstalling bootstrap packages =="
echo "Make sure that your device is woken up and connected to the Internet"
echo "Press Enter to continue"
read
#
# Now that we have all dependencies to run ipkg bootstraped on device,
# we need to use ipkg to reinstall itself and all those dependencies,
# to make sure they're installed and configured properly.
#
PATH=/opt/bin:/bin /opt/bin/ipkg update
PATH=/opt/bin:/bin /opt/bin/ipkg install ipkg-opt
PATH=/opt/bin:/bin /opt/bin/ipkg install wget
PATH=/opt/bin:/bin /opt/bin/ipkg install busybox
echo "== Cleaning local directory =="
rm -rf opt arm-2008q1
t_remount_ro /system
echo "Optware for Android installation complete."
echo "To start optware session, execute $OPTWARE_DIR/$start_script (aka $OPTWARE_DIR/s) on the device"
echo "Also, make sure you have mounted whichever partition contains Optware as rw when you execute an update"
pfalcon, let me know if you want me to add any license headers to this.

[GUIDE] Simple Java6 installation on Precise/Mint-Maya/Ubuntu 12.04 LTS

Hi all. I recently upgraded and was having a heck of a time trying to find out how to install java6 on the new Mint 13 since they pulled all the PPA's due to licensing restrictions. These are the steps I took to get it installed and working with Mint 13 Maya. This SHOULD work for other flavors of Precise.
Open terminal and in it type:
Code:
sudo apt-get purge openjdk*
ENTER
Code:
sudo apt-get purge *jre*
ENTER
Open up synaptics package manager and do a search for JRE or any other java related packages, make sure they are uninstalled.
NOW.
Once you are sure you've cleansed your system of any other java muck that might conflict you need to download this script.
https://github.com/flexiondotorg/oab-java6/blob/master/oab-java6.sh
Alternatively, open up a plain txt file and copy this code into it. The download link will more than likely be more up to date, but i'm putting this here for shiggles. Name it whatever you want.
Code:
#!/usr/bin/env bash
# Copyright (c) Martin Wimpress
# http://flexion.org/
# See the file "LICENSE" for the full license governing this code.
# References
# - https://github.com/rraptorr/sun-java6
# - http://ubuntuforums.org/showthread.php?t=1090731
# - http://irtfweb.ifa.hawaii.edu/~lockhart/gpg/gpg-cs.html
# Variables
VER="0.2.1"
function copyright_msg() {
local MODE=${1}
if [ "${MODE}" == "build_docs" ]; then
echo "OAB-Java6"
echo "========="
fi
echo `basename ${0}`" v${VER} - Create a local 'apt' repository for Ubuntu Java packages."
echo "Copyright (c) Martin Wimpress, http://flexion.org. MIT License"
echo
echo "By running this script to download Java you acknowledge that you have"
echo "read and accepted the terms of the Oracle end user license agreement."
echo
echo "* http://www.oracle.com/technetwork/java/javase/terms/license/"
echo
# Adjust the output if we are executing the script.
# It doesn't make sense to see this message here in the documentation.
if [ "${MODE}" != "build_docs" ]; then
echo "If you want to see what this is script is doing while it is running then execute"
echo "the following from another shell:"
echo
echo " tail -f `pwd`/`basename ${0}`.log"
echo
fi
}
function usage() {
local MODE=${1}
echo "Usage"
echo "-----"
echo "::"
echo
echo " sudo ${0}"
echo
echo "Optional parameters"
echo
echo "* ``-c`` : Remove pre-existing packages from ``/var/local/oab/deb``"
echo "* ``-s`` : Skip building if the packages already exist"
echo "* ``-h`` : This help"
echo
echo "How do I download and run this thing?"
echo "-------------------------------------"
echo "Like this."
echo "::"
echo
echo " cd ~/"
echo " wget https://github.com/flexiondotorg/oab-java6/raw/${VER}/`basename ${0}` -O `basename ${0}`"
echo " chmod +x `basename ${0}`"
echo " sudo ./`basename ${0}`"
echo
echo "If you are behind a proxy you may need to run using:"
echo "::"
echo
echo " sudo -i ./`basename ${0}`"
echo
# Adjust the output if we are building the docs.
if [ "${MODE}" == "build_docs" ]; then
echo "If you want to see what this is script is doing while it is running then execute"
echo "the following from another shell:"
echo "::"
echo
echo " tail -f ./`basename ${0}`.log"
echo
fi
echo "How it works"
echo "------------"
echo "This script is merely a wrapper for the most excellent Debian packaging"
echo "scripts prepared by Janusz Dziemidowicz."
echo
echo "* https://github.com/rraptorr/sun-java6"
echo
echo "The basic execution steps are:"
echo
echo "* Remove, my now disabled, Java PPA 'ppa:flexiondotorg/java'."
echo "* Install the tools required to build the Java packages."
echo "* Create download cache in ``/var/local/oab/pkg``."
echo "* Download the i586 and x64 Java install binaries from Oracle. Yes, both are required."
echo "* Clone the build scripts from https://github.com/rraptorr/sun-java6"
echo "* Build the Java packages applicable to your system."
echo "* Create local ``apt`` repository in ``/var/local/oab/deb`` for the newly built Java Packages."
echo "* Create a GnuPG signing key in ``/var/local/oab/gpg`` if none exists."
echo "* Sign the local ``apt`` repository using the local GnuPG signing key."
echo
echo "What gets installed?"
echo "--------------------"
echo "Nothing!"
echo
echo "This script will no longer try and directly install or upgrade any Java"
echo "packages, instead a local ``apt`` repository is created that hosts locally"
echo "built Java packages applicable to your system. It is up to you to install"
echo "or upgrade the Java packages you require using ``apt-get``, ``aptitude`` or"
echo "``synaptic``, etc. For example, once this script has been run you can simply"
echo "install the JRE by executing the following from a shell."
echo "::"
echo
echo " sudo apt-get install sun-java6-jre"
echo
echo "Or if you already have the *\"official\"* Ubuntu packages installed then you"
echo "can upgrade by executing the following from a shell."
echo "::"
echo
echo " sudo apt-get upgrade"
echo
echo "The local ``apt`` repository is just that, **local**. It is not accessible"
echo "remotely and `basename ${0}` will never enable that capability to ensure"
echo "compliance with Oracle's asinine license requirements."
echo
echo "Known Issues"
echo "------------"
echo
echo "* The Oracle download servers can be horribly slow. My script caches the downloads so you only need download each file once."
echo
echo "What is 'oab'?"
echo "--------------"
echo "Because, O.A.B! ;-)"
echo
# Only exit if we are not build docs.
if [ "${MODE}" != "build_docs" ]; then
exit 1
fi
}
function build_docs() {
copyright_msg build_docs > README.rst
# Add the usage instructions
usage build_docs >> README.rst
# Add the CHANGES
if [ -e CHANGES ]; then
cat CHANGES >> README.rst
fi
# Add the AUTHORS
if [ -e AUTHORS ]; then
cat AUTHORS >> README.rst
fi
# Add the TODO
if [ -e TODO ]; then
cat TODO >> README.rst
fi
# Add the LICENSE
if [ -e LICENSE ]; then
cat LICENSE >> README.rst
fi
echo "Documentation built."
exit 0
}
copyright_msg
# 'source' my common functions
if [ -r /tmp/common.sh ]; then
source /tmp/common.sh
if [ $? -ne 0 ]; then
echo "ERROR! Couldn't import common functions from /tmp/common.sh"
rm /tmp/common.sh 2>/dev/null
exit 1
else
update_thyself
fi
else
echo "Downloading common.sh"
wget --no-check-certificate -q "https://github.com/flexiondotorg/common/raw/master/common.sh" -O /tmp/common.sh
chmod 666 /tmp/common.sh
source /tmp/common.sh
if [ $? -ne 0 ]; then
echo "ERROR! Couldn't import common functions from /tmp/common.sh"
rm /tmp/common.sh 2>/dev/null
exit 1
fi
fi
# Check we are running on a supported system in the correct way.
check_root
check_sudo
check_ubuntu "all"
BUILD_KEY=""
BUILD_CLEAN=0
SKIP_REBUILD=""
# Parse the options
OPTSTRING=bchk:s
while getopts ${OPTSTRING} OPT
do
case ${OPT} in
b) build_docs;;
c) BUILD_CLEAN=1;;
h) usage;;
k) BUILD_KEY=${OPTARG};;
s) SKIP_REBUILD=1;;
*) usage;;
esac
done
shift "$(( $OPTIND - 1 ))"
# Remove my, now disabled, Java PPA.
if [ -e /etc/apt/sources.list.d/flexiondotorg-java-${LSB_CODE}.list ]; then
ncecho " [x] Removing ppa:flexiondotorg/java "
rm -v /etc/apt/sources.list.d/flexiondotorg-java-${LSB_CODE}.list* >> "$log" 2>&1
cecho success
fi
# Determine the build and runtime requirements.
BUILD_DEPS="build-essential debhelper defoma devscripts dpkg-dev git-core \
gnupg imvirt libasound2 libxi6 libxt6 libxtst6 rng-tools unixodbc unzip"
if [ "${LSB_ARCH}" == "amd64" ]; then
BUILD_DEPS="${BUILD_DEPS} lib32asound2 ia32-libs"
fi
# Install the Java build requirements
ncecho " [x] Installing Java build requirements "
apt-get install -y --no-install-recommends ${BUILD_DEPS} >> "$log" 2>&1 &
pid=$!;progress $pid
# Make sure the required dirs exist.
ncecho " [x] Making build directories "
mkdir -p /var/local/oab/{deb,gpg,pkg} >> "$log" 2>&1 &
pid=$!;progress $pid
# Set the permissions appropriately for 'gpg'
chown root:root /var/local/oab/gpg 2>/dev/null
chmod 0700 /var/local/oab/gpg 2>/dev/null
# Remove the 'src' directory everytime.
ncecho " [x] Removing clones of https://github.com/rraptorr/sun-java6 "
rm -rfv /var/local/oab/sun-java6* 2>/dev/null >> "$log" 2>&1
rm -rfv /var/local/oab/src 2>/dev/null >> "$log" 2>&1 &
pid=$!;progress $pid
# Clone the code
ncecho " [x] Cloning https://github.com/rraptorr/sun-java6 "
cd /var/local/oab/ >> "$log" 2>&1
git clone https://github.com/rraptorr/sun-java6 src >> "$log" 2>&1 &
pid=$!;progress $pid
# Get the last commit tag.
cd /var/local/oab/src >> "$log" 2>&1
TAG=`git tag -l | tail -n1`
# Checkout the tagged, stable, version.
ncecho " [x] Checking out ${TAG} "
git checkout ${TAG} >> "$log" 2>&1 &
pid=$!;progress $pid
# Cet the current Debian package version and package urgency
DEB_VERSION=`head -n1 /var/local/oab/src/debian/changelog | cut -d'(' -f2 | cut -d')' -f1 | cut -d'~' -f1`
DEB_URGENCY=`head -n1 /var/local/oab/src/debian/changelog | cut -d'=' -f2`
# Determine the currently supported Java version and update
JAVA_VER=`echo ${DEB_VERSION} | cut -d'.' -f1`
JAVA_UPD=`echo ${DEB_VERSION} | cut -d'.' -f2 | cut -d'-' -f1`
# Try and dynamic find the JDK downloads
ncecho " [x] Getting Java SE download page"
wget "http://www.oracle.com/technetwork/java/javase/downloads/index.html" -O /tmp/oab-index.html >> "$log" 2>&1 &
pid=$!;progress $pid
# See if the Java version is on the download frontpage, otherwise look for it in
# the previous releases page.
DOWNLOAD_INDEX=`grep -P -o "/technetwork/java/javase/downloads/jdk-${JAVA_VER}u${JAVA_UPD}-downloads-\d+\.html" /tmp/oab-index.html | uniq`
if [ -n "${DOWNLOAD_INDEX}" ]; then
ncecho " [x] Getting current release download page "
wget http://www.oracle.com/${DOWNLOAD_INDEX} -O /tmp/oab-download.html >> "$log" 2>&1 &
pid=$!;progress $pid
else
ncecho " [x] Getting previous releases download page "
wget http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html -O /tmp/oab-download.html >> "$log" 2>&1 &
pid=$!;progress $pid
fi
# Download the Oracle install packages.
for JAVA_BIN in jdk-${JAVA_VER}u${JAVA_UPD}-linux-i586.bin jdk-${JAVA_VER}u${JAVA_UPD}-linux-x64.bin
do
# Get the download URL and size
DOWNLOAD_URL=`grep ${JAVA_BIN} /tmp/oab-download.html | cut -d'{' -f2 | cut -d',' -f3 | cut -d'"' -f4`
DOWNLOAD_SIZE=`grep ${JAVA_BIN} /tmp/oab-download.html | cut -d'{' -f2 | cut -d',' -f2 | cut -d':' -f2 | sed 's/"//g'`
# Cookies required for download
COOKIES="oraclelicensejdk-${JAVA_VER}u${JAVA_UPD}-oth-JPR=accept-securebackup-cookie;gpw_e24=http://edelivery.oracle.com"
ncecho " [x] Downloading ${JAVA_BIN} : ${DOWNLOAD_SIZE} "
wget --no-check-certificate --header="Cookie: ${COOKIES}" -c "${DOWNLOAD_URL}" -O /var/local/oab/pkg/${JAVA_BIN} >> "$log" 2>&1 &
pid=$!;progress_loop $pid
ncecho " [x] Symlinking ${JAVA_BIN} "
ln -s /var/local/oab/pkg/${JAVA_BIN} /var/local/oab/src/${JAVA_BIN} >> "$log" 2>&1 &
pid=$!;progress_loop $pid
done
# Determine the new version
NEW_VERSION="${DEB_VERSION}~${LSB_CODE}1"
if [ -n "${SKIP_REBUILD}" -a -r "/var/local/oab/deb/sun-java${JAVA_VER}_${NEW_VERSION}_${LSB_ARCH}.changes" ]; then
echo " [!] Package exists, skipping build "
echo "All done!"
exit
fi
# Genereate a build message
BUILD_MESSAGE="Automated build for ${LSB_REL} using https://github.com/rraptorr/sun-java6"
# Change directory to the build directory
cd /var/local/oab/src
# Update the changelog
ncecho " [x] Updating the changelog "
dch --distribution ${LSB_CODE} --force-distribution --newversion ${NEW_VERSION} --force-bad-version --urgency=${DEB_URGENCY} "${BUILD_MESSAGE}" >> "$log" 2>&1 &
pid=$!;progress $pid
# Build the binary packages
ncecho " [x] Building the packages "
dpkg-buildpackage -b >> "$log" 2>&1 &
pid=$!;progress_can_fail $pid
if [ -e /var/local/oab/sun-java${JAVA_VER}_${NEW_VERSION}_${LSB_ARCH}.changes ]; then
# Remove any existing .deb files if the 'clean' option was selected.
if [ ${BUILD_CLEAN} -eq 1 ]; then
ncecho " [x] Removing existing .deb packages "
rm -fv /var/local/oab/deb/* >> "$log" 2>&1 &
pid=$!;progress $pid
fi
# Populate the 'apt' repository with .debs
ncecho " [x] Moving the packages "
mv -v /var/local/oab/sun-java${JAVA_VER}_${NEW_VERSION}_${LSB_ARCH}.changes /var/local/oab/deb/ >> "$log" 2>&1
mv -v /var/local/oab/*sun-java${JAVA_VER}-*_${NEW_VERSION}_*.deb /var/local/oab/deb/ >> "$log" 2>&1 &
pid=$!;progress $pid
else
error_msg "ERROR! Packages failed to build."
fi
# Create a temporary 'override' file, which may contain duplicates
echo "#Override" > /tmp/override
echo "#Package priority section" >> /tmp/override
for FILE in /var/local/oab/deb/*.deb
do
DEB_PACKAGE=`dpkg --info ${FILE} | grep Package | cut -d':' -f2`
DEB_SECTION=`dpkg --info ${FILE} | grep Section | cut -d'/' -f2`
echo "${DEB_PACKAGE} high ${DEB_SECTION}" >> /tmp/override
done
# Remove the duplicates from the overide file
uniq /tmp/override > /var/local/oab/deb/override
# Create the 'apt' Packages.gz
ncecho " [x] Creating Packages.gz file "
cd /var/local/oab/deb
dpkg-scanpackages . override 2>/dev/null > Packages
cat Packages | gzip -c9 > Packages.gz
rm /var/local/oab/deb/override 2>/dev/null
cecho success
# Create a 'Release' file
ncecho " [x] Creating Release file "
cd /var/local/oab/deb
echo "Origin: `hostname --fqdn`" > Release
echo "Label: Java" >> Release
echo "Suite: ${LSB_CODE}" >> Release
echo "Version: ${LSB_REL}" >> Release
echo "Codename: ${LSB_CODE}" >> Release
echo "Date: `date -R`" >> Release
echo "Architectures: ${LSB_ARCH}" >> Release
echo "Components: restricted" >> Release
echo "Description: Local Java Repository" >> Release
echo "MD5Sum:" >> Release
for PACKAGE in Packages*
do
printf ' '`md5sum ${PACKAGE} | cut -d' ' -f1`" %16d ${PACKAGE}\n" `wc --bytes ${PACKAGE} | cut -d' ' -f1` >> Release
done
cecho success
# Skip anything todo with automated key creation if this script is running in
# an OpenVZ container.
if [[ `imvirt` != "OpenVZ" ]]; then
# Do we need to create signing keys
if [ ! -e /var/local/oab/gpg/pubring.gpg ] && [ ! -e /var/local/oab/gpg/secring.gpg ] && [ ! -e /var/local/oab/gpg/trustdb.gpg ]; then
ncecho " [x] Create GnuPG configuration "
echo "Key-Type: DSA" > /var/local/oab/gpg-key.conf
echo "Key-Length: 1024" >> /var/local/oab/gpg-key.conf
echo "Subkey-Type: ELG-E" >> /var/local/oab/gpg-key.conf
echo "Subkey-Length: 2048" >> /var/local/oab/gpg-key.conf
echo "Name-Real: `hostname --fqdn`" >> /var/local/oab/gpg-key.conf
echo "Name-Email: [email protected]`hostname --fqdn`" >> /var/local/oab/gpg-key.conf
echo "Expire-Date: 0" >> /var/local/oab/gpg-key.conf
cecho success
# Stop the system 'rngd'.
/etc/init.d/rng-tools stop >> "$log" 2>&1
ncecho " [x] Start generating entropy "
rngd -r /dev/urandom -p /tmp/rngd.pid >> "$log" 2>&1 &
pid=$!;progress $pid
ncecho " [x] Creating signing key "
gpg --homedir /var/local/oab/gpg --batch --gen-key /var/local/oab/gpg-key.conf >> "$log" 2>&1 &
pid=$!;progress $pid
ncecho " [x] Stop generating entropy "
kill -9 `cat /tmp/rngd.pid` >> "$log" 2>&1 &
pid=$!;progress $pid
rm /tmp/rngd.pid 2>/dev/null
# Start the system 'rngd'.
/etc/init.d/rng-tools start >> "$log" 2>&1
fi
fi
# Do we have signing keys, if so use them.
if [ -e /var/local/oab/gpg/pubring.gpg ] && [ -e /var/local/oab/gpg/secring.gpg ] && [ -e /var/local/oab/gpg/trustdb.gpg ]; then
# Sign the Release
ncecho " [x] Signing the 'Release' file "
rm /var/local/oab/deb/Release.gpg 2>/dev/null
gpg --homedir /var/local/oab/gpg --armor --detach-sign --output /var/local/oab/deb/Release.gpg /var/local/oab/deb/Release >> "$log" 2>&1 &
pid=$!;progress $pid
# Export public signing key
ncecho " [x] Exporting public key "
gpg --homedir /var/local/oab/gpg --export -a "`hostname --fqdn`" > /var/local/oab/deb/pubkey.asc
cecho success
# Add the public signing key
ncecho " [x] Adding public key "
apt-key add /var/local/oab/deb/pubkey.asc >> "$log" 2>&1 &
pid=$!;progress $pid
fi
# Update apt cache
echo "deb file:///var/local/oab/deb / #Sun Java6 - https://github.com/flexiondotorg/oab-java6" > /etc/apt/sources.list.d/oab.list
apt_update
echo "All done!"
Whether you download the script, or if you make your own text file, you need to enable the executing permission bit. So change your directory to wherever you saved the script and then in terminal type this and hit enter:
Code:
chmod +x ./whatever_the_script_is_named
Then in the terminal run the script with:
Code:
sudo ./oab-java6.sh
or
Code:
sudo ./whatever_you_named_this_script
What this does, is build packages for your system and places them in a local repository for apt-get to install. This bypasses java anal retentive licensing bullsquash. So, now we need to install it with:
Code:
sudo apt-get install sun-java6-jre
ENTER
Wait for it to finish and ensure your version is correcty by typing:
Code:
java -version
ENTER
You should get an output similar to:
Code:
[email protected] ~ $ java -version
java version "1.6.0_32"
Java(TM) SE Runtime Environment (build 1.6.0_32-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.7-b02, mixed mode)
[email protected] ~ $
Hope this helps someone and I hope this is in the correct forum!
Im going to be editing this as it seems there's really no reason to purge OpenJDK from the system, I think. I'm also having some compiling errors so once I get those nailed down, I'll probably just write a guide detailing the entire setup/config for 12.04.
It works !!!
Thanks for posting this, this worked well.
Only thing I would like to add is that if someone is looking to add the java plugin to firefox, then they would need to manually create a link in the firefox plugins directory:
$ cd /usr/lib/firefox-addons/plugins
$ sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.32/jre/lib/i386/libnpjp2.so
$ ls -lrt
total 0
lrwxrwxrwx 1 root root 57 2011-12-20 11:05 libnpjp2.so -> /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386/libnpjp2.so
Restart firefox, it should work now.
Keep It All!
Hi folks
I'll just chuck an alternative method in for good measure and one that I successfully on ubuntu versions 11.10 , 12.04 and 12.10 as well every other debian derivative
Add these three repositories like so.
Code:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy-updates main multiverse"
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
You can then install both version 5 and 6 of the sun jdk and leave any existing installs in tact.
For extra beans you can install openjdk-7-jdk without any adverse effects - I ran the following
Code:
sudo apt-get install sun-java6-jdk
sudo apt-get install sun-java5-jdk
sudo apt-get install openjdk-7-jdk
After that you can use /bin/update-aleternatives to manage which version to use. for example
Code:
sudo update-alternatives --config java
This gives me the following versions of java to use as my "java" command
Code:
There are 4 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java 53 manual mode
2 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
3 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
* 4 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode
Press enter to keep the current choice[*], or type selection number:
Pick which version you need/want to use and away you go, you can switch most of the applications on the java platform painlessy with this method this includes javaws, javah , javac , jdb. if you're working with android only javac and java is required however, so do the same for javac
Code:
sudo update-alternatives --config javac
see "/etc/alternatives" for a list of application which may have alternatives and obviously the man and help has full details and how you can manage applications I also think there is a Kde, Gnome front end for it as well.
I got the repo info for sun jdk 5/6 from google's Android AOSP build instructions
Ta
thank you!
Thank you! I've tried many other scripts and sites without success. I should have started with xda for this. Thank you again.
Script location update.
Just an FYI, the location of the script has change, as the author has also included it to install Java 7.
The new location is https github.com/flexiondotorg/oab-java6
NOTE: the script pasted in the OP no longer works as making the .deb file will fail unless you download the jce_poclicy-6.zip. (which the script deletes the next time you run it)
EDIT: I also tested this on Ubuntu 10.04, and it is working for both JRE and JDK
Can you confirm whether this method still works? I have followed the directions here and on the source.android.com website to install sun-java6-sdk and my ubuntu 12.04 is not finding the install package. When I run the update script the hardy repository is giving me 404 errors. Have things changed significantly since this was posted?
trevd said:
Hi folks
I'll just chuck an alternative method in for good measure and one that I successfully on ubuntu versions 11.10 , 12.04 and 12.10 as well every other debian derivative
Add these three repositories like so.
Code:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy-updates main multiverse"
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
You can then install both version 5 and 6 of the sun jdk and leave any existing installs in tact.
For extra beans you can install openjdk-7-jdk without any adverse effects - I ran the following
Code:
sudo apt-get install sun-java6-jdk
sudo apt-get install sun-java5-jdk
sudo apt-get install openjdk-7-jdk
After that you can use /bin/update-aleternatives to manage which version to use. for example
Code:
sudo update-alternatives --config java
This gives me the following versions of java to use as my "java" command
Code:
There are 4 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java 53 manual mode
2 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
3 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
* 4 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode
Press enter to keep the current choice[*], or type selection number:
Pick which version you need/want to use and away you go, you can switch most of the applications on the java platform painlessy with this method this includes javaws, javah , javac , jdb. if you're working with android only javac and java is required however, so do the same for javac
Code:
sudo update-alternatives --config javac
see "/etc/alternatives" for a list of application which may have alternatives and obviously the man and help has full details and how you can manage applications I also think there is a Kde, Gnome front end for it as well.
I got the repo info for sun jdk 5/6 from google's Android AOSP build instructions
Ta
Click to expand...
Click to collapse
jaxsin said:
Can you confirm whether this method still works? I have followed the directions here and on the source.android.com website to install sun-java6-sdk and my ubuntu 12.04 is not finding the install package. When I run the update script the hardy repository is giving me 404 errors. Have things changed significantly since this was posted?
Click to expand...
Click to collapse
Hi There,
Yes I believe they have as I noticed the same thing just recently, Although I will be looking a bit deeper when I installl 13.10. You are better off using the webupd8 team oracle java installer now I think, additionally AOSP master branch doesn't build anymore with the sun java version.
trevd said:
Hi There,
Yes I believe they have as I noticed the same thing just recently, Although I will be looking a bit deeper when I installl 13.10. You are better off using the webupd8 team oracle java installer now I think, additionally AOSP master branch doesn't build anymore with the sun java version.
Click to expand...
Click to collapse
which java version is worth using then? Openjdk v6, 7 or 8? I am considering trying to build CM 10.2 and I see they recommend to use Openjdk. Any thoughts?
jaxsin said:
which java version is worth using then? Openjdk v6, 7 or 8? I am considering trying to build CM 10.2 and I see they recommend to use Openjdk. Any thoughts?
Click to expand...
Click to collapse
I haven't use the openJDK offerings so I couldn't recommend one, I'm afraid. However, I did a little moreresearch google search into Hardy's disappearance. it turns out Hardy Heron 8.04 was EOL'd in May [ Announcement on the Ubuntu Fridge ]
All is not lost though as the hardy repos have just been moved to http://old-releases.ubuntu.com/ .
so if If you really need the sun java6 jdk or even sun's java5 jdk you can add these lines to you /etc/apt/sources.list and they should install fine.
Code:
deb http://archive.canonical.com/ lucid partner
deb http://old-releases.ubuntu.com/ubuntu hardy-updates main multiverse
deb http://old-releases.ubuntu.com/ubuntu hardy main multiverse
However as previously mentioned the sun java6 jdk no longer builds the master branch of the AOSP but at least the correct links are there for future reference. Currently Webupd8 team have the latest (now) oracle's version of the java6 jdk which is what I currently use for building. So to install oracle's versions of the jdk, do the following
Code:
sudo add-apt-repository --yes ppa:webupd8team/java
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java7-installer
sudo apt-get install oracle-java6-installer
Obviously you can use update-alternatives to switch between them as/if required and make's the question of which is worth using/installing kinda moot ... Install them ALL! I haz every java. lol
Thanks
trevd :good:

[UBUNTU][DEBIAN]Common Commands used in Linux

Common Commands used in Linux.
Since, Android is based on Linux, there is much possibility that there is a need to use a Linux based OS. For such use, UBUNTU
is favoured, for its easy and more user friendly.
Today, I am going to Post a few commands that are very useful to the newbies to development
I myself am new, and have faced many problems with this, so I am posting a this thread, to help all the noobs/newbies find what they need in a single place
Okay so, lets start with some basic commands, which can be classified as general commands, and each Linux user MUST KNOW ALL OF THEM !!
Code:
sudo
It simply means "Superuser do". It requires password.
Code:
sudo apt-get install APPLICATION_name
This installs the application finding it on the internet, and gives you the suitable output(If the app exists or not).
Code:
sudo apt-get remove APPLICATION_name
It Removes the application
Code:
sudo apt-get update
it updates the repositories
Code:
sudo apt-get upgrade
upgrades your installed application with their latest versions from Ubuntu repositories
Code:
killall APPLICATION_NAME
kills (terminates) an application
Code:
ps -e
displays currently running processes
Code:
kill APPLICATION_PID
kills an application; where APPLICATION_PID.
NOTE: YOU CAN FIND "PID" USING EARLIER CODE.
Code:
wget http://path_to_file.com
downloads a file from the web to current directory
Code:
cd /PATH/TO/DIR
changes current directory to DIR. Use cd to change the current directory into any dir
Code:
cd ..
Like ms-dos, goes up one directory
Code:
dir
OR
Code:
ls
lists directory content
Code:
man COMMAND
Displays manual for command.
eg: man sudo
Code:
cp ORIGINALFILE NEWFILE
Copy a file
Code:
mv SOURCE DESTINATION
Moves a file
NOTE: YOU CAN ALSO RENAME A FILE WITH THIS.
EG: mv old_filename new_filename
Code:
mkdir FOLDERNAME
Make a directory/folder
Miscellaneous: Level 2
Code:
du -sh folder name
This calculates the size of the folder
Code:
ps -aux
This shows all the running processes
Code:
chown -R User:User dir
Change owner of files and directories
Code:
chmod 777 yourScript
This makes a shell script ".sh" extension
Code:
netstat -anltp | grep "LISTEN"
See all open ports on your machine
Code:
sudo apt-get install ufw
sudo ufw allow 80/tcp
sudo ufw allow 22/tcp
sudo ufw allow 443/tcp
sudo ufw allow 21/tcp
sudo ufw enable
Ubuntu provides a uncomplicated firewall (ufw). To install it and only allow SSH, FTP, and webtraffic use the following command.
Network Commands
Code:
ifconfig
Shows the network connections
WILL UPDATE REGULARLY AS MUCH I COULD.
Code:
passwd
Run after installing Linux when you see "[email protected]:~$" to set your root pass word
Code:
adduser
Replace and run to add a new user
Code:
adduser sudo
Replace and run to add that user to sudo
Code:
sudo apt-get purge
Replace and run to purge your system of that package
Code:
apt-cache search
Replace and run to search for new packages to install
Note: "wild cards" eg "*" are acceptable
Code:
find -type f -iname 'some-compressed-file*' -print0 | xargs -0 sudo tar -vxpzf
Replace with at least the "root" directory you want to search through and Replace " some-compressed-file " (leave the single quotes ' ' and the wild card *) and run to find every file under the given directory that has that name and the pipe " | " it out to tar so that'll extract to your current directory
Note: "find" does the finding, the "-type -f" tells find to only look for files, the "-iname" tells find to search parts of file names, the ' ' around "some-compressed-file" keeps the * from doing bad things, the "print0" tells find to "scrub" for spaces and such before outputting a result, the " | " pipes the results of find to xargs, the "-0" is because of "print0" in the find side of the pipe, and "sudo tar - vxpzf" is where tar extracts the findings of find.
Code:
find $HOME -type f -iname '*zip' -print0 | xargs -0 ls
Run to find and list every zip file under the home folder
Say you want to make a file to contain some notes wile in the command line
Code:
sudo cat > $HOME/someNotes.txt <<EOF
# place a command here
echo "hello world, I update aptget"
sudo apt-get update -q
EOF
Try editing the part after $HOME; type it in or write a file that contains the combo of " cat > $HOME/someNotes.txt <<EOF " some text or commands " EOF " and you'll find making custom scripts of varying complexity to be easy.
.......
Hope some of these are also found to be useful for others.
Thanks for starting this here thread.
Hit the link in my signature for more help with Linux for new and seasoned users
Edit 08082013- added another useful tip and reformatted commands to better fit the OP's formatting.
Sent from either my SPH-D700 or myTouch3Gs
Debian Kit/QEMU Linux Install guide for all android devices that I'm writing:
http://forum.xda-developers.com/showthread.php?t=2240397
Now have working Installers for ARM Java 7 JDK + Maptools + jMonkey
Yo ! Nice Share
To delete contents of a large text file ..
Code:
cat /dev/null > NameOfTheFile
Useful variations of ls command :
Show dir content in a list
Code:
ls -l
Show dir content in a list sorted by modification time (newer first)
Code:
ls -lt
Show dir content in a list sorted by modification time (older first)
Code:
ls -lrt
Show subdirectories recursively
Code:
ls -R
If you want to show files starting with . (hidden file), you can add -a option.
More options with command :
Code:
man ls
Useful variations of grep command :
grep is used to print lines matching a pattern.
Find the entry for current user in file /etc/passwd :
Code:
cat /etc/passwd | grep $USER
Find all the entry except current user entry in file /etc/passwd :
Code:
cat /etc/passwd | grep -v $USER
Find all the numbers in file /etc/passwd :
Code:
cat /etc/passwd|grep '[0-9]*'
Add color to grep command :
Code:
cat /etc/passwd | grep --color $USER
(You can add
Code:
alias grep='grep --color=auto'
in ~/.bashrc to always have colored grep)
Useful variations of tar command :
Create archive_name.tar from dirname :
Code:
tar cvf archive_name.tar dirname/
Create archive_name.tar.gz (compressed) from dirname :
Code:
tar zcvf archive_name.tar.gz dirname/
Extract archive_name.tar.gz :
Code:
tar zxvf archive_name.tar.gz
Useful variations of mkdir command :
Create directory and subdirectories if not existing :
Code:
mkdir -p /tmp/a/b/c
(mkdir /tmp/a/b/c will fail if /tmp/a and /tmp/a/b don't exist)
Useful tip :
Use bash variable "!$" to get the value of the last argument of the last command interpreted.
For example :
Code:
mkdir /tmp/test_a
cd !$ (equivalent cd /tmp/test_a)
or,
Code:
mv /tmp/a /tmp/b
ls !$ (equivalent ls /tmp/b)

[Q] Latest Linux version of Flashtool does not see libusb

As I still don't made sufficient posts to put it directly to dev forum, it's here. Admins, please move it to correct sections as you desire.
I installed the latest version of Flashtool for Linux. I followed the instructions at flashtool. net/install. php and tried to run './Flashtool'. here is the output:
[[email protected] FlashTool]# ./FlashTool
Running as root.
JAVA_HOME not set. Using default value : ./x10flasher_lib/linjre64
libusb.LibUsbException: Libusb not found. Minimum libusb version is 1.0.15. It can be downloaded on libusbx. org
at libusb.UsbSystem.initSystem(UsbSystem.java:28)
at libusb.UsbSystem.<init>(UsbSystem.java:15)
at linuxlib.JUsb.init(JUsb.java:21)
at gui.Main.initLinuxUsb(Main.java:47)
at gui.Main.main(Main.java:34)
I have libusbx 1.0.16 and libusb 0.1.5 installed, so how can I debug this? if someone can forward this to Androxyde I will be very grateful.
I am running Fedora 19 x64 with both 32 and 64 bit libs installed, as per Flashtool site instructions. Current Java (Oracle) is Java(TM) SE Runtime Environment (build 1.7.0_45-b18), 64-bit version.
Thank you
***EDIT*** This post is no longer relevant, check the next post down.
luzemario said:
As I still don't made sufficient posts to put it directly to dev forum, it's here. Admins, please move it to correct sections as you desire.
I installed the latest version of Flashtool for Linux. I followed the instructions at flashtool. net/install. php and tried to run './Flashtool'. here is the output:
[[email protected] FlashTool]# ./FlashTool
Running as root.
JAVA_HOME not set. Using default value : ./x10flasher_lib/linjre64
libusb.LibUsbException: Libusb not found. Minimum libusb version is 1.0.15. It can be downloaded on libusbx. org
at libusb.UsbSystem.initSystem(UsbSystem.java:28)
at libusb.UsbSystem.<init>(UsbSystem.java:15)
at linuxlib.JUsb.init(JUsb.java:21)
at gui.Main.initLinuxUsb(Main.java:47)
at gui.Main.main(Main.java:34)
I have libusbx 1.0.16 and libusb 0.1.5 installed, so how can I debug this? if someone can forward this to Androxyde I will be very grateful.
I am running Fedora 19 x64 with both 32 and 64 bit libs installed, as per Flashtool site instructions. Current Java (Oracle) is Java(TM) SE Runtime Environment (build 1.7.0_45-b18), 64-bit version.
Thank you
Click to expand...
Click to collapse
I found on my system (arch linux) the libusbx libs were named differently from what flashtool is looking for.
FlashTool was looking for "/usr/lib/libusbx-1.0.so" and "/usr/lib/libusbx-1.0.so.0.1.0"
but what i had was "/usr/lib/libusb-1.0.so" and "/usr/lib/libusb-1.0.so.0.1.0" respectively.
I created Symbolic links so that flashtool would find what it was looking for...
"ln -s /usr/lib/libusb-1.0.so.0.1.0 /usr/lib/libusbx-1.0.so.0.1.0"
&
"ln -s /usr/lib/libusb-1.0.so /usr/lib/libusbx-1.0.so"
(Ran in root terminal without qoutes) That fixed it for me.
Perhaps those libs are also named differently on fedora too? i used "find / -name libusb*" (in root terminal without qoutes) to check for them on my system.
It's also possible to change the searched for filenames in "FlashTool" (the launching script) itself by editing it but that would need to be redone with every new version unless fixed/changed by the developers. the lines that would need changed are..
"ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib32/libusbx-1.0.so"
"ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib64/libusbx-1.0.so"
(I've bolded the part to be changed for flashtool-0.9.13.0, it might be different in the future)
Hope this helps :good:
I decided to change flashtool's script/launcher so it looks for libusbx in a more robust (i hope) way. i've attached the changed file. If this works for you then we can submit the changes to the devs for their consideration.
#!/bin/sh
export BASEDIR=$(dirname $0)
export system64=$(uname -m)
export OS=$(uname -s)
cd $BASEDIR
if test "$OS" = "Linux"
then
chmod 755 ./x10flasher_lib/adb.linux
chmod 755 ./x10flasher_lib/fastboot.linux
chmod 755 ./x10flasher_lib/unyaffs.linux
chmod 755 ./x10flasher_lib/bin2elf
chmod 755 ./x10flasher_lib/bin2sin
if [ "$(whoami)" != "root" ]
then
export HASRULES="false"
if test -d /etc/udev/rules.d
then
if grep -rl "0fce" /etc/udev/rules.d >/dev/null
then
export HASRULES="true"
fi
fi
if test "$HASRULES" = "true"
then
echo "Not running as root but Sony/SonyEriccson Vendor ID found on your udev rules"
echo "if Flashing didn't work well, run flashtool as root"
else
echo "Not running as root and there is no Sony/SonyEriccson Vendor ID on your udev rules"
echo "The user must be granted access to adb/flashmode/fastboot"
echo "If you are unsure what to do, run flashtool as root"
exit 1
fi
else
echo "Running as root."
fi
if test -z "${JAVA_HOME}"
then
if test "${system64}" = "x86_64"
then
export JAVA_HOME=./x10flasher_lib/linjre64
else
export JAVA_HOME=./x10flasher_lib/linjre32
fi
echo "JAVA_HOME not set. Using default value : ${JAVA_HOME}"
fi
if test -e ${JAVA_HOME}/bin/java
then
export LD_LIBRARY_PATH=./x10flasher_lib/linux/lib32
export LD_LIBRARY_PATH=./x10flasher_lib/linux/lib64:$LD_LIBRARY_PATH
#Begin changes by deagon 02/11/13
#ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib32/libusbx-1.0.so
#ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib64/libusbx-1.0.so
find /*/lib -name 'libusb*.0.1.0' -exec ln -sf {\} ./x10flasher_lib/linux/lib32/libusbx-1.0.so \;
find /*/lib -name 'libusb*.0.1.0' -exec ln -sf {\} ./x10flasher_lib/linux/lib64/libusbx-1.0.so \;
#End changes by deagon 02/11/13
ISJAVA6=$($JAVA_HOME/bin/java -version 2>&1|grep version|grep 1.6|wc -l)
ISJAVA7=$($JAVA_HOME/bin/java -version 2>&1|grep version|grep 1.7|wc -l)
ISJAVA64=$($JAVA_HOME/bin/java -version 2>&1|grep 64-Bit|wc -l)
if test $ISJAVA6 -gt 0 -o $ISJAVA7 -gt 0
then
if test $ISJAVA64 -gt 0
then
ln -sf swt64.jar ./x10flasher_lib/swtlin/swt.jar
else
ln -sf swt32.jar ./x10flasher_lib/swtlin/swt.jar
fi
$JAVA_HOME/bin/java -Xms128m -Xmx512m -Duser.country=US -Duser.language=en -jar x10flasher.jar
else
echo "Java version must be 1.6 or 1.7"
fi
else
echo "No Java in specified path in JAVA_HOME=${JAVA_HOME}"
echo "Set the variable to a valid Java installation"
fi
else
chmod 755 ./x10flasher_lib/adb.mac
chmod 755 ./x10flasher_lib/fastboot.mac
chmod 755 ./x10flasher_lib/unyaffs.mac
export DYLD_LIBRARY_PATH=./x10flasher_lib/mac/lib64:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=./x10flasher_lib/mac/lib32:$DYLD_LIBRARY_PATH
ln -sf libusbx-1.0.0.dylib ./x10flasher_lib/mac/lib64/libusbx-1.0.dylib
ln -sf libusbx-1.0.0.dylib ./x10flasher_lib/mac/lib32/libusbx-1.0.dylib
ISJAVA6=$(java -version 2>&1|grep version|grep 1.6|wc -l)
ISJAVA7=$(java -version 2>&1|grep version|grep 1.7|wc -l)
ISJAVA64=$(java -version 2>&1|grep 64-Bit|wc -l)
if test $ISJAVA64 -gt 0
then
ln -sf swt64.jar ./x10flasher_lib/swtmac/swt.jar
else
ln -sf swt32.jar ./x10flasher_lib/swtmac/swt.jar
fi
if test $ISJAVA6 -gt 0 -o $ISJAVA7 -gt 0
then
java -XstartOnFirstThread -Xms128m -Xmx512m -Duser.country=US -Duser.language=en -jar x10flasher.jar
else
echo "Java version must be 1.6 or 1.7"
fi
fi
let me know how you get on :good:
-- deagon
***EDIT*** I found a downside. The the new script/launcher is going to find and use either the old libusb or libusbx so it may create more problems than it solves for some users if they dont install libusbx before using flashtool.
Another problem will arise if the distro's libusbx package maintainers havent over written the old libusb libs to use libusbx as a drop in replacement like on arch and fedora 19 (i checked inside the fedora libusbx package before) because the changed script/launcher will likely link to libusb before libusbx if they are sitting next to each other.
Deagon said:
I decided to change flashtool's script/launcher so it looks for libusbx in a more robust (i hope) way. i've attached the changed file. If this works for you then we can submit the changes to the devs for their consideration.
#!/bin/sh
export BASEDIR=$(dirname $0)
export system64=$(uname -m)
export OS=$(uname -s)
cd $BASEDIR
if test "$OS" = "Linux"
then
chmod 755 ./x10flasher_lib/adb.linux
chmod 755 ./x10flasher_lib/fastboot.linux
chmod 755 ./x10flasher_lib/unyaffs.linux
chmod 755 ./x10flasher_lib/bin2elf
chmod 755 ./x10flasher_lib/bin2sin
if [ "$(whoami)" != "root" ]
then
export HASRULES="false"
if test -d /etc/udev/rules.d
then
if grep -rl "0fce" /etc/udev/rules.d >/dev/null
then
export HASRULES="true"
fi
fi
if test "$HASRULES" = "true"
then
echo "Not running as root but Sony/SonyEriccson Vendor ID found on your udev rules"
echo "if Flashing didn't work well, run flashtool as root"
else
echo "Not running as root and there is no Sony/SonyEriccson Vendor ID on your udev rules"
echo "The user must be granted access to adb/flashmode/fastboot"
echo "If you are unsure what to do, run flashtool as root"
exit 1
fi
else
echo "Running as root."
fi
if test -z "${JAVA_HOME}"
then
if test "${system64}" = "x86_64"
then
export JAVA_HOME=./x10flasher_lib/linjre64
else
export JAVA_HOME=./x10flasher_lib/linjre32
fi
echo "JAVA_HOME not set. Using default value : ${JAVA_HOME}"
fi
if test -e ${JAVA_HOME}/bin/java
then
export LD_LIBRARY_PATH=./x10flasher_lib/linux/lib32
export LD_LIBRARY_PATH=./x10flasher_lib/linux/lib64:$LD_LIBRARY_PATH
#Begin changes by deagon 02/11/13
#ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib32/libusbx-1.0.so
#ln -sf libusbx-1.0.so.0.1.0 ./x10flasher_lib/linux/lib64/libusbx-1.0.so
find /*/lib -name 'libusb*.0.1.0' -exec ln -sf {\} ./x10flasher_lib/linux/lib32/libusbx-1.0.so \;
find /*/lib -name 'libusb*.0.1.0' -exec ln -sf {\} ./x10flasher_lib/linux/lib64/libusbx-1.0.so \;
#End changes by deagon 02/11/13
ISJAVA6=$($JAVA_HOME/bin/java -version 2>&1|grep version|grep 1.6|wc -l)
ISJAVA7=$($JAVA_HOME/bin/java -version 2>&1|grep version|grep 1.7|wc -l)
ISJAVA64=$($JAVA_HOME/bin/java -version 2>&1|grep 64-Bit|wc -l)
if test $ISJAVA6 -gt 0 -o $ISJAVA7 -gt 0
then
if test $ISJAVA64 -gt 0
then
ln -sf swt64.jar ./x10flasher_lib/swtlin/swt.jar
else
ln -sf swt32.jar ./x10flasher_lib/swtlin/swt.jar
fi
$JAVA_HOME/bin/java -Xms128m -Xmx512m -Duser.country=US -Duser.language=en -jar x10flasher.jar
else
echo "Java version must be 1.6 or 1.7"
fi
else
echo "No Java in specified path in JAVA_HOME=${JAVA_HOME}"
echo "Set the variable to a valid Java installation"
fi
else
chmod 755 ./x10flasher_lib/adb.mac
chmod 755 ./x10flasher_lib/fastboot.mac
chmod 755 ./x10flasher_lib/unyaffs.mac
export DYLD_LIBRARY_PATH=./x10flasher_lib/mac/lib64:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=./x10flasher_lib/mac/lib32:$DYLD_LIBRARY_PATH
ln -sf libusbx-1.0.0.dylib ./x10flasher_lib/mac/lib64/libusbx-1.0.dylib
ln -sf libusbx-1.0.0.dylib ./x10flasher_lib/mac/lib32/libusbx-1.0.dylib
ISJAVA6=$(java -version 2>&1|grep version|grep 1.6|wc -l)
ISJAVA7=$(java -version 2>&1|grep version|grep 1.7|wc -l)
ISJAVA64=$(java -version 2>&1|grep 64-Bit|wc -l)
if test $ISJAVA64 -gt 0
then
ln -sf swt64.jar ./x10flasher_lib/swtmac/swt.jar
else
ln -sf swt32.jar ./x10flasher_lib/swtmac/swt.jar
fi
if test $ISJAVA6 -gt 0 -o $ISJAVA7 -gt 0
then
java -XstartOnFirstThread -Xms128m -Xmx512m -Duser.country=US -Duser.language=en -jar x10flasher.jar
else
echo "Java version must be 1.6 or 1.7"
fi
fi
let me know how you get on :good:
-- deagon
***EDIT*** I found a downside. The the new script/launcher is going to find and use either the old libusb or libusbx so it may create more problems than it solves for some users if they dont install libusbx before using flashtool.
Another problem will arise if the distro's libusbx package maintainers havent over written the old libusb libs to use libusbx as a drop in replacement like on arch and fedora 19 (i checked inside the fedora libusbx package before) because the changed script/launcher will likely link to libusb before libusbx if they are sitting next to each other.
Click to expand...
Click to collapse
not working for me. same error.
Same error
QkiZMR said:
not working for me. same error.
Click to expand...
Click to collapse
Same error here, need help please!!
nefsation said:
Same error here, need help please!!
Click to expand...
Click to collapse
first go to this http://www.libusbx.org
and download latest source (tarball)
extract that .tar.gz and go to that dir
now run the following commands
Code:
./config
make
sudo make install
assuming your Flashtool folder is in home
run the following commands
Code:
cd
cp /usr/local/lib/libusb-1.0.so.0.1.0 FlashTool/x10flasher_lib/linux/lib64
cp /usr/local/lib/libusb-1.0.so.0.1.0 FlashTool/x10flasher_lib/linux/lib32
replace the FlashTool script in FlashTool folder by this one FlashTool
FlashTool developer decided to bundle full JRE (both 32 and 64 bit) plus all these binaries and libraries with a relatively simple Java application for some strange reason. Lame. I've spent more than an hour downloading the 113 MB 7z archive from some sh*tty file-share service, instead spending just 1/4 of that time, and do something useful for the rest!
An average Linux user should be able to install these deps by herself, all she needs is a decent README specifiying the deps...
At least with the Ubuntu 13.10 (Saucy), libusb, which is at version 1.0.1.16, should work, so one does not need no freakin libusbx... This is for Saucy x86_64;
Code:
# One also needs basic 32-bit support, for running stuff like bin2sin, check libc6:i386 or similar:
sudo apt-get install android-tools-adb android-tools-fastboot libusb-1.0-0 default-jre
sudo ln -s libusb-1.0.so.0.1.0 /lib/x86_64-linux-gnu/libusbx-1.0.so
# Remove 260MB of rubbish:
cd <wherever you unpacked FlashTool>
rm -rf x10flasher_lib/{adb,fastboot}.linux x10flasher_lib/lin*
ln -s /usr/bin/adb x10flasher_lib/adb.linux
ln -s /usr/bin/fastboot x10flasher_lib/fastboot.linux
ln -s swt64.jar x10flasher_lib/swtlin/swt.jar
# Now, start the application
java -Xms128m -Xmx512m -Duser.language=en -jar x10flasher.jar
Zgembo said:
Code:
ln -s swt64.jar x10flasher_lib/swtlin/swt.jar
Click to expand...
Click to collapse
when i execute above command..it gives this error..
Code:
ln: failed to create symbolic link ‘x10flasher_lib/swtlin/swt.jar’: File exists
Edit: aha..finally flashtool successfully started with this method..i just replaced -s with -sf which forcefully does the operation

Categories

Resources