10/28/13

makeself - Make self-extractable archives on Unix

EX: makeself --nox11 --bzip2 --nowait /home/dangquang/Downloads/hplip-3.13.10 mysetup.run "install hplib GUI" ./hplip-install

makeself.sh is a small shell script that generates a self-extractable tar.gz archive from a directory. The resulting file appears as a shell script (many of those have a .run suffix), and can be launched as is. The archive will then uncompress itself to a temporary directory and an optional arbitrary command will be executed (for example an installation script). This is pretty similar to archives generated with WinZip Self-Extractor in the Windows world. Makeself archives also include checksums for integrity self-validation (CRC and/or MD5 checksums).
The makeself.sh script itself is used only to create the archives from a directory of files. The resultant archive is actually a compressed (using gzip, bzip2, or compress) TAR archive, with a small shell script stub at the beginning. This small stub performs all the steps of extracting the files, running the embedded command, and removing the temporary files when it's all over. All what the user has to do to install the software contained in such an archive is to "run" the archive, i.e sh nice-software.run. I recommend using the "run" (which was introduced by some Makeself archives released by Loki Software) or "sh" suffix for such archives not to confuse the users, since they know it's actually shell scripts (with quite a lot of binary data attached to it though!).
I am trying to keep the code of this script as portable as possible, i.e it's not relying on any bash-specific features and only calls commands that are installed on any functioning UNIX-compatible system. This script as well as the archives it generates should run on any Unix flavor, with any compatible Bourne shell, provided of course that the compression programs are available.
As of version 2.1, Makeself has been rewritten and tested on the following platforms :
  • Linux (all distributions)
  • Sun Solaris (8 and above)
  • HP-UX (tested on 11.0 and 11i on HPPA RISC)
  • SCO OpenUnix and OpenServer
  • IBM AIX 5.1L
  • MacOS X (Darwin)
  • SGI IRIX 6.5
  • FreeBSD
  • UnicOS / Cray
  • Cygwin (Windows)
If you successfully run Makeself and/or archives created with it on another system, then let me know!

Examples of publicly available archives made using makeself are :
  • Game patches and installers for Id Software games like Quake 3 for Linux or Return To Castle Wolfenstien ;
  • All game patches released by Loki Software for the Linux version of popular games ;
  • The nVidia drivers for Linux
  • The installer for the Linux version of Google Earth
  • The VirtualBox installers for Linux
  • The Makeself distribution itself ;-)
  • and countless others...

Important note for Apache users: By default, most Web servers will think that Makeself archives are regular text files and thus they may show up as text in a Web browser. The correct way to prevent this is to add a MIME type for this file format, like so (in httpd.conf) :
AddType application/x-makeself .run
Important note for recent GNU/Linux distributions: Archives created with Makeself prior to v2.1.2 were using an old syntax for the head and tail Unix commands that is being progressively obsoleted in their GNU forms. Therefore you may have problems uncompressing some of these archives. A workaround for this is to set the environment variable $_POSIX2_VERSION to enable the old syntax, i.e. :
export _POSIX2_VERSION=199209

Usage

The syntax of makeself is the following:
makeself.sh [args] archive_dir file_name label startup_script [script_args]
  • args are optional options for Makeself. The available ones are :
    • --version : Prints the version number on stdout, then exits immediately
    • --gzip : Use gzip for compression (is the default on platforms on which gzip is commonly available, like Linux)
    • --bzip2 : Use bzip2 instead of gzip for better compression. The bzip2 command must be available in the command path. I recommend that you set the prefix to something like '.bz2.run' for the archive, so that potential users know that they'll need bzip2 to extract it.
    • --compress : Use the UNIX "compress" command to compress the data. This should be the default on all platforms that don't have gzip available.
    • --nocomp : Do not use any compression for the archive, which will then be an uncompressed TAR.
    • --notemp : The generated archive will not extract the files to a temporary directory, but in a new directory created in the current directory. This is better to distribute software packages that may extract and compile by themselves (i.e. launch the compilation through the embedded script).
    • --current : Files will be extracted to the current directory, instead of in a subdirectory. This option implies --notemp above.
    • --follow : Follow the symbolic links inside of the archive directory, i.e. store the files that are being pointed to instead of the links themselves.
    • --append (new in 2.1.x): Append data to an existing archive, instead of creating a new one. In this mode, the settings from the original archive are reused (compression type, label, embedded script), and thus don't need to be specified again on the command line.
    • --header : Makeself 2.0 uses a separate file to store the header stub, called "makeself-header.sh". By default, it is assumed that it is stored in the same location as makeself.sh. This option can be used to specify its actual location if it is stored someplace else.
    • --copy : Upon extraction, the archive will first extract itself to a temporary directory. The main application of this is to allow self-contained installers stored in a Makeself archive on a CD, when the installer program will later need to unmount the CD and allow a new one to be inserted. This prevents "Filesystem busy" errors for installers that span multiple CDs.
    • --nox11 : Disable the automatic spawning of a new terminal in X11.
    • --nowait : When executed from a new X11 terminal, disable the user prompt at the end of the script execution.
    • --nomd5 and --nocrc : Disable the creation of a MD5 / CRC checksum for the archive. This speeds up the extraction process if integrity checking is not necessary.
    • --lsm file : Provide and LSM file to makeself, that will be embedded in the generated archive. LSM files are describing a software package in a way that is easily parseable. The LSM entry can then be later retrieved using the '-lsm' argument to the archive. An exemple of a LSM file is provided with Makeself.
  • archive_dir is the name of the directory that contains the files to be archived
  • file_name is the name of the archive to be created
  • label is an arbitrary text string describing the package. It will be displayed while extracting the files.
  • startup_script is the command to be executed from within the directory of extracted files. Thus, if you wish to execute a program contain in this directory, you must prefix your command with "./". For example, ./program will be fine. The script_args are additionnal arguments for this command.
Here is an example, assuming the user has a package image stored in a /home/joe/mysoft, and he wants to generate a self-extracting package named mysoft.sh, which will launch the "setup" script initially stored in /home/joe/mysoft :
makeself.sh /home/joe/mysoft mysoft.sh "Joe's Nice Software Package" ./setup
Here is also how I created the makeself.run archive which contains the Makeself distribution :
makeself.sh --notemp makeself makeself.run "Makeself by Stephane Peter" echo "Makeself has extracted itself"

Archives generated with Makeself 2.1 can be passed the following arguments:

  • --keep : Prevent the files to be extracted in a temporary directory that will be removed after the embedded script's execution. The files will then be extracted in the current working directory and will stay here until you remove them.
  • --verbose : Will prompt the user before executing the embedded command
  • --target dir : Allows to extract the archive in an arbitrary place.
  • --nox11 : Do not spawn a X11 terminal.
  • --confirm : Prompt the user for confirmation before running the embedded command.
  • --info : Print out general information about the archive (does not extract).
  • --lsm : Print out the LSM entry, if it is present.
  • --list : List the files in the archive.
  • --check : Check the archive for integrity using the embedded checksums. Does not extract the archive.
  • --nochown : By default, a "chown -R" command is run on the target directory after extraction, so that all files belong to the current user. This is mostly needed if you are running as root, as tar will then try to recreate the initial user ownerships. You may disable this behavior with this flag.
  • --tar : Run the tar command on the contents of the archive, using the following arguments as parameter for the command.
  • --noexec : Do not run the embedded script after extraction.
Any subsequent arguments to the archive will be passed as additional arguments to the embedded command. You should explicitly use the -- special command-line construct before any such options to make sure that Makeself will not try to interpret them.

License

Makeself is covered by the GNU General Public License (GPL) version 2 and above. Archives generated by Makeself don't have to be placed under this license (although I encourage it ;-)), since the archive itself is merely data for Makeself.

Download

Get the latest official distribution here (version 2.1.5).
The latest development version can be grabbed from GitHub. Feel free to submit any patches there through the fork process.

Version history

  • v1.0: Initial public release
  • v1.1: The archive can be passed parameters that will be passed on to the embedded script, thanks to John C. Quillan
  • v1.2: Cosmetic updates, support for bzip2 compression and non-temporary archives. Many ideas thanks to Francois Petitjean.
  • v1.3: More patches from Bjarni R. Einarsson and Francois Petitjean: Support for no compression (--nocomp), script is no longer mandatory, automatic launch in an xterm, optional verbose output, and -target archive option to indicate where to extract the files.
  • v1.4: Many patches from Francois Petitjean: improved UNIX compatibility, automatic integrity checking, support of LSM files to get info on the package at run time..
  • v1.5.x: A lot of bugfixes, and many other patches, including automatic verification through the usage of checksums. Version 1.5.5 was the stable release for a long time, even though the Web page didn't get updated ;-). Makeself was also officially made a part of the Loki Setup installer, and its source is being maintained as part of this package.
  • v2.0: Complete internal rewrite of Makeself. The command-line parsing was vastly improved, the overall maintenance of the package was greatly improved by separating the stub from makeself.sh. Also Makeself was ported and tested to a variety of Unix platforms.
  • v2.0.1: First public release of the new 2.0 branch. Prior versions are officially obsoleted. This release introduced the '--copy' argument that was introduced in response to a need for the UT2K3 Linux installer.
  • v2.1.0: Big change : Makeself can now support multiple embedded tarballs, each stored separately with their own checksums. An existing archive can be updated with the --append flag. Checksums are also better managed, and the --nochown option for archives appeared.
  • v2.1.1: Fixes related to the Unix compression (compress command). Some Linux distributions made the insane choice to make it unavailable, even though gzip is capable of uncompressing these files, plus some more bugfixes in the extraction and checksum code.
  • v2.1.2: Some bug fixes. Use head -n to avoid problems with POSIX conformance.
  • v2.1.3: Bug fixes with the command line when spawning terminals. Added --tar, --noexec for archives. Added --nomd5 and --nocrc to avoid creating checksums in archives. The embedded script is now run through "eval". The --info output now includes the command used to create the archive. A man page was contributed by Bartosz Fenski.
  • v2.1.4: Fixed --info output. Generate random directory name when extracting files to . to avoid problems. Better handling of errors with wrong permissions for the directory containing the files. Avoid some race conditions, Unset the $CDPATH variable to avoid problems if it is set. Better handling of dot files in the archive directory.
  • v2.1.5: Made the md5sum detection consistent with the header code. Check for the presence of the archive directory. Added --encrypt for symmetric encryption through gpg (Eric Windisch). Added support for the digest command on Solaris 10 for MD5 checksums. Check for available disk space before extracting to the target directory (Andreas Schweitzer). Allow extraction to run asynchronously (patch by Peter Hatch). Use file descriptors internally to avoid error messages (patch by Kay Tiong Khoo).

Links

  • Check out the "Loki setup" installer, used to install many Linux games and other applications, and of which I am the co-author. Since the demise of Loki, I am now the official maintainer of the project, and it is now being hosted on icculus.org, as well as a bunch of other ex-Loki projects (and a lot of other good stuff!).
  • Bjarni R. Einarsson also wrote the setup.sh installer script, inspired by Makeself. Check it out !

Contact

This script was written by Stéphane Peter (megastep at megastep.org) I welcome any enhancements and suggestions.
Contributions were included from John C. Quillan, Bjarni R. Einarsson, Francois Petitjean, and Ryan C. Gordon, thanks to them! If you think I forgot your name, don't hesitate to contact me.
icculus.org also has a Bugzilla server available that allows bug reports to be submitted for Loki setup, and since Makeself is a part of Loki setup, you can submit bug reports from there!

10/22/13

Fix Random Freezes With Ivy Bridge Integrated HD 4000 Graphics

From link: http://www.howtoeverything.net/linux/hardware/random-freezes-integrated-hd-4000-graphics

If you equipped your system with an Ivy Bridge Intel processor with HD 4000 graphics and use the latest LTS Ubuntu version (12.04) or Linux Mint (13/Maya), you might also experience unpredictable system freezes from time to time. This article outlines the reason and the fix.

The Issue
If you are using any Linux distribution that utilizes the Linux Kernel 3.2, as Ubuntu 12.04, Linux Mint 13 or every other distribution based on it does, you run into a bug causing a system freeze because some problem between this kernel and your integrated graphics chip. You might have chosen this version of Ubuntu since it is a LTS one. Also the most obvious reason to think of would be that system freezes are caused by compiz or any other window decorator or window manager, it is really just a incompatibility with the kernel.

Are Google Chrome or Chromium responsible?
Since the last Google Chrome and Chromium Update, you might think that these browsers are responsible, since you suddenly find some entries in your syslog that contain:
audit ... comm="chromium-browse" reason="seccomp" sig=0 syscall=4 compat=0 ... code=0x50002
Unfortunately it is a bit more complicated: not the browsers themselves are creating the errors, but they are just printing errors logged in the syslog that are the effect of the  problem with the kernel. Most of the times you might even experience the freezing issue using Chrome or Chromium, but this is not mainly because of these browsers but because you use them most of the time you use your computer. This makes it significantly more possible that you experience the issue while browsing the internet.

The Fix
If you upgrade to the next highest version of your distribution (e.g. Ubuntu 12.10 or Linux Mint 14) you automatically get the newer Linux Kernel version 3.5 and won't experience the problem anymore. If you don't feel like upgrading, it is also possible to install the kernel of the next Ubuntu / Linux Mint version without doing an complete system upgrade. If you are using Ubuntu 12.04 or Linux Mint 13 you can install a package called linux-generic-lts-quantal. It is a special meta package to equip the LTS (Long Time Support) versions Ubuntu 12.04 / Linux Mint 13 with the most uptodate kernel from the next Ubuntu version, which is codenamed Quantal Quetzal. Install it like this:
  • open up a terminal window and copy/paste the following into it and hit return
  • sudo apt-get install linux-generic-lts-quantal
  • if asked whether to install all necessary packages enter Y
  • reboot to use the newest kernel
  • you can still boot with the old kernel through your boot menu 

Is it really fixed?
Fixing an issue like this always comes with the uncertainty whether the problem is really gone for good. A couple of things you can check to be reassured:
  • booting your system with the new kernel and using Chromium or Chrome shouldn't produce any of the above mentioned syslog entries anymore
  • playing a couple of youtube videos in full HD and holding ALT + Tab to switch between them very fast shouldn't make the system hang anymore
  • if you're using animations with compiz, you should also notice that everything moves much more fluently now. You won't get the small hangs anymore, that you might have experience e.g. when unminimizing windows from heavy applications. 
Additionally: we applied the fix to one of our own machines, which stalled at least once per day because of this issue. It now has worked flawlessly for a whole week 24/7, even with running burn-in tests during nights! So it seems the kernel upgrade really resolved this issue for good, and the best thing: you can stick to the latest LTS version from Ubuntu and Linux Mint without the need for doing a distribution upgrade just because of the newer kernel.

10/4/13

Set up USB for Virtualbox

Set up USB for Virtualbox

Note: There is no longer a "pay" version for individual copies/licenses of VirtualBox. For more information please see:http://www.virtualbox.org/wiki/Licensing_FAQ

For Precise Pangolin 12.04

This was tested with VBox 4.1.12-Ubuntu_r77245 (Ubuntu Reps) with Matching Extensions, and Guest Additions.
Add yourself to the user group vboxusers.
However the Manage Groups Applet is no longer installed in 12.04 by default.
Open Software Centre, Search "Gnome-System-Tools" and install.
Tap Super Key to get the Dash, Type "user" and click the Users and Groups icon to start up the Groups Manager. Click "Manage Groups", find vboxusers, click properties, add your own and any other desired users to the vboxusers group.
Click OK.
Now log out and back in, to make use of available USB devices. Connect USB Devce(s)
===FOR PERSISTENT CONNECTION TO VM===
Open VBox, go to Settings for the VM, Go to USB.
Click USB+ Icon and select device from List (Be careful not to select your mouse device)
This will add a Filter Spec to the List, repeat as necessary for more devices
Start VM - Devices should appear in Guest OS, and mount or request drivers etc as normal for the OS.
Devices Mounted in Guest OS will likely be unavailable in Host OS
===FOR TEMPORARY CONNECTION TO VM===
Insert USB Device & Wait for it to activate in Host OS
Start or go to VM
Right Click USB Icon in the VM Status Bar at bottom of screen, OR from Menu go Devices > USB Devices, and select desired device.
Devices should appear in Guest OS, and mount or request drivers etc as normal for the OS.

Devices Mounted in Guest OS will likely be unavailable in Host OS

10/3/13

Date calculation in iReport: set default of Date input at the first day of current month

new GroovyShell(new Binding()).evaluate("""
Calendar c = Calendar.getInstance()
c.set(Calendar.DAY_OF_MONTH, 0)
return "" + (c.getTime().getYear() + 1900) + "-" + c.getTime().getMonth() + "-" + c.getTime().getDay()
""")

9/19/13

CheckInstall - Building Deb file from OpenSource Codes

Introduction


CheckInstall keeps track of all files installed by a "make install" or equivalent, creates a Slackware, RPM, or Debian package with those files, and adds it to the installed packages database, allowing for easy package removal or distribution.
IconsPage/IconTip.png Use CheckInstall instead of just running "sudo make install", as that will likely put files all over the filesystem, with no easy way of removing them if things go wrong. If in the future you try to install a package that contains the same file as the software you are compiling, you will receive errors and the software you compiled may stop working.
(In fact, checkinstall can keep track of files modified by any command line, not just a "make install", so you can use it for any type of installation task outside of apt, and it will keep track of the installation in the package manager.)
IconsPage/dont.png CheckInstall is not designed to produce packages suitable for distribution. Do not use it to produce packages intended for the Ubuntu archive or PPAs. Instead, follow the Packaging Guide.
IconsPage/warning.png From the checkinstall README: "The Debian support in CheckInstall is still new, so handle it with care. It has been reported to work OK in some Debian systems and it certainly works OK in my Slackware development system with dpkg installed. Your mileage may vary."

Installation


Install the package checkinstall from the Repositories.
For help on installing software in Ubuntu, see InstallingSoftware.
A quick method via the terminal for those who like to copy and paste:
sudo aptitude install checkinstall

Usage


Instead of
sudo make install
you will use
sudo checkinstall

When called with no arguments, checkinstall will call "make install". If you need other arguments, they can be supplied:
sudo checkinstall make install_package

The installed package can then also easily be removed via Synaptic or via the terminal:
sudo dpkg -r packagename

Example:
sudo dpkg -r pidgin

IconsPage/IconNote.png Note that the .deb package it creates can also be used elsewhere, which simplifies installation of the same program on many machines.

Use CheckInstall with auto-apt


You can use auto-apt when you want to build a simple package from source with checkinstall. You need to have auto-apt installed!
Instead of
./configure

you use:
auto-apt run ./configure

If the dependencies are available, a dialog box opens and ask you to install them.
The rest remains the same
make
sudo checkinstall

9/13/13

White balance with Canon DSLRs

White balance with Canon DSLRs

A couple of my colleagues at Northern Arizona University’s School of Communication noted how difficult it is to do manual white balance with the Canon DSLRs some of our students are using.

All I can say: Not as easy as video cameras. The Canon presets have worked pretty well for all the projects I’ve shot, but I’m using a Canon 5D Mark II where I dial in the color temperature I want. Beginning students may know what color temperature to use or just rely on presets — especially when they have to go through the steps I outline below. Or some may just want to use the simplicity of video cameras. Whatever camera you choose to shoot with, manual white balance is an important step not to neglect.

And if it’s more difficult with a DSLR, then you have to decide if it’s worth the extra effort. For me and many of my students who have purchased their own DSLRs, we realize one thing: The image quality, baby, the image quality. But knowing how to color balance is part of mastering the image quality.

Why do we even bother with adjusting color temperature in the first place? Why not just set the camera to automatic. If you’re controlling your image professionally, then you need to use the manual settings so it doesn’t do things you don’t want it to be doing.

Our eyes balance white automatically. A camera’s sensor isn’t as smart as us and it doesn’t have the multitasking capabilities of our minds. So you need to tell the camera what kind of light it’s seeing so it can find true white. White indoors is different than white outdoors. See the chart below:

Color temperature in degree Kelvins. This chart provides a list of different lamps and their corresponding color temps. (Image courtesy of Mapawatt.)

So if you’ve set your DSLR to an indoor light setting (~3700K), such as standard tungsten (a regular light bulb) and you go outdoors (~5500K), the white the camera saw indoors is now different and now has a bluish tint to it. If you’ve set your camera to daylight and you go indoors, the camera’s image now contains a warm yellow cast. See the images below.

The top image contains the bluish tint of an indoor white balance setting used incorrectly outdoors. The bottom image is too yellow — the typical problem with an outdoor setting used incorrectly indoors. The center image is properly color balanced. Photos by Kurt Lancaster (courtesy of Focal Press).

And if you are shooting a scene with multiple light sources (such as a window and a room with fluorescent lighting), you need to tell the camera which one it should see. Is the window your key light? Then dial in the proper color temperature or set the custom white balance.

8/21/13

LightDM: THE SYSTEM IS RUNNIG IN LOW GRAPHIC MODE

Fix Error: “THE SYSTEM IS RUNNIG IN LOW GRAPHIC MODE”

“THE SYSTEM IS RUNNIG IN LOW GRAPHIC MODE” erorr is a very common error forLightDM.
When you get this error, click the OK button in the graphical window and tick the box saying “run in low graphics mode for just one session”.
Next, you will have to do this:
$ sudo apt-get install --reinstall unity-greeter
$ sudo dpkg-reconfigure lightdm
Now open the /etc/lightdm/lightdm.conf (with sudo) and make the greeter-session=line look like this:
greeter-session=unity-greeter
This error fixing works for Ubuntu, Linut Mint and other Linux boxes that use lightdm.

7/12/13

Ubuntu: How to disable integrated webcam and still be able to use an external one

On a fresh kernel just echo it with zero. For example:
Search what we need to be turned off:
lsusb
This returns a list of devices:
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 0402:5602 ALi Corp. M5602 Video Camera Controller
Bus 001 Device 003: ID 045e:0723 Microsoft Corp. LifeCam VX-7000 (UVC-compliant)
Change 1-6 to your device ports to be disabled: cat /sys/bus/usb/devices/1-6/idProduct
This gives me 5602.
Now we've found it (to iterate search, change 1-6 to all your device ports), now just turn it off:
echo "0" > /sys/bus/usb/devices/1-6/bConfigurationValue
After making sure it works as desired, make it load every startup (for example, in /etc/rc.local.)

7/8/13

Ubuntu 12.04: Wireless network - connected, got ip, but no packets through (Fixed on 13.04)

Test if it running

Please try:
Code:
lsmod | grep iwl
See if your wireless driver is iwlagn or iwlwifi and then remove it and reload it with a parameter.
Code:
sudo modprobe -r iwlwifi
sudo modprobe iwlwifi 11n_disable=1
Any improvement? If so, we'll need to write one file to make it permanent.

----

Do if the upper_test fixs your problem

The iwlwifi driver is troubled with a bug wherein it doesn't handle N traffic at all well. It seems to clog and pass NO traffic at all. Fortunately,there is a fix; tell the driver to disable ts N capability. It's a compromise, I know, but there seem to be two choices: it works without N or it doesn't work at all.

Please open a terminal and do:
Code:
sudo gedit /etc/modprobe.d/iwlwifi.conf
Of course, use the actual name of your driver, if not iwlwifi. Write one line:
Code:
options iwlwifi 11n_disable=1
Proofread carefully, save and close gedit. 

reboot your system.