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 their.

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).

Friday, November 13, 2015

Running i3 under HiDPI display

I recently got a MacbookPro (early 2015) with retina display for work.  I installed a fresh Slackware64-current on to it with rEFInd as the boot loader.  The process was quite smooth, I used a USB boot image then network install (with a thunderbolt gigabyte adapter).  Some devices/functions are not fully functional but usable for me. Console font is using the kernel built in SUN12x22 font with kernel option "fbcon:font=SUN12x22".

Since this laptop has a 2560x1600 on a 13" display, roughly 227DI, my old setting for i3 did not work well, although I already using xft font for status bar display.  After a few search, I found out xorg server always set DPI 96, that is a bad move in my opinion, as it makes previous valid DPI calculation wrong and still wrong for those cases that the calculation do not fit.  And I have to add a line
xrandr --fbmm 286x179
in .xinitrc file in order to let i3 pick up the correct DPI setting.  OK, now the i3 status bar display fine.  The default dmenu I initially installed does not support xft font, so it looks really small.  Luckily there is a dmenu2 which merged the xft patched.  Remove the old dmenu package and install the dmenu2 package, then add the font parameter to the dmenu_run command in i3's config Latest dmenu works with xft font now. Everything works fine.

I have the following settings in my .Xresources file.
Xft.dpi : 227
Xft.antialias: false
Xft.rgba: rgb

URxvt.scrollstyle: xterm
URxvt.background: black
URxvt.foreground: gray
URxvt.preeditType: Root
URxvt.scrollBar_right: true
URxvt.jumpScroll: true
URxvt.perl-ext-common:  tabbed
URxvt.tabbed.tabbar-fg: 2
URxvt.tabbed.tabbar-bg: 0
URxvt.tabbed.tab-fg:    3
URxvt.tabbed.tab-bg:    0
URxvt.termName: rxvt
URxvt.geometry: 83x27
urxvt.font: xft:DejaVuSansMono:size=8

Xpdf*fontList: -adobe-helvetica-bold-r-normal--0-0-0-0-p-0-iso8859-1
Xpdf.initialZoom: 200

Xcursor.size: 64

With the following, the width should be $((11*COLUMNS+13)) pixels;
! in contrast, the fixed = 6x13 bitmap font is typically used on a
! low-definition screen, giving a width of $((6*COLUMNS+13)) pixels.
XTerm*faceName:  Monospace
XTerm*faceSize:  10
! For xterm menus. This font is large enough, but a bit ugly.
XTerm*font:  -adobe-helvetica-bold-r-normal--0-0-0-0-p-0-iso8859-1
My default terminal is rxvt-unicode, so it works fine. You may notice I have turn antialias off, the font looks sharp, you may see zigzag when looking really close, but for 227DPI, it's very clear without it already.  Most of the document on line regarding GTK+3's HiDPI support is by setting
export GDK_SCALE=2
export GDK_DPI_SCALE=05
I found the program behave a little strange when this kind of scaling in effect.  Font is a little blur than none scale one. For the Gnat Programing Studio (GPS), with the scaling effect, the menu display strangely:
compare with the one without scaling:
I am not sure whether its GTK3' fault or GPS's fault.  I would hope for a GDK_IMAGE_SCALE and only scale image, maybe that will work better.


P.S. After upgrade to kernel 4.4, all the special keys (fn+Fx) works as expected (with pommed-light)

Thursday, October 1, 2015

Using mutool to repair a PDF file that has corrupted xref table

Someone send me a PDF and I could not opened it on my Nexus 5 with Adobe's PDF reader (It suits me the best for a PDF viewer in the android phone).  But both XPDF and muPDF under Linux could opened it with some error message saying the xref table is corrupted and try to rebuild it. 

How could I repair the pdf file?  The first tool comes in my mind is pdftk, it failed to read the corrupted file and give exception.  Then I try pdf2ps, it failed either. 

Google shows me some one saying mutool from muPDF could repair it.  I have using muPDF for some time, it is the default PDF viewer in my Slackware desktop.  But I never take attention to the little tools come along with it, after man mutool, the following command save me:
mutool clean corrupted.pdf clean.pdf
The repaired PDF file is in clean.pdf.

P.S. muPDF does not come with Slackware, but it has a SlackBuild script.  For Windows user, muPDF provide windows version too.

Thursday, September 24, 2015

gnatpp could not align exception declaration properly

I normally use the GNAT Pretty-Printer gnatpp to format my Ada code.  The output of it is not perfect but acceptable and make my code look consistent.

It has a small alignment bug, for exception declaration, it could not handle it properly.  For this specification align_test.ads:
package Align_Test is
    Index: Integer;
    Number_Test : Integer;

    Bad_File : exception;
    Bad_Argument : exception;
end Align_Test;
gnatpp -r align_test.ads will produce:
package Align_Test is
   Index       : Integer;
   Number_Test : Integer;

   Bad_File : exception;
   Bad_Argument : exception;
end Align_Test;
I have to manually align the declaration and add specific comments to fence it from gnatpp to change my alignment in future. 
package Align_Test is
   Index       : Integer;
   Number_Test : Integer;

   --!pp off
   Bad_File     : exception;
   Bad_Argument : exception;
   --!pp on
end Align_Test;
It does not look good, but acceptable.  Wish next version of gnatpp could solve this problem.

P.S. Hooray, today (May. 19, 2016) AdaCore fixed the alignment problem. It will properly show up in GNAT GPL 2016.

Wednesday, September 16, 2015

Where/when is my next laptop purchase

My fastest computer in my home right now is a MacBook from 2009.  It's hard disk has been replaced by a SSD and runs smoothly with the latest OS X and Slackware with some minor glitches (web-camera not working, occasionally system have USB bus error, result in non usable system without keyboard, have to reboot back to OS X to fix it).  I have been searching for my next laptop for some time, but still don't find a perfect one that suites my particular requirements:
  • With 13"/14" screen resolution must be high DPI, the higher the better, minimum 3200x1800.
  • Must have optical digital sound output, be it dedicated TOSLINK connector or combo with head phone jack (this has been standard for MacBook for years).
  • Be lightweight and have longer battery life (>= 8 hours)
  • Must be Linux friendly.
Actually, Dell's XPS 13 almost meets the requirement, except for the optical digital sound output.  Apple's MacBook Pro comes close but it is not Linux friendly, and screen resolution is lower than Dell's.  All of Lenovo's offers lack optical digital sound output, X1 carbon does not have high resolution screen, Yoga Pro does not have enough CPU power.

Maybe I should wait one or two more years, then Intel's new 3D XPoint maybe used for storage, oh my, maybe I will never buy a new one ... ...