Wednesday, November 30, 2016

ZSTD - A new compression tool

I has some personal interest in compression. Recently, I found this new compression tool: ZStd. It compresses much faster than gzip with better compression ratio.

For a not so scientific benchmark ^_^, to compress linux-4.4.34.tar (648867840 bytes) kernel, time reports the following:

time zstd linux-4.4.34.tar
real    0m5.157s
user    0m4.116s
sys     0m0.534s

time gzip -k linux-4.4.34.tar
real    0m21.255s
user    0m20.891s
sys     0m0.175s

time xz  -k linux-4.4.34.tar
real    4m21.785s
user    4m21.430s
sys     0m0.265s

648867840  linux-4.4.34.tar
132581836  linux-4.4.34.tar.zst (20.43%)    5.157s
137210920  linux-4.4.34.tar.gz  (21.15%)   21.255s
 90543184  linux-4.4.34.tar.xz  (13.95%) 4m21.785s

It took zstd much less time to compress with slightly better compression than gzip. For a better benchmark, please refer to the zstd's home page.

There is a SlackBuilds package maintain by me for Slackware also.

Tuesday, September 13, 2016

Ada programming environment based on GCC 6.2 and GNAT GPL 2016 in Slackware64 14.2

New release of Slackware and new version of GNAT GPL 2016 prompt me to update the Ada programming environment under Slackware.

First, I was trying to use the stock 5.3 compiler, but encounter gnat compiler error when compiling gprbuild. So has to use the FSF GCC 6.2 as the based.

The FSF GCC compiler

At the writing, the latest release of GCC is 6.2.0. First I update the build script to matched what's in the current tree. I have changed the build directory to a fixed location to avoid the random location in the original script. As it is needed for gnat_util build, a fixed location is easier for the script to find the right files. Built and install without problem.

GNAT Environment package

This package contains startup scripts to setup Ada project path environment variable ADA_PROJECT_PATH and GPR_PROJECT_PATH. They will be installed into /etc/profile.d by the doinst.sh.

Also soft link of the GNAT Ada run time libraries are also created in doinst.sh.

XMLAda

For XMLAda GPL 2016, the default build process is making use of gprbuild, which depends on XMLAda. I followed what was done on Arch Linux and created a custom Makefile.SlackBuild. But I installed the package with the following scheme, similar to what GNAT GPL 2016 is doing but with sub-directories for each sub-module:
 usr/include/xmlada
             |- input
             |- unicode
             ...
 usr/lib64/xmlada
           |- input
           |  |- static
           |  `- relocatable
           |- unicode
           |  |- static
           |  `- relocatable
           ...
The document build requires Sphinx, as SlackBuilds.orgprovides all necessary build scripts, it is a matter of installing the relevant packages and dependencies.

GPRBuild

The 2016 version of gprbuild required gprbuild itself. So Similar to XMLAda, a custom Makefile was borrowed from the Arch Linux project and modified to suite the needs of Slackware. A patch was developed for the gprinstall program, so that its default library subdir and library soft link subdir points to lib64 under Slackware64. A gpr library is also created, as it is needed by a few other programs

GNAT_UTIL

The GNAT Util Libraryprovides access to GNAT compiler internals for AdaCore utilities. The latest release is 5.1.0, it is used for our GCC 6.2.0. The build went well.

GTKAda

It does not build very well at the first few builds, it keeps installing libs into /usr/lib in stead of /usr/lib64 on 64-bit system. It seems the generate file still insist on the lib's path. So more sed commands are added to change the lib path to lib64 on 64-bit system. After that, it built without problem with proper installation path.

Aunit

Aunit's build script has no big change from the previous version, except for the version bump.

GNATColl

I used version 16.1 from GitHub. GNATColl compiled OK, with minor problem with lib's installation path, similar to the problem in GtkAda. I always got gpr.gpr problem when compiling GPS, latter I found that not sure why, the installing process of gnatcoll will install a copy of the gpr.gpr project file and related object file and source into its own directory structure with some modification to gpr.gpr and causing error on the project file. I have to manually remove all gpr related files and directories and entries in the manifests file. Then GPS will compile with correct project file.

GPS

After fixing the gprbuild, gpr and gnatcoll libraries, GPS compile without problem. When running GPS, it gave python script warning about pep8 and jedi, after install those two from SlackBuilds.org, everything is working fine.

Florist

No trouble when compile and install florist.

Asis

Asis has no problem to compile and install after fixed the gprbuild install path.

Gnatmem and Ahven

Gnatmem (need to compile the binutils for Slackware 14.2 and use the build tree) and Aheven gave no trouble when compiled for the 2016 version.

All build scripts are available at GitHub.

Sunday, June 19, 2016

How to mount NTFS filesystem on OS X

I have a Dell backup drive and would like to backup some of my files on OS X to it. But unfortunately it is formatted as NTFS, by default it is mounted read only on OS X.

Searching around, I found someone mention about the NTFS-3G, that is the tool I am using for Linux. It seems the fastest access is NTFS for Mac from Tuxera.com, it is also the sponsor of the open source project NTFS-3G. At first, I try to see if I could order it, but it has a price tag of $36.33, well, if it were below the $10 mark I will buy it, this price is a little pricy.

Next I try to find if any ntfs-3g binary package is available, the latest I could find is from 2010, a little bit out dated. Then I came across this OSXFuse's project wiki about NTFS-3G. I install the latest 3.4 OSXFUSE. Then the package manager "Homebrew".

Follow the procedure from the wiki, I issue the command

brew install homebrew/fuse/ntfs-3g
Then it starts to download and compiling ... After a few minutes, I got ntfs-3g install.

Then I try the commands from a command shell.

mkdir /Volumes/ntfs 
ntfs-3g /dev/disk1s1 /Volumes/ntfs
Hooray, I got a writable NTFS disk mounted! I did not try to replace the system's mount_ntfs for automount NTFS to read/write. The current form works for me.

PS. Of course, in order to compile all related programs, you need to have Xcode installed.

Thursday, March 24, 2016

Google's hterm: HTML5 terminal emulator

Google's hterm is a nice terminal emulator. I would like to use the hterm part only and do some remote telnet session test (I used libtelnet for the back-end server). But I encountered some usage problems.

First, you could not build a functional hterm script with the github repository, you will need to checkout the full repository from https://chromium.googlesource.com/apps/libapps/ and build from there.

Second, the embedded document is lagging. After following the description in the document, the terminal could be displayed without problem, but there is no input at all. The call back function register to the io.onVTKeystroke() never get called. After digging through other part of the libapps repository for hterm's usage, I found term.installKeyboard() function of the hterm terminal instance need to be called after the term.decorate() call. After that input event could be received.

Third, I haven't found a way to make it acknowledge IME input. Cut and paste utf8 encoded characters causing it to output escaped utf8 stream (utf8 encoded of an utf8 stream).